improve server relay and client

This commit is contained in:
juancwu 2025-12-07 21:17:52 -05:00
commit fd0e2afddb
6 changed files with 461 additions and 109 deletions

View file

@ -1,8 +1,28 @@
package protocol
// MessageType ensures we only use valid protocol commands
type MessageType string
const (
// TypeLogin: Client -> Server (Handshake with Public Key)
TypeLogin MessageType = "login"
// TypeIdentity: Server -> Client (Here is your Account Number)
TypeIdentity MessageType = "identity"
// TypeLookup: Client -> Server (Who owns Account #10050?)
TypeLookup MessageType = "lookup"
// TypeLookupResponse: Server -> Client (Here is the Public Key for #10050)
TypeLookupResponse MessageType = "lookup_response"
// TypeMsg: Client -> Server -> Client (Encrypted Payload)
TypeMsg MessageType = "msg"
)
type Message struct {
Type string `json:"type"`
Sender string `json:"sender"`
Target string `json:"target"`
Content string `json:"content"`
Type MessageType `json:"type"`
Sender string `json:"sender"` // Hex Public Key
Target string `json:"target"` // Hex Public Key (msg) or Account # (lookup)
Content string `json:"content"`
}