From d63176e22d21e347cf1c197084afe8eb1d5376b4 Mon Sep 17 00:00:00 2001 From: bt Date: Sat, 18 Apr 2026 23:12:11 +0200 Subject: [docs] Update protocol docs --- README.md | 16 +- core/errors.go | 13 +- docs/protocol.ksy | 126 ++++++++ docs/protocol.svg | 827 ++++++++++++++++++++++++++++------------------------ docs/rfc.html | 164 ++++++++--- docs/rfc.md | 48 +-- docs/rfc.txt | 56 ++-- notes.txt | 3 - solec-wireshark.lua | 340 +++++++++++++++++++++ solec.ksy | 119 -------- solec.lua | 304 ------------------- tools/build_spec.sh | 11 +- tools/run-many.sh | 1 + 13 files changed, 1113 insertions(+), 915 deletions(-) create mode 100644 docs/protocol.ksy delete mode 100644 notes.txt create mode 100644 solec-wireshark.lua delete mode 100644 solec.ksy delete mode 100644 solec.lua diff --git a/README.md b/README.md index d56c4fa..2c6f30f 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Use following to setup Git hooks: `git config --local core.hooksPath hooks` * `tools/run.sh` - build and start server and few clients +* `tools/run-many.sh` - build and start two servers and two clients * `tools/build-spec.sh` - build Kaitai spec ## Wireshark plugin @@ -30,18 +31,3 @@ After building foked KSC use `./tools/build_spec.sh` to build the plugin and the it into Wireshark plugins directory. There is a problem with dissecting specific payloads. - -## TODO - -- Protocol - - Design authentication process - - Desing messages history sync - -- Server - - User to user messaging - - User to channel messaging - - Better error handling - -- Network library - - Handle partial TCP packets - - Better error handling diff --git a/core/errors.go b/core/errors.go index ed6702d..a50fbf7 100644 --- a/core/errors.go +++ b/core/errors.go @@ -3,11 +3,10 @@ package core import "errors" var ( - ErrUnexpectedPayloadType = errors.New("unexpected payload type") - ErrAuthInvalidUser = errors.New("invalid user") - ErrAuthInvalidPassword = errors.New("invalid password") - ErrAuthReverseLookupFailed = errors.New("declared name does not match with DNS name") - ErrInvalidAddress = errors.New("invalid address") - ErrNotSupported = errors.New("not supported") - ErrDisconnected = errors.New("disconnected") + ErrUnexpectedPayloadType = errors.New("unexpected payload type") + ErrAuthInvalidUser = errors.New("invalid user") + ErrAuthInvalidPassword = errors.New("invalid password") + ErrInvalidAddress = errors.New("invalid address") + ErrNotSupported = errors.New("not supported") + ErrDisconnected = errors.New("disconnected") ) diff --git a/docs/protocol.ksy b/docs/protocol.ksy new file mode 100644 index 0000000..169ba18 --- /dev/null +++ b/docs/protocol.ksy @@ -0,0 +1,126 @@ +meta: + id: solec + file-extension: hex + endian: be + +doc: SOLEC protocol +doc-ref: https://git.rctt.net/solec/plain/docs/protocol.svg?h=main + +seq: + - id: type_payload + type: u1 + enum: payload_type + - id: len_payload + type: u2 + - id: payload + size: len_payload + type: + switch-on: type_payload + cases: + 'payload_type::success': success + 'payload_type::error': error + 'payload_type::handshake': handshake + 'payload_type::user_auth': user_auth + 'payload_type::server_auth': server_auth + 'payload_type::message': message + 'payload_type::test': test + +enums: + payload_type: + 0x01: success + 0x02: error + 0x03: handshake + 0x04: user_auth + 0x05: message + 0x06: server_auth + 0xFF: test + + error_type: + 0x01: user_auth_failed + 0x02: not_found + + conn_type: + 0x01: user_conn + 0x02: server_conn + +types: + string: + doc: UTF-8 encoded string. + seq: + - id: len_payload + type: u2 + - id: payload + type: str + size: len_payload + encoding: UTF-8 + + success: + doc: Send from server if operation succeded. + + error: + doc: Senf from server if operation failed. + seq: + - id: error_code + type: u1 + enum: error_type + + handshake: + doc: | + Handshake is sent by the client during connection initialization. + If protocol_ver_major is different than version used by the server + connection will be aborted. + seq: + - id: proto_ver_major + type: u1 + - id: proto_ver_minor + type: u1 + - id: conn_type + type: u1 + enum: conn_type + + user_auth: + seq: + - id: name + type: string + - id: pass + type: string + + server_auth: + seq: + - id: name + type: string + + message: + doc: | + Source and target fields are addresses in user@server format. + seq: + - id: source + type: string + - id: target + type: string + - id: timestamp + doc: Set just before sending the message. + type: u8 + - id: content + type: string + + test: + doc: Test payload, used for parsers testing + seq: + - id: num1 + type: u1 + - id: time1 + type: u8 + - id: str1 + type: string + - id: num2 + type: u2 + - id: str2 + type: string + - id: num3 + type: u4 + - id: str3 + type: string + - id: num4 + type: u8 + diff --git a/docs/protocol.svg b/docs/protocol.svg index 20a9119..b029409 100644 --- a/docs/protocol.svg +++ b/docs/protocol.svg @@ -4,489 +4,542 @@ - - - + + + cluster__solec - -Solec + +Solec -cluster__auth - -Solec::Auth +cluster__error + +Solec::Error -cluster__error - -Solec::Error +cluster__handshake + +Solec::Handshake -cluster__handshake - -Solec::Handshake +cluster__message + +Solec::Message -cluster__message - -Solec::Message +cluster__server_auth + +Solec::ServerAuth cluster__string - -Solec::String + +Solec::String cluster__success - -Solec::Success + +Solec::Success cluster__test - -Solec::Test + +Solec::Test + + +cluster__user_auth + +Solec::UserAuth solec__seq - - -pos - - -size - - -type - - -id - -0 - -1 - -u1→PayloadType - -type_payload - -1 - -2 - -u2be - -len_payload - -3 - -... - -switch (type_payload) - -payload + + +pos + + +size + + +type + + +id + +0 + +1 + +u1→PayloadType + +type_payload + +1 + +2 + +u2be + +len_payload + +3 + +... + +switch (type_payload) + +payload - + solec__seq:type_payload_type->solec__seq:payload_type - - + + solec__seq_payload_switch - - -case - - -type - -:payload_type_auth - -Auth - -:payload_type_error - -Error - -:payload_type_handshake - -Handshake - -:payload_type_message - -Message - -:payload_type_success - -Success - -:payload_type_test - -Test + + +case + + +type + +:payload_type_error + +Error + +:payload_type_handshake + +Handshake + +:payload_type_message + +Message + +:payload_type_server_auth + +ServerAuth + +:payload_type_success + +Success + +:payload_type_test + +Test + +:payload_type_user_auth + +UserAuth solec__seq:payload_type->solec__seq_payload_switch - - - - - -auth__seq - - -pos - - -size - - -type - - -id - -0 - -... - -String - -name - -... - -... - -String - -pass - - - -solec__seq_payload_switch:case0->auth__seq - - + + - + error__seq - - -pos - - -size - - -type - - -id - -0 - -1 - -u1→ErrorType - -error_code + + +pos + + +size + + +type + + +id + +0 + +1 + +u1→ErrorType + +error_code - -solec__seq_payload_switch:case1->error__seq - - + +solec__seq_payload_switch:case0->error__seq + + - + handshake__seq - - -pos - - -size - - -type - - -id - -0 - -1 - -u1 - -proto_ver_major - -1 - -1 - -u1 - -proto_ver_minor + + +pos + + +size + + +type + + +id + +0 + +1 + +u1 + +proto_ver_major + +1 + +1 + +u1 + +proto_ver_minor + +2 + +1 + +u1→ConnType + +conn_type - -solec__seq_payload_switch:case2->handshake__seq - - + +solec__seq_payload_switch:case1->handshake__seq + + - + message__seq - - -pos - - -size - - -type - - -id - -0 - -... - -String - -source - -... - -... - -String - -target - -... - -8 - -u8be - -timestamp - -... - -... - -String - -content + + +pos + + +size + + +type + + +id + +0 + +... + +String + +source + +... + +... + +String + +target + +... + +8 + +u8be + +timestamp + +... + +... + +String + +content + +solec__seq_payload_switch:case2->message__seq + + + + + +server_auth__seq + + +pos + + +size + + +type + + +id + +0 + +... + +String + +name + + -solec__seq_payload_switch:case3->message__seq - - +solec__seq_payload_switch:case3->server_auth__seq + + success__seq - - -pos - - -size - - -type - - -id + + +pos + + +size + + +type + + +id solec__seq_payload_switch:case4->success__seq - - + + test__seq - - -pos - - -size - - -type - - -id - -0 - -1 - -u1 - -num1 - -1 - -8 - -u8be - -time1 - -9 - -... - -String - -str1 - -... - -2 - -u2be - -num2 - -... - -... - -String - -str2 - -... - -4 - -u4be - -num3 - -... - -... - -String - -str3 - -... - -8 - -u8be - -num4 + + +pos + + +size + + +type + + +id + +0 + +1 + +u1 + +num1 + +1 + +8 + +u8be + +time1 + +9 + +... + +String + +str1 + +... + +2 + +u2be + +num2 + +... + +... + +String + +str2 + +... + +4 + +u4be + +num3 + +... + +... + +String + +str3 + +... + +8 + +u8be + +num4 solec__seq_payload_switch:case5->test__seq - - + + + + + +user_auth__seq + + +pos + + +size + + +type + + +id + +0 + +... + +String + +name + +... + +... + +String + +pass + + + +solec__seq_payload_switch:case6->user_auth__seq + + string__seq - - -pos - - -size - - -type - - -id - -0 - -2 - -u2be - -len_payload - -2 - -len_payload - -str(UTF-8) - -payload - - - -auth__seq:name_type->string__seq - - + + +pos + + +size + + +type + + +id + +0 + +2 + +u2be + +len_payload + +2 + +len_payload + +str(UTF-8) + +payload - + -auth__seq:pass_type->string__seq - - +message__seq:source_type->string__seq + + -message__seq:source_type->string__seq - - +message__seq:target_type->string__seq + + -message__seq:target_type->string__seq - - +message__seq:content_type->string__seq + + - + -message__seq:content_type->string__seq - - +server_auth__seq:name_type->string__seq + + string__seq:len_payload_type->string__seq:payload_size - - + + test__seq:str1_type->string__seq - - + + test__seq:str2_type->string__seq - - + + test__seq:str3_type->string__seq - - + + + + + +user_auth__seq:name_type->string__seq + + + + + +user_auth__seq:pass_type->string__seq + + diff --git a/docs/rfc.html b/docs/rfc.html index 84b5c0a..99a6a34 100644 --- a/docs/rfc.html +++ b/docs/rfc.html @@ -1220,7 +1220,7 @@ li > p:last-of-type:only-child {
bt -Expires 16 October 2026 +Expires 20 October 2026 [Page]
@@ -1233,12 +1233,12 @@ li > p:last-of-type:only-child {
SOLEC
Published:
- +
Intended Status:
Experimental
Expires:
-
+
Author:
@@ -1274,7 +1274,7 @@ SOLEC system.

time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

- This Internet-Draft will expire on 16 October 2026.

+ This Internet-Draft will expire on 20 October 2026.

-
+
-

-2.4.4. Auth +

+2.4.4. UserAuth

@@ -1739,13 +1756,35 @@ different auth method will be used.
Table 6
-
+
-

-2.4.5. Message +

+2.4.5. ServerAuth

+ + + + + + + + + + + + +
Table 7
TypeName
stringname
+
+
+
+
+

+2.4.6. Message +

+ + @@ -1774,14 +1813,14 @@ different auth method will be used.
-
+

-2.4.6. Test +2.4.7. Test

-

Test payload is used for encoder and decoders testing. Clients and servers -should ignore this kind of payload.

-
Table 8
Type
- +

Test payload is used for encoder and decoders testing. Clients and servers +should ignore this kind of payload.

+
Table 8
+ @@ -1835,12 +1874,14 @@ should ignore this kind of payload.

Some operations require multiple rounds of communication. In this case payloads are send in a sequence. Payload that is not part of this specific operation (for example incoming message) cannot interrupt this process.

- +
+
+

+2.6. Client-Server connection initialisation +

+
+--------+                   +--------+
 | Client |                   | Server |
 +----+---+                   +----+---+
@@ -1851,19 +1892,72 @@ specific operation (for example incoming message) cannot interrupt this process.
      | Send [Handshake]           |
      +--------------------------->|
      |                            |
-     |                            +- If [ver_major] does not match server
-     |                            |  protocol version close the connection
+     |                            +- If [ver_major] does not match
+     |                            |  server protocol version close
+     |                            |  the connection.
      |                            |
-     | Send [Auth]                |
+     | Send [UserAuth]            |
      +--------------------------->|
      |                            |
      | Send [Error 0x01]          |
-     |<---------------------------+- If [username] or [password] does not match
-     |                            |  and close the connection
+     |<---------------------------+- If [username] or [password]
+     |                            |  does not match and close
+     |                            |  the connection.
+     |                            |
+     | Send [Sucesss]             |
+     |<---------------------------+
+
+
+
+
+
+
+

+2.7. Exchanging messages between servers +

+

Exchanging messages between SOLEC servers is a core concept behind the project. +Sending message to user residing on a different server require estabilishing a +connection between both servers.

+
+
+

+2.7.1. Authentication +

+

Server authentication is crucial to prevent message spoofing and other forms of +abuse. Server cannot use same auth process as clients because that would require +creating account for each server on any other server which is impossible. +Possible solution are TLS or other public key based protocol.

+

As for now the issue remains open and server authorization uses mock +[ServerAuth] payload which specifies just the connecting server name. +This is obviously insecure.

+
+
+
+
+

+2.7.2. Server-Server connection initialisation +

+
+
+--------+                   +--------+
+| Server |                   | Server |
++----+---+                   +----+---+
+     |                            |
+     | Initialise TCP connection  |
+     +--------------------------->|
+     |                            |
+     | Send [Handshake]           |
+     +--------------------------->|
+     |                            |
+     |                            +- If [ver_major] does not match
+     |                            |  server protocol version close
+     |                            |  the connection.
+     |                            |
+     | Send [ServerAuth]          |
+     +--------------------------->|
      |                            |
      | Send [Sucesss]             |
      |<---------------------------+
-
+
diff --git a/docs/rfc.md b/docs/rfc.md index 8296cfa..854d737 100644 --- a/docs/rfc.md +++ b/docs/rfc.md @@ -180,7 +180,6 @@ Payload is always empty for this type. |------|-----------------------------------------------------------| | 0x01 | Client auth failed. Invalid username or password. | | 0x02 | Not found. User or channel cannot access user or channel. | -| 0x03 | Server auth failed. Unknown name. | ### Handshake @@ -246,7 +245,7 @@ Some operations require multiple rounds of communication. In this case payloads are send in a sequence. Payload that is not part of this specific operation (for example incoming message) cannot interrupt this process. -### Client-Server connection initialisation +## Client-Server connection initialisation ~~~ ascii-art +--------+ +--------+ @@ -259,20 +258,40 @@ specific operation (for example incoming message) cannot interrupt this process. | Send [Handshake] | +--------------------------->| | | - | +- If [ver_major] does not match server - | | protocol version close the connection + | +- If [ver_major] does not match + | | server protocol version close + | | the connection. | | - | Send [UserAuth] | + | Send [UserAuth] | +--------------------------->| | | | Send [Error 0x01] | - |<---------------------------+- If [username] or [password] does not match - | | and close the connection + |<---------------------------+- If [username] or [password] + | | does not match and close + | | the connection. | | | Send [Sucesss] | |<---------------------------+ ~~~ +## Exchanging messages between servers + +Exchanging messages between SOLEC servers is a core concept behind the project. +Sending message to user residing on a different server require estabilishing a +connection between both servers. + + +### Authentication + +Server authentication is crucial to prevent message spoofing and other forms of +abuse. Server cannot use same auth process as clients because that would require +creating account for each server on any other server which is impossible. +Possible solution are TLS or other public key based protocol. + +As for now the issue remains open and server authorization uses mock +[ServerAuth] payload which specifies just the connecting server name. +This is obviously insecure. + ### Server-Server connection initialisation ~~~ ascii-art @@ -286,22 +305,13 @@ specific operation (for example incoming message) cannot interrupt this process. | Send [Handshake] | +--------------------------->| | | - | +- If [ver_major] does not match server - | | protocol version close the connection + | +- If [ver_major] does not match + | | server protocol version close + | | the connection. | | | Send [ServerAuth] | +--------------------------->| | | - | Send [Error 0x03] | - |<---------------------------+- If [name] is not present in known public - | | keys list. - | | | Send [Sucesss] | |<---------------------------+ ~~~ - -## Server to server operation - -Exchanging messages between SOLEC servers is a core concept behind the project. -Sending message to user residing on a different server require estabilishing a -connection between both servers. diff --git a/docs/rfc.txt b/docs/rfc.txt index ffd2f67..83cd029 100644 --- a/docs/rfc.txt +++ b/docs/rfc.txt @@ -34,9 +34,10 @@ Table of Contents 2.4.6. Message 2.4.7. Test 2.5. Sequential operations - 2.5.1. Client-Server connection initialisation - 2.5.2. Server-Server connection initialisation - 2.6. Server + 2.6. Client-Server connection initialisation + 2.7. Exchanging messages between servers + 2.7.1. Authentication + 2.7.2. Server-Server connection initialisation 1. Introduction @@ -167,7 +168,7 @@ Table of Contents +------+------------+------------+ | 0x03 | Handshake | SC | +------+------------+------------+ - | 0x04 | UserAuth | C | + | 0x04 | UserAuth | C | +------+------------+------------+ | 0x05 | Message | SC | +------+------------+------------+ @@ -201,8 +202,6 @@ Table of Contents +------+------------------------------------------------------------+ | 0x02 | Not found. User or channel cannot access user or | | | channel. | - +------+------------------------------------------------------------+ - | 0x03 | Server auth failed. Unknown name. | +------+------------------------------------------------------------+ Table 3 @@ -310,7 +309,7 @@ Table of Contents this specific operation (for example incoming message) cannot interrupt this process. -2.5.1. Client-Server connection initialisation +2.6. Client-Server connection initialisation +--------+ +--------+ | Client | | Server | @@ -322,20 +321,40 @@ Table of Contents | Send [Handshake] | +--------------------------->| | | - | +- If [ver_major] does not match server - | | protocol version close the connection + | +- If [ver_major] does not match + | | server protocol version close + | | the connection. | | - | Send [UserAuth] | + | Send [UserAuth] | +--------------------------->| | | | Send [Error 0x01] | - |<---------------------------+- If [username] or [password] does not match - | | and close the connection + |<---------------------------+- If [username] or [password] + | | does not match and close + | | the connection. | | | Send [Sucesss] | |<---------------------------+ -2.5.2. Server-Server connection initialisation +2.7. Exchanging messages between servers + + Exchanging messages between SOLEC servers is a core concept behind + the project. Sending message to user residing on a different server + require estabilishing a connection between both servers. + +2.7.1. Authentication + + Server authentication is crucial to prevent message spoofing and + other forms of abuse. Server cannot use same auth process as clients + because that would require creating account for each server on any + other server which is impossible. Possible solution are TLS or other + public key based protocol. + + As for now the issue remains open and server authorization uses mock + [ServerAuth] payload which specifies just the connecting server name. + This is obviously insecure. + +2.7.2. Server-Server connection initialisation +--------+ +--------+ | Server | | Server | @@ -347,17 +366,12 @@ Table of Contents | Send [Handshake] | +--------------------------->| | | - | +- If [ver_major] does not match server - | | protocol version close the connection + | +- If [ver_major] does not match + | | server protocol version close + | | the connection. | | | Send [ServerAuth] | +--------------------------->| | | - | Send [Error 0x03] | - |<---------------------------+- If [name] is not present in known public - | | keys list. - | | | Send [Sucesss] | |<---------------------------+ - -2.6. Server diff --git a/notes.txt b/notes.txt deleted file mode 100644 index 64817ad..0000000 --- a/notes.txt +++ /dev/null @@ -1,3 +0,0 @@ -# personal notes and snippets - -ifconfig lo0 alias 127.0.0.2 diff --git a/solec-wireshark.lua b/solec-wireshark.lua new file mode 100644 index 0000000..c09c564 --- /dev/null +++ b/solec-wireshark.lua @@ -0,0 +1,340 @@ +-- This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild +-- +-- This file is compatible with Lua 5.3 + +package.path = "kaitai_struct_lua_runtime/?.lua" .. package.path +local class = require("class") +require("tvbstream") +require("kaitaistruct") +local proto = Proto('solec', 'Solec') +proto.fields = {} +local enum = require("enum") +local Solec_type_payload = ProtoField.new('type_payload', 'Solec.type_payload', ftypes.BYTES) +table.insert(proto.fields, Solec_type_payload) +local Solec_len_payload = ProtoField.new('len_payload', 'Solec.len_payload', ftypes.UINT32) +table.insert(proto.fields, Solec_len_payload) +local Solec_Test_num1 = ProtoField.new('num1', 'Solec.Test.num1', ftypes.UINT8) +table.insert(proto.fields, Solec_Test_num1) +local Solec_Test_time1 = ProtoField.new('time1', 'Solec.Test.time1', ftypes.UINT32) +table.insert(proto.fields, Solec_Test_time1) +local Solec_Test_num2 = ProtoField.new('num2', 'Solec.Test.num2', ftypes.UINT32) +table.insert(proto.fields, Solec_Test_num2) +local Solec_Test_num3 = ProtoField.new('num3', 'Solec.Test.num3', ftypes.UINT32) +table.insert(proto.fields, Solec_Test_num3) +local Solec_Test_num4 = ProtoField.new('num4', 'Solec.Test.num4', ftypes.UINT32) +table.insert(proto.fields, Solec_Test_num4) +local Solec_String_len_payload = ProtoField.new('len_payload', 'Solec.String.len_payload', ftypes.UINT32) +table.insert(proto.fields, Solec_String_len_payload) +local str_decode = require("string_decode") +local Solec_String_payload = ProtoField.new('payload', 'Solec.String.payload', ftypes.STRINGZ) +table.insert(proto.fields, Solec_String_payload) +local Solec_Error_error_code = ProtoField.new('error_code', 'Solec.Error.error_code', ftypes.BYTES) +table.insert(proto.fields, Solec_Error_error_code) +local Solec_Handshake_proto_ver_major = ProtoField.new('proto_ver_major', 'Solec.Handshake.proto_ver_major', ftypes.UINT8) +table.insert(proto.fields, Solec_Handshake_proto_ver_major) +local Solec_Handshake_proto_ver_minor = ProtoField.new('proto_ver_minor', 'Solec.Handshake.proto_ver_minor', ftypes.UINT8) +table.insert(proto.fields, Solec_Handshake_proto_ver_minor) +local Solec_Handshake_conn_type = ProtoField.new('conn_type', 'Solec.Handshake.conn_type', ftypes.BYTES) +table.insert(proto.fields, Solec_Handshake_conn_type) +local Solec_Message_timestamp = ProtoField.new('timestamp', 'Solec.Message.timestamp', ftypes.UINT32) +table.insert(proto.fields, Solec_Message_timestamp) + +function proto.dissector(tvb, pinfo, root) + pinfo.cols.protocol = 'Solec' + local tree = root:add(proto, tvb(), 'Solec') + local io = KaitaiStream(TVBStream(tvb)) + local obj = Solec(io, tree) +end + +-- +-- SOLEC protocol. +-- See also: Source (https://git.rctt.net/solec/plain/docs/protocol.svg?h=main) +Solec = class.class(KaitaiStruct) + +Solec.PayloadType = enum.Enum { + success = 1, + error = 2, + handshake = 3, + user_auth = 4, + message = 5, + server_auth = 6, + test = 255, +} + +Solec.ErrorType = enum.Enum { + auth_failed = 1, + not_found = 2, +} + +Solec.ConnType = enum.Enum { + user_conn = 1, + server_conn = 2, +} + +function Solec:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec:_read() + local _offset = self._io:pos() + self.type_payload = Solec.PayloadType(self._io:read_u1()) + self._tree:add(Solec_type_payload, self._io._io.tvb(_offset, self._io:pos() - _offset)) + local _offset = self._io:pos() + self.len_payload = self._io:read_u2be() + self._tree:add(Solec_len_payload, self._io._io.tvb(_offset, self._io:pos() - _offset), self.len_payload) + local _offset = self._io:pos() + local _on = self.type_payload + if _on == Solec.PayloadType.user_auth then + self._raw_payload = self._io:read_bytes(self.len_payload) + local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) + local _io = KaitaiStream(TVBStream(_tvb)) + local _tree = self._tree:add(_tvb, 'payload') + self.payload = Solec.UserAuth(_io, _tree, self, self._root) + elseif _on == Solec.PayloadType.server_auth then + self._raw_payload = self._io:read_bytes(self.len_payload) + local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) + local _io = KaitaiStream(TVBStream(_tvb)) + local _tree = self._tree:add(_tvb, 'payload') + self.payload = Solec.ServerAuth(_io, _tree, self, self._root) + elseif _on == Solec.PayloadType.handshake then + self._raw_payload = self._io:read_bytes(self.len_payload) + local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) + local _io = KaitaiStream(TVBStream(_tvb)) + local _tree = self._tree:add(_tvb, 'payload') + self.payload = Solec.Handshake(_io, _tree, self, self._root) + elseif _on == Solec.PayloadType.test then + self._raw_payload = self._io:read_bytes(self.len_payload) + local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) + local _io = KaitaiStream(TVBStream(_tvb)) + local _tree = self._tree:add(_tvb, 'payload') + self.payload = Solec.Test(_io, _tree, self, self._root) + elseif _on == Solec.PayloadType.error then + self._raw_payload = self._io:read_bytes(self.len_payload) + local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) + local _io = KaitaiStream(TVBStream(_tvb)) + local _tree = self._tree:add(_tvb, 'payload') + self.payload = Solec.Error(_io, _tree, self, self._root) + elseif _on == Solec.PayloadType.success then + self._raw_payload = self._io:read_bytes(self.len_payload) + local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) + local _io = KaitaiStream(TVBStream(_tvb)) + local _tree = self._tree:add(_tvb, 'payload') + self.payload = Solec.Success(_io, _tree, self, self._root) + elseif _on == Solec.PayloadType.message then + self._raw_payload = self._io:read_bytes(self.len_payload) + local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) + local _io = KaitaiStream(TVBStream(_tvb)) + local _tree = self._tree:add(_tvb, 'payload') + self.payload = Solec.Message(_io, _tree, self, self._root) + else + self.payload = self._io:read_bytes(self.len_payload) + end +end + + +-- +-- Test payload, used for parsers testing. +Solec.Test = class.class(KaitaiStruct) + +function Solec.Test:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec.Test:_read() + local _offset = self._io:pos() + self.num1 = self._io:read_u1() + self._tree:add(Solec_Test_num1, self._io._io.tvb(_offset, self._io:pos() - _offset), self.num1) + local _offset = self._io:pos() + self.time1 = self._io:read_u8be() + self._tree:add(Solec_Test_time1, self._io._io.tvb(_offset, self._io:pos() - _offset), self.time1) + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'str1') + self.str1 = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) + local _offset = self._io:pos() + self.num2 = self._io:read_u2be() + self._tree:add(Solec_Test_num2, self._io._io.tvb(_offset, self._io:pos() - _offset), self.num2) + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'str2') + self.str2 = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) + local _offset = self._io:pos() + self.num3 = self._io:read_u4be() + self._tree:add(Solec_Test_num3, self._io._io.tvb(_offset, self._io:pos() - _offset), self.num3) + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'str3') + self.str3 = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) + local _offset = self._io:pos() + self.num4 = self._io:read_u8be() + self._tree:add(Solec_Test_num4, self._io._io.tvb(_offset, self._io:pos() - _offset), self.num4) +end + + +Solec.UserAuth = class.class(KaitaiStruct) + +function Solec.UserAuth:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec.UserAuth:_read() + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'name') + self.name = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'pass') + self.pass = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) +end + + +-- +-- Send from server if operation succeded. +Solec.Success = class.class(KaitaiStruct) + +function Solec.Success:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec.Success:_read() +end + + +-- +-- UTF-8 encoded string. +Solec.String = class.class(KaitaiStruct) + +function Solec.String:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec.String:_read() + local _offset = self._io:pos() + self.len_payload = self._io:read_u2be() + self._tree:add(Solec_String_len_payload, self._io._io.tvb(_offset, self._io:pos() - _offset), self.len_payload) + local _offset = self._io:pos() + self.payload = str_decode.decode(self._io:read_bytes(self.len_payload), "UTF-8") + self._tree:add(Solec_String_payload, self._io._io.tvb(_offset, self._io:pos() - _offset), self.payload) +end + + +-- +-- Senf from server if operation failed. +Solec.Error = class.class(KaitaiStruct) + +function Solec.Error:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec.Error:_read() + local _offset = self._io:pos() + self.error_code = Solec.ErrorType(self._io:read_u1()) + self._tree:add(Solec_Error_error_code, self._io._io.tvb(_offset, self._io:pos() - _offset), self.error_code) +end + + +-- +-- Handshake is sent by the client during connection initialization. +-- If protocol_ver_major is different than version used by the server +-- connection will be aborted. +Solec.Handshake = class.class(KaitaiStruct) + +function Solec.Handshake:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec.Handshake:_read() + local _offset = self._io:pos() + self.proto_ver_major = self._io:read_u1() + self._tree:add(Solec_Handshake_proto_ver_major, self._io._io.tvb(_offset, self._io:pos() - _offset), self.proto_ver_major) + local _offset = self._io:pos() + self.proto_ver_minor = self._io:read_u1() + self._tree:add(Solec_Handshake_proto_ver_minor, self._io._io.tvb(_offset, self._io:pos() - _offset), self.proto_ver_minor) + local _offset = self._io:pos() + self.conn_type = Solec.ConnType(self._io:read_u1()) + self._tree:add(Solec_Handshake_conn_type, self._io._io.tvb(_offset, self._io:pos() - _offset), self.conn_type) +end + + +-- +-- Source and target fields are addresses in user@server format. +Solec.Message = class.class(KaitaiStruct) + +function Solec.Message:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec.Message:_read() + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'source') + self.source = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'target') + self.target = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) + local _offset = self._io:pos() + self.timestamp = self._io:read_u8be() + self._tree:add(Solec_Message_timestamp, self._io._io.tvb(_offset, self._io:pos() - _offset), self.timestamp) + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'content') + self.content = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) +end + +-- +-- Set just before sending the message. + +Solec.ServerAuth = class.class(KaitaiStruct) + +function Solec.ServerAuth:_init(io, tree, parent, root) + KaitaiStruct._init(self, io) + self._parent = parent + self._root = root or self + self._tree = tree + self:_read() +end + +function Solec.ServerAuth:_read() + local _offset = self._io:pos() + local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'name') + self.name = Solec.String(self._io, _tree, self, self._root) + _tree:set_len(self._io:pos() - _offset) +end + + +local tcp_port = DissectorTable.get("tcp.port") +tcp_port:add(9999, proto) diff --git a/solec.ksy b/solec.ksy deleted file mode 100644 index 7117413..0000000 --- a/solec.ksy +++ /dev/null @@ -1,119 +0,0 @@ -meta: - id: solec - file-extension: hex - endian: be - -doc: SOLEC protocol -doc-ref: https://git.rctt.net/solec/plain/docs/protocol.svg?h=main - -seq: - - id: type_payload - type: u1 - enum: payload_type - - id: len_payload - type: u2 - - id: payload - size: len_payload - type: - switch-on: type_payload - cases: - 'payload_type::success': success - 'payload_type::error': error - 'payload_type::handshake': handshake - 'payload_type::auth': auth - 'payload_type::message': message - 'payload_type::test': test - -enums: - payload_type: - 0x01: success - 0x02: error - 0x03: handshake - 0x04: auth - 0x05: message - 0xFF: test - - error_type: - 0x01: auth_failed - 0x02: not_found - - conn_type: - 0x01: user_conn - 0x02: server_conn - -types: - string: - doc: UTF-8 encoded string. - seq: - - id: len_payload - type: u2 - - id: payload - type: str - size: len_payload - encoding: UTF-8 - - success: - doc: Send from server if operation succeded. - - error: - doc: Senf from server if operation failed. - seq: - - id: error_code - type: u1 - enum: error_type - - handshake: - doc: | - Handshake is sent by the client during connection initialization. - If protocol_ver_major is different than version used by the server - connection will be aborted. - seq: - - id: proto_ver_major - type: u1 - - id: proto_ver_minor - type: u1 - - id: conn_type - type: u1 - enum: conn_type - - auth: - seq: - - id: name - type: string - - id: pass - type: string - - message: - doc: | - Source and target fields are addresses in user@server format. - seq: - - id: source - type: string - - id: target - type: string - - id: timestamp - doc: Set just before sending the message. - type: u8 - - id: content - type: string - - test: - doc: Test payload, used for parsers testing - seq: - - id: num1 - type: u1 - - id: time1 - type: u8 - - id: str1 - type: string - - id: num2 - type: u2 - - id: str2 - type: string - - id: num3 - type: u4 - - id: str3 - type: string - - id: num4 - type: u8 - diff --git a/solec.lua b/solec.lua deleted file mode 100644 index 93e7faa..0000000 --- a/solec.lua +++ /dev/null @@ -1,304 +0,0 @@ --- This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild --- --- This file is compatible with Lua 5.3 - -package.path = "kaitai_struct_lua_runtime/?.lua" .. package.path -local class = require("class") -require("tvbstream") -require("kaitaistruct") -local proto = Proto('solec', 'Solec') -proto.fields = {} -local enum = require("enum") -local Solec_type_payload = ProtoField.new('type_payload', 'Solec.type_payload', ftypes.BYTES) -table.insert(proto.fields, Solec_type_payload) -local Solec_len_payload = ProtoField.new('len_payload', 'Solec.len_payload', ftypes.UINT32) -table.insert(proto.fields, Solec_len_payload) -local Solec_Test_num1 = ProtoField.new('num1', 'Solec.Test.num1', ftypes.UINT8) -table.insert(proto.fields, Solec_Test_num1) -local Solec_Test_time1 = ProtoField.new('time1', 'Solec.Test.time1', ftypes.UINT32) -table.insert(proto.fields, Solec_Test_time1) -local Solec_Test_num2 = ProtoField.new('num2', 'Solec.Test.num2', ftypes.UINT32) -table.insert(proto.fields, Solec_Test_num2) -local Solec_Test_num3 = ProtoField.new('num3', 'Solec.Test.num3', ftypes.UINT32) -table.insert(proto.fields, Solec_Test_num3) -local Solec_Test_num4 = ProtoField.new('num4', 'Solec.Test.num4', ftypes.UINT32) -table.insert(proto.fields, Solec_Test_num4) -local Solec_String_len_payload = ProtoField.new('len_payload', 'Solec.String.len_payload', ftypes.UINT32) -table.insert(proto.fields, Solec_String_len_payload) -local str_decode = require("string_decode") -local Solec_String_payload = ProtoField.new('payload', 'Solec.String.payload', ftypes.STRINGZ) -table.insert(proto.fields, Solec_String_payload) -local Solec_Error_error_code = ProtoField.new('error_code', 'Solec.Error.error_code', ftypes.BYTES) -table.insert(proto.fields, Solec_Error_error_code) -local Solec_Handshake_proto_ver_major = ProtoField.new('proto_ver_major', 'Solec.Handshake.proto_ver_major', ftypes.UINT8) -table.insert(proto.fields, Solec_Handshake_proto_ver_major) -local Solec_Handshake_proto_ver_minor = ProtoField.new('proto_ver_minor', 'Solec.Handshake.proto_ver_minor', ftypes.UINT8) -table.insert(proto.fields, Solec_Handshake_proto_ver_minor) -local Solec_Message_timestamp = ProtoField.new('timestamp', 'Solec.Message.timestamp', ftypes.UINT32) -table.insert(proto.fields, Solec_Message_timestamp) - -function proto.dissector(tvb, pinfo, root) - pinfo.cols.protocol = 'Solec' - local tree = root:add(proto, tvb(), 'Solec') - local io = KaitaiStream(TVBStream(tvb)) - local obj = Solec(io, tree) -end - --- --- SOLEC protocol. --- See also: Source (https://git.rctt.net/solec/plain/docs/protocol.svg?h=main) -Solec = class.class(KaitaiStruct) - -Solec.PayloadType = enum.Enum { - success = 1, - error = 2, - handshake = 3, - auth = 4, - message = 5, - test = 255, -} - -Solec.ErrorType = enum.Enum { - auth_failed = 1, -} - -function Solec:_init(io, tree, parent, root) - KaitaiStruct._init(self, io) - self._parent = parent - self._root = root or self - self._tree = tree - self:_read() -end - -function Solec:_read() - local _offset = self._io:pos() - self.type_payload = Solec.PayloadType(self._io:read_u1()) - self._tree:add(Solec_type_payload, self._io._io.tvb(_offset, self._io:pos() - _offset)) - local _offset = self._io:pos() - self.len_payload = self._io:read_u2be() - self._tree:add(Solec_len_payload, self._io._io.tvb(_offset, self._io:pos() - _offset), self.len_payload) - local _offset = self._io:pos() - local _on = self.type_payload - if _on == Solec.PayloadType.auth then - self._raw_payload = self._io:read_bytes(self.len_payload) - local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) - local _io = KaitaiStream(TVBStream(_tvb)) - local _tree = self._tree:add(_tvb, 'payload') - self.payload = Solec.Auth(_io, _tree, self, self._root) - elseif _on == Solec.PayloadType.handshake then - self._raw_payload = self._io:read_bytes(self.len_payload) - local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) - local _io = KaitaiStream(TVBStream(_tvb)) - local _tree = self._tree:add(_tvb, 'payload') - self.payload = Solec.Handshake(_io, _tree, self, self._root) - elseif _on == Solec.PayloadType.test then - self._raw_payload = self._io:read_bytes(self.len_payload) - local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) - local _io = KaitaiStream(TVBStream(_tvb)) - local _tree = self._tree:add(_tvb, 'payload') - self.payload = Solec.Test(_io, _tree, self, self._root) - elseif _on == Solec.PayloadType.error then - self._raw_payload = self._io:read_bytes(self.len_payload) - local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) - local _io = KaitaiStream(TVBStream(_tvb)) - local _tree = self._tree:add(_tvb, 'payload') - self.payload = Solec.Error(_io, _tree, self, self._root) - elseif _on == Solec.PayloadType.success then - self._raw_payload = self._io:read_bytes(self.len_payload) - local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) - local _io = KaitaiStream(TVBStream(_tvb)) - local _tree = self._tree:add(_tvb, 'payload') - self.payload = Solec.Success(_io, _tree, self, self._root) - elseif _on == Solec.PayloadType.message then - self._raw_payload = self._io:read_bytes(self.len_payload) - local _tvb = self._io._io.tvb(_offset, self._io:pos() - _offset) - local _io = KaitaiStream(TVBStream(_tvb)) - local _tree = self._tree:add(_tvb, 'payload') - self.payload = Solec.Message(_io, _tree, self, self._root) - else - self.payload = self._io:read_bytes(self.len_payload) - end -end - - --- --- Test payload, used for parsers testing. -Solec.Test = class.class(KaitaiStruct) - -function Solec.Test:_init(io, tree, parent, root) - KaitaiStruct._init(self, io) - self._parent = parent - self._root = root or self - self._tree = tree - self:_read() -end - -function Solec.Test:_read() - local _offset = self._io:pos() - self.num1 = self._io:read_u1() - self._tree:add(Solec_Test_num1, self._io._io.tvb(_offset, self._io:pos() - _offset), self.num1) - local _offset = self._io:pos() - self.time1 = self._io:read_u8be() - self._tree:add(Solec_Test_time1, self._io._io.tvb(_offset, self._io:pos() - _offset), self.time1) - local _offset = self._io:pos() - local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'str1') - self.str1 = Solec.String(self._io, _tree, self, self._root) - _tree:set_len(self._io:pos() - _offset) - local _offset = self._io:pos() - self.num2 = self._io:read_u2be() - self._tree:add(Solec_Test_num2, self._io._io.tvb(_offset, self._io:pos() - _offset), self.num2) - local _offset = self._io:pos() - local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'str2') - self.str2 = Solec.String(self._io, _tree, self, self._root) - _tree:set_len(self._io:pos() - _offset) - local _offset = self._io:pos() - self.num3 = self._io:read_u4be() - self._tree:add(Solec_Test_num3, self._io._io.tvb(_offset, self._io:pos() - _offset), self.num3) - local _offset = self._io:pos() - local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'str3') - self.str3 = Solec.String(self._io, _tree, self, self._root) - _tree:set_len(self._io:pos() - _offset) - local _offset = self._io:pos() - self.num4 = self._io:read_u8be() - self._tree:add(Solec_Test_num4, self._io._io.tvb(_offset, self._io:pos() - _offset), self.num4) -end - - --- --- Send from server if operation succeded. -Solec.Success = class.class(KaitaiStruct) - -function Solec.Success:_init(io, tree, parent, root) - KaitaiStruct._init(self, io) - self._parent = parent - self._root = root or self - self._tree = tree - self:_read() -end - -function Solec.Success:_read() -end - - -Solec.Auth = class.class(KaitaiStruct) - -function Solec.Auth:_init(io, tree, parent, root) - KaitaiStruct._init(self, io) - self._parent = parent - self._root = root or self - self._tree = tree - self:_read() -end - -function Solec.Auth:_read() - local _offset = self._io:pos() - local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'name') - self.name = Solec.String(self._io, _tree, self, self._root) - _tree:set_len(self._io:pos() - _offset) - local _offset = self._io:pos() - local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'pass') - self.pass = Solec.String(self._io, _tree, self, self._root) - _tree:set_len(self._io:pos() - _offset) -end - - --- --- UTF-8 encoded string. -Solec.String = class.class(KaitaiStruct) - -function Solec.String:_init(io, tree, parent, root) - KaitaiStruct._init(self, io) - self._parent = parent - self._root = root or self - self._tree = tree - self:_read() -end - -function Solec.String:_read() - local _offset = self._io:pos() - self.len_payload = self._io:read_u2be() - self._tree:add(Solec_String_len_payload, self._io._io.tvb(_offset, self._io:pos() - _offset), self.len_payload) - local _offset = self._io:pos() - self.payload = str_decode.decode(self._io:read_bytes(self.len_payload), "UTF-8") - self._tree:add(Solec_String_payload, self._io._io.tvb(_offset, self._io:pos() - _offset), self.payload) -end - - --- --- Senf from server if operation failed. -Solec.Error = class.class(KaitaiStruct) - -function Solec.Error:_init(io, tree, parent, root) - KaitaiStruct._init(self, io) - self._parent = parent - self._root = root or self - self._tree = tree - self:_read() -end - -function Solec.Error:_read() - local _offset = self._io:pos() - self.error_code = Solec.ErrorType(self._io:read_u1()) - self._tree:add(Solec_Error_error_code, self._io._io.tvb(_offset, self._io:pos() - _offset), self.error_code) -end - - --- --- Handshake is sent by the client during connection initialization. --- If protocol_ver_major is different than version used by the server --- connection will be aborted. -Solec.Handshake = class.class(KaitaiStruct) - -function Solec.Handshake:_init(io, tree, parent, root) - KaitaiStruct._init(self, io) - self._parent = parent - self._root = root or self - self._tree = tree - self:_read() -end - -function Solec.Handshake:_read() - local _offset = self._io:pos() - self.proto_ver_major = self._io:read_u1() - self._tree:add(Solec_Handshake_proto_ver_major, self._io._io.tvb(_offset, self._io:pos() - _offset), self.proto_ver_major) - local _offset = self._io:pos() - self.proto_ver_minor = self._io:read_u1() - self._tree:add(Solec_Handshake_proto_ver_minor, self._io._io.tvb(_offset, self._io:pos() - _offset), self.proto_ver_minor) -end - - --- --- Source and target fields are addresses in user@server format. -Solec.Message = class.class(KaitaiStruct) - -function Solec.Message:_init(io, tree, parent, root) - KaitaiStruct._init(self, io) - self._parent = parent - self._root = root or self - self._tree = tree - self:_read() -end - -function Solec.Message:_read() - local _offset = self._io:pos() - local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'source') - self.source = Solec.String(self._io, _tree, self, self._root) - _tree:set_len(self._io:pos() - _offset) - local _offset = self._io:pos() - local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'target') - self.target = Solec.String(self._io, _tree, self, self._root) - _tree:set_len(self._io:pos() - _offset) - local _offset = self._io:pos() - self.timestamp = self._io:read_u8be() - self._tree:add(Solec_Message_timestamp, self._io._io.tvb(_offset, self._io:pos() - _offset), self.timestamp) - local _offset = self._io:pos() - local _tree = self._tree:add(self._io._io.tvb(_offset, 0), 'content') - self.content = Solec.String(self._io, _tree, self, self._root) - _tree:set_len(self._io:pos() - _offset) -end - --- --- Set just before sending the message. - -local tcp_port = DissectorTable.get("tcp.port") -tcp_port:add(9999, proto) diff --git a/tools/build_spec.sh b/tools/build_spec.sh index f5272b4..52a32da 100755 --- a/tools/build_spec.sh +++ b/tools/build_spec.sh @@ -6,16 +6,17 @@ else SED=sed fi -kaitai-struct-compiler -t graphviz solec.ksy +kaitai-struct-compiler -t graphviz docs/protocol.ksy dot -Tsvg solec.dot > docs/protocol.svg rm solec.dot -~/bin/kaitai-struct-compiler-ws/bin/kaitai-struct-compiler -t wireshark --read-pos solec.ksy +~/bin/kaitai-struct-compiler-ws/bin/kaitai-struct-compiler -t wireshark --read-pos docs/protocol.ksy +mv solec.lua solec-wireshark.lua -${SED} -i -e '5s/.*/package.path = "kaitai_struct_lua_runtime\/?.lua" .. package.path/' solec.lua -${SED} -i -e 's/, self.type_payload//' solec.lua +${SED} -i -e '5s/.*/package.path = "kaitai_struct_lua_runtime\/?.lua" .. package.path/' solec-wireshark.lua +${SED} -i -e 's/, self.type_payload//' solec-wireshark.lua -cat <> solec.lua +cat <> solec-wireshark.lua local tcp_port = DissectorTable.get("tcp.port") tcp_port:add(9999, proto) EOT diff --git a/tools/run-many.sh b/tools/run-many.sh index 9c84e0d..4d4bf1e 100755 --- a/tools/run-many.sh +++ b/tools/run-many.sh @@ -4,6 +4,7 @@ # following lines to hosts file # 127.0.0.1 localhost s1 # 127.0.0.2 s2 +# for mac: ifconfig lo0 alias 127.0.0.2 tmux \ new-session "go run cmd/daemon/main.go -a 127.0.0.1:9999 -n s1; read" \; \ -- cgit v1.2.3
Table 9
Type