From e9aebac1a2a4732763c2f7e4428a23983d4eb6a3 Mon Sep 17 00:00:00 2001 From: bt Date: Fri, 10 Apr 2026 19:31:31 +0200 Subject: [common] Exchange messages between servers --- core/payload.go | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'core/payload.go') diff --git a/core/payload.go b/core/payload.go index b8e8b9f..e943647 100644 --- a/core/payload.go +++ b/core/payload.go @@ -36,11 +36,12 @@ func DecodeError(buf io.Reader) (Error, error) { type Handshake struct { Major, Minor uint8 + ConnType ConnType } func (h Handshake) Wrap() (PayloadType, []any) { return PayloadHandshake, []any{ - h.Major, h.Minor, + h.Major, h.Minor, h.ConnType, } } @@ -57,22 +58,27 @@ func DecodeHandshake(buf io.Reader) (Handshake, error) { return h, err } + err = decodeNumeric(buf, &h.ConnType) + if err != nil { + return h, err + } + return h, nil } -type Auth struct { +type UserAuth struct { Name string Pass string } -func (a Auth) Wrap() (PayloadType, []any) { - return PayloadAuth, []any{ +func (a UserAuth) Wrap() (PayloadType, []any) { + return PayloadUserAuth, []any{ a.Name, a.Pass, } } -func DecodeAuth(buf io.Reader) (Auth, error) { - var a Auth +func DecodeUserAuth(buf io.Reader) (UserAuth, error) { + var a UserAuth err := decodeString(buf, &a.Name) if err != nil { return a, err @@ -86,6 +92,22 @@ func DecodeAuth(buf io.Reader) (Auth, error) { return a, nil } +type ServerAuth struct { + Name string +} + +func (a ServerAuth) Wrap() (PayloadType, []any) { + return PayloadServerAuth, []any{ + a.Name, + } +} + +func DecodeServerAuth(buf io.Reader) (ServerAuth, error) { + var a ServerAuth + err := decodeString(buf, &a.Name) + return a, err +} + type Message struct { Source string Target string -- cgit v1.2.3