mirror of
https://github.com/bestnite/sub2sing-box.git
synced 2025-06-16 10:03:18 +08:00
update dependency
This commit is contained in:
@ -72,26 +72,28 @@ func ParseHysteria(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
remarks = strings.TrimSpace(remarks)
|
||||
|
||||
return model.Outbound{Outbound: option.Outbound{
|
||||
Type: "hysteria",
|
||||
Tag: remarks,
|
||||
HysteriaOptions: option.HysteriaOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Up: upmbps,
|
||||
Down: downmbps,
|
||||
Auth: []byte(auth),
|
||||
Obfs: obfs,
|
||||
Network: option.NetworkList(protocol),
|
||||
OutboundTLSOptionsContainer: option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: enableTLS,
|
||||
Insecure: insecureBool,
|
||||
ALPN: alpn,
|
||||
},
|
||||
outboundOptions := option.HysteriaOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Up: upmbps,
|
||||
Down: downmbps,
|
||||
Auth: []byte(auth),
|
||||
Obfs: obfs,
|
||||
Network: option.NetworkList(protocol),
|
||||
OutboundTLSOptionsContainer: option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: enableTLS,
|
||||
Insecure: insecureBool,
|
||||
ALPN: alpn,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return model.Outbound{Outbound: option.Outbound{
|
||||
Type: "hysteria",
|
||||
Tag: remarks,
|
||||
Options: outboundOptions,
|
||||
}}, nil
|
||||
}
|
||||
|
@ -71,36 +71,40 @@ func ParseHysteria2(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
remarks = strings.TrimSpace(remarks)
|
||||
|
||||
result := model.Outbound{
|
||||
Outbound: option.Outbound{
|
||||
Type: "hysteria2",
|
||||
Tag: strings.TrimSpace(remarks),
|
||||
Hysteria2Options: option.Hysteria2OutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Password: password,
|
||||
OutboundTLSOptionsContainer: option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: enableTLS,
|
||||
Insecure: insecureBool,
|
||||
ServerName: sni,
|
||||
ALPN: alpn,
|
||||
},
|
||||
},
|
||||
Network: option.NetworkList(network),
|
||||
outboundOptions := option.Hysteria2OutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Password: password,
|
||||
OutboundTLSOptionsContainer: option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: enableTLS,
|
||||
Insecure: insecureBool,
|
||||
ServerName: sni,
|
||||
ALPN: alpn,
|
||||
},
|
||||
},
|
||||
Network: option.NetworkList(network),
|
||||
}
|
||||
|
||||
if pinSHA256 != "" {
|
||||
result.Hysteria2Options.OutboundTLSOptionsContainer.TLS.Certificate = []string{pinSHA256}
|
||||
outboundOptions.TLS.Certificate = []string{pinSHA256}
|
||||
}
|
||||
if obfs != "" {
|
||||
result.Hysteria2Options.Obfs = &option.Hysteria2Obfs{
|
||||
outboundOptions.Obfs = &option.Hysteria2Obfs{
|
||||
Type: obfs,
|
||||
Password: obfsPassword,
|
||||
}
|
||||
}
|
||||
|
||||
result := model.Outbound{
|
||||
Outbound: option.Outbound{
|
||||
Type: "hysteria2",
|
||||
Tag: strings.TrimSpace(remarks),
|
||||
Options: outboundOptions,
|
||||
},
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
@ -107,20 +107,22 @@ func ParseShadowsocks(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
remarks = strings.TrimSpace(remarks)
|
||||
|
||||
outboundOptions := option.ShadowsocksOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Method: method,
|
||||
Password: password,
|
||||
Plugin: plugin,
|
||||
PluginOptions: options,
|
||||
}
|
||||
|
||||
result := model.Outbound{
|
||||
Outbound: option.Outbound{
|
||||
Type: "shadowsocks",
|
||||
Tag: remarks,
|
||||
ShadowsocksOptions: option.ShadowsocksOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Method: method,
|
||||
Password: password,
|
||||
Plugin: plugin,
|
||||
PluginOptions: options,
|
||||
},
|
||||
Type: "shadowsocks",
|
||||
Tag: remarks,
|
||||
Options: outboundOptions,
|
||||
},
|
||||
}
|
||||
return result, nil
|
||||
|
@ -70,18 +70,21 @@ func ParseSocks(proxy string) (model.Outbound, error) {
|
||||
password = splitStr[1]
|
||||
}
|
||||
}
|
||||
|
||||
outboundOptions := option.SOCKSOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Username: username,
|
||||
Password: password,
|
||||
}
|
||||
|
||||
return model.Outbound{
|
||||
Outbound: option.Outbound{
|
||||
Type: "socks",
|
||||
Tag: remarks,
|
||||
SocksOptions: option.SocksOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Username: username,
|
||||
Password: password,
|
||||
},
|
||||
Type: "socks",
|
||||
Tag: remarks,
|
||||
Options: outboundOptions,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/nitezs/sub2sing-box/constant"
|
||||
"github.com/nitezs/sub2sing-box/model"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing/common/json/badoption"
|
||||
)
|
||||
|
||||
func ParseTrojan(proxy string) (model.Outbound, error) {
|
||||
@ -69,21 +70,17 @@ func ParseTrojan(proxy string) (model.Outbound, error) {
|
||||
|
||||
enableUTLS := fp != ""
|
||||
|
||||
result := model.Outbound{Outbound: option.Outbound{
|
||||
Type: "trojan",
|
||||
Tag: remarks,
|
||||
TrojanOptions: option.TrojanOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
Password: password,
|
||||
Network: option.NetworkList(network),
|
||||
outboundOptions := option.TrojanOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
}}
|
||||
Password: password,
|
||||
Network: option.NetworkList(network),
|
||||
}
|
||||
|
||||
if security == "xtls" || security == "tls" || sni != "" {
|
||||
result.TrojanOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
outboundOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: true,
|
||||
ALPN: alpn,
|
||||
@ -94,7 +91,7 @@ func ParseTrojan(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
|
||||
if security == "reality" {
|
||||
result.TrojanOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
outboundOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: true,
|
||||
ServerName: sni,
|
||||
@ -113,11 +110,11 @@ func ParseTrojan(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
|
||||
if network == "ws" {
|
||||
result.TrojanOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "ws",
|
||||
WebsocketOptions: option.V2RayWebsocketOptions{
|
||||
Path: path,
|
||||
Headers: map[string]option.Listable[string]{
|
||||
Headers: badoption.HTTPHeader{
|
||||
"Host": {host},
|
||||
},
|
||||
},
|
||||
@ -125,7 +122,7 @@ func ParseTrojan(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
|
||||
if network == "http" {
|
||||
result.TrojanOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "http",
|
||||
HTTPOptions: option.V2RayHTTPOptions{
|
||||
Host: []string{host},
|
||||
@ -135,19 +132,26 @@ func ParseTrojan(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
|
||||
if network == "quic" {
|
||||
result.TrojanOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "quic",
|
||||
QUICOptions: option.V2RayQUICOptions{},
|
||||
}
|
||||
}
|
||||
|
||||
if network == "grpc" {
|
||||
result.TrojanOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "grpc",
|
||||
GRPCOptions: option.V2RayGRPCOptions{
|
||||
ServiceName: serviceName,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
result := model.Outbound{Outbound: option.Outbound{
|
||||
Type: "trojan",
|
||||
Tag: remarks,
|
||||
Options: outboundOptions,
|
||||
}}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/nitezs/sub2sing-box/constant"
|
||||
"github.com/nitezs/sub2sing-box/model"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing/common/json/badoption"
|
||||
)
|
||||
|
||||
func ParseVless(proxy string) (model.Outbound, error) {
|
||||
@ -60,21 +61,17 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
remarks = strings.TrimSpace(remarks)
|
||||
|
||||
result := model.Outbound{Outbound: option.Outbound{
|
||||
Type: "vless",
|
||||
Tag: remarks,
|
||||
VLESSOptions: option.VLESSOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
UUID: uuid,
|
||||
Flow: flow,
|
||||
outboundOptions := option.VLESSOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: server,
|
||||
ServerPort: port,
|
||||
},
|
||||
}}
|
||||
UUID: uuid,
|
||||
Flow: flow,
|
||||
}
|
||||
|
||||
if security == "tls" {
|
||||
result.VLESSOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
outboundOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: true,
|
||||
ALPN: alpn,
|
||||
@ -85,7 +82,7 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
|
||||
if security == "reality" {
|
||||
result.VLESSOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
outboundOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: true,
|
||||
ALPN: alpn,
|
||||
@ -105,29 +102,29 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
|
||||
if _type == "ws" {
|
||||
result.VLESSOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "ws",
|
||||
WebsocketOptions: option.V2RayWebsocketOptions{
|
||||
Path: path,
|
||||
},
|
||||
}
|
||||
if host != "" {
|
||||
if result.VLESSOptions.Transport.WebsocketOptions.Headers == nil {
|
||||
result.VLESSOptions.Transport.WebsocketOptions.Headers = make(map[string]option.Listable[string])
|
||||
if outboundOptions.Transport.WebsocketOptions.Headers == nil {
|
||||
outboundOptions.Transport.WebsocketOptions.Headers = badoption.HTTPHeader{}
|
||||
}
|
||||
result.VLESSOptions.Transport.WebsocketOptions.Headers["Host"] = option.Listable[string]{host}
|
||||
outboundOptions.Transport.WebsocketOptions.Headers["Host"] = badoption.Listable[string]{host}
|
||||
}
|
||||
}
|
||||
|
||||
if _type == "quic" {
|
||||
result.VLESSOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "quic",
|
||||
QUICOptions: option.V2RayQUICOptions{},
|
||||
}
|
||||
}
|
||||
|
||||
if _type == "grpc" {
|
||||
result.VLESSOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "grpc",
|
||||
GRPCOptions: option.V2RayGRPCOptions{
|
||||
ServiceName: serviceName,
|
||||
@ -144,7 +141,7 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
result.VLESSOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "http",
|
||||
HTTPOptions: option.V2RayHTTPOptions{
|
||||
Host: strings.Split(hosts, ","),
|
||||
@ -153,11 +150,17 @@ func ParseVless(proxy string) (model.Outbound, error) {
|
||||
}
|
||||
|
||||
if enableUTLS {
|
||||
result.VLESSOptions.OutboundTLSOptionsContainer.TLS.UTLS = &option.OutboundUTLSOptions{
|
||||
outboundOptions.OutboundTLSOptionsContainer.TLS.UTLS = &option.OutboundUTLSOptions{
|
||||
Enabled: enableUTLS,
|
||||
Fingerprint: fp,
|
||||
}
|
||||
}
|
||||
|
||||
result := model.Outbound{Outbound: option.Outbound{
|
||||
Type: "vless",
|
||||
Tag: remarks,
|
||||
Options: outboundOptions,
|
||||
}}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"github.com/nitezs/sub2sing-box/model"
|
||||
"github.com/nitezs/sub2sing-box/util"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing/common/json/badoption"
|
||||
)
|
||||
|
||||
func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
@ -64,20 +65,14 @@ func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
name = vmess.Ps
|
||||
}
|
||||
|
||||
result := model.Outbound{
|
||||
Outbound: option.Outbound{
|
||||
Type: "vmess",
|
||||
Tag: name,
|
||||
VMessOptions: option.VMessOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: vmess.Add,
|
||||
ServerPort: port,
|
||||
},
|
||||
UUID: vmess.Id,
|
||||
AlterId: aid,
|
||||
Security: vmess.Scy,
|
||||
},
|
||||
outboundOptions := option.VMessOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
Server: vmess.Add,
|
||||
ServerPort: port,
|
||||
},
|
||||
UUID: vmess.Id,
|
||||
AlterId: aid,
|
||||
Security: vmess.Scy,
|
||||
}
|
||||
|
||||
if vmess.Tls == "tls" {
|
||||
@ -87,7 +82,7 @@ func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
} else {
|
||||
alpn = nil
|
||||
}
|
||||
result.VMessOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
outboundOptions.OutboundTLSOptionsContainer = option.OutboundTLSOptionsContainer{
|
||||
TLS: &option.OutboundTLSOptions{
|
||||
Enabled: true,
|
||||
UTLS: &option.OutboundUTLSOptions{
|
||||
@ -98,7 +93,7 @@ func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
},
|
||||
}
|
||||
if vmess.Fp != "" {
|
||||
result.VMessOptions.OutboundTLSOptionsContainer.TLS.UTLS = &option.OutboundUTLSOptions{
|
||||
outboundOptions.OutboundTLSOptionsContainer.TLS.UTLS = &option.OutboundUTLSOptions{
|
||||
Enabled: true,
|
||||
Fingerprint: vmess.Fp,
|
||||
}
|
||||
@ -112,11 +107,11 @@ func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
if vmess.Host == "" {
|
||||
vmess.Host = vmess.Add
|
||||
}
|
||||
result.VMessOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "ws",
|
||||
WebsocketOptions: option.V2RayWebsocketOptions{
|
||||
Path: vmess.Path,
|
||||
Headers: map[string]option.Listable[string]{
|
||||
Headers: badoption.HTTPHeader{
|
||||
"Host": {vmess.Host},
|
||||
},
|
||||
},
|
||||
@ -125,7 +120,7 @@ func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
|
||||
if vmess.Net == "quic" {
|
||||
quic := option.V2RayQUICOptions{}
|
||||
result.VMessOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "quic",
|
||||
QUICOptions: quic,
|
||||
}
|
||||
@ -136,7 +131,7 @@ func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
ServiceName: vmess.Path,
|
||||
PermitWithoutStream: true,
|
||||
}
|
||||
result.VMessOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "grpc",
|
||||
GRPCOptions: grpc,
|
||||
}
|
||||
@ -147,11 +142,19 @@ func ParseVmess(proxy string) (model.Outbound, error) {
|
||||
Host: strings.Split(vmess.Host, ","),
|
||||
Path: vmess.Path,
|
||||
}
|
||||
result.VMessOptions.Transport = &option.V2RayTransportOptions{
|
||||
outboundOptions.Transport = &option.V2RayTransportOptions{
|
||||
Type: "http",
|
||||
HTTPOptions: httpOps,
|
||||
}
|
||||
}
|
||||
|
||||
result := model.Outbound{
|
||||
Outbound: option.Outbound{
|
||||
Type: "vmess",
|
||||
Tag: name,
|
||||
Options: outboundOptions,
|
||||
},
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user