Skip to content

Commit

Permalink
fix geph exit
Browse files Browse the repository at this point in the history
  • Loading branch information
nullchinchilla committed Jun 4, 2024
1 parent c439a05 commit 7586a7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion binaries/geph5-client/src/client_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static CONN_REQ_CHAN: CtxField<(

static COUNTER: AtomicU64 = AtomicU64::new(0);

static CONCURRENCY: usize = 6;
static CONCURRENCY: usize = 1;

#[tracing::instrument(skip_all, fields(instance=COUNTER.fetch_add(1, Ordering::Relaxed)))]
pub async fn client_once(ctx: AnyCtx<Config>) -> anyhow::Result<()> {
Expand Down Expand Up @@ -218,8 +218,10 @@ async fn client_auth(
crypt_hello: ClientCryptHello::X25519((&my_esk).into()),
};
write_prepend_length(&client_hello.stdcode(), &mut pipe).await?;
tracing::trace!(server, "wrote client hello");
let exit_hello: ExitHello =
stdcode::deserialize(&read_prepend_length(&mut pipe).await?)?;
tracing::trace!(server, "received exit hello");
// verify the exit hello
let signed_value = (&client_hello, &exit_hello.inner).stdcode();
pubkey
Expand Down
16 changes: 12 additions & 4 deletions binaries/geph5-exit/src/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod b2e_process;
use crate::{
broker::BrokerRpcTransport,
proxy::proxy_stream,
ratelimit::{get_load, get_ratelimiter, TOTAL_BYTE_COUNT},
ratelimit::{get_load, get_ratelimiter, RateLimiter, TOTAL_BYTE_COUNT},
CONFIG_FILE, SIGNING_SECRET,
};

Expand Down Expand Up @@ -176,6 +176,8 @@ async fn handle_client(mut client: impl Pipe) -> anyhow::Result<()> {
// execute the authentication
let client_hello: ClientHello = stdcode::deserialize(&read_prepend_length(&mut client).await?)?;

tracing::debug!("client_hello received");

let keys: Option<([u8; 32], [u8; 32])>;
let exit_hello_inner: ExitHelloInner = match client_hello.crypt_hello {
ClientCryptHello::SharedSecretChallenge(key) => {
Expand All @@ -195,9 +197,15 @@ async fn handle_client(mut client: impl Pipe) -> anyhow::Result<()> {
}
};

let (level, token, _sig): (AccountLevel, ClientToken, UnblindedSignature) =
stdcode::deserialize(&client_hello.credentials)?;
let ratelimit = get_ratelimiter(level, token).await;
let ratelimit = if CONFIG_FILE.wait().broker.is_some() {
let (level, token, _sig): (AccountLevel, ClientToken, UnblindedSignature) =
stdcode::deserialize(&client_hello.credentials)
.context("cannot deserialize credentials")?;
get_ratelimiter(level, token).await
} else {
RateLimiter::unlimited()
};

// TODO authenticate against broker's public key

let exit_hello = ExitHello {
Expand Down

0 comments on commit 7586a7f

Please sign in to comment.