Shivaram Lingamneni 4 anni fa
parent
commit
14bcd46588
3 ha cambiato i file con 16 aggiunte e 4 eliminazioni
  1. 1
    1
      irc/config.go
  2. 10
    1
      irc/errors.go
  3. 5
    2
      oragono.go

+ 1
- 1
irc/config.go Vedi File

@@ -746,7 +746,7 @@ func (conf *Config) Operators(oc map[string]*OperClass) (map[string]*Oper, error
746 746
 func loadTlsConfig(config TLSListenConfig, webSocket bool) (tlsConfig *tls.Config, err error) {
747 747
 	cert, err := tls.LoadX509KeyPair(config.Cert, config.Key)
748 748
 	if err != nil {
749
-		return nil, ErrInvalidCertKeyPair
749
+		return nil, &CertKeyError{Err: err}
750 750
 	}
751 751
 	clientAuth := tls.RequestClientCert
752 752
 	if webSocket {

+ 10
- 1
irc/errors.go Vedi File

@@ -7,6 +7,8 @@ package irc
7 7
 
8 8
 import (
9 9
 	"errors"
10
+	"fmt"
11
+
10 12
 	"github.com/oragono/oragono/irc/utils"
11 13
 )
12 14
 
@@ -78,10 +80,17 @@ var (
78 80
 	errInvalidCharacter  = errors.New("Invalid character")
79 81
 )
80 82
 
83
+type CertKeyError struct {
84
+	Err error
85
+}
86
+
87
+func (ck *CertKeyError) Error() string {
88
+	return fmt.Sprintf("Invalid TLS cert/key pair: %v", ck.Err)
89
+}
90
+
81 91
 // Config Errors
82 92
 var (
83 93
 	ErrDatastorePathMissing    = errors.New("Datastore path missing")
84
-	ErrInvalidCertKeyPair      = errors.New("tls cert+key: invalid pair")
85 94
 	ErrLimitsAreInsane         = errors.New("Limits aren't setup properly, check them and make them sane")
86 95
 	ErrLineLengthsTooSmall     = errors.New("Line lengths must be 512 or greater (check the linelen section under server->limits)")
87 96
 	ErrLoggerExcludeEmpty      = errors.New("Encountered logging type '-' with no type to exclude")

+ 5
- 2
oragono.go Vedi File

@@ -145,8 +145,11 @@ Options:
145 145
 
146 146
 	configfile := arguments["--conf"].(string)
147 147
 	config, err := irc.LoadConfig(configfile)
148
-	if err != nil && !(err == irc.ErrInvalidCertKeyPair && arguments["mkcerts"].(bool)) {
149
-		log.Fatal("Config file did not load successfully: ", err.Error())
148
+	if err != nil {
149
+		_, isCertError := err.(*irc.CertKeyError)
150
+		if !(isCertError && arguments["mkcerts"].(bool)) {
151
+			log.Fatal("Config file did not load successfully: ", err.Error())
152
+		}
150 153
 	}
151 154
 
152 155
 	logman, err := logger.NewManager(config.Logging)

Loading…
Annulla
Salva