mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
strategy: return fwdr's addr when only 1 fwdr left
This commit is contained in:
1 parent
063dc1bc01
commit
6c8141e43b
2 files changed
+8
-7
No files matched your search
@@ -15,11 +15,6 @@ import (
|
||||
"github.com/nadoo/glider/proxy"
|
||||
)
|
||||
|
||||
// Checker is an interface of forwarder checker.
|
||||
type Checker interface {
|
||||
Check()
|
||||
}
|
||||
|
||||
// Config is strategy config struct.
|
||||
type Config struct {
|
||||
Strategy string
|
||||
@@ -107,7 +102,13 @@ func newDialer(fwdrs []*Forwarder, c *Config) *Dialer {
|
||||
}
|
||||
|
||||
// Addr returns forwarder's address.
|
||||
func (d *Dialer) Addr() string { return "STRATEGY" }
|
||||
func (d *Dialer) Addr() string {
|
||||
if d.fwdrs.Len() == 1 {
|
||||
return d.fwdrs[0].Addr()
|
||||
}
|
||||
|
||||
return "STRATEGY"
|
||||
}
|
||||
|
||||
// Dial connects to the address addr on the network net.
|
||||
func (d *Dialer) Dial(network, addr string) (net.Conn, string, error) {
|
||||
|
||||
Reference in new issue
Block a user