mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
parent
0d5a4fd584
commit
5fe4d0b133
@ -313,10 +313,7 @@ type Config struct {
|
||||
Listeners map[string]listenerConfigBlock
|
||||
UnixBindMode os.FileMode `yaml:"unix-bind-mode"`
|
||||
TorListeners TorListenersConfig `yaml:"tor-listeners"`
|
||||
// Listen and TLSListeners are the legacy style:
|
||||
Listen []string
|
||||
TLSListeners map[string]TLSListenConfig `yaml:"tls-listeners"`
|
||||
// either way, the result is this:
|
||||
// they get parsed into this internal representation:
|
||||
trueListeners map[string]listenerConfig
|
||||
STS STSConfig
|
||||
LookupHostnames *bool `yaml:"lookup-hostnames"`
|
||||
@ -558,8 +555,11 @@ func loadTlsConfig(config TLSListenConfig) (tlsConfig *tls.Config, err error) {
|
||||
|
||||
// prepareListeners populates Config.Server.trueListeners
|
||||
func (conf *Config) prepareListeners() (err error) {
|
||||
listeners := make(map[string]listenerConfig)
|
||||
if 0 < len(conf.Server.Listeners) {
|
||||
if len(conf.Server.Listeners) == 0 {
|
||||
return fmt.Errorf("No listeners were configured")
|
||||
}
|
||||
|
||||
conf.Server.trueListeners = make(map[string]listenerConfig)
|
||||
for addr, block := range conf.Server.Listeners {
|
||||
var lconf listenerConfig
|
||||
lconf.Tor = block.Tor
|
||||
@ -575,32 +575,8 @@ func (conf *Config) prepareListeners() (err error) {
|
||||
lconf.TLSConfig = tlsConfig
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user