From 1c3118ff483e66fa21dfc96a3e19fa145ee07186 Mon Sep 17 00:00:00 2001 From: ycc Date: Mon, 19 Sep 2022 14:58:03 +0200 Subject: [PATCH] Server cleanup --- server/server.go | 55 ------------------------------------------------ 1 file changed, 55 deletions(-) delete mode 100644 server/server.go diff --git a/server/server.go b/server/server.go deleted file mode 100644 index 2c8dc47..0000000 --- a/server/server.go +++ /dev/null @@ -1,55 +0,0 @@ -package server - -import ( - "fmt" - "time" - - "forge.redroom.link/yves/meowlib" -) - -type InternalServer struct { - ServerData meowlib.Server `json:"server_data,omitempty"` - Presence bool `json:"presence,omitempty"` - LastCheck time.Time `json:"last_check,omitempty"` - Uptime time.Duration `json:"uptime,omitempty"` - Login string `json:"login,omitempty"` - Password string `json:"password,omitempty"` - Me meowlib.KeyPair `json:"me,omitempty"` -} - -type InternalServerList struct { - Name string - Servers []InternalServer -} - -func InternalServerFromUrl(url string) *InternalServer { - var is InternalServer - is.ServerData.Url = url - return &is -} - -func (sl *InternalServerList) AddUrls(urls []string) { - for _, url := range urls { - sl.Servers = append(sl.Servers, *InternalServerFromUrl(url)) - } -} - -// AsymEncryptMessage prepares a message to send to a specific internal server -func (ints *InternalServer) AsymEncryptMessage(Message []byte) (EncryptedMsg []byte, Signature []byte, err error) { - EncryptedMsg, Signature, err = meowlib.AsymEncryptAndSign(ints.ServerData.PublicKey, ints.Me.Private, Message) - if err != nil { - fmt.Println(err.Error()) - return nil, nil, err - } - return EncryptedMsg, Signature, err -} - -// AsymDecryptMessage reads a message from a specific internal server -func (ints *InternalServer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMsg []byte, err error) { - DecryptedMsg, err = meowlib.AsymDecryptAndCheck(ints.Me.Private, ints.ServerData.PublicKey, Message, Signature) - if err != nil { - fmt.Println(err.Error()) - return nil, err - } - return DecryptedMsg, err -}