diff options
Diffstat (limited to 'pkg/server/sockopt.go')
-rw-r--r-- | pkg/server/sockopt.go | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/pkg/server/sockopt.go b/pkg/server/sockopt.go index 8061f41a..e2b1c086 100644 --- a/pkg/server/sockopt.go +++ b/pkg/server/sockopt.go @@ -17,8 +17,8 @@ package server import ( - "fmt" "net" + "syscall" log "github.com/sirupsen/logrus" ) @@ -39,52 +39,24 @@ func setTCPMinTTLSockopt(conn *net.TCPConn, ttl int) error { return setTcpMinTTLSockopt(conn, ttl) } -type tcpDialer struct { - net.Dialer - - // MD5 authentication password. - AuthPassword string - - // The TTL value to set outgoing connection. - TTL uint8 - - // The minimum TTL value for incoming packets. - TTLMin uint8 -} - -func (d *tcpDialer) DialTCP(addr string, port int) (*net.TCPConn, error) { - if d.AuthPassword != "" { +func dialerControl(network, address string, c syscall.RawConn, ttl, ttlMin uint8, password string) error { + if password != "" { log.WithFields(log.Fields{ "Topic": "Peer", - "Key": addr, + "Key": address, }).Warn("setting md5 for active connection is not supported") } - if d.TTL != 0 { + if ttl != 0 { log.WithFields(log.Fields{ "Topic": "Peer", - "Key": addr, + "Key": address, }).Warn("setting ttl for active connection is not supported") } - if d.TTLMin != 0 { + if ttlMin != 0 { log.WithFields(log.Fields{ "Topic": "Peer", - "Key": addr, + "Key": address, }).Warn("setting min ttl for active connection is not supported") } - - raddr, err := net.ResolveTCPAddr("tcp", net.JoinHostPort(addr, fmt.Sprintf("%d", port))) - if err != nil { - return nil, fmt.Errorf("invalid remote address: %s", err) - } - laddr, err := net.ResolveTCPAddr("tcp", d.LocalAddr.String()) - if err != nil { - return nil, fmt.Errorf("invalid local address: %s", err) - } - - dialer := net.Dialer{LocalAddr: laddr, Timeout: d.Timeout} - conn, err := dialer.Dial("tcp", raddr.String()) - if err != nil { - return nil, err - } - return conn.(*net.TCPConn), nil + return nil } |