From a89cbe5a93aede3703cd5981ea71827b55db0866 Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 12 Feb 2024 18:16:16 +0800 Subject: initial version --- yggdrasil/server.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 yggdrasil/server.go (limited to 'yggdrasil/server.go') diff --git a/yggdrasil/server.go b/yggdrasil/server.go new file mode 100644 index 0000000..818f3ed --- /dev/null +++ b/yggdrasil/server.go @@ -0,0 +1,26 @@ +package yggdrasil + +type Server interface { + // HasJoined returns nil if and only if err != nil + HasJoined(username string, serverID string) (*HasJoinedResponse, error) + // Name returns a human-readable, unique name of this server + Name() string +} + +type HasJoinedResponse struct { + StatusCode int `json:"-"` + RawBody []byte `json:"-"` + ServerName string `json:"-"` + + ID string `json:"id"` + Name string `json:"name"` + Properties []struct { + Name string `json:"name"` + Value string `json:"value"` + Signature string `json:"signature,omitempty"` + } `json:"properties"` +} + +func (r HasJoinedResponse) HasJoined() bool { + return r.StatusCode == 200 && r.ID != "" && r.Name != "" +} -- cgit v1.2.3