Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,555 changes: 750 additions & 805 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]

members = ["libraries/*", "binaries/*"]
resolver = "2"
resolver = "3"

[workspace.package]
version = "0.2.33"
Expand Down
48 changes: 25 additions & 23 deletions binaries/geph5-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
[package]
name = "geph5-bridge"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MPL-2.0"

[dependencies]
geph5-misc-rpc = { path = "../../libraries/geph5-misc-rpc" }
picomux = { path = "../../libraries/picomux" }
rand = "0.8.5"
rand = "0.9.0"
sillad = { path = "../../libraries/sillad" }
sillad-sosistab3 = { path = "../../libraries/sillad-sosistab3" }
smolscale = "0.4.7"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
smolscale = "0.4.15"
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
geph5-broker-protocol = { path = "../../libraries/geph5-broker-protocol" }
nanorpc = "0.1.12"
nanorpc = "0.1.13"
nanorpc-sillad = { path = "../../libraries/nanorpc-sillad" }
async-trait = "0.1.80"
blake3 = "1.5.1"
async-io = "2.3.3"
async-trait = "0.1.86"
blake3 = "1.6.1"
async-io = "2.4.0"
tap = "1.0.1"
reqwest = { version = "0.12.5", default-features = false, features = [
reqwest = { version = "0.12.12", default-features = false, features = [
"rustls-tls",
"json"
"json",
] }
moka = { version = "0.12.7", features = ["future"] }
anyhow = "1.0.86"
moka = { version = "0.12.10", features = ["future"] }
anyhow = "1.0.96"
stdcode = "0.1.14"
smol = "2.0.0"
futures-util = { version = "0.3.30", features = ["io"] }
deadpool = "0.12.1"
once_cell = "1.19.0"
dashmap = "6.0.1"
serde_json = "1.0.120"
smol = "2.0.2"
futures-util = { version = "0.3.31", features = ["io"] }
deadpool = "0.12.2"
once_cell = "1.20.3"
dashmap = "6.1.0"
serde_json = "1.0.139"
scopeguard = "1.2.0"
smol-timeout2 = "0.6.1"
async-channel = "2.3.1"
oneshot = "0.1.8"
async-io-bufpool = "0.1.0"
tikv-jemallocator = { version = "0.6.0", features = ["unprefixed_malloc_on_supported_platforms"] }
flate2 = "1.0.35"
oneshot = "0.1.11"
async-io-bufpool = "0.1.2"
tikv-jemallocator = { version = "0.6.0", features = [
"unprefixed_malloc_on_supported_platforms",
] }
flate2 = "1.1.0"
#jemalloc_pprof = "0.6.0"
6 changes: 3 additions & 3 deletions binaries/geph5-bridge/src/listen_forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::{
net::{IpAddr, SocketAddr},
str::FromStr,
sync::{
atomic::{AtomicU64, AtomicUsize, Ordering},
Arc, LazyLock,
atomic::{AtomicU64, AtomicUsize, Ordering},
},
time::Duration,
};
Expand All @@ -19,7 +19,7 @@ use moka::future::Cache;
use once_cell::sync::Lazy;
use picomux::{PicoMux, Stream};
use rand::Rng;
use sillad::{dialer::Dialer, listener::Listener, tcp::TcpListener, Pipe};
use sillad::{Pipe, dialer::Dialer, listener::Listener, tcp::TcpListener};
use smol::future::FutureExt as _;
use smol::io::AsyncWriteExt;
use smol_timeout2::TimeoutExt;
Expand Down Expand Up @@ -68,7 +68,7 @@ impl BridgeControlProtocol for State {

async fn random_tcp_listener() -> TcpListener {
loop {
let rando = rand::thread_rng().gen_range(2048u16..65535);
let rando = rand::rng().random_range(2048u16..65535);
match TcpListener::bind(format!("0.0.0.0:{rando}").parse().unwrap()).await {
Ok(listener) => return listener,
Err(err) => {
Expand Down
12 changes: 7 additions & 5 deletions binaries/geph5-bridge/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ use std::{
use anyhow::Context as _;
use asn_count::ASN_BYTES;
use geph5_broker_protocol::{BridgeDescriptor, Mac};
use listen_forward::{listen_forward_loop, BYTE_COUNT};
use listen_forward::{BYTE_COUNT, listen_forward_loop};
use rand::Rng;
use sillad::{
dialer::DialerExt,
tcp::{TcpDialer, TcpListener},
};
use sillad_sosistab3::{listener::SosistabListener, Cookie};
use sillad_sosistab3::{Cookie, listener::SosistabListener};
use smol::future::FutureExt as _;

use smol_timeout2::TimeoutExt;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};

#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
Expand All @@ -36,7 +36,9 @@ fn main() {
if std::env::var("GEPH5_BRIDGE_CHILD").is_err() {
for _ in 0..available_parallelism().unwrap().get() {
std::thread::spawn(|| {
std::env::set_var("GEPH5_BRIDGE_CHILD", "1");
unsafe {
std::env::set_var("GEPH5_BRIDGE_CHILD", "1");
}
let current_exe = std::env::current_exe().unwrap();

// Collect the current command-line arguments
Expand Down Expand Up @@ -83,7 +85,7 @@ fn main() {
)
.unwrap();

let port = rand::thread_rng().gen_range(1024..10000);
let port = rand::rng().random_range(1024..10000);
let control_listen = SocketAddr::new(my_ip, port);
let control_cookie = format!("bridge-cookie-{}", rand::random::<u128>());

Expand Down
61 changes: 33 additions & 28 deletions binaries/geph5-broker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
[package]
name = "geph5-broker"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MPL-2.0"

[dependencies]
anyhow = "1.0.86"
axum = { version = "0.7.5", features = ["json"] }
futures-util = "0.3.30"
once_cell = { version = "1.19.0", features = ["parking_lot"] }
pollster = "0.3.0"
serde = "1.0.204"
serde_json = "1.0.120"
anyhow = "1.0.96"
axum = { version = "0.8.1", features = ["json"] }
futures-util = "0.3.31"
once_cell = { version = "1.20.3", features = ["parking_lot"] }
pollster = "0.4.0"
serde = "1.0.218"
serde_json = "1.0.139"
serde_yaml = "0.9.34"
smolscale = "0.4.7"
sqlx = { version = "0.7", features = [
smolscale = "0.4.15"
sqlx = { version = "0.8.3", features = [
"runtime-tokio-rustls",
"postgres",
"chrono",
] }
geph5-broker-protocol = { path = "../../libraries/geph5-broker-protocol" }
geph5-misc-rpc = { path = "../../libraries/geph5-misc-rpc" }
async-trait = "0.1.80"
nanorpc = "0.1.12"
thiserror = "1.0.61"
tracing = "0.1.40"
rand = "0.8.5"
async-io = "2.3.3"
moka = { version = "0.12.7", features = ["future"] }
blake3 = "1.5.1"
async-trait = "0.1.86"
nanorpc = "0.1.13"
thiserror = "2.0.11"
tracing = "0.1.41"
rand = "0.9.0"
async-io = "2.4.0"
moka = { version = "0.12.10", features = ["future"] }
blake3 = "1.6.1"
isocountry = "0.3.2"
ed25519-dalek = {version="2", default-features=false, features=["serde"]}
tokio = { version = "1.38", features = ["full"] }
tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] }
ed25519-dalek = { version = "2", default-features = false, features = [
"serde",
] }
tokio = { version = "1.43", features = ["full"] }
tracing-subscriber = { version = "0.3.19", features = ["fmt", "env-filter"] }
nanorpc-sillad = { path = "../../libraries/nanorpc-sillad" }
sillad = { path = "../../libraries/sillad" }
mizaru2 = { path = "../../libraries/mizaru2" }
sillad-sosistab3 = { path = "../../libraries/sillad-sosistab3" }
smol-timeout2 = "0.6.0"
smol-timeout2 = "0.6.1"
stdcode = "0.1.14"
bytes = { version = "1.6.0", features = ["serde"] }
bytes = { version = "1.10.0", features = ["serde"] }
argon2 = "0.5.3"
rusty_pool = "0.7.0"
oneshot = "0.1.8"
cadence = "1.4.0"
clap = { version = "4.5.8", features = ["derive"] }
reqwest = { version = "0.12.5", default-features = false, features=["json", "rustls-tls-webpki-roots"] }
oneshot = "0.1.11"
cadence = "1.5.0"
clap = { version = "4.5.31", features = ["derive"] }
reqwest = { version = "0.12.12", default-features = false, features = [
"json",
"rustls-tls-webpki-roots",
] }
hex = "0.4.3"
tap = "1.0.1"
blocking = "1.6.1"
cached = {version="0.54.0", features=["async"]}
cached = { version = "0.54.0", features = ["async"] }
smol = "2.0.2"
6 changes: 3 additions & 3 deletions binaries/geph5-broker/src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use argon2::{password_hash::Encoding, Argon2, PasswordHash, PasswordVerifier};
use argon2::{Argon2, PasswordHash, PasswordVerifier, password_hash::Encoding};

use cached::proc_macro::cached;
use geph5_broker_protocol::{AccountLevel, AuthError, Credential, UserInfo};
Expand Down Expand Up @@ -46,7 +46,7 @@ pub async fn register_secret(user_id: Option<i32>) -> anyhow::Result<String> {
Ok(secret)
} else {
let secret = (0..23)
.map(|_| rand::thread_rng().gen_range(0..9))
.map(|_| rand::rng().random_range(0..9))
.fold(String::new(), |a, b| format!("{a}{b}"));
let secret = format!("9{secret}");

Expand Down Expand Up @@ -124,7 +124,7 @@ pub async fn validate_username_pwd(username: &str, password: &str) -> Result<i32

pub async fn new_auth_token(user_id: i32) -> anyhow::Result<String> {
let token: String = std::iter::repeat(())
.map(|()| rand::thread_rng().sample(rand::distributions::Alphanumeric))
.map(|()| rand::rng().sample(rand::distr::Alphanumeric))
.map(char::from)
.take(30)
.collect();
Expand Down
4 changes: 2 additions & 2 deletions binaries/geph5-broker/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use moka::future::Cache;

use rand::Rng;
use sqlx::{
PgPool,
pool::PoolOptions,
postgres::{PgConnectOptions, PgSslMode},
prelude::FromRow,
PgPool,
};

use crate::CONFIG_FILE;
Expand Down Expand Up @@ -39,7 +39,7 @@ pub static POSTGRES: LazyLock<PgPool> = LazyLock::new(|| {
pub async fn database_gc_loop() -> anyhow::Result<()> {
tracing::info!("starting the database GC loop");
loop {
let sleep_time = Duration::from_secs_f64(rand::thread_rng().gen_range(60.0..120.0));
let sleep_time = Duration::from_secs_f64(rand::rng().random_range(60.0..120.0));
tracing::debug!("sleeping {:?}", sleep_time);
Timer::after(sleep_time).await;
let res = sqlx::query("delete from exits_new where expiry < extract(epoch from now())")
Expand Down
4 changes: 2 additions & 2 deletions binaries/geph5-broker/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::Context;
use axum::{routing::post, Json, Router};
use axum::{Json, Router, routing::post};
use clap::Parser;
use database::database_gc_loop;
use ed25519_dalek::SigningKey;
Expand All @@ -12,7 +12,7 @@ use self_stat::self_stat_loop;
use serde::Deserialize;
use smolscale::immortal::{Immortal, RespawnStrategy};
use std::{fmt::Debug, fs, net::SocketAddr, path::PathBuf, sync::LazyLock};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};

mod auth;
mod database;
Expand Down
1 change: 0 additions & 1 deletion binaries/geph5-broker/src/news.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::sync::Arc;
use std::time::{Duration, SystemTime};

use anyhow::Context;
Expand Down
4 changes: 2 additions & 2 deletions binaries/geph5-broker/src/payments.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use axum::async_trait;
use nanorpc::{nanorpc_derive, JrpcRequest, JrpcResponse, RpcTransport};
use async_trait::async_trait;
use nanorpc::{JrpcRequest, JrpcResponse, RpcTransport, nanorpc_derive};
use serde::{Deserialize, Serialize};

use crate::CONFIG_FILE;
Expand Down
4 changes: 2 additions & 2 deletions binaries/geph5-broker/src/puzzle.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use rand::RngCore;

use crate::{database::POSTGRES, CONFIG_FILE};
use crate::{CONFIG_FILE, database::POSTGRES};

pub async fn new_puzzle() -> String {
let mut bts = [0u8; 20];
rand::thread_rng().fill_bytes(&mut bts);
rand::rng().fill_bytes(&mut bts);
hex::encode(bts)
}

Expand Down
4 changes: 2 additions & 2 deletions binaries/geph5-broker/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use nanorpc_sillad::DialerTransport;

use rand::RngCore;
use sillad::tcp::TcpDialer;
use sillad_sosistab3::{dialer::SosistabDialer, Cookie};
use sillad_sosistab3::{Cookie, dialer::SosistabDialer};
use smol_timeout2::TimeoutExt;
use std::{
net::SocketAddr,
Expand Down Expand Up @@ -86,7 +86,7 @@ pub async fn bridge_to_leaf_route(

fn gencookie() -> String {
let mut b = [0u8; 16];
rand::thread_rng().fill_bytes(&mut b);
rand::rng().fill_bytes(&mut b);
hex::encode(b)
}

Expand Down
22 changes: 11 additions & 11 deletions binaries/geph5-broker/src/rpc_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use bytes::Bytes;
use cadence::prelude::*;
use cadence::{StatsdClient, UdpMetricSink};
use ed25519_dalek::VerifyingKey;
use futures_util::{future::join_all, TryFutureExt};
use futures_util::{TryFutureExt, future::join_all};
use geph5_broker_protocol::{
AccountLevel, AuthError, AvailabilityData, BridgeDescriptor, BrokerProtocol, BrokerService,
Credential, ExitDescriptor, ExitList, GenericError, Mac, NewsItem, RouteDescriptor, Signed,
UserInfo, DOMAIN_EXIT_DESCRIPTOR,
Credential, DOMAIN_EXIT_DESCRIPTOR, ExitDescriptor, ExitList, GenericError, Mac, NewsItem,
RouteDescriptor, Signed, UserInfo,
};
use isocountry::CountryCode;
use mizaru2::{BlindedClientToken, BlindedSignature, ClientToken, UnblindedSignature};
Expand All @@ -22,18 +22,18 @@ use std::{
};

use crate::{
auth::{get_subscription_expiry, get_user_info, register_secret, validate_credential},
CONFIG_FILE, FREE_MIZARU_SK, MASTER_SECRET, PLUS_MIZARU_SK,
auth::{new_auth_token, valid_auth_token},
database::{ExitRow, POSTGRES, insert_exit, query_bridges},
routes::bridge_to_leaf_route,
};
use crate::{
auth::{get_user_info, register_secret, validate_credential},
log_error,
news::fetch_news,
payments::{payment_sessid, PaymentClient, PaymentTransport, StartStripeArgs},
payments::{PaymentClient, PaymentTransport, StartStripeArgs, payment_sessid},
puzzle::{new_puzzle, verify_puzzle_solution},
};
use crate::{
auth::{new_auth_token, valid_auth_token, validate_username_pwd},
database::{insert_exit, query_bridges, ExitRow, POSTGRES},
routes::bridge_to_leaf_route,
CONFIG_FILE, FREE_MIZARU_SK, MASTER_SECRET, PLUS_MIZARU_SK,
};

pub struct WrappedBrokerService(BrokerService<BrokerImpl>);

Expand Down
Loading