Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/gateway provider merge #208

Merged
merged 71 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
db79251
Initial draft for ClientsHandler
jstuczyn Apr 21, 2020
38b9dea
Created listener struct
jstuczyn Apr 22, 2020
3b04e58
typo
jstuczyn Apr 22, 2020
3a761cc
Stateful websocket connection handler
jstuczyn Apr 22, 2020
5a16db7
Exposing modules
jstuczyn Apr 22, 2020
4043d4e
Depdendencies updates
jstuczyn Apr 22, 2020
e672035
Moved listener to correct file + made start consume listener
jstuczyn Apr 22, 2020
c4a7d68
Main starting new listener
jstuczyn Apr 22, 2020
72cead5
Catching sigint
jstuczyn Apr 22, 2020
fe28c3b
Copied client storage from provider into gateway
jstuczyn Apr 22, 2020
c405ddc
Exposed websocket listener type for nicer import path
jstuczyn Apr 22, 2020
dda664c
Defined websocket message receiver concrete type
jstuczyn Apr 22, 2020
c74c1ad
Client ledger struct without implementation
jstuczyn Apr 22, 2020
0dd2c95
ClientsHandler using more concrete types
jstuczyn Apr 22, 2020
6c8d30d
Mixnet sender + receiver and exposed listener type
jstuczyn Apr 22, 2020
22e4e9a
Handling mix packets
jstuczyn Apr 22, 2020
062c1f8
Ability to forward mix packets
jstuczyn Apr 22, 2020
0a3a43e
"starting" both listeners at main
jstuczyn Apr 22, 2020
7e081f2
Depedencies updates
jstuczyn Apr 22, 2020
00bcde8
Initial type definitions for client messages
jstuczyn Apr 22, 2020
b617bb5
Initial "gateway-requests" with AuthToken
jstuczyn Apr 23, 2020
52e3ca8
ibid.
jstuczyn Apr 23, 2020
2d52390
Restored most of ledger's functionalities
jstuczyn Apr 23, 2020
01be25f
Ability to retrieve all messages regardless of rate limit
jstuczyn Apr 23, 2020
6432758
ClientsHandler request handling logic
jstuczyn Apr 23, 2020
a82608b
Required 'new' dependencies
jstuczyn Apr 23, 2020
c9975e5
Main changes required for compilation
jstuczyn Apr 23, 2020
0da7d04
PacketProcessor getting private key pointer
jstuczyn Apr 23, 2020
5247b48
"moved" types into gateway requests crate
jstuczyn Apr 23, 2020
da51be9
Moved and renamed types
jstuczyn Apr 23, 2020
9ae8564
ibid.
jstuczyn Apr 23, 2020
2e29021
Added required serde_json dependency
jstuczyn Apr 23, 2020
82d9fa5
Skeleton for websocket request handling
jstuczyn Apr 23, 2020
2bcd569
helper methods on ServerResponse
jstuczyn Apr 24, 2020
8a04e0a
WebSocket Handler pushing received mix messages directly to client
jstuczyn Apr 24, 2020
2a17b52
PacketForwarder returning JoinHandle alongside the channel
jstuczyn Apr 24, 2020
d688525
ClientsHandler following the same pattern
jstuczyn Apr 24, 2020
be87f86
Made websocket listener start method consistent with mix listener
jstuczyn Apr 24, 2020
e946a01
Syntax error + formatting
jstuczyn Apr 24, 2020
26c1e15
Websocket handler having access to mix forwarder
jstuczyn Apr 24, 2020
59b529a
Minimal binary request parsing
jstuczyn Apr 24, 2020
9b7acab
Implicitly derived std::error::Error on GatewayRequestsError
jstuczyn Apr 24, 2020
e55019f
Handling of all websocket requests
jstuczyn Apr 24, 2020
24616a7
Types import cleanup
jstuczyn Apr 24, 2020
65c56c7
Updated placeholder fields
jstuczyn Apr 24, 2020
72b8b7a
Everything put into main
jstuczyn Apr 24, 2020
27db08b
Missing license notices
jstuczyn Apr 24, 2020
0b37a08
Cleaned up unused code
jstuczyn Apr 24, 2020
b414eee
Merge branch 'develop' into feature/gateway_provider_merge
jstuczyn Apr 24, 2020
9a90b0b
Copied and did initial minor changes to commands and config
jstuczyn Apr 24, 2020
d841b4f
It's actually gateway
jstuczyn Apr 24, 2020
8d3b440
Gateway sending its regular presence to directory server
jstuczyn Apr 27, 2020
c4df48d
Re-organisation of gateway code + Gateway struct
jstuczyn Apr 27, 2020
a30bb91
Updated provider argument description
jstuczyn Apr 27, 2020
08f125d
Restored duplicate ip check without importing NymTopology trait
jstuczyn Apr 27, 2020
20ec7f3
Moved hardcoded values into config
jstuczyn Apr 27, 2020
bc9aa84
Cargo fmt
jstuczyn Apr 27, 2020
91acc63
Compilation errors in other crates due to topology adjustments
jstuczyn Apr 27, 2020
7261aa2
Test fixes
jstuczyn Apr 27, 2020
a8f5bd1
Initial gateway-client
jstuczyn Apr 28, 2020
96a98e0
Seemingly working version with bunch of hardcoded and temporary values
jstuczyn Apr 29, 2020
64ca290
cargo fmt
jstuczyn Apr 29, 2020
5638098
Removed provider poller
jstuczyn Apr 29, 2020
1b6cfd5
Updated config with gateway values instead of provider
jstuczyn Apr 29, 2020
6873057
Gateway address including ws
jstuczyn Apr 29, 2020
3f8f75a
Removed hardcoded gateway address
jstuczyn Apr 29, 2020
441c63c
Properly skipping loop cover messages
jstuczyn Apr 29, 2020
e3ba13d
Updated log filter with tokio tungstenite related modules
jstuczyn Apr 29, 2020
7283400
Updated sphinx version used
jstuczyn Apr 29, 2020
ec15f0d
Very minor cleanup
jstuczyn Apr 29, 2020
5aca68a
unused import
jstuczyn Apr 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 47 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"clients/desktop",
"clients/webassembly",
"common/client-libs/directory-client",
"common/client-libs/gateway-client",
"common/client-libs/mix-client",
"common/client-libs/multi-tcp-client",
"common/client-libs/provider-client",
Expand All @@ -19,6 +20,7 @@ members = [
"common/pemstore",
"common/topology",
"gateway",
"gateway/gateway-requests",
"mixnode",
"sfw-provider",
"sfw-provider/sfw-provider-requests",
Expand Down
4 changes: 3 additions & 1 deletion clients/desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ serde = { version = "1.0.104", features = ["derive"] }
serde_json = "1.0.44"
tokio = { version = "0.2", features = ["full"] }
tokio-tungstenite = "0.10.1"
url = "2.1"

## internal
config = {path = "../../common/config"}
crypto = {path = "../../common/crypto"}
directory-client = { path = "../../common/client-libs/directory-client" }
gateway-client = { path = "../../common/client-libs/gateway-client" }
gateway-requests = { path = "../../gateway/gateway-requests" }
healthcheck = { path = "../../common/healthcheck" }
mix-client = { path = "../../common/client-libs/mix-client" }
multi-tcp-client = { path = "../../common/client-libs/multi-tcp-client" }
nymsphinx = { path = "../../common/nymsphinx" }
pemstore = {path = "../../common/pemstore"}
provider-client = { path = "../../common/client-libs/provider-client" }
sfw-provider-requests = { path = "../../sfw-provider/sfw-provider-requests" }
topology = {path = "../../common/topology" }

[build-dependencies]
Expand Down
41 changes: 22 additions & 19 deletions clients/desktop/src/client/mix_traffic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

use futures::channel::mpsc;
use futures::StreamExt;
use gateway_client::GatewayClient;
use log::*;
use nymsphinx::SphinxPacket;
use std::net::SocketAddr;
use std::time::Duration;
use tokio::runtime::Handle;
use tokio::task::JoinHandle;

Expand All @@ -31,37 +31,40 @@ impl MixMessage {
}
}

