1
0
mirror of https://github.com/nitezs/sub2sing-box.git synced 2024-12-23 14:34:41 -05:00

fix: hy2 parser

This commit is contained in:
Nite07 2024-11-16 00:26:54 +08:00
parent e89c70dd85
commit 0681136d65
2 changed files with 12 additions and 3 deletions

View File

@ -55,6 +55,7 @@ func ParseHysteria(proxy string) (model.Outbound, error) {
protocol, auth, insecure, upmbps, downmbps, obfs, alpnStr := query.Get("protocol"), query.Get("auth"), query.Get("insecure"), query.Get("upmbps"), query.Get("downmbps"), query.Get("obfs"), query.Get("alpn") protocol, auth, insecure, upmbps, downmbps, obfs, alpnStr := query.Get("protocol"), query.Get("auth"), query.Get("insecure"), query.Get("upmbps"), query.Get("downmbps"), query.Get("obfs"), query.Get("alpn")
insecureBool, err := strconv.ParseBool(insecure) insecureBool, err := strconv.ParseBool(insecure)
enableTLS := insecureBool || alpnStr != ""
if err != nil { if err != nil {
insecureBool = false insecureBool = false
} }
@ -86,7 +87,7 @@ func ParseHysteria(proxy string) (model.Outbound, error) {
Network: option.NetworkList(protocol), Network: option.NetworkList(protocol),
OutboundTLSOptionsContainer: option.OutboundTLSOptionsContainer{ OutboundTLSOptionsContainer: option.OutboundTLSOptionsContainer{
TLS: &option.OutboundTLSOptions{ TLS: &option.OutboundTLSOptions{
Enabled: true, Enabled: enableTLS,
Insecure: insecureBool, Insecure: insecureBool,
ALPN: alpn, ALPN: alpn,
}, },

View File

@ -55,9 +55,16 @@ func ParseHysteria2(proxy string) (model.Outbound, error) {
Raw: portStr, Raw: portStr,
} }
} }
network, obfs, obfsPassword, pinSHA256, insecure, sni := query.Get("network"), query.Get("obfs"), query.Get("obfs-password"), query.Get("pinSHA256"), query.Get("insecure"), query.Get("sni") network, obfs, obfsPassword, pinSHA256, insecure, sni, alpnStr := query.Get("network"), query.Get("obfs"), query.Get("obfs-password"), query.Get("pinSHA256"), query.Get("insecure"), query.Get("sni"), query.Get("alpn")
enableTLS := pinSHA256 != "" || sni != ""
insecureBool := insecure == "1" insecureBool := insecure == "1"
enableTLS := pinSHA256 != "" || sni != "" || alpnStr != ""
var alpn []string
alpnStr = strings.TrimSpace(alpnStr)
if alpnStr != "" {
alpn = strings.Split(alpnStr, ",")
}
remarks := link.Fragment remarks := link.Fragment
if remarks == "" { if remarks == "" {
remarks = fmt.Sprintf("%s:%s", server, portStr) remarks = fmt.Sprintf("%s:%s", server, portStr)
@ -79,6 +86,7 @@ func ParseHysteria2(proxy string) (model.Outbound, error) {
Enabled: enableTLS, Enabled: enableTLS,
Insecure: insecureBool, Insecure: insecureBool,
ServerName: sni, ServerName: sni,
ALPN: alpn,
}, },
}, },
Network: option.NetworkList(network), Network: option.NetworkList(network),