36 lines
701 B
Go
36 lines
701 B
Go
package hysteria2
|
|
|
|
import "vpnclient/internal/config"
|
|
|
|
// EnrichProfile fills empty hy2 option fields from the share URI.
|
|
func EnrichProfile(p *config.Profile) {
|
|
if p == nil || p.Protocol != config.ProtocolHysteria2 || p.Proxy == "" {
|
|
return
|
|
}
|
|
ep, err := ParseEndpoint(p.Proxy)
|
|
if err != nil {
|
|
return
|
|
}
|
|
if p.Hy2SNI == "" {
|
|
p.Hy2SNI = ep.SNI
|
|
}
|
|
if p.Hy2Obfs == "" {
|
|
p.Hy2Obfs = ep.Obfs
|
|
}
|
|
if p.Hy2ObfsPassword == "" {
|
|
p.Hy2ObfsPassword = ep.ObfsPassword
|
|
}
|
|
if p.Hy2PinSHA256 == "" {
|
|
p.Hy2PinSHA256 = ep.PinSHA256
|
|
}
|
|
if ep.Insecure {
|
|
p.Hy2Insecure = true
|
|
}
|
|
if p.Hy2Congestion == "" {
|
|
p.Hy2Congestion = "bbr"
|
|
}
|
|
if p.Hy2BBRProfile == "" {
|
|
p.Hy2BBRProfile = "standard"
|
|
}
|
|
}
|