diff options
author | Himbeer <himbeer@disroot.org> | 2024-10-13 22:39:14 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-10-13 22:44:46 +0200 |
commit | e3048097f2e618061d8f3d7b2c91b0f5783133a4 (patch) | |
tree | f53c0661c3108eb10adc3817340410955ef69288 /run.go | |
parent | 542955410600d337d595fc3b63910d8716e6a19f (diff) |
Overhaul fallback logic
Fallback is now set up by configuring individual servers to build up a
fallback chain. Each server now only accepts a single fallback server
name and global fallback server definitions have been removed entirely.
Fallback is attempted if there is a kick or if the RUDP connection is
lost. If following the fallback chain is unsuccessful for any reason,
the client is disconnected with the original kick sent by the original
server or an error message about the loss of connection. If fallback
cannot be initiated at any part of the chain (e.g. due to the client not
being connected to a server in the first place) the client is
disconnected with an error message.
This commit fixes #150.
Diffstat (limited to 'run.go')
-rw-r--r-- | run.go | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -156,18 +156,24 @@ func runFunc() { if err := doConnect(srvName, srv); err != nil { cc.Log("<-", err) - cc.SendChatMsg("Could not connect, triggering fallback. Error:", err.Error()) + cc.SendChatMsg("Could not connect, trying fallback server. Error:", err) - for _, fbName := range FallbackServers(srvName) { - fb, ok := conf.Servers[fbName] + fbName := srv.Fallback + for fbName != "" { + var ok bool + srv, ok = conf.Servers[fbName] if !ok { cc.Log("<-", "invalid fallback") continue } - if err := doConnect(fbName, fb); err != nil { + if err := doConnect(fbName, srv); err != nil { + fbName = srv.Fallback + cc.Log("<-", err) - cc.SendChatMsg("Could not connect, continuing fallback. Error:", err.Error()) + cc.SendChatMsg("Could not connect, trying next fallback server. Error:", err.Error()) + } else { + break } } } |