feat(anytls): add AnyTLS protocol support with parsing and configuration options
This commit is contained in:
@@ -57,6 +57,7 @@ func (c *Clash) parseProxy(p proxy.Proxy, uuid string) (*Proxy, error) {
|
||||
"vmess": parseVmess,
|
||||
"hysteria2": parseHysteria2,
|
||||
"tuic": parseTuic,
|
||||
"anytls": parseAnyTLS,
|
||||
}
|
||||
|
||||
if parseFunc, exists := parseFuncs[p.Protocol]; exists {
|
||||
|
||||
@@ -136,6 +136,35 @@ func parseTuic(data proxy.Proxy, uuid string) (*Proxy, error) {
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func parseAnyTLS(data proxy.Proxy, uuid string) (*Proxy, error) {
|
||||
anyTLS, ok := data.Option.(proxy.AnyTLS)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid type for AnyTLS")
|
||||
}
|
||||
|
||||
p := &Proxy{
|
||||
Name: data.Name,
|
||||
Type: "anytls",
|
||||
Server: data.Server,
|
||||
Port: data.Port,
|
||||
Password: uuid,
|
||||
UDP: true,
|
||||
ALPN: []string{
|
||||
"h2",
|
||||
"http/1.1",
|
||||
},
|
||||
}
|
||||
|
||||
if anyTLS.SecurityConfig.SNI != "" {
|
||||
p.SNI = anyTLS.SecurityConfig.SNI
|
||||
}
|
||||
if anyTLS.SecurityConfig.AllowInsecure {
|
||||
p.SkipCertVerify = anyTLS.SecurityConfig.AllowInsecure
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func setSecurityOptions(p *Proxy, security string, config proxy.SecurityConfig) {
|
||||
switch security {
|
||||
case "tls":
|
||||
|
||||
Reference in New Issue
Block a user