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:
Ken-Håvard Lieng 2017-07-04 11:28:56 +02:00
parent 3f70567d56
commit c005fc7cae
7 changed files with 81 additions and 22 deletions

View file

@ -1,6 +1,7 @@
package server
import (
"crypto/x509"
"encoding/json"
"github.com/khlieng/dispatch/irc"
@ -27,10 +28,16 @@ type ServerName struct {
Name string `json:"name"`
}
type ReconnectSettings struct {
Server string `json:"server"`
SkipVerify bool `json:"skipVerify"`
}
type ConnectionUpdate struct {
Server string `json:"server"`
Connected bool `json:"connected"`
Error string `json:"error,omitempty"`
ErrorType string `json:"errorType,omitempty"`
}
func newConnectionUpdate(server string, state irc.ConnectionState) ConnectionUpdate {
@ -40,6 +47,9 @@ func newConnectionUpdate(server string, state irc.ConnectionState) ConnectionUpd
}
if state.Error != nil {
status.Error = state.Error.Error()
if _, ok := state.Error.(x509.UnknownAuthorityError); ok {
status.ErrorType = "verify"
}
}
return status
}