diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-21 17:54:03 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-10-19 01:26:21 +0200 |
commit | e5f52695a3b83f8ab38ffe949b2f7a04726dc0ab (patch) | |
tree | 2a2c6decbb72ad66b2e6a0949c668adfc854fdc0 /pkg/server/fsm.go | |
parent | c8e54e7f8a2a49c8c035d5becf33b21fc0babf25 (diff) |
implement pluggable transporttransport
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
Diffstat (limited to 'pkg/server/fsm.go')
-rw-r--r-- | pkg/server/fsm.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pkg/server/fsm.go b/pkg/server/fsm.go index 2228b7ca..d7521f4e 100644 --- a/pkg/server/fsm.go +++ b/pkg/server/fsm.go @@ -179,8 +179,8 @@ type fsm struct { outgoingCh *channels.InfiniteChannel incomingCh *channels.InfiniteChannel reason *fsmStateReason - conn net.Conn - connCh chan net.Conn + conn Conn + connCh chan Conn idleHoldTime float64 opensentHoldTime float64 adminState adminState @@ -274,7 +274,7 @@ func newFSM(gConf *config.Global, pConf *config.Neighbor) *fsm { state: bgp.BGP_FSM_IDLE, outgoingCh: channels.NewInfiniteChannel(), incomingCh: channels.NewInfiniteChannel(), - connCh: make(chan net.Conn, 1), + connCh: make(chan Conn, 1), opensentHoldTime: float64(holdtimeOpensent), adminState: adminState, adminStateCh: make(chan adminStateOperation, 1), @@ -548,13 +548,13 @@ func (h *fsmHandler) connectLoop(ctx context.Context, wg *sync.WaitGroup) { } if err == nil { - d := net.Dialer{ + d := transport.NewDialer(&net.Dialer{ LocalAddr: laddr, Timeout: time.Duration(tick-1) * time.Second, Control: func(network, address string, c syscall.RawConn) error { return dialerControl(network, address, c, ttl, ttlMin, password, bindInterface) }, - } + }) conn, err := d.DialContext(ctx, "tcp", net.JoinHostPort(addr, strconv.Itoa(port))) select { @@ -638,7 +638,7 @@ func (h *fsmHandler) active(ctx context.Context) (bgp.FSMState, *fsmStateReason) ttl = int(fsm.pConf.Transport.Config.Ttl) } if ttl != 0 { - if err := setTCPTTLSockopt(conn.(*net.TCPConn), ttl); err != nil { + if err := conn.SetTCPTTLSockopt(ttl); err != nil { log.WithFields(log.Fields{ "Topic": "Peer", "Key": fsm.pConf.Config.NeighborAddress, @@ -647,7 +647,7 @@ func (h *fsmHandler) active(ctx context.Context) (bgp.FSMState, *fsmStateReason) } } if ttlMin != 0 { - if err := setTCPMinTTLSockopt(conn.(*net.TCPConn), ttlMin); err != nil { + if err := conn.SetTCPMinTTLSockopt(ttlMin); err != nil { log.WithFields(log.Fields{ "Topic": "Peer", "Key": fsm.pConf.Config.NeighborAddress, |