mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
simplify listener rehash logic
This commit is contained in:
parent
c426cc8bab
commit
17909a5db0
@ -740,19 +740,13 @@ func (server *Server) setupListeners(config *Config) (err error) {
|
|||||||
newConfig, stillConfigured := config.Server.trueListeners[addr]
|
newConfig, stillConfigured := config.Server.trueListeners[addr]
|
||||||
|
|
||||||
if stillConfigured {
|
if stillConfigured {
|
||||||
reloadErr := currentListener.Reload(newConfig)
|
if reloadErr := currentListener.Reload(newConfig); reloadErr == nil {
|
||||||
// attempt to stop and replace the listener if the reload failed
|
|
||||||
if reloadErr != nil {
|
|
||||||
currentListener.Stop()
|
|
||||||
newListener, newErr := NewListener(server, addr, newConfig, config.Server.UnixBindMode)
|
|
||||||
if newErr == nil {
|
|
||||||
server.listeners[addr] = newListener
|
|
||||||
} else {
|
|
||||||
delete(server.listeners, addr)
|
|
||||||
return newErr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logListener(addr, newConfig)
|
logListener(addr, newConfig)
|
||||||
|
} else {
|
||||||
|
// stop the listener; we will attempt to replace it below
|
||||||
|
currentListener.Stop()
|
||||||
|
delete(server.listeners, addr)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
currentListener.Stop()
|
currentListener.Stop()
|
||||||
delete(server.listeners, addr)
|
delete(server.listeners, addr)
|
||||||
@ -761,7 +755,8 @@ func (server *Server) setupListeners(config *Config) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
publicPlaintextListener := ""
|
publicPlaintextListener := ""
|
||||||
// create new listeners that were not previously configured
|
// create new listeners that were not previously configured,
|
||||||
|
// or that couldn't be reloaded above:
|
||||||
for newAddr, newConfig := range config.Server.trueListeners {
|
for newAddr, newConfig := range config.Server.trueListeners {
|
||||||
if strings.HasPrefix(newAddr, ":") && !newConfig.Tor && !newConfig.STSOnly && newConfig.TLSConfig == nil {
|
if strings.HasPrefix(newAddr, ":") && !newConfig.Tor && !newConfig.STSOnly && newConfig.TLSConfig == nil {
|
||||||
publicPlaintextListener = newAddr
|
publicPlaintextListener = newAddr
|
||||||
|
Loading…
Reference in New Issue
Block a user