mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 01:15:41 +08:00
ipset: move to separate package
This commit is contained in:
parent
978029bd2b
commit
f4eab4d1b2
@ -2,7 +2,7 @@
|
||||
// @mdlayher https://github.com/mdlayher/netlink
|
||||
// Ref: https://github.com/vishvananda/netlink/blob/master/nl/nl_linux.go
|
||||
|
||||
package main
|
||||
package ipset
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -1,6 +1,6 @@
|
||||
// +build !linux
|
||||
|
||||
package main
|
||||
package ipset
|
||||
|
||||
import (
|
||||
"errors"
|
3
main.go
3
main.go
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/nadoo/glider/common/log"
|
||||
"github.com/nadoo/glider/dns"
|
||||
"github.com/nadoo/glider/ipset"
|
||||
"github.com/nadoo/glider/proxy"
|
||||
"github.com/nadoo/glider/rule"
|
||||
"github.com/nadoo/glider/strategy"
|
||||
@ -37,7 +38,7 @@ func main() {
|
||||
}
|
||||
|
||||
dialer := rule.NewDialer(conf.rules, strategy.NewDialer(conf.Forward, &conf.StrategyConfig))
|
||||
ipsetM, _ := NewIPSetManager(conf.IPSet, conf.rules)
|
||||
ipsetM, _ := ipset.NewIPSetManager(conf.IPSet, conf.rules)
|
||||
|
||||
// DNS Server
|
||||
if conf.DNS != "" {
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/nadoo/glider/common/log"
|
||||
)
|
||||
|
||||
// Forwarder is a forwarder
|
||||
@ -69,10 +71,11 @@ func (f *Forwarder) Dial(network, addr string) (c net.Conn, err error) {
|
||||
c, err = f.Dialer.Dial(network, addr)
|
||||
if err != nil {
|
||||
atomic.AddUint32(&f.failures, 1)
|
||||
}
|
||||
|
||||
if f.Failures() >= f.MaxFailures {
|
||||
f.Disable()
|
||||
log.F("[forwarder] %s, dials %s, error:%s", f.addr, addr, err)
|
||||
if f.Failures() >= f.MaxFailures {
|
||||
f.Disable()
|
||||
log.F("[forwarder] %s reaches maxfailures, set to disabled", f.addr)
|
||||
}
|
||||
}
|
||||
|
||||
return c, err
|
||||
|
Loading…
Reference in New Issue
Block a user