From 99cb5928bc62f01d6030b72d965684d287b5fd5b Mon Sep 17 00:00:00 2001 From: utf-4096 Date: Wed, 22 Mar 2023 16:55:04 +0100 Subject: [PATCH] Publish protocol 2.0 --- protobuf/2.0/Authentication.proto | 17 ++++++++++++ protobuf/2.0/Container.proto | 18 ++++++++++++ protobuf/2.0/Message.proto | 12 ++++++++ protobuf/2.0/PublishDiscover.proto | 44 ++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 protobuf/2.0/Authentication.proto create mode 100644 protobuf/2.0/Container.proto create mode 100644 protobuf/2.0/Message.proto create mode 100644 protobuf/2.0/PublishDiscover.proto diff --git a/protobuf/2.0/Authentication.proto b/protobuf/2.0/Authentication.proto new file mode 100644 index 0000000..7a78a9f --- /dev/null +++ b/protobuf/2.0/Authentication.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +// Client -> Server +// Request logging into the server +// seed: the seed used to generate the address +message AuthenticationRequest { + fixed64 seed = 1; +} + +// Server -> Client +// Login response +// status: 0 if successful, anything else is an error +// address: the address assigned to the peer +message AuthenticationResponse { + uint32 status = 1; + fixed64 address = 2; +} \ No newline at end of file diff --git a/protobuf/2.0/Container.proto b/protobuf/2.0/Container.proto new file mode 100644 index 0000000..bdd7ec7 --- /dev/null +++ b/protobuf/2.0/Container.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +// Client <-> Server +message Container { + enum MessageType { + AuthenticationRequest = 0; + AuthenticationResponse = 1; + Message = 2; + PublishRequest = 3; + PublishResponse = 4; + DiscoverRequest = 5; + DiscoverResponse = 6; + } + + MessageType type = 1; + uint32 id = 2; + bytes data = 3; +} \ No newline at end of file diff --git a/protobuf/2.0/Message.proto b/protobuf/2.0/Message.proto new file mode 100644 index 0000000..208098a --- /dev/null +++ b/protobuf/2.0/Message.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +// Client <-> Server +// address: +// Client -> Server: destination +// Server -> Client: source +// data: message data +message Message { + fixed64 address = 1; + fixed32 port = 2; + bytes data = 3; +} \ No newline at end of file diff --git a/protobuf/2.0/PublishDiscover.proto b/protobuf/2.0/PublishDiscover.proto new file mode 100644 index 0000000..2e8b32e --- /dev/null +++ b/protobuf/2.0/PublishDiscover.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +// Client -> Server +// Request a port to be published or deleted on Discover +// port: the port to publish +// publish: +// true: publish the port +// false: delete the port +// flags: search flags +message PublishRequest { + fixed32 port = 1; + bool publish = 2; + repeated string flags = 3; +} + +// Server -> Client +// Acknowledge a PublishRequest +// status: 0 if successful, anything else is an error +message PublishResponse { + uint32 status = 1; +} + +// Client -> Server +// Search for peers on Discover +// limit: maximum number of peers to search for +// flags: flags to search for +message DiscoverRequest { + uint32 limit = 1; + repeated string flags = 2; +} + +// Server -> Client +// Response to a DiscoverRequest with a list of peers +// status: 0 if successful, anything else is an error +// peers: a list of peers, empty if nothing is found +message DiscoverResponse { + message DiscoverPeer { + uint32 port = 1; + fixed64 address = 2; + repeated string flags = 3; + } + uint32 status = 1; + repeated DiscoverPeer peers = 2; +}