commit 98550d8

Hubert Hirtz  ·  2021-05-26 12:00:29 +0000 UTC
parent 5cb1bbe
Do not go into infinite loops on TLS mismatch

- do the TLS eagerly instead of waiting for the first write, so that an
  error message can be printed,
- sleep for 10 seconds before reconnecting, otherwise when connecting
  without TLS to a TLS server, the connection will always succeed while
  the first writes will not.
1 files changed,  +6, -0
M app.go
M app.go
+6, -0
 1@@ -164,6 +164,7 @@ func (app *App) ircLoop() {
 2 			HeadColor: ui.ColorRed,
 3 			Body:      "Connection lost",
 4 		})
 5+		time.Sleep(10 * time.Second)
 6 	}
 7 }
 8 
 9@@ -211,6 +212,11 @@ func (app *App) tryConnect() (conn net.Conn, err error) {
10 			ServerName: host,
11 			NextProtos: []string{"irc"},
12 		})
13+		err = conn.(*tls.Conn).Handshake()
14+		if err != nil {
15+			conn.Close()
16+			return nil, err
17+		}
18 	}
19 
20 	return