1
0
mirror of https://github.com/nitezs/sub2sing-box.git synced 2024-12-23 10:44: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")
insecureBool, err := strconv.ParseBool(insecure)
enableTLS := insecureBool || alpnStr != ""
if err != nil {
insecureBool = false
}
@ -86,7 +87,7 @@ func ParseHysteria(proxy string) (model.Outbound, error) {
Network: option.NetworkList(protocol),
OutboundTLSOptionsContainer: option.OutboundTLSOptionsContainer{
TLS: &option.OutboundTLSOptions{
Enabled: true,
Enabled: enableTLS,
Insecure: insecureBool,
ALPN: alpn,
},

View File

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