Page MenuHomePhabricator

D7431.id25265.diff
No OneTemporary

D7431.id25265.diff

diff --git a/.buildkite/tunnelbroker_client.yml b/.buildkite/tunnelbroker_client.yml
deleted file mode 100644
--- a/.buildkite/tunnelbroker_client.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-env:
- PATH: '$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH'
-steps:
- - label: ':nix: Tunnelbroker Client (Shared)'
- command:
- - 'cd shared/tunnelbroker-client'
- - 'rm -rf target'
- - 'nix develop --accept-flake-config -c cargo test'
- agents:
- - 'mac=true'
diff --git a/.buildkite/tunnelbroker_unittests.yml b/.buildkite/tunnelbroker_unittests.yml
--- a/.buildkite/tunnelbroker_unittests.yml
+++ b/.buildkite/tunnelbroker_unittests.yml
@@ -6,10 +6,6 @@
- 'cd services/tunnelbroker'
- 'rm -rf target'
- 'nix develop --accept-flake-config -c bash -c "cargo build && cargo test"'
- - 'cd src/libcpp/test'
- - 'rm -rf build'
- - 'nix develop --accept-flake-config -c bash -c "cmake -B build . && make -C build -j"'
- - 'build/runTests --gtest_filter="-AmqpManager*:DatabaseManager*"'
retry:
automatic: true
agents:
diff --git a/services/tunnelbroker/Dockerfile b/services/tunnelbroker/Dockerfile
--- a/services/tunnelbroker/Dockerfile
+++ b/services/tunnelbroker/Dockerfile
@@ -18,10 +18,6 @@
WORKDIR /transferred/services/tunnelbroker/docker
COPY services/tunnelbroker/docker .
-# Install SDKs
-RUN ./install_amqp_cpp.sh
-RUN ./install_libuv.sh
-
# Copying of the shared code
WORKDIR /transferred
COPY services/lib/src/ services/lib/src/
@@ -31,18 +27,13 @@
WORKDIR /transferred/services/tunnelbroker
COPY services/tunnelbroker/ .
-# Build C++ library gTests by CMake
-WORKDIR /transferred/services/tunnelbroker/src/libcpp/test
-RUN cmake -B build . && make -C build -j$(nproc)
-
# Build Rust by Cargo
WORKDIR /transferred/services/tunnelbroker
RUN cargo build --release
CMD if [ "$COMM_TEST_SERVICES" -eq 1 ];\
then\
- src/libcpp/test/build/bin/runTests --gtest_filter='-AmqpManager*:DatabaseManager*'\
- && cargo test;\
+ cargo test;\
else\
cargo run;\
fi
diff --git a/services/tunnelbroker/build.rs b/services/tunnelbroker/build.rs
--- a/services/tunnelbroker/build.rs
+++ b/services/tunnelbroker/build.rs
@@ -1 +1,12 @@
-fn main() {}
+fn main() {
+ tonic_build::configure()
+ .build_server(true)
+ .build_client(false)
+ .compile(
+ &["../../shared/protos/tunnelbroker.proto"],
+ &["../../shared/protos/"],
+ )
+ .expect("Failed to compile protobuf file");
+
+ println!("cargo:rerun-if-changed=../../shared/protos/tunnelbroker.proto");
+}
diff --git a/services/tunnelbroker/src/cxx_bridge.rs b/services/tunnelbroker/old/cxx_bridge.rs
rename from services/tunnelbroker/src/cxx_bridge.rs
rename to services/tunnelbroker/old/cxx_bridge.rs
diff --git a/services/tunnelbroker/src/libcpp/Tunnelbroker.h b/services/tunnelbroker/old/libcpp/Tunnelbroker.h
rename from services/tunnelbroker/src/libcpp/Tunnelbroker.h
rename to services/tunnelbroker/old/libcpp/Tunnelbroker.h
diff --git a/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp b/services/tunnelbroker/old/libcpp/Tunnelbroker.cpp
rename from services/tunnelbroker/src/libcpp/Tunnelbroker.cpp
rename to services/tunnelbroker/old/libcpp/Tunnelbroker.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/Amqp/AmqpManager.h b/services/tunnelbroker/old/libcpp/src/Amqp/AmqpManager.h
rename from services/tunnelbroker/src/libcpp/src/Amqp/AmqpManager.h
rename to services/tunnelbroker/old/libcpp/src/Amqp/AmqpManager.h
diff --git a/services/tunnelbroker/src/libcpp/src/Amqp/AmqpManager.cpp b/services/tunnelbroker/old/libcpp/src/Amqp/AmqpManager.cpp
rename from services/tunnelbroker/src/libcpp/src/Amqp/AmqpManager.cpp
rename to services/tunnelbroker/old/libcpp/src/Amqp/AmqpManager.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/Constants.h b/services/tunnelbroker/old/libcpp/src/Constants.h
rename from services/tunnelbroker/src/libcpp/src/Constants.h
rename to services/tunnelbroker/old/libcpp/src/Constants.h
diff --git a/services/tunnelbroker/src/libcpp/src/Database/DatabaseManager.h b/services/tunnelbroker/old/libcpp/src/Database/DatabaseManager.h
rename from services/tunnelbroker/src/libcpp/src/Database/DatabaseManager.h
rename to services/tunnelbroker/old/libcpp/src/Database/DatabaseManager.h
diff --git a/services/tunnelbroker/src/libcpp/src/Database/DatabaseManager.cpp b/services/tunnelbroker/old/libcpp/src/Database/DatabaseManager.cpp
rename from services/tunnelbroker/src/libcpp/src/Database/DatabaseManager.cpp
rename to services/tunnelbroker/old/libcpp/src/Database/DatabaseManager.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.h b/services/tunnelbroker/old/libcpp/src/Database/DeviceSessionItem.h
rename from services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.h
rename to services/tunnelbroker/old/libcpp/src/Database/DeviceSessionItem.h
diff --git a/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.cpp b/services/tunnelbroker/old/libcpp/src/Database/DeviceSessionItem.cpp
rename from services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.cpp
rename to services/tunnelbroker/old/libcpp/src/Database/DeviceSessionItem.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/Database/MessageItem.h b/services/tunnelbroker/old/libcpp/src/Database/MessageItem.h
rename from services/tunnelbroker/src/libcpp/src/Database/MessageItem.h
rename to services/tunnelbroker/old/libcpp/src/Database/MessageItem.h
diff --git a/services/tunnelbroker/src/libcpp/src/Database/MessageItem.cpp b/services/tunnelbroker/old/libcpp/src/Database/MessageItem.cpp
rename from services/tunnelbroker/src/libcpp/src/Database/MessageItem.cpp
rename to services/tunnelbroker/old/libcpp/src/Database/MessageItem.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/Database/PublicKeyItem.h b/services/tunnelbroker/old/libcpp/src/Database/PublicKeyItem.h
rename from services/tunnelbroker/src/libcpp/src/Database/PublicKeyItem.h
rename to services/tunnelbroker/old/libcpp/src/Database/PublicKeyItem.h
diff --git a/services/tunnelbroker/src/libcpp/src/Database/PublicKeyItem.cpp b/services/tunnelbroker/old/libcpp/src/Database/PublicKeyItem.cpp
rename from services/tunnelbroker/src/libcpp/src/Database/PublicKeyItem.cpp
rename to services/tunnelbroker/old/libcpp/src/Database/PublicKeyItem.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/Database/SessionSignItem.h b/services/tunnelbroker/old/libcpp/src/Database/SessionSignItem.h
rename from services/tunnelbroker/src/libcpp/src/Database/SessionSignItem.h
rename to services/tunnelbroker/old/libcpp/src/Database/SessionSignItem.h
diff --git a/services/tunnelbroker/src/libcpp/src/Database/SessionSignItem.cpp b/services/tunnelbroker/old/libcpp/src/Database/SessionSignItem.cpp
rename from services/tunnelbroker/src/libcpp/src/Database/SessionSignItem.cpp
rename to services/tunnelbroker/old/libcpp/src/Database/SessionSignItem.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/DeliveryBroker/DeliveryBroker.h b/services/tunnelbroker/old/libcpp/src/DeliveryBroker/DeliveryBroker.h
rename from services/tunnelbroker/src/libcpp/src/DeliveryBroker/DeliveryBroker.h
rename to services/tunnelbroker/old/libcpp/src/DeliveryBroker/DeliveryBroker.h
diff --git a/services/tunnelbroker/src/libcpp/src/DeliveryBroker/DeliveryBroker.cpp b/services/tunnelbroker/old/libcpp/src/DeliveryBroker/DeliveryBroker.cpp
rename from services/tunnelbroker/src/libcpp/src/DeliveryBroker/DeliveryBroker.cpp
rename to services/tunnelbroker/old/libcpp/src/DeliveryBroker/DeliveryBroker.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/DeliveryBroker/DeliveryBrokerEntites.h b/services/tunnelbroker/old/libcpp/src/DeliveryBroker/DeliveryBrokerEntites.h
rename from services/tunnelbroker/src/libcpp/src/DeliveryBroker/DeliveryBrokerEntites.h
rename to services/tunnelbroker/old/libcpp/src/DeliveryBroker/DeliveryBrokerEntites.h
diff --git a/services/tunnelbroker/src/libcpp/src/Tools/AwsTools.h b/services/tunnelbroker/old/libcpp/src/Tools/AwsTools.h
rename from services/tunnelbroker/src/libcpp/src/Tools/AwsTools.h
rename to services/tunnelbroker/old/libcpp/src/Tools/AwsTools.h
diff --git a/services/tunnelbroker/src/libcpp/src/Tools/AwsTools.cpp b/services/tunnelbroker/old/libcpp/src/Tools/AwsTools.cpp
rename from services/tunnelbroker/src/libcpp/src/Tools/AwsTools.cpp
rename to services/tunnelbroker/old/libcpp/src/Tools/AwsTools.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/Tools/ConfigManager.h b/services/tunnelbroker/old/libcpp/src/Tools/ConfigManager.h
rename from services/tunnelbroker/src/libcpp/src/Tools/ConfigManager.h
rename to services/tunnelbroker/old/libcpp/src/Tools/ConfigManager.h
diff --git a/services/tunnelbroker/src/libcpp/src/Tools/ConfigManager.cpp b/services/tunnelbroker/old/libcpp/src/Tools/ConfigManager.cpp
rename from services/tunnelbroker/src/libcpp/src/Tools/ConfigManager.cpp
rename to services/tunnelbroker/old/libcpp/src/Tools/ConfigManager.cpp
diff --git a/services/tunnelbroker/src/libcpp/src/Tools/Tools.h b/services/tunnelbroker/old/libcpp/src/Tools/Tools.h
rename from services/tunnelbroker/src/libcpp/src/Tools/Tools.h
rename to services/tunnelbroker/old/libcpp/src/Tools/Tools.h
diff --git a/services/tunnelbroker/src/libcpp/src/Tools/Tools.cpp b/services/tunnelbroker/old/libcpp/src/Tools/Tools.cpp
rename from services/tunnelbroker/src/libcpp/src/Tools/Tools.cpp
rename to services/tunnelbroker/old/libcpp/src/Tools/Tools.cpp
diff --git a/services/tunnelbroker/src/libcpp/test/AmqpManagerTest.cpp b/services/tunnelbroker/old/libcpp/test/AmqpManagerTest.cpp
rename from services/tunnelbroker/src/libcpp/test/AmqpManagerTest.cpp
rename to services/tunnelbroker/old/libcpp/test/AmqpManagerTest.cpp
diff --git a/services/tunnelbroker/src/libcpp/test/CMakeLists.txt b/services/tunnelbroker/old/libcpp/test/CMakeLists.txt
rename from services/tunnelbroker/src/libcpp/test/CMakeLists.txt
rename to services/tunnelbroker/old/libcpp/test/CMakeLists.txt
diff --git a/services/tunnelbroker/src/libcpp/test/DatabaseManagerTest.cpp b/services/tunnelbroker/old/libcpp/test/DatabaseManagerTest.cpp
rename from services/tunnelbroker/src/libcpp/test/DatabaseManagerTest.cpp
rename to services/tunnelbroker/old/libcpp/test/DatabaseManagerTest.cpp
diff --git a/services/tunnelbroker/src/libcpp/test/DeliveryBrokerTest.cpp b/services/tunnelbroker/old/libcpp/test/DeliveryBrokerTest.cpp
rename from services/tunnelbroker/src/libcpp/test/DeliveryBrokerTest.cpp
rename to services/tunnelbroker/old/libcpp/test/DeliveryBrokerTest.cpp
diff --git a/services/tunnelbroker/src/libcpp/test/ToolsTest.cpp b/services/tunnelbroker/old/libcpp/test/ToolsTest.cpp
rename from services/tunnelbroker/src/libcpp/test/ToolsTest.cpp
rename to services/tunnelbroker/old/libcpp/test/ToolsTest.cpp
diff --git a/services/tunnelbroker/src/libcpp/test/TunnelBrokerTest.cpp b/services/tunnelbroker/old/libcpp/test/TunnelBrokerTest.cpp
rename from services/tunnelbroker/src/libcpp/test/TunnelBrokerTest.cpp
rename to services/tunnelbroker/old/libcpp/test/TunnelBrokerTest.cpp
diff --git a/services/tunnelbroker/src/libcpp/test/main.cpp b/services/tunnelbroker/old/libcpp/test/main.cpp
rename from services/tunnelbroker/src/libcpp/test/main.cpp
rename to services/tunnelbroker/old/libcpp/test/main.cpp
diff --git a/services/tunnelbroker/src/notifications/apns.rs b/services/tunnelbroker/old/notifications/apns.rs
rename from services/tunnelbroker/src/notifications/apns.rs
rename to services/tunnelbroker/old/notifications/apns.rs
diff --git a/services/tunnelbroker/src/notifications/config.rs b/services/tunnelbroker/old/notifications/config.rs
rename from services/tunnelbroker/src/notifications/config.rs
rename to services/tunnelbroker/old/notifications/config.rs
diff --git a/services/tunnelbroker/src/notifications/fcm.rs b/services/tunnelbroker/old/notifications/fcm.rs
rename from services/tunnelbroker/src/notifications/fcm.rs
rename to services/tunnelbroker/old/notifications/fcm.rs
diff --git a/services/tunnelbroker/src/notifications/mod.rs b/services/tunnelbroker/old/notifications/mod.rs
rename from services/tunnelbroker/src/notifications/mod.rs
rename to services/tunnelbroker/old/notifications/mod.rs
diff --git a/services/tunnelbroker/src/server/mod.rs b/services/tunnelbroker/old/server/mod.rs
rename from services/tunnelbroker/src/server/mod.rs
rename to services/tunnelbroker/old/server/mod.rs
diff --git a/services/tunnelbroker/src/server/tools.rs b/services/tunnelbroker/old/server/tools.rs
rename from services/tunnelbroker/src/server/tools.rs
rename to services/tunnelbroker/old/server/tools.rs
diff --git a/services/tunnelbroker/src/comm_server/mod.rs b/services/tunnelbroker/src/comm_server/mod.rs
new file mode 100644
--- /dev/null
+++ b/services/tunnelbroker/src/comm_server/mod.rs
@@ -0,0 +1,37 @@
+mod proto {
+ tonic::include_proto!("tunnelbroker");
+}
+
+use proto::tunnelbroker_service_server::{
+ TunnelbrokerService, TunnelbrokerServiceServer,
+};
+use tonic::transport::Server;
+
+use crate::constants;
+
+#[derive(Debug, Default)]
+struct TunnelbrokerGRPC {}
+
+#[tonic::async_trait]
+impl TunnelbrokerService for TunnelbrokerGRPC {
+ async fn send_message_to_device(
+ &self,
+ _request: tonic::Request<proto::MessageToDevice>,
+ ) -> Result<tonic::Response<proto::Empty>, tonic::Status> {
+ unimplemented!()
+ }
+}
+
+pub async fn run_identity_server() -> Result<(), tonic::transport::Error> {
+ let addr = format!("[::1]:{}", constants::GRPC_SERVER_PORT)
+ .parse()
+ .expect("Unable to parse identity address");
+
+ tracing::info!("Websocket server listening on {}", &addr);
+ Server::builder()
+ .http2_keepalive_interval(Some(constants::GRPC_KEEP_ALIVE_PING_INTERVAL))
+ .http2_keepalive_timeout(Some(constants::GRPC_KEEP_ALIVE_PING_TIMEOUT))
+ .add_service(TunnelbrokerServiceServer::new(TunnelbrokerGRPC::default()))
+ .serve(addr)
+ .await
+}
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
@@ -1,6 +1,7 @@
+pub mod comm_server;
pub mod constants;
pub mod websockets;
-use std::io;
+use std::io::{self, Error, ErrorKind};
use tracing;
#[tokio::main]
@@ -9,5 +10,15 @@
tracing::subscriber::set_global_default(subscriber)
.expect("Unable to configure tracing");
- websockets::create_server().await
+ let comm_server = comm_server::run_identity_server();
+ let websocket_server = websockets::create_server();
+
+ tokio::select! {
+ Ok(_) = comm_server => { Ok(()) },
+ Ok(_) = websocket_server => { Ok(()) },
+ else => {
+ tracing::error!("A grpc or websocket server crashed.");
+ Err(Error::new(ErrorKind::Other, "A grpc or websocket server crashed."))
+ }
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 12:36 PM (18 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2452212
Default Alt Text
D7431.id25265.diff (14 KB)

Event Timeline