mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
strategy: removed unnecessary funcs
This commit is contained in:
parent
4f69372656
commit
104e51ae3c
@ -1,8 +1,6 @@
|
|||||||
package strategy
|
package strategy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
|
|
||||||
"github.com/nadoo/glider/proxy"
|
"github.com/nadoo/glider/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,18 +12,10 @@ func newHADialer(dialers []*proxy.Forwarder, webhost string, duration int) proxy
|
|||||||
return &haDialer{rrDialer: newRRDialer(dialers, webhost, duration)}
|
return &haDialer{rrDialer: newRRDialer(dialers, webhost, duration)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ha *haDialer) nextDialer(dstAddr string) *proxy.Forwarder {
|
func (ha *haDialer) NextDialer(dstAddr string) proxy.Dialer {
|
||||||
d := ha.fwdrs[ha.Index()]
|
d := ha.fwdrs[ha.Index()]
|
||||||
if !d.Enabled() || d.Priority() < ha.Priority() {
|
if !d.Enabled() || d.Priority() < ha.Priority() {
|
||||||
d = ha.nextDialer(dstAddr)
|
d = ha.nextDialer(dstAddr)
|
||||||
}
|
}
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ha *haDialer) Dial(network, addr string) (net.Conn, error) {
|
|
||||||
return ha.nextDialer(addr).Dial(network, addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ha *haDialer) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) {
|
|
||||||
return ha.nextDialer(addr).DialUDP(network, addr)
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package strategy
|
package strategy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
|
|
||||||
"github.com/nadoo/glider/proxy"
|
"github.com/nadoo/glider/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +12,7 @@ func newLHADialer(dialers []*proxy.Forwarder, webhost string, duration int) prox
|
|||||||
return &lhaDialer{rrDialer: newRRDialer(dialers, webhost, duration)}
|
return &lhaDialer{rrDialer: newRRDialer(dialers, webhost, duration)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lha *lhaDialer) nextDialer(dstAddr string) *proxy.Forwarder {
|
func (lha *lhaDialer) NextDialer(dstAddr string) proxy.Dialer {
|
||||||
idx := lha.Index()
|
idx := lha.Index()
|
||||||
var lowest int64
|
var lowest int64
|
||||||
for i, fwder := range lha.fwdrs {
|
for i, fwder := range lha.fwdrs {
|
||||||
@ -36,11 +34,3 @@ func (lha *lhaDialer) nextDialer(dstAddr string) *proxy.Forwarder {
|
|||||||
lha.SetIndex(idx)
|
lha.SetIndex(idx)
|
||||||
return lha.fwdrs[idx]
|
return lha.fwdrs[idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lha *lhaDialer) Dial(network, addr string) (net.Conn, error) {
|
|
||||||
return lha.nextDialer(addr).Dial(network, addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (lha *lhaDialer) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) {
|
|
||||||
return lha.nextDialer(addr).DialUDP(network, addr)
|
|
||||||
}
|
|
||||||
|
@ -46,11 +46,11 @@ func newRRDialer(fwdrs []*proxy.Forwarder, website string, interval int) *rrDial
|
|||||||
func (rr *rrDialer) Addr() string { return "STRATEGY" }
|
func (rr *rrDialer) Addr() string { return "STRATEGY" }
|
||||||
|
|
||||||
func (rr *rrDialer) Dial(network, addr string) (net.Conn, error) {
|
func (rr *rrDialer) Dial(network, addr string) (net.Conn, error) {
|
||||||
return rr.nextDialer(addr).Dial(network, addr)
|
return rr.NextDialer(addr).Dial(network, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rr *rrDialer) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) {
|
func (rr *rrDialer) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) {
|
||||||
return rr.nextDialer(addr).DialUDP(network, addr)
|
return rr.NextDialer(addr).DialUDP(network, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rr *rrDialer) NextDialer(dstAddr string) proxy.Dialer { return rr.nextDialer(dstAddr) }
|
func (rr *rrDialer) NextDialer(dstAddr string) proxy.Dialer { return rr.nextDialer(dstAddr) }
|
||||||
|
Loading…
Reference in New Issue
Block a user