general: update some doc or comment for new features.

This commit is contained in:
nadoo 2018-08-27 19:38:42 +08:00
parent 20616dfd10
commit ac94540ab8
5 changed files with 18 additions and 5 deletions

View File

@ -219,7 +219,7 @@ Available forward strategies:
rr: Round Robin mode
ha: High Availability mode
lha: Latency based High Availability mode
dh: destination hashing mode
dh: Destination Hashing mode
Forwarder option scheme: FORWARD_URL#OPTIONS
priority: set the priority of that forwarder, default:0

View File

@ -191,7 +191,7 @@ func usage() {
fmt.Fprintf(os.Stderr, " rr: Round Robin mode\n")
fmt.Fprintf(os.Stderr, " ha: High Availability mode\n")
fmt.Fprintf(os.Stderr, " lha: Latency based High Availability mode\n")
fmt.Fprintf(os.Stderr, " dh: destination hashing mode\n")
fmt.Fprintf(os.Stderr, " dh: Destination Hashing mode\n")
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "Forwarder option scheme: FORWARD_URL#OPTIONS\n")

View File

@ -60,12 +60,22 @@ listen=socks5://:1080
# Forwarders, we can setup multiple forwarders.
# forward=SCHEME#OPTIONS
# FORWARDER OPTIONS
# priority: set the priority of that forwarder, default:0
# interface: set local interface or ip address used to connect remote server
# Socks5 proxy as forwarder
# forward=socks5://192.168.1.10:1080
# Socks5 proxy as forwarder with priority 100
# forward=socks5://192.168.1.10:1080#priority=100
# Socks5 proxy as forwarder with priority 100 and use `eth0` as source interface
# forward=socks5://192.168.1.10:1080#priority=100&interface=eth0
# Socks5 proxy as forwarder with priority 100 and use `192.168.1.100` as source ip
# forward=socks5://192.168.1.10:1080#priority=100&interface=192.168.1.100
# SS proxy as forwarder
# forward=ss://method:pass@1.1.1.1:8443

View File

@ -14,9 +14,8 @@ import (
"syscall"
"unsafe"
"github.com/nadoo/glider/rule"
"github.com/nadoo/glider/common/log"
"github.com/nadoo/glider/rule"
)
// NFNL_SUBSYS_IPSET netfilter netlink message types

View File

@ -155,6 +155,7 @@ func (d *Dialer) initAvailable() {
}
if len(d.available) == 0 {
log.F("[strategy] no available forwarders, just use: %s, please check your settings or network", d.fwdrs[0])
d.available = append(d.available, d.fwdrs[0])
}
}
@ -239,14 +240,17 @@ func (d *Dialer) check(i int) {
}
}
// Round Robin
func (d *Dialer) scheduleRR(dstAddr string) *proxy.Forwarder {
return d.available[atomic.AddUint32(&d.index, 1)%uint32(len(d.available))]
}
// High Availability
func (d *Dialer) scheduleHA(dstAddr string) *proxy.Forwarder {
return d.available[0]
}
// Latency based High Availability
func (d *Dialer) scheduleLHA(dstAddr string) *proxy.Forwarder {
fwdr := d.available[0]
lowest := fwdr.Latency()
@ -256,10 +260,10 @@ func (d *Dialer) scheduleLHA(dstAddr string) *proxy.Forwarder {
fwdr = f
}
}
return fwdr
}
// Destination Hashing
func (d *Dialer) scheduleDH(dstAddr string) *proxy.Forwarder {
fnv1a := fnv.New32a()
fnv1a.Write([]byte(dstAddr))