summaryrefslogtreecommitdiff
path: root/yggdrasil/server.go
diff options
context:
space:
mode:
authorKeuin <[email protected]>2024-02-12 18:16:16 +0800
committerKeuin <[email protected]>2024-02-12 18:18:45 +0800
commita89cbe5a93aede3703cd5981ea71827b55db0866 (patch)
tree165089cb6c94e00c5f00d57da1a83e84c46722cb /yggdrasil/server.go
initial version
Diffstat (limited to 'yggdrasil/server.go')
-rw-r--r--yggdrasil/server.go26
1 files changed, 26 insertions, 0 deletions
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 != ""
+}