mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-29 07:29:31 +01:00
parent
0d5a4fd584
commit
5fe4d0b133
@ -313,10 +313,7 @@ type Config struct {
|
|||||||
Listeners map[string]listenerConfigBlock
|
Listeners map[string]listenerConfigBlock
|
||||||
UnixBindMode os.FileMode `yaml:"unix-bind-mode"`
|
UnixBindMode os.FileMode `yaml:"unix-bind-mode"`
|
||||||
TorListeners TorListenersConfig `yaml:"tor-listeners"`
|
TorListeners TorListenersConfig `yaml:"tor-listeners"`
|
||||||
// Listen and TLSListeners are the legacy style:
|
// they get parsed into this internal representation:
|
||||||
Listen []string
|
|
||||||
TLSListeners map[string]TLSListenConfig `yaml:"tls-listeners"`
|
|
||||||
// either way, the result is this:
|
|
||||||
trueListeners map[string]listenerConfig
|
trueListeners map[string]listenerConfig
|
||||||
STS STSConfig
|
STS STSConfig
|
||||||
LookupHostnames *bool `yaml:"lookup-hostnames"`
|
LookupHostnames *bool `yaml:"lookup-hostnames"`
|
||||||
@ -558,8 +555,11 @@ func loadTlsConfig(config TLSListenConfig) (tlsConfig *tls.Config, err error) {
|
|||||||
|
|
||||||
// prepareListeners populates Config.Server.trueListeners
|
// prepareListeners populates Config.Server.trueListeners
|
||||||
func (conf *Config) prepareListeners() (err error) {
|
func (conf *Config) prepareListeners() (err error) {
|
||||||
listeners := make(map[string]listenerConfig)
|
if len(conf.Server.Listeners) == 0 {
|
||||||
if 0 < len(conf.Server.Listeners) {
|
return fmt.Errorf("No listeners were configured")
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.Server.trueListeners = make(map[string]listenerConfig)
|
||||||
for addr, block := range conf.Server.Listeners {
|
for addr, block := range conf.Server.Listeners {
|
||||||
var lconf listenerConfig
|
var lconf listenerConfig
|
||||||
lconf.Tor = block.Tor
|
lconf.Tor = block.Tor
|
||||||
@ -575,32 +575,8 @@ func (conf *Config) prepareListeners() (err error) {
|
|||||||
lconf.TLSConfig = tlsConfig
|
lconf.TLSConfig = tlsConfig
|
||||||
lconf.ProxyBeforeTLS = block.TLS.Proxy
|
lconf.ProxyBeforeTLS = block.TLS.Proxy
|
||||||
}
|
}
|
||||||
listeners[addr] = lconf
|
conf.Server.trueListeners[addr] = lconf
|
||||||
}
|
}
|
||||||
} else if 0 < len(conf.Server.Listen) {
|
|
||||||
log.Printf("WARNING: configuring listeners via the legacy `server.listen` config option")
|
|
||||||
log.Printf("This will be removed in a later release: you should update to use `server.listeners`")
|
|
||||||
torListeners := make(map[string]bool, len(conf.Server.TorListeners.Listeners))
|
|
||||||
for _, addr := range conf.Server.TorListeners.Listeners {
|
|
||||||
torListeners[addr] = true
|
|
||||||
}
|
|
||||||
for _, addr := range conf.Server.Listen {
|
|
||||||
var lconf listenerConfig
|
|
||||||
lconf.Tor = torListeners[addr]
|
|
||||||
tlsListenConf, ok := conf.Server.TLSListeners[addr]
|
|
||||||
if ok {
|
|
||||||
tlsConfig, err := loadTlsConfig(tlsListenConf)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
lconf.TLSConfig = tlsConfig
|
|
||||||
}
|
|
||||||
listeners[addr] = lconf
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return fmt.Errorf("No listeners were configured")
|
|
||||||
}
|
|
||||||
conf.Server.trueListeners = listeners
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user