From 9b640a555ae4a867e2050247d8c5b0997f87fab6 Mon Sep 17 00:00:00 2001 From: Jett Chen Date: Sat, 2 Nov 2024 11:38:34 +0800 Subject: [PATCH] WIP: protobuf defs --- .vscode/settings.json | 5 ++++ proto/burrow.proto | 3 +++ proto/burrowweb.proto | 42 ++++++++++++++++++++++++++++++++++ proto/wireguard.proto | 53 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 proto/burrowweb.proto create mode 100644 proto/wireguard.proto diff --git a/.vscode/settings.json b/.vscode/settings.json index eb85504..74f05af 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,5 +22,10 @@ "editor.autoIndent": "advanced", "diffEditor.ignoreTrimWhitespace": false, "editor.formatOnSave": false + }, + "protoc": { + "options": [ + "--proto_path=proto/" + ] } } diff --git a/proto/burrow.proto b/proto/burrow.proto index 2355b8d..125cc6d 100644 --- a/proto/burrow.proto +++ b/proto/burrow.proto @@ -3,6 +3,9 @@ package burrow; import "google/protobuf/timestamp.proto"; +// Internal service for managing tunnels and networks +// Used for IPC + service Tunnel { rpc TunnelConfiguration (Empty) returns (stream TunnelConfigurationResponse); rpc TunnelStart (Empty) returns (Empty); diff --git a/proto/burrowweb.proto b/proto/burrowweb.proto new file mode 100644 index 0000000..317d5aa --- /dev/null +++ b/proto/burrowweb.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package burrowweb; + +import "wireguard.proto"; + + +// TODO: Frontend sends slack token → receive JWT +// TODO: create/delete/list routes + +service BurrowWeb { + rpc SlackAuth (SlackAuthRequest) returns (JWTInfo); + // Server assigns a IP address, generates a token, saves a user entry, + // then responds back with WireGuard configuration + rpc CreateDevice (CreateDeviceRequest) returns (CreateDeviceResponse); + rpc DeleteDevice (JWTInfo) returns (Empty); + rpc ListDevices (JWTInfo) returns (ListDevicesResponse); +} + +message Empty {} + +message SlackAuthRequest { + string slack_token = 1; +} + + +message JWTInfo { + string jwt = 1; +} + +message CreateDeviceRequest { + JWTInfo jwt = 1; + string public_key = 2; // User's specified WG Public Key +} + +message CreateDeviceResponse { + wireguard.Config wg_config = 1; +} + +message ListDevicesResponse { + repeated wireguard.Device devices = 1; +} diff --git a/proto/wireguard.proto b/proto/wireguard.proto new file mode 100644 index 0000000..f740f60 --- /dev/null +++ b/proto/wireguard.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package wireguard; + +message Peer { + string public_key = 1; + optional string preshared_key = 2; + repeated string allowed_ips = 3; + string endpoint = 4; + optional uint32 persistent_keepalive = 5; + optional string name = 6; +} + +message InterfaceConfig { + // Does not include private key; the client is responsible for generating & persisting that + repeated string address = 1; + optional uint32 listen_port = 2; + repeated string dns = 3; + optional uint32 mtu = 4; +} + +message Device { + int32 id = 1; + optional string name = 2; + string public_key = 3; + optional string apns_token = 4; + int32 user_id = 5; + string created_at = 6; + string ipv4 = 7; + string ipv6 = 8; + string access_token = 9; + string refresh_token = 10; + string expires_at = 11; +} + +message User { + int32 id = 1; + string created_at = 2; +} + +message UserConnection { + int32 user_id = 1; + string openid_provider = 2; + string openid_user_id = 3; + string openid_user_name = 4; + string access_token = 5; + string refresh_token = 6; +} + + +message Config { + InterfaceConfig interface = 1; + repeated Peer peers = 2; +}