pub(crate) struct MixTrafficController {
tcp_client: multi_tcp_client::Client,
pub(crate) struct MixTrafficController<'a> {
// TODO: most likely to be replaced by some higher level construct as
// later on gateway_client will need to be accessible by other entities
gateway_client: GatewayClient<'a, url::Url>,
mix_rx: MixMessageReceiver,
}

impl MixTrafficController {
impl<'a> MixTrafficController<'static> {
pub(crate) fn new(
initial_reconnection_backoff: Duration,
maximum_reconnection_backoff: Duration,
initial_connection_timeout: Duration,
mix_rx: MixMessageReceiver,
) -> Self {
let tcp_client_config = multi_tcp_client::Config::new(
initial_reconnection_backoff,
maximum_reconnection_backoff,
initial_connection_timeout,
);

gateway_client: GatewayClient<'a, url::Url>,
) -> MixTrafficController<'a> {
MixTrafficController {
tcp_client: multi_tcp_client::Client::new(tcp_client_config),
gateway_client,
mix_rx,
}
}

async fn on_message(&mut self, mix_message: MixMessage) {
debug!("Got a mix_message for {:?}", mix_message.0);
self.tcp_client
// TODO: possibly we might want to get an actual result here at some point
.send(mix_message.0, mix_message.1.to_bytes(), false)
match self
.gateway_client
.send_sphinx_packet(mix_message.0, mix_message.1.to_bytes())
.await
.unwrap(); // if we're not waiting for response, we MUST get an Ok
{
Err(e) => error!("Failed to send sphinx packet to the gateway! - {:?}", e),
Ok(was_successful) if !was_successful => {
warn!("Sent sphinx packet to the gateway but it failed to get processed!")
}
Ok(was_successful) if was_successful => {
trace!("Successfully forwarded sphinx packet to the gateway!")
}
Ok(_) => unreachable!("to shut up the compiler because all patterns ARE covered"),
}
}

pub(crate) async fn run(&mut self) {
Expand Down
Loading