fix: fix dialer switching if only one node and fix ss+simple-obfs

This commit is contained in:
mzz2017 2023-02-11 22:24:14 +08:00
parent f2fba0a261
commit 55301897e0
2 changed files with 12 additions and 11 deletions

View File

@ -153,7 +153,7 @@ func (a *AliveDialerSet) NotifyLatencyChange(dialer *Dialer, alive bool) {
a.minLatency.latency = latency
a.minLatency.dialer = dialer
} else if a.minLatency.dialer == dialer {
if latency > a.minLatency.latency {
if !alive || latency > a.minLatency.latency {
// Latency increases.
a.minLatency.latency = time.Hour
a.minLatency.dialer = nil

View File

@ -48,16 +48,8 @@ func (s *Shadowsocks) Dialer(option *dialer.GlobalOption, iOption dialer.Instanc
default:
return nil, fmt.Errorf("unsupported shadowsocks encryption method: %v", s.Cipher)
}
var err error
d := dialer.FullconeDirect // Shadowsocks Proxy supports full-cone.
d, err := protocol.NewDialer("shadowsocks", d, protocol.Header{
ProxyAddress: net.JoinHostPort(s.Server, strconv.Itoa(s.Port)),
Cipher: s.Cipher,
Password: s.Password,
IsClient: true,
})
if err != nil {
return nil, err
}
switch s.Plugin.Name {
case "simple-obfs":
uSimpleObfs := url.URL{
@ -74,7 +66,16 @@ func (s *Shadowsocks) Dialer(option *dialer.GlobalOption, iOption dialer.Instanc
return nil, err
}
}
return dialer.NewDialer(d, option, iOption, s.Name, s.Protocol, s.ExportToURL()), nil
d, err = protocol.NewDialer("shadowsocks", d, protocol.Header{
ProxyAddress: net.JoinHostPort(s.Server, strconv.Itoa(s.Port)),
Cipher: s.Cipher,
Password: s.Password,
IsClient: true,
})
if err != nil {
return nil, err
}
return dialer.NewDialer(d, option, iOption, s.Name, s.Protocol, s.ExportToURL()), nil
}
func ParseSSURL(u string) (data *Shadowsocks, err error) {