have the tunConn close things after a 2 minute timeout

This commit is contained in:
Arceliar 2019-05-28 18:35:52 -05:00
parent 5ea864869a
commit b2513fce56
2 changed files with 53 additions and 13 deletions

View file

@ -229,10 +229,11 @@ func (tun *TunAdapter) handler() error {
func (tun *TunAdapter) wrap(conn *yggdrasil.Conn) (c *tunConn, err error) {
// Prepare a session wrapper for the given connection
s := tunConn{
tun: tun,
conn: conn,
send: make(chan []byte, 32), // TODO: is this a sensible value?
stop: make(chan interface{}),
tun: tun,
conn: conn,
send: make(chan []byte, 32), // TODO: is this a sensible value?
stop: make(chan struct{}),
alive: make(chan struct{}, 1),
}
// Get the remote address and subnet of the other side
remoteNodeID := conn.RemoteAddr()
@ -259,6 +260,7 @@ func (tun *TunAdapter) wrap(conn *yggdrasil.Conn) (c *tunConn, err error) {
// Start the connection goroutines
go s.reader()
go s.writer()
go s.checkForTimeouts()
// Return
return c, err
}