diff options
author | pg9182 <96569817+pg9182@users.noreply.github.com> | 2022-10-15 02:37:29 -0400 |
---|---|---|
committer | pg9182 <96569817+pg9182@users.noreply.github.com> | 2022-10-15 02:37:29 -0400 |
commit | ec4a20f9fe68273b3784ff0fb6bd1e2a59f31110 (patch) | |
tree | a238ffee097cfe9c4e7e06afcd31b5c280bb8b4e /pkg/api/api0/api.go | |
parent | 62737f1e52146987718fbe36bc8e4fbe14edc25c (diff) | |
download | Atlas-ec4a20f9fe68273b3784ff0fb6bd1e2a59f31110.tar.gz Atlas-ec4a20f9fe68273b3784ff0fb6bd1e2a59f31110.zip |
pkg/api/api0: Implement /client/servers
And it's _fast_, even with thousands of servers and hundreds of
requests per second.
Diffstat (limited to 'pkg/api/api0/api.go')
-rw-r--r-- | pkg/api/api0/api.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/api/api0/api.go b/pkg/api/api0/api.go index f64203c..b376a14 100644 --- a/pkg/api/api0/api.go +++ b/pkg/api/api0/api.go @@ -9,6 +9,7 @@ // - More HTTP methods and features are supported (e.g., HEAD, OPTIONS, Content-Encoding). // - Website split into a separate handler (set Handler.NotFound to http.HandlerFunc(web.ServeHTTP) for identical behaviour). // - /accounts/write_persistence returns a error message for easier debugging. +// - Alive/dead servers can be replaced by a new successful registration from the same ip/port. This eliminates the main cause of the duplicate server error requiring retries, and doesn't add much risk since you need to custom fuckery to start another server when you're already listening on the port. package api0 import ( @@ -29,6 +30,9 @@ import ( // Handler serves requests for the original master server API. type Handler struct { + // ServerList stores registered servers. + ServerList *ServerList + // AccountStorage stores accounts. It must be non-nil. AccountStorage AccountStorage @@ -71,6 +75,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { h.handleClientOriginAuth(w, r) case "/client/auth_with_self": h.handleClientAuthWithSelf(w, r) + case "/client/servers": + h.handleClientServers(w, r) case "/accounts/write_persistence": h.handleAccountsWritePersistence(w, r) case "/accounts/get_username": |