ipset: move to separate package

This commit is contained in:
nadoo 2018-08-13 00:42:59 +08:00
parent 978029bd2b
commit f4eab4d1b2
4 changed files with 11 additions and 7 deletions

View File

@ -2,7 +2,7 @@
// @mdlayher https://github.com/mdlayher/netlink // @mdlayher https://github.com/mdlayher/netlink
// Ref: https://github.com/vishvananda/netlink/blob/master/nl/nl_linux.go // Ref: https://github.com/vishvananda/netlink/blob/master/nl/nl_linux.go
package main package ipset
import ( import (
"bytes" "bytes"

View File

@ -1,6 +1,6 @@
// +build !linux // +build !linux
package main package ipset
import ( import (
"errors" "errors"

View File

@ -8,6 +8,7 @@ import (
"github.com/nadoo/glider/common/log" "github.com/nadoo/glider/common/log"
"github.com/nadoo/glider/dns" "github.com/nadoo/glider/dns"
"github.com/nadoo/glider/ipset"
"github.com/nadoo/glider/proxy" "github.com/nadoo/glider/proxy"
"github.com/nadoo/glider/rule" "github.com/nadoo/glider/rule"
"github.com/nadoo/glider/strategy" "github.com/nadoo/glider/strategy"
@ -37,7 +38,7 @@ func main() {
} }
dialer := rule.NewDialer(conf.rules, strategy.NewDialer(conf.Forward, &conf.StrategyConfig)) 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 // DNS Server
if conf.DNS != "" { if conf.DNS != "" {

View File

@ -6,6 +6,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync/atomic" "sync/atomic"
"github.com/nadoo/glider/common/log"
) )
// Forwarder is a forwarder // 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) c, err = f.Dialer.Dial(network, addr)
if err != nil { if err != nil {
atomic.AddUint32(&f.failures, 1) atomic.AddUint32(&f.failures, 1)
} log.F("[forwarder] %s, dials %s, error:%s", f.addr, addr, err)
if f.Failures() >= f.MaxFailures {
if f.Failures() >= f.MaxFailures { f.Disable()
f.Disable() log.F("[forwarder] %s reaches maxfailures, set to disabled", f.addr)
}
} }
return c, err return c, err