mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +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
|
// @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"
|
@ -1,6 +1,6 @@
|
|||||||
// +build !linux
|
// +build !linux
|
||||||
|
|
||||||
package main
|
package ipset
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
3
main.go
3
main.go
@ -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 != "" {
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user