diff options
| author | bt <bt@rctt.net> | 2026-03-07 19:27:49 +0100 |
|---|---|---|
| committer | bt <bt@rctt.net> | 2026-03-07 19:27:49 +0100 |
| commit | c772746ea7600f19c0252c8ca2c10cc57d6f8e82 (patch) | |
| tree | c98fe4e1af8ec2fe5e50882586141aeb5cafb1b7 | |
| parent | d4ff53aa8469354d70d7d79850d440d1dac7d981 (diff) | |
| download | solec-c772746ea7600f19c0252c8ca2c10cc57d6f8e82.tar.gz solec-c772746ea7600f19c0252c8ca2c10cc57d6f8e82.zip | |
Update PROTOCOL.md
| -rw-r--r-- | PROTOCOL.md | 40 | ||||
| -rw-r--r-- | cmd/mock/main.go | 33 |
2 files changed, 72 insertions, 1 deletions
diff --git a/PROTOCOL.md b/PROTOCOL.md index e69de29..d17eded 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -0,0 +1,40 @@ +# SOLEC protocol specification + +## Data format + +Everything is big endian. `text` is always null terminated UTF-8. +Every packet starts with `uint8` denoting type of the rest of remaining data. + +## Event types + +| Type | Name | +|------|-----------| +| 0x01 | Handshake | +| 0x02 | Ping | +| 0x03 | Pong | + +## Events + +### Handshake + +Sent after estabilishing TCP connection. First by the client and then by the server. +If one of the sides uses different protocol version connection should be aborted. + +| Type | Name | Description | +|-------|------|------------------| +| uint8 | ver | Protocol version | + + +### Ping + +Empty. + +### Pong + +`time` field contains Unix timestamp generated just before sending the packet. +Timezone should always be UTC. + +| Type | Name | Description | +|--------|------|------------------| +| uint64 | time | Unix timestamp | + diff --git a/cmd/mock/main.go b/cmd/mock/main.go index cc0a048..8516821 100644 --- a/cmd/mock/main.go +++ b/cmd/mock/main.go @@ -1,7 +1,38 @@ package main -import "log" +import ( + "flag" + "log" + "net" +) + +var listenAddr string func main() { + flag.StringVar(&listenAddr, "a", "localhost:9999", "Listening address:port") + flag.Parse() + log.Print("Starting solec daemon mock") + log.Fatal(listen()) +} + +func listen() error { + ln, err := net.Listen("tcp", listenAddr) + if err != nil { + return err + } + + log.Print("Server is listening on: ", listenAddr) + + for { + conn, err := ln.Accept() + if err != nil { + log.Print("Cannot accept connection: ", err) + } + go handle(conn) + } +} + +func handle(conn net.Conn) { + log.Print("Received connection from: ", conn.RemoteAddr()) } |
