mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
proxy: improve interface binding (by setsockopt) on linux
This commit is contained in:
1 parent
5b1a127d04
commit
39ae201afe
4 files changed
+27
-4
No files matched your search
+4
-3
@@ -33,9 +33,6 @@ func NewDirect(intface string, dialTimeout, relayTimeout time.Duration) (*Direct
|
||||
return nil, errors.New(err.Error() + ": " + intface)
|
||||
}
|
||||
d.iface = iface
|
||||
if ips := d.IFaceIPs(); len(ips) > 0 {
|
||||
d.ip = ips[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +85,10 @@ func (d *Direct) dial(network, addr string, localIP net.IP) (net.Conn, error) {
|
||||
}
|
||||
|
||||
dialer := &net.Dialer{LocalAddr: la, Timeout: d.dialTimeout}
|
||||
if d.iface != nil {
|
||||
bind(dialer, d.iface)
|
||||
}
|
||||
|
||||
c, err := dialer.Dial(network, addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user