diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a94e31 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.go +*.rs diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2af2e72 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "go-capnp"] + path = go-capnp + url = https://github.com/capnproto/go-capnp.git diff --git a/README.md b/README.md deleted file mode 100644 index 4a5a7a4..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# hermes-backend-typings - diff --git a/data.capnp b/data.capnp new file mode 100644 index 0000000..a0a1974 --- /dev/null +++ b/data.capnp @@ -0,0 +1,126 @@ +@0x92a7c8962141ef12; + +using Go = import "/go.capnp"; +$Go.package("commonbackend"); +$Go.import("git.terah.dev/imterah/hermes/backend/commonbackend"); + +enum Protocol { + tcp @0; + udp @1; +} + +enum StatusCode { + success @0; + failure @1; +} + +struct Start { + id @0 :UInt8 = 0; + arguments @1 :Data; +} + +struct Stop { + id @0 :UInt8 = 1; +} + +struct AddProxy { + id @0 :UInt8 = 2; + sourceIP @1 :Data; + sourcePort @2 :UInt16; + destPort @3 :UInt16; + protocol @4 :Protocol; +} + +struct RemoveProxy { + id @0 :UInt8 = 3; + sourceIP @1 :Data; + sourcePort @2 :UInt16; + destPort @3 :UInt16; + protocol @4 :Protocol; +} + +struct ProxyStatusRequest { + id @0 :UInt8 = 4; + sourceIP @1 :Data; + sourcePort @2 :UInt16; + destPort @3 :UInt16; + protocol @4 :Protocol; +} + +struct ProxyStatusResponse { + id @0 :UInt8 = 5; + sourceIP @1 :Data; + sourcePort @2 :UInt16; + destPort @3 :UInt16; + protocol @4 :Protocol; + isActive @5 :Bool; +} + +struct ProxyInstanceRequest { + id @0 :UInt8 = 6; +} + +struct ProxyInstanceResponse { + id @0 :UInt8 = 7; + proxies @1 :List(ProxyInstance); + + struct ProxyInstance { + sourceIP @0 :Text; + sourcePort @1 :UInt16; + destPort @2 :UInt16; + protocol @3 :Protocol; + } +} + +struct BackendStatusRequest { + id @0 :UInt8 = 8; +} + +struct BackendStatusResponse { + id @0 :UInt8 = 9; + isRunning @1 :Bool; + statusCode @2 :StatusCode; + message @3 :Text; +} + +struct ProxyConnectionsRequest { + id @0 :UInt8 = 10; +} + +struct ProxyConnectionsResponse { + id @0 :UInt8 = 11; + connections @1 :List(Connection); + + struct Connection { + sourceIP @0 :Data; + sourcePort @1 :UInt16; + destPort @2 :UInt16; + clientIP @3 :Data; + clientPort @4 :UInt16; + } +} + +struct CheckClientParameters { + id @0 :UInt8 = 12; + sourceIP @1 :Data; + sourcePort @2 :UInt16; + destPort @3 :UInt16; + protocol @4 :Protocol; +} + +struct CheckServerParameters { + id @0 :UInt8 = 13; + arguments @1 :Data; +} + +struct CheckParametersResponse { + id @0 :UInt8 = 14; + inResponseTo @1 :InResponseTo; + isValid @2 :Bool; + message @3 :Text; + + enum InResponseTo { + checkClientParameters @0; + checkServerParameters @1; + } +} \ No newline at end of file diff --git a/go-capnp b/go-capnp new file mode 160000 index 0000000..f9295d9 --- /dev/null +++ b/go-capnp @@ -0,0 +1 @@ +Subproject commit f9295d9b67d8cf9f3f992cb70e793c09f0b2b2d5 diff --git a/scripts/go-build.sh b/scripts/go-build.sh new file mode 100755 index 0000000..3c937e0 --- /dev/null +++ b/scripts/go-build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo $PATH +capnp compile -I ./go-capnp/std -ogo ./*.capnp \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..1bd3834 --- /dev/null +++ b/shell.nix @@ -0,0 +1,7 @@ +{ + pkgs ? import { }, +}: pkgs.mkShell { + buildInputs = with pkgs; [ + capnproto + ]; +}