Skip to content

Commit

Permalink
Optimize imports, cleanup unused variables, and comment out unused fu…
Browse files Browse the repository at this point in the history
…nction stat_set_num
  • Loading branch information
nullchinchilla committed Jul 18, 2024
1 parent 3de3e37 commit eb06f5b
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 34 deletions.
11 changes: 4 additions & 7 deletions binaries/geph5-client-android/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{net::TcpStream, sync::Arc};
use std::sync::Arc;

use egui::ViewportId;
use egui_wgpu::wgpu::{self, rwh::HasDisplayHandle};
Expand All @@ -8,10 +8,7 @@ use egui_winit::winit::{
};

use geph5_client_gui::App;
use jni::{
objects::{JObject, JValue},
JNIEnv, JavaVM,
};
use jni::{objects::JObject, JNIEnv, JavaVM};
use once_cell::sync::OnceCell;
use winit::event_loop::{EventLoop, EventLoopBuilder, EventLoopWindowTarget};

Expand Down Expand Up @@ -148,7 +145,7 @@ fn _main(event_loop: EventLoop<CustomEvent>) {
window = None;
}
Event::WindowEvent {
window_id,
window_id: _,
event: WindowEvent::RedrawRequested,
} => {
if let Some(window) = window.as_ref() {
Expand All @@ -158,7 +155,7 @@ fn _main(event_loop: EventLoop<CustomEvent>) {
log::debug!("RedrawRequested: calling ctx.run()");
let full_output = ctx.run(raw_input, |ctx| {
let app = app.get_or_insert_with(|| App::new(ctx));
egui::CentralPanel::default().show(ctx, |ui| {
egui::CentralPanel::default().show(ctx, |_ui| {
// ui.add_space(90.0);
app.render(ctx);
});
Expand Down
4 changes: 2 additions & 2 deletions binaries/geph5-client-gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() {

use geph5_client_gui::logs::LOGS;
use single_instance::SingleInstance;
use tracing_subscriber::{fmt::format::FmtSpan, Layer};

let instance = SingleInstance::new("geph5-client-gui");
if let Ok(instance) = instance {
if !instance.is_single() {
Expand Down Expand Up @@ -79,7 +79,7 @@ fn main() {
};

let mut cell = None;
eframe::run_simple_native(l10n("geph"), native_options, move |ctx, frame| {
eframe::run_simple_native(l10n("geph"), native_options, move |ctx, _frame| {
let app = cell.get_or_insert_with(|| geph5_client_gui::App::new(ctx));
app.render(ctx)
})
Expand Down
12 changes: 1 addition & 11 deletions binaries/geph5-client-gui/src/tabs/logs.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use std::{
fmt::Write as _,
time::{Duration, SystemTime, UNIX_EPOCH},
};
use std::time::Duration;

use chrono::{DateTime, Utc};
use itertools::Itertools;

use crate::{daemon::DAEMON_HANDLE, logs::LOGS, refresh_cell::RefreshCell};
Expand Down Expand Up @@ -63,9 +59,3 @@ impl Logs {
Ok(())
}
}

fn chrono_to_system_time(dt: chrono::DateTime<chrono::Utc>) -> SystemTime {
let duration_since_epoch = dt.timestamp_nanos_opt().unwrap();
let std_duration = Duration::from_nanos(duration_since_epoch as u64);
UNIX_EPOCH + std_duration
}
4 changes: 2 additions & 2 deletions binaries/geph5-client/src/bin/geph5-client.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{ops::Deref, path::PathBuf};
use std::path::PathBuf;

use clap::Parser;
use geph5_client::{logs::LOGS, Client, Config};
use tracing_subscriber::{fmt::format::FmtSpan, prelude::*, EnvFilter};
use tracing_subscriber::{prelude::*, EnvFilter};

/// Run the Geph5 client.
#[derive(Parser)]
Expand Down
5 changes: 2 additions & 3 deletions binaries/geph5-client/src/control_prot.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{
collections::BTreeMap,
convert::Infallible,
time::{Duration, SystemTime, UNIX_EPOCH},
time::{Duration, SystemTime},
};

use anyctx::AnyCtx;
Expand All @@ -12,7 +11,7 @@ use itertools::Itertools;
use nanorpc::{nanorpc_derive, JrpcRequest, JrpcResponse, RpcService, RpcTransport};
use parking_lot::Mutex;
use serde::{Deserialize, Serialize};
use smol_str::SmolStr;


use crate::{client::CtxField, logs::LOGS, stats::stat_get_num, Config};

Expand Down
2 changes: 1 addition & 1 deletion binaries/geph5-client/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub async fn get_dialer(
.context("no exits that fit the criterion")?;
tracing::debug!(exit = debug(&exit), "narrowed down choice of exit");
vpn_whitelist(exit.c2e_listen.ip());
let direct_dialer = TcpDialer {
let _direct_dialer = TcpDialer {
dest_addr: exit.c2e_listen,
}
.delay(Duration::from_secs(
Expand Down
12 changes: 6 additions & 6 deletions binaries/geph5-client/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use crate::{client::CtxField, Config};

static NUM_STATS: CtxField<DashMap<SmolStr, AtomicF64>> = |_| DashMap::new();

pub fn stat_set_num(ctx: &AnyCtx<Config>, stat: &str, num: f64) {
ctx.get(NUM_STATS)
.entry(stat.into())
.or_default()
.store(num, Ordering::Relaxed);
}
// pub fn stat_set_num(ctx: &AnyCtx<Config>, stat: &str, num: f64) {
// ctx.get(NUM_STATS)
// .entry(stat.into())
// .or_default()
// .store(num, Ordering::Relaxed);
// }

pub fn stat_incr_num(ctx: &AnyCtx<Config>, stat: &str, num: f64) {
ctx.get(NUM_STATS)
Expand Down
4 changes: 2 additions & 2 deletions binaries/geph5-client/src/vpn/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct VpnCapture {
}

impl VpnCapture {
pub fn new(ctx: AnyCtx<Config>) -> Self {
pub fn new(_ctx: AnyCtx<Config>) -> Self {
todo!()
}

Expand All @@ -19,6 +19,6 @@ impl VpnCapture {
}
}

pub fn vpn_whitelist(addr: IpAddr) {
pub fn vpn_whitelist(_addr: IpAddr) {
// noop
}

0 comments on commit eb06f5b

Please sign in to comment.