feat: 增加hysteria2协议的支持

This commit is contained in:
2023-10-31 15:14:29 +08:00
parent 50877b1691
commit d0696aad5b
6 changed files with 108 additions and 6 deletions

View File

@ -18,11 +18,12 @@ func GetSupportProxyTypes(clashType ClashType) map[string]bool {
}
if clashType == ClashMeta {
return map[string]bool{
"ss": true,
"ssr": true,
"vmess": true,
"trojan": true,
"vless": true,
"ss": true,
"ssr": true,
"vmess": true,
"trojan": true,
"vless": true,
"hysteria2": true,
}
}
return nil

View File

@ -45,6 +45,11 @@ type Proxy struct {
UDPOverTCP bool `yaml:"udp-over-tcp,omitempty"`
UDPOverTCPVersion int `yaml:"udp-over-tcp-version,omitempty"`
SubName string `yaml:"-"`
Up string `yaml:"up,omitempty"`
Down string `yaml:"down,omitempty"`
CustomCA string `yaml:"ca,omitempty"`
CustomCAString string `yaml:"ca-str,omitempty"`
CWND int `yaml:"cwnd,omitempty"`
}
func (p Proxy) MarshalYAML() (interface{}, error) {
@ -59,6 +64,8 @@ func (p Proxy) MarshalYAML() (interface{}, error) {
return ProxyToVless(p), nil
case "trojan":
return ProxyToTrojan(p), nil
case "hysteria2":
return ProxyToHysteria2(p), nil
}
return nil, nil
}

41
model/proxy_hysteria2.go Normal file
View File

@ -0,0 +1,41 @@
package model
type Hysteria2 struct {
Type string `yaml:"type"`
Name string `yaml:"name"`
Server string `yaml:"server"`
Port int `yaml:"port"`
Up string `yaml:"up,omitempty"`
Down string `yaml:"down,omitempty"`
Password string `yaml:"password,omitempty"`
Obfs string `yaml:"obfs,omitempty"`
ObfsPassword string `yaml:"obfs-password,omitempty"`
SNI string `yaml:"sni,omitempty"`
SkipCertVerify bool `yaml:"skip-cert-verify,omitempty"`
Fingerprint string `yaml:"fingerprint,omitempty"`
ALPN []string `yaml:"alpn,omitempty"`
CustomCA string `yaml:"ca,omitempty"`
CustomCAString string `yaml:"ca-str,omitempty"`
CWND int `yaml:"cwnd,omitempty"`
}
func ProxyToHysteria2(p Proxy) Hysteria2 {
return Hysteria2{
Type: "hysteria2",
Name: p.Name,
Server: p.Server,
Port: p.Port,
Up: p.Up,
Down: p.Down,
Password: p.Password,
Obfs: p.Obfs,
ObfsPassword: p.ObfsParam,
SNI: p.Sni,
SkipCertVerify: p.SkipCertVerify,
Fingerprint: p.Fingerprint,
ALPN: p.Alpn,
CustomCA: p.CustomCA,
CustomCAString: p.CustomCAString,
CWND: p.CWND,
}
}