fix minor bugs (#936)

1. update upx to v5.0.1 to avoid mips bug.
2. use latest mimalloc.
3. fix panic in ospf route
4. potential residual conn.
This commit is contained in:
Sijie.Sun
2025-06-05 11:55:44 +08:00
committed by GitHub
parent 9f7ba8ab8f
commit 96fc19b803
8 changed files with 82 additions and 44 deletions

View File

@@ -27,6 +27,8 @@ rustflags = [
"atomic",
"-l",
"ctz",
"-l",
"gcc",
]
[target.mips-unknown-linux-musl]
@@ -44,6 +46,8 @@ rustflags = [
"atomic",
"-l",
"ctz",
"-l",
"gcc",
]
[target.armv7-unknown-linux-musleabihf]

View File

@@ -223,13 +223,6 @@ jobs:
mv ./target/$TARGET/release/easytier-web ./target/$TARGET/release/easytier-web-embed
cargo build --release --verbose --target $TARGET
- name: Install UPX
if: ${{ matrix.OS != 'macos-latest' }}
uses: crazy-max/ghaction-upx@v3
with:
version: latest
install-only: true
- name: Compress
run: |
mkdir -p ./artifacts/objects/
@@ -251,8 +244,11 @@ jobs:
fi
if [[ $OS =~ ^ubuntu.*$ && ! $TARGET =~ ^.*freebsd$ ]]; then
upx --lzma --best ./target/$TARGET/release/easytier-core"$SUFFIX"
upx --lzma --best ./target/$TARGET/release/easytier-cli"$SUFFIX"
UPX_VERSION=5.0.1
curl -L https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz -s | tar xJvf -
cp upx-${UPX_VERSION}-amd64_linux/upx .
./upx --lzma --best ./target/$TARGET/release/easytier-core"$SUFFIX"
./upx --lzma --best ./target/$TARGET/release/easytier-cli"$SUFFIX"
fi
mv ./target/$TARGET/release/easytier-core"$SUFFIX" ./artifacts/objects/

37
Cargo.lock generated
View File

@@ -1550,12 +1550,6 @@ dependencies = [
"cipher",
]
[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]]
name = "curve25519-dalek"
version = "4.1.3"
@@ -1965,7 +1959,7 @@ dependencies = [
"kcp-sys",
"machine-uid",
"maplit",
"mimalloc-rust",
"mimalloc",
"multimap",
"netlink-packet-core",
"netlink-packet-route 0.21.0",
@@ -4097,6 +4091,16 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "libmimalloc-sys"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec9d6fac27761dabcd4ee73571cdb06b7022dc99089acbe5435691edffaac0f4"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "libredox"
version = "0.1.3"
@@ -4299,21 +4303,12 @@ dependencies = [
]
[[package]]
name = "mimalloc-rust"
version = "0.2.1"
source = "git+https://github.com/EasyTier/mimalloc-rust#eb61c4d50fef4eb5fbd5db83e4ea83153646b482"
name = "mimalloc"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "995942f432bbb4822a7e9c3faa87a695185b0d09273ba85f097b54f4e458f2af"
dependencies = [
"cty",
"mimalloc-rust-sys",
]
[[package]]
name = "mimalloc-rust-sys"
version = "2.1.2-source"
source = "git+https://github.com/EasyTier/mimalloc-rust#eb61c4d50fef4eb5fbd5db83e4ea83153646b482"
dependencies = [
"cc",
"cty",
"libmimalloc-sys",
]
[[package]]

View File

@@ -154,7 +154,7 @@ humansize = "2.1.3"
base64 = "0.22"
mimalloc-rust = { git = "https://github.com/EasyTier/mimalloc-rust", optional = true }
mimalloc = { version = "*", optional = true }
# mips
atomic-shim = "0.2.0"
@@ -297,7 +297,7 @@ full = [
mips = ["aes-gcm", "mimalloc", "wireguard", "tun", "smoltcp", "socks5"]
wireguard = ["dep:boringtun", "dep:ring"]
quic = ["dep:quinn", "dep:rustls", "dep:rcgen"]
mimalloc = ["dep:mimalloc-rust"]
mimalloc = ["dep:mimalloc"]
aes-gcm = ["dep:aes-gcm"]
tun = ["dep:tun"]
websocket = [

View File

@@ -39,11 +39,11 @@ use easytier::{
windows_service::define_windows_service!(ffi_service_main, win_service_main);
#[cfg(all(feature = "mimalloc", not(feature = "jemalloc")))]
use mimalloc_rust::GlobalMiMalloc;
use mimalloc::MiMalloc;
#[cfg(all(feature = "mimalloc", not(feature = "jemalloc")))]
#[global_allocator]
static GLOBAL_MIMALLOC: GlobalMiMalloc = GlobalMiMalloc;
static GLOBAL_MIMALLOC: MiMalloc = MiMalloc;
#[cfg(feature = "jemalloc")]
use jemalloc_ctl::{epoch, stats, Access as _, AsName as _};

View File

@@ -118,8 +118,14 @@ impl Peer {
}
pub async fn add_peer_conn(&self, mut conn: PeerConn) {
let close_event_sender = self.close_event_sender.clone();
let close_notifier = conn.get_close_notifier();
let conn_info = conn.get_conn_info();
conn.start_recv_loop(self.packet_recv_chan.clone()).await;
conn.start_pingpong();
self.conns.insert(conn.get_conn_id(), Arc::new(conn));
let close_event_sender = self.close_event_sender.clone();
tokio::spawn(async move {
let conn_id = close_notifier.get_conn_id();
if let Some(mut waiter) = close_notifier.get_waiter().await {
@@ -130,12 +136,8 @@ impl Peer {
}
});
conn.start_recv_loop(self.packet_recv_chan.clone()).await;
conn.start_pingpong();
self.global_ctx
.issue_event(GlobalCtxEvent::PeerConnAdded(conn.get_conn_info()));
self.conns.insert(conn.get_conn_id(), Arc::new(conn));
.issue_event(GlobalCtxEvent::PeerConnAdded(conn_info));
}
async fn select_conn(&self) -> Option<ArcPeerConn> {

View File

@@ -423,7 +423,8 @@ impl PeerManager {
let mut peer = PeerConn::new(self.my_peer_id, self.global_ctx.clone(), tunnel);
peer.do_handshake_as_server().await?;
if self.global_ctx.config.get_flags().private_mode
&& peer.get_network_identity().network_name != self.global_ctx.get_network_identity().network_name
&& peer.get_network_identity().network_name
!= self.global_ctx.get_network_identity().network_name
{
return Err(Error::SecretKeyError(
"private mode is turned on, network identity not match".to_string(),
@@ -1085,7 +1086,8 @@ mod tests {
use crate::{
common::{config::Flags, global_ctx::tests::get_mock_global_ctx},
connector::{
create_connector_by_url, udp_hole_punch::tests::create_mock_peer_manager_with_mock_stun,
create_connector_by_url, direct::PeerManagerForDirectConnector,
udp_hole_punch::tests::create_mock_peer_manager_with_mock_stun,
},
instance::listeners::get_listener_by_url,
peers::{
@@ -1096,7 +1098,12 @@ mod tests {
tests::{connect_peer_manager, wait_route_appear, wait_route_appear_with_cost},
},
proto::common::{CompressionAlgoPb, NatType, PeerFeatureFlag},
tunnel::{common::tests::wait_for_condition, TunnelConnector, TunnelListener},
tunnel::{
common::tests::wait_for_condition,
filter::{tests::DropSendTunnelFilter, TunnelWithFilter},
ring::create_ring_tunnel_pair,
TunnelConnector, TunnelListener,
},
};
use super::PeerManager;
@@ -1336,4 +1343,36 @@ mod tests {
.await;
assert_eq!(ret, Some(peer_mgr_b.my_peer_id));
}
#[tokio::test]
async fn test_client_inbound_blackhole() {
let peer_mgr_a = create_mock_peer_manager_with_mock_stun(NatType::Unknown).await;
let peer_mgr_b = create_mock_peer_manager_with_mock_stun(NatType::Unknown).await;
// a is client, b is server
let (a_ring, b_ring) = create_ring_tunnel_pair();
let a_ring = Box::new(TunnelWithFilter::new(
a_ring,
DropSendTunnelFilter::new(2, 50000),
));
let a_mgr_copy = peer_mgr_a.clone();
tokio::spawn(async move {
a_mgr_copy.add_client_tunnel(a_ring).await.unwrap();
});
let b_mgr_copy = peer_mgr_b.clone();
tokio::spawn(async move {
b_mgr_copy.add_tunnel_as_server(b_ring, true).await.unwrap();
});
wait_for_condition(
|| async {
let peers = peer_mgr_a.list_peers().await;
peers.is_empty()
},
Duration::from_secs(10),
)
.await;
}
}

View File

@@ -1315,7 +1315,9 @@ impl PeerRouteServiceImpl {
let all_peer_ids = &conn_bitmap.peer_ids;
for (peer_idx, (peer_id, _)) in all_peer_ids.iter().enumerate() {
let connected = self.synced_route_info.conn_map.get(peer_id).unwrap();
let Some(connected) = self.synced_route_info.conn_map.get(peer_id) else {
continue;
};
for (idx, (other_peer_id, _)) in all_peer_ids.iter().enumerate() {
if connected.0.contains(other_peer_id) {