|
@@ -13,17 +13,17 @@ type PassConfig struct {
|
13
|
13
|
Password string
|
14
|
14
|
}
|
15
|
15
|
|
16
|
|
-// SSLListenConfig defines configuration options for listening on SSL
|
17
|
|
-type SSLListenConfig struct {
|
|
16
|
+// TLSListenConfig defines configuration options for listening on TLS
|
|
17
|
+type TLSListenConfig struct {
|
18
|
18
|
Cert string
|
19
|
19
|
Key string
|
20
|
20
|
}
|
21
|
21
|
|
22
|
|
-// Certificate returns the SSL certificate assicated with this SSLListenConfig
|
23
|
|
-func (conf *SSLListenConfig) Config() (*tls.Config, error) {
|
|
22
|
+// Certificate returns the TLS certificate assicated with this TLSListenConfig
|
|
23
|
+func (conf *TLSListenConfig) Config() (*tls.Config, error) {
|
24
|
24
|
cert, err := tls.LoadX509KeyPair(conf.Cert, conf.Key)
|
25
|
25
|
if err != nil {
|
26
|
|
- return nil, errors.New("ssl cert+key: invalid pair")
|
|
26
|
+ return nil, errors.New("tls cert+key: invalid pair")
|
27
|
27
|
}
|
28
|
28
|
|
29
|
29
|
return &tls.Config{
|
|
@@ -49,14 +49,13 @@ type Config struct {
|
49
|
49
|
Name string
|
50
|
50
|
Database string
|
51
|
51
|
Listen []string
|
52
|
|
- Wslisten string
|
|
52
|
+ Wslisten string `yaml:"ws-listen"`
|
|
53
|
+ TLSListeners map[string]*TLSListenConfig `yaml:"tls-listeners"`
|
53
|
54
|
Log string
|
54
|
55
|
MOTD string
|
55
|
56
|
ProxyAllowedFrom []string `yaml:"proxy-allowed-from"`
|
56
|
57
|
}
|
57
|
58
|
|
58
|
|
- SSLListener map[string]*SSLListenConfig
|
59
|
|
-
|
60
|
59
|
Operator map[string]*PassConfig
|
61
|
60
|
|
62
|
61
|
Theater map[string]*PassConfig
|
|
@@ -82,16 +81,16 @@ func (conf *Config) Theaters() map[Name][]byte {
|
82
|
81
|
return theaters
|
83
|
82
|
}
|
84
|
83
|
|
85
|
|
-func (conf *Config) SSLListeners() map[Name]*tls.Config {
|
86
|
|
- sslListeners := make(map[Name]*tls.Config)
|
87
|
|
- for s, sslListenersConf := range conf.SSLListener {
|
88
|
|
- config, err := sslListenersConf.Config()
|
|
84
|
+func (conf *Config) TLSListeners() map[Name]*tls.Config {
|
|
85
|
+ tlsListeners := make(map[Name]*tls.Config)
|
|
86
|
+ for s, tlsListenersConf := range conf.Server.TLSListeners {
|
|
87
|
+ config, err := tlsListenersConf.Config()
|
89
|
88
|
if err != nil {
|
90
|
89
|
log.Fatal(err)
|
91
|
90
|
}
|
92
|
|
- sslListeners[NewName(s)] = config
|
|
91
|
+ tlsListeners[NewName(s)] = config
|
93
|
92
|
}
|
94
|
|
- return sslListeners
|
|
93
|
+ return tlsListeners
|
95
|
94
|
}
|
96
|
95
|
|
97
|
96
|
func LoadConfig(filename string) (config *Config, err error) {
|