运行环境:OpenWrt 23.05.5
mips-openwrt-linux-musl 32位mips系统
$ file ./target/mips-unknown-linux-musl/release/geph4-client
./target/mips-unknown-linux-musl/release/geph4-client: ELF 32-bit MSB pie executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-mips-sf.so.1, stripped
交叉编译需要更改一些64位数据类型到32位,不知道是不是这个原因,看起来不像。是服务器不支持32位client吗?数据格式不对,直接把连接close掉了?
32位路由器市场还是挺大的,改动点也不大,能否支持一下。
# ./geph4-client connect --exit-server 51.159.101.60 --socks5-listen 0.0.0.0:9909 --http-listen 0.0.0.0:9910 auth-password --username 。。。
。。。 。。。
[geph5_client::client_inner WARN]: individual client thread failed err=inner connection to 51.15.124.90:34755 failed
Caused by:
unexpected end of file
[geph5_client::client_inner DEBG]: deprioritizing route due to failed dial addr=91.134.96.63:44251
[geph5_client::client_inner WARN]: individual client thread failed err=inner connection to 91.134.96.63:44251 failed
Caused by:
unexpected end of file
[geph5_client::client_inner DEBG]: deprioritizing route due to failed dial addr=51.79.25.164:38567
[geph5_client::client_inner WARN]: individual client thread failed err=inner connection to 51.79.25.164:38567 failed
Caused by:
unexpected end of file
[geph5_client::client_inner DEBG]: deprioritizing route due to failed dial addr=51.79.25.164:38567
[geph5_client::client_inner WARN]: individual client thread failed err=inner connection to 51.79.25.164:38567 failed
Caused by:
unexpected end of file
[geph5_client::client_inner DEBG]: deprioritizing route due to failed dial addr=51.79.25.164:38567
[geph5_client::client_inner WARN]: individual client thread failed err=inner connection to 51.79.25.164:38567 failed
Caused by:
unexpected end of file
[geph5_client::client_inner DEBG]: deprioritizing route due to failed dial addr=51.79.25.164:38567
[geph5_client::client_inner WARN]: individual client thread failed err=inner connection to 51.79.25.164:38567 failed
Caused by:
unexpected end of file
[geph5_client::client_inner DEBG]: deprioritizing route due to failed dial addr=51.79.25.164:38567
[geph5_client::client_inner WARN]: individual client thread failed err=inner connection to 51.79.25.164:38567 failed
Caused by:
unexpected end of file
[geph5_client::client_inner DEBG]: deprioritizing route due to failed dial addr=51.79.25.164:38567
[geph5_client::client_inner WARN]: individual client thread failed err=inner connection to 51.79.25.164:38567 failed
。。。 。。。
具体改的代码如下:
geph5-client-0.2.27/src/client_inner.rs
@@ -131,4 +131,4 @@
// jitter here to avoid thundering herd effects
- let mut sleep_secs: f64 = rand::random();
- smol::Timer::after(Duration::from_secs_f64(sleep_secs)).await;
+ let mut sleep_secs: f32 = rand::random();
+ smol::Timer::after(Duration::from_secs_f32(sleep_secs)).await;
loop {
@@ -144,3 +144,3 @@
rand::thread_rng().gen_range(sleep_secs..=(sleep_secs * 1.5));
- smol::Timer::after(Duration::from_secs_f64(sleep_secs)).await;
+ smol::Timer::after(Duration::from_secs_f32(sleep_secs)).await;
}
@@ -258,3 +258,3 @@
if let Some(latency) = mux.last_latency() {
- stat_set_num(&ctx, "ping", latency.as_secs_f64());
+ stat_set_num(&ctx, "ping", latency.as_secs_f32());
}
geph5-client-0.2.27/src/control_prot.rs
@@ -20,3 +20,3 @@
async fn conn_info(&self) -> ConnInfo;
- async fn stat_num(&self, stat: String) -> f64;
+ async fn stat_num(&self, stat: String) -> f32;
async fn start_time(&self) -> SystemTime;
@@ -54,3 +54,3 @@
- async fn stat_num(&self, stat: String) -> f64 {
+ async fn stat_num(&self, stat: String) -> f32 {
stat_get_num(&self.ctx, &stat)
geph5-client-0.2.27/src/stats.rs
@@ -4,3 +4,3 @@
use async_trait::async_trait;
-use atomic_float::AtomicF64;
+use atomic_float::AtomicF32;
use dashmap::DashMap;
@@ -12,5 +12,5 @@
-static NUM_STATS: CtxField<DashMap<SmolStr, AtomicF64>> = |_| DashMap::new();
+static NUM_STATS: CtxField<DashMap<SmolStr, AtomicF32>> = |_| DashMap::new();
-pub fn stat_set_num(ctx: &AnyCtx<Config>, stat: &str, num: f64) {
+pub fn stat_set_num(ctx: &AnyCtx<Config>, stat: &str, num: f32) {
ctx.get(NUM_STATS)
@@ -21,3 +21,3 @@
-pub fn stat_incr_num(ctx: &AnyCtx<Config>, stat: &str, num: f64) {
+pub fn stat_incr_num(ctx: &AnyCtx<Config>, stat: &str, num: f32) {
ctx.get(NUM_STATS)
@@ -28,3 +28,3 @@
-pub fn stat_get_num(ctx: &AnyCtx<Config>, stat: &str) -> f64 {
+pub fn stat_get_num(ctx: &AnyCtx<Config>, stat: &str) -> f32 {
ctx.get(NUM_STATS)
@@ -39,3 +39,3 @@
impl ClientControlProtocol for ClientControlImpl {
- async fn stat_num(&self, stat: SmolStr) -> f64 {
+ async fn stat_num(&self, stat: SmolStr) -> f32 {
stat_get_num(&self.0, &stat)
@@ -49,3 +49,3 @@
/// Get the current statistics.
- async fn stat_num(&self, stat: SmolStr) -> f64;
+ async fn stat_num(&self, stat: SmolStr) -> f32;
}
mizaru-0.1.3/src/keypair.rs
@@ -6,3 +6,3 @@
use std::{
- sync::{atomic::AtomicU64, atomic::Ordering},
+ sync::{atomic::AtomicUsize, atomic::Ordering},
time::SystemTime,
@@ -30,3 +30,3 @@
pub fn generate() -> Self {
- let count = AtomicU64::new(0);
+ let count = AtomicUsize::new(0);
// first we generate the massive number of rsa keys
picomux-0.1.9/src/lib.rs
@@ -12,3 +12,3 @@
sync::{
- atomic::{AtomicU64, Ordering},
+ atomic::{AtomicUsize, Ordering},
Arc,
@@ -177,3 +177,3 @@
-static MUX_ID_CTR: AtomicU64 = AtomicU64::new(0);
+static MUX_ID_CTR: AtomicUsize = AtomicUsize::new(0);
ipstack-geph-0.2.7/Cargo.toml
@@ -65,2 +65,3 @@
-moka = {version="0.12.8", features=["sync"]}
+moka = {version="0.12.8", default-features = false, features=["sync"]}
moka自己支持32位,但是AtomicU64使用在default feature里,禁止后打开sync或者async都可以
其余调用moka的模块都类似修改
smolscale-0.4.11/src/queues.rs
@@ -9,3 +9,3 @@
use st3::fifo::{Stealer, Worker};
-use std::sync::atomic::{AtomicU64, Ordering};
+use std::sync::atomic::{AtomicUsize, Ordering};
@@ -17,3 +17,3 @@
stealers: ShardedLock<FxHashMap<u64, Stealer<Runnable>>>,
- id_ctr: AtomicU64,
+ id_ctr: AtomicUsize,
event: Event,
@@ -27,3 +27,3 @@
stealers: Default::default(),
- id_ctr: AtomicU64::new(0),
+ id_ctr: AtomicUsize::new(0),
event: Event::new(),
@@ -40,3 +40,3 @@
let worker = Worker::<Runnable>::new(8192);
- let id = self.id_ctr.fetch_add(1, Ordering::Relaxed);
+ let id:u64 = self.id_ctr.fetch_add(1, Ordering::Relaxed).try_into().unwrap();
self.stealers.write().unwrap().insert(id, worker.stealer());
error: "Unknown target CPU"
aws-lc-sys-0.24.0/aws-lc/include/openssl/target.h:78:2:
+52 #elif defined(__MIPSEB__) && !defined(__LP64__)
+53 #define OPENSSL_32_BIT
+54 #define OPENSSL_MIPS
+55 #define OPENSSL_BIG_ENDIAN
56 #elif defined(__MIPSEL__) && !defined(__LP64__)
57 #define OPENSSL_32_BIT
58 #define OPENSSL_MIPS
59 #elif defined(__MIPSEL__) && defined(__LP64__)
60 #define OPENSSL_64_BIT
61 #define OPENSSL_MIPS64
以下是geph4-client的改动点:
Cargo.toml
-governor = "0.3.2"
+governor = "0.8.0"
-rustls = "0.19.1"
-webpki-roots = "0.21.1"
+rustls = "0.23.20"
+webpki-roots = "0.26.7"
-moka = "0.11.3"
+moka = { version = "0.12.8", default-features = false, features = ["sync"] }
src/connect/socks5.rs
@@ -91,10 +91,10 @@ async fn handle_socks5(
let (conn_read, conn_write) = conn.split();
smol::future::race(
geph4_aioutils::copy_with_stats(conn_read, s5client.clone(), |n| {
- STATS_RECV_BYTES.fetch_add(n as u64, Ordering::Relaxed);
+ STATS_RECV_BYTES.fetch_add(n as usize, Ordering::Relaxed);
}),
geph4_aioutils::copy_with_stats(s5client, conn_write, |n| {
- STATS_SEND_BYTES.fetch_add(n as u64, Ordering::Relaxed);
+ STATS_SEND_BYTES.fetch_add(n as usize, Ordering::Relaxed);
}),
)
.await?;
rc/connect/stats.rs
@@ -1,7 +1,7 @@
pub mod gatherer;
use std::{
- sync::atomic::{AtomicU64, Ordering},
+ sync::atomic::{AtomicUsize, Ordering},
time::{Duration, SystemTime, UNIX_EPOCH},
};
@@ -205,6 +205,6 @@ pub enum Timeseries {
pub static STATS_GATHERER: Lazy<StatsGatherer> = Lazy::new(Default::default);
-pub static STATS_SEND_BYTES: Lazy<AtomicU64> = Lazy::new(|| AtomicU64::new(0));
+pub static STATS_SEND_BYTES: Lazy<AtomicUsize> = Lazy::new(|| AtomicUsize::new(0));
-pub static STATS_RECV_BYTES: Lazy<AtomicU64> = Lazy::new(|| AtomicU64::new(0));
+pub static STATS_RECV_BYTES: Lazy<AtomicUsize> = Lazy::new(|| AtomicUsize::new(0));
src/connect/stats/gatherer.rs
@@ -9,8 +9,8 @@ pub struct StatItem {
pub endpoint: SmolStr,
pub protocol: SmolStr,
pub ping: Duration,
- pub send_bytes: u64,
- pub recv_bytes: u64,
+ pub send_bytes: usize,
+ pub recv_bytes: usize,
}
src/connect/tunnel.rs
@@ -94,11 +94,11 @@ impl ClientTunnel {
time: SystemTime::now(),
endpoint: conn.bridge.into(),
protocol: conn.protocol.into(),
- ping: Duration::from_secs_f64(
+ ping: Duration::from_secs_f32(
handle.stat_num("ping".into()).await.unwrap(),
),
- send_bytes: send_bytes as u64,
- recv_bytes: recv_bytes as u64,
+ send_bytes: send_bytes as usize,
+ recv_bytes: recv_bytes as usize,
}),
}
}