mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 17:15:43 +00:00
merge
This commit is contained in:
@@ -13,6 +13,7 @@ use crate::proto::rpc_impl::standalone::{StandAloneClient, StandAloneServer};
|
|||||||
use crate::proto::rpc_types::controller::BaseController;
|
use crate::proto::rpc_types::controller::BaseController;
|
||||||
use crate::tunnel::tcp::{TcpTunnelConnector, TcpTunnelListener};
|
use crate::tunnel::tcp::{TcpTunnelConnector, TcpTunnelListener};
|
||||||
use crate::utils::task::CancellableTask;
|
use crate::utils::task::CancellableTask;
|
||||||
|
use std::io;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::{Notify, broadcast};
|
use tokio::sync::{Notify, broadcast};
|
||||||
use tokio::task::{JoinError, JoinSet};
|
use tokio::task::{JoinError, JoinSet};
|
||||||
@@ -215,7 +216,7 @@ impl DnsNodeRuntime {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DnsNode {
|
pub struct DnsNode {
|
||||||
runtime: DnsNodeRuntime,
|
runtime: DnsNodeRuntime,
|
||||||
task: CancellableTask,
|
task: CancellableTask<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DnsNode {
|
impl DnsNode {
|
||||||
@@ -244,7 +245,7 @@ impl DnsNode {
|
|||||||
Self { runtime, task }
|
Self { runtime, task }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn stop(self) -> Result<(), JoinError> {
|
pub async fn stop(self) -> io::Result<()> {
|
||||||
self.task.stop(None).await
|
self.task.stop(None).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ impl DnsServer {
|
|||||||
async fn reload_listeners(
|
async fn reload_listeners(
|
||||||
&self,
|
&self,
|
||||||
listeners: impl IntoIterator<Item = NameServerAddr>,
|
listeners: impl IntoIterator<Item = NameServerAddr>,
|
||||||
runtime: &mut Option<CancellableTask>,
|
runtime: &mut Option<CancellableTask<()>>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let listeners = listeners.into_iter().collect();
|
let listeners = listeners.into_iter().collect();
|
||||||
|
|
||||||
@@ -204,8 +204,8 @@ impl DnsServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*runtime = Some(CancellableTask::with_token(
|
let token = server.shutdown_token().clone();
|
||||||
server.shutdown_token().clone(),
|
let handle = tokio::spawn(
|
||||||
async move {
|
async move {
|
||||||
server
|
server
|
||||||
.block_until_done()
|
.block_until_done()
|
||||||
@@ -213,7 +213,9 @@ impl DnsServer {
|
|||||||
.unwrap_or_else(|e| tracing::error!("DNS server exited with error: {:?}", e));
|
.unwrap_or_else(|e| tracing::error!("DNS server exited with error: {:?}", e));
|
||||||
}
|
}
|
||||||
.instrument(tracing::info_span!("DNS server backend runtime")),
|
.instrument(tracing::info_span!("DNS server backend runtime")),
|
||||||
));
|
);
|
||||||
|
|
||||||
|
*runtime = Some(CancellableTask::with_handle(token, handle));
|
||||||
|
|
||||||
*self.listeners.write() = listeners;
|
*self.listeners.write() = listeners;
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,6 @@ use std::sync::{Arc, Weak};
|
|||||||
#[cfg(feature = "tun")]
|
#[cfg(feature = "tun")]
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Context;
|
|
||||||
use cidr::{IpCidr, Ipv4Inet};
|
|
||||||
use futures::FutureExt;
|
|
||||||
use tokio::sync::{Mutex, Notify};
|
|
||||||
#[cfg(feature = "tun")]
|
|
||||||
use tokio::{sync::oneshot, task::JoinSet};
|
|
||||||
|
|
||||||
use crate::common::PeerId;
|
use crate::common::PeerId;
|
||||||
use crate::common::acl_processor::AclRuleBuilder;
|
use crate::common::acl_processor::AclRuleBuilder;
|
||||||
use crate::common::config::ConfigLoader;
|
use crate::common::config::ConfigLoader;
|
||||||
@@ -59,6 +52,13 @@ use crate::proto::rpc_types::controller::BaseController;
|
|||||||
use crate::rpc_service::InstanceRpcService;
|
use crate::rpc_service::InstanceRpcService;
|
||||||
use crate::utils::weak_upgrade;
|
use crate::utils::weak_upgrade;
|
||||||
use crate::vpn_portal::{self, VpnPortal};
|
use crate::vpn_portal::{self, VpnPortal};
|
||||||
|
use anyhow::Context;
|
||||||
|
use cidr::{IpCidr, Ipv4Inet};
|
||||||
|
use futures::FutureExt;
|
||||||
|
use tokio::sync::{Mutex, Notify};
|
||||||
|
#[cfg(feature = "tun")]
|
||||||
|
use tokio::{sync::oneshot, task::JoinSet};
|
||||||
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
|
|
||||||
use super::listeners::ListenerManager;
|
use super::listeners::ListenerManager;
|
||||||
use super::public_ipv6_provider::{
|
use super::public_ipv6_provider::{
|
||||||
|
|||||||
@@ -190,9 +190,8 @@ pub async fn socket_addrs(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::defer;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use guarden::defer;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_matrix_cases() {
|
fn parse_matrix_cases() {
|
||||||
|
|||||||
Reference in New Issue
Block a user