diff options
| author | bt <bt@rctt.net> | 2026-04-10 19:31:31 +0200 |
|---|---|---|
| committer | bt <bt@rctt.net> | 2026-04-18 22:33:20 +0200 |
| commit | e9aebac1a2a4732763c2f7e4428a23983d4eb6a3 (patch) | |
| tree | b66ea36939ea75360ed6c554cf352348d19786bb /core/data.go | |
| parent | f66e28aa88a5f4176934001fa9e4967ddccde4a9 (diff) | |
| download | solec-e9aebac1a2a4732763c2f7e4428a23983d4eb6a3.tar.gz solec-e9aebac1a2a4732763c2f7e4428a23983d4eb6a3.zip | |
[common] Exchange messages between servers
Diffstat (limited to 'core/data.go')
| -rw-r--r-- | core/data.go | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/core/data.go b/core/data.go index a96b56f..dd2777f 100644 --- a/core/data.go +++ b/core/data.go @@ -16,13 +16,14 @@ type Wrapper interface { type PayloadType uint8 const ( - PayloadUnknown PayloadType = 0x00 - PayloadSuccess = 0x01 - PayloadError = 0x02 - PayloadHandshake = 0x03 - PayloadAuth = 0x04 - PayloadMessage = 0x05 - PayloadTest = 0xFF + PayloadUnknown PayloadType = 0x00 + PayloadSuccess = 0x01 + PayloadError = 0x02 + PayloadHandshake = 0x03 + PayloadUserAuth = 0x04 + PayloadMessage = 0x05 + PayloadServerAuth = 0x06 + PayloadTest = 0xFF ) type ErrorType uint8 @@ -33,6 +34,14 @@ const ( ErrorNotFound = 0x02 ) +type ConnType uint8 + +const ( + ConnTypeUnknown ConnType = 0x00 + ConnTypeUser = 0x01 + ConnTypeServer = 0x02 +) + type Frame struct { Length uint16 Type PayloadType @@ -99,7 +108,7 @@ func Decode(buf io.Reader) (any, error) { err := binary.Read(buf, binary.BigEndian, &pTypeByte) if err != nil { - return nil, fmt.Errorf("cannot read payload type: %v", err) + return nil, fmt.Errorf("cannot read payload type: %w", err) } pType := PayloadType(pTypeByte) @@ -107,7 +116,7 @@ func Decode(buf io.Reader) (any, error) { var pLen uint16 err = binary.Read(buf, binary.BigEndian, &pLen) if err != nil { - return nil, fmt.Errorf("cannot read payload length: %v", err) + return nil, fmt.Errorf("cannot read payload length: %w", err) } switch pType { @@ -117,8 +126,10 @@ func Decode(buf io.Reader) (any, error) { return DecodeError(buf) case PayloadHandshake: return DecodeHandshake(buf) - case PayloadAuth: - return DecodeAuth(buf) + case PayloadUserAuth: + return DecodeUserAuth(buf) + case PayloadServerAuth: + return DecodeServerAuth(buf) case PayloadMessage: return DecodeMessage(buf) case PayloadTest: |
