Add initial support for choosing to still connect when the server uses a self-signed cert and verify_vertificates is turned on
This commit is contained in:
parent
3f70567d56
commit
c005fc7cae
7 changed files with 81 additions and 22 deletions
16
irc/conn.go
16
irc/conn.go
|
@ -3,6 +3,7 @@ package irc
|
|||
import (
|
||||
"bufio"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
@ -33,6 +34,10 @@ func (c *Client) Connect(address string) {
|
|||
go c.run()
|
||||
}
|
||||
|
||||
func (c *Client) Reconnect() {
|
||||
close(c.reconnect)
|
||||
}
|
||||
|
||||
func (c *Client) Write(data string) {
|
||||
c.out <- data + "\r\n"
|
||||
}
|
||||
|
@ -64,8 +69,9 @@ func (c *Client) run() {
|
|||
return
|
||||
|
||||
case <-c.reconnect:
|
||||
c.disconnect()
|
||||
c.connChange(false, nil)
|
||||
if c.Connected() {
|
||||
c.disconnect()
|
||||
}
|
||||
|
||||
c.sendRecv.Wait()
|
||||
c.reconnect = make(chan struct{})
|
||||
|
@ -107,6 +113,9 @@ func (c *Client) tryConnect() {
|
|||
err := c.connect()
|
||||
if err != nil {
|
||||
c.connChange(false, err)
|
||||
if _, ok := err.(x509.UnknownAuthorityError); ok {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
c.backoff.Reset()
|
||||
|
||||
|
@ -181,7 +190,8 @@ func (c *Client) recv() {
|
|||
return
|
||||
|
||||
default:
|
||||
close(c.reconnect)
|
||||
c.connChange(false, nil)
|
||||
c.Reconnect()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue