author | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-07-22 11:31:48 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-07-22 11:31:48 UTC |
parent | bdd86e0b494bba9a81323fd6803f3323a244f22e |
5medias.go | +7 | -0 |
diff --git a/5medias.go b/5medias.go index bab4e4e..bafc907 100644 --- a/5medias.go +++ b/5medias.go @@ -69,6 +69,10 @@ func (c *Conn) Logf(f string, a ...interface{}) { func (c *Conn) Handle() { defer c.conn.Close() + // Connetions should attempt to dial within 15s (this deadline is + // cancelled before dial below). + c.conn.SetDeadline(time.Now().Add(15 * time.Second)) + c.Logf("connected") if err := c.handshake(); err != nil { c.Logf("handshake error: %v", err) @@ -81,6 +85,9 @@ func (c *Conn) Handle() { return } + // Reset the deadline, now it'll be up to the dial. + c.conn.SetDeadline(time.Time{}) + c.Logf("dial %q", dstAddr) dstConn, err := net.DialTimeout("tcp", dstAddr, *dialTimeout) if err != nil {