Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3298334
D7400.id25049.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7400.id25049.diff
View Options
diff --git a/services/tunnelbroker/src/main.rs b/services/tunnelbroker/src/main.rs
--- a/services/tunnelbroker/src/main.rs
+++ b/services/tunnelbroker/src/main.rs
@@ -2,7 +2,7 @@
pub mod cxx_bridge;
pub mod notifications;
pub mod server;
-mod websockets;
+pub mod websockets;
use std::io;
use tracing;
diff --git a/services/tunnelbroker/src/websockets/messages.rs b/services/tunnelbroker/src/websockets/messages.rs
new file mode 100644
--- /dev/null
+++ b/services/tunnelbroker/src/websockets/messages.rs
@@ -0,0 +1,79 @@
+// This file intends to preserve the original structure of the tunnelbroker
+// protobuf RPCs. However, this is converted to simple rust datastructures
+// to allow for deserialization and serialization into JSON websocket messages
+
+// Original Tunnelbroker Service definition:
+//
+// service TunnelbrokerService {
+// rpc SessionSignature(SessionSignatureRequest) returns (SessionSignatureResponse) {}
+// rpc NewSession(NewSessionRequest) returns (NewSessionResponse) {}
+// rpc MessagesStream(stream MessageToTunnelbroker) returns (stream MessageToClient) {}
+// }
+
+// Session
+pub struct SessionSignatureRequest {
+ pub device_id: String,
+}
+pub struct SessionSignatureResponse {
+ pub to_sign: String,
+}
+
+pub enum DeviceTypes {
+ Mobile,
+ Web,
+ Keyserver,
+}
+
+pub struct SessionRequest {
+ pub device_id: String,
+ pub public_key: String,
+ pub signature: String,
+ pub notify_token: Option<String>,
+ pub device_type: DeviceTypes,
+ pub device_app_version: String,
+ pub device_os: String,
+}
+
+pub struct SessionResponse {
+ pub session_id: String,
+}
+
+// Common messages structures for the MessagesStream
+pub struct ProcessedMessages {
+ pub message_id: Vec<String>,
+}
+
+// The messages from the Client to the Tunnelbroker
+pub struct MessageToTunnelbrokerStruct {
+ pub to_device_id: String,
+ pub payload: String,
+ pub blob_hashes: Vec<String>,
+}
+
+pub struct MessagesToSend {
+ pub messages: Vec<MessageToTunnelbrokerStruct>,
+}
+
+pub enum MessageToTunnelbroker {
+ Messages(MessagesToSend),
+ ProcessedMessages(ProcessedMessages),
+ NewNotifyToken(String),
+}
+
+// The messages from the Tunnelbroker to the Client
+pub struct MessageToClientStruct {
+ pub message_id: String,
+ pub from_device_id: String,
+ pub payload: String,
+ pub blob_hashes: Vec<String>,
+}
+
+pub struct MessagesToDeliver {
+ pub messages: Vec<MessageToClientStruct>,
+}
+
+pub enum MessageToClient {
+ Messages(MessagesToDeliver),
+ ProcessedMessages(ProcessedMessages),
+ NewNotifyTokenRequired,
+}
diff --git a/services/tunnelbroker/src/websockets/mod.rs b/services/tunnelbroker/src/websockets/mod.rs
--- a/services/tunnelbroker/src/websockets/mod.rs
+++ b/services/tunnelbroker/src/websockets/mod.rs
@@ -1,3 +1,5 @@
+pub mod messages;
+
use std::{env, io::Error};
use tokio::net::{TcpListener, TcpStream};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 5:47 AM (20 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2533315
Default Alt Text
D7400.id25049.diff (2 KB)
Attached To
Mode
D7400: [Tunnelbroker] Add message types for existing protobuf messages
Attached
Detach File
Event Timeline
Log In to Comment