summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2021-05-26 14:00:29 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-05-26 14:00:29 +0200
commit98550d817d73d07bdd291b53234ca77195457369 (patch)
tree9058fe4619e3551ab1f916f2beb3b49d08c99f34
parentFix ui tests (diff)
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.
-rw-r--r--app.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/app.go b/app.go
index aebf157..c49c2aa 100644
--- a/app.go
+++ b/app.go
@@ -164,6 +164,7 @@ func (app *App) ircLoop() {
HeadColor: ui.ColorRed,
Body: "Connection lost",
})
+ time.Sleep(10 * time.Second)
}
}
@@ -211,6 +212,11 @@ func (app *App) tryConnect() (conn net.Conn, err error) {
ServerName: host,
NextProtos: []string{"irc"},
})
+ err = conn.(*tls.Conn).Handshake()
+ if err != nil {
+ conn.Close()
+ return nil, err
+ }
}
return