mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 17:15:43 +00:00
fix: address shared tun ci failures
This commit is contained in:
@@ -953,8 +953,9 @@ mod manager {
|
|||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
|
|
||||||
let (first_id, Some(shared_dev_name)) = first else {
|
let (first_id, shared_dev_name) = first;
|
||||||
return vec![first.0];
|
let Some(shared_dev_name) = shared_dev_name else {
|
||||||
|
return vec![first_id];
|
||||||
};
|
};
|
||||||
|
|
||||||
let ids: Vec<uuid::Uuid> = self
|
let ids: Vec<uuid::Uuid> = self
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ impl MagicDnsServerInstance {
|
|||||||
netns: Option<String>,
|
netns: Option<String>,
|
||||||
cost: Option<i32>,
|
cost: Option<i32>,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
let ifcfg = IfConfiger {};
|
let ifcfg = IfConfiger::default();
|
||||||
let _guard = NetNS::new(netns).guard();
|
let _guard = NetNS::new(netns).guard();
|
||||||
match ifcfg.add_ipv4_route(tun_dev_name, fake_ip, 32, cost).await {
|
match ifcfg.add_ipv4_route(tun_dev_name, fake_ip, 32, cost).await {
|
||||||
Err(EtError::IOError(err)) if err.kind() == io::ErrorKind::AlreadyExists => {
|
Err(EtError::IOError(err)) if err.kind() == io::ErrorKind::AlreadyExists => {
|
||||||
@@ -534,7 +534,7 @@ impl MagicDnsServerInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn remove_fake_ip_route(tun_dev_name: &str, fake_ip: Ipv4Addr, netns: Option<String>) {
|
async fn remove_fake_ip_route(tun_dev_name: &str, fake_ip: Ipv4Addr, netns: Option<String>) {
|
||||||
let ifcfg = IfConfiger {};
|
let ifcfg = IfConfiger::default();
|
||||||
let _guard = NetNS::new(netns).guard();
|
let _guard = NetNS::new(netns).guard();
|
||||||
if let Err(err) = ifcfg.remove_ipv4_route(tun_dev_name, fake_ip, 32).await {
|
if let Err(err) = ifcfg.remove_ipv4_route(tun_dev_name, fake_ip, 32).await {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
|
|||||||
@@ -1737,18 +1737,16 @@ impl Instance {
|
|||||||
.with_context(|| "add ip failed")?;
|
.with_context(|| "add ip failed")?;
|
||||||
|
|
||||||
#[cfg(feature = "magic-dns")]
|
#[cfg(feature = "magic-dns")]
|
||||||
|
{
|
||||||
let magic_dns_runner = if let Some(ipv4) = global_ctx.get_ipv4() {
|
let magic_dns_runner = if let Some(ipv4) = global_ctx.get_ipv4() {
|
||||||
Self::create_magic_dns_runner(peer_manager.clone(), None, ipv4)
|
Self::create_magic_dns_runner(peer_manager.clone(), None, ipv4)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
Self::use_new_nic_ctx(
|
Self::use_new_nic_ctx(nic_ctx.clone(), new_nic_ctx, magic_dns_runner).await;
|
||||||
nic_ctx.clone(),
|
}
|
||||||
new_nic_ctx,
|
#[cfg(not(feature = "magic-dns"))]
|
||||||
#[cfg(feature = "magic-dns")]
|
Self::use_new_nic_ctx(nic_ctx.clone(), new_nic_ctx).await;
|
||||||
magic_dns_runner,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -698,7 +698,7 @@ impl SharedVirtualNicMember {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn member_id(&self) -> SharedVirtualNicMemberId {
|
pub fn member_id(&self) -> SharedVirtualNicMemberId {
|
||||||
self.member_id.clone()
|
self.member_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shared_nic(&self) -> Arc<Mutex<SharedVirtualNic>> {
|
pub fn shared_nic(&self) -> Arc<Mutex<SharedVirtualNic>> {
|
||||||
@@ -957,7 +957,7 @@ impl SharedVirtualNicRegistry {
|
|||||||
let needs_new_entry = self
|
let needs_new_entry = self
|
||||||
.nics
|
.nics
|
||||||
.get(&dev_name)
|
.get(&dev_name)
|
||||||
.map_or(true, |entry| !entry.is_valid());
|
.is_none_or(|entry| !entry.is_valid());
|
||||||
if needs_new_entry {
|
if needs_new_entry {
|
||||||
let entry = SharedVirtualNicRegistryEntry::new(SharedVirtualNic::new(config));
|
let entry = SharedVirtualNicRegistryEntry::new(SharedVirtualNic::new(config));
|
||||||
self.nics.insert(dev_name.clone(), entry);
|
self.nics.insert(dev_name.clone(), entry);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ impl EasyTierLauncher {
|
|||||||
let Some(tun_fd) = tun_fd_receiver.recv().await.flatten() else {
|
let Some(tun_fd) = tun_fd_receiver.recv().await.flatten() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let _ = Instance::setup_nic_ctx_for_mobile(
|
if let Err(err) = Instance::setup_nic_ctx_for_mobile(
|
||||||
nic_ctx.clone(),
|
nic_ctx.clone(),
|
||||||
global_ctx.clone(),
|
global_ctx.clone(),
|
||||||
peer_mgr.clone(),
|
peer_mgr.clone(),
|
||||||
@@ -137,7 +137,10 @@ impl EasyTierLauncher {
|
|||||||
shared_virtual_nic_registry.clone(),
|
shared_virtual_nic_registry.clone(),
|
||||||
tun_fd,
|
tun_fd,
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
|
{
|
||||||
|
tracing::error!(?err, tun_fd, "setup mobile nic ctx failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -345,12 +345,11 @@ async fn wait_proxy_route_to_peer(
|
|||||||
wait_for_condition(
|
wait_for_condition(
|
||||||
|| async {
|
|| async {
|
||||||
let routes = mgr.list_routes().await;
|
let routes = mgr.list_routes().await;
|
||||||
let route_found = routes.iter().any(|route| {
|
routes.iter().any(|route| {
|
||||||
route.peer_id == dst_peer_id
|
route.peer_id == dst_peer_id
|
||||||
&& route.ipv4_addr == Some(ipv4.parse().unwrap())
|
&& route.ipv4_addr == Some(ipv4.parse().unwrap())
|
||||||
&& route.proxy_cidrs.contains(&proxy_cidr)
|
&& route.proxy_cidrs.contains(&proxy_cidr)
|
||||||
});
|
})
|
||||||
route_found
|
|
||||||
},
|
},
|
||||||
Duration::from_secs(8),
|
Duration::from_secs(8),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user