move common::dns to utils::dns

move dns

move
This commit is contained in:
Luna Yao
2026-04-18 22:01:24 +02:00
parent c71ab7543f
commit 5a516a195c
9 changed files with 12 additions and 16 deletions
-1
View File
@@ -15,7 +15,6 @@ pub mod compressor;
pub mod config;
pub mod constants;
pub mod defer;
pub mod dns;
pub mod env_parser;
pub mod error;
pub mod global_ctx;
+1 -1
View File
@@ -22,7 +22,7 @@ use stun_codec::{Message, MessageClass, MessageDecoder, MessageEncoder};
use crate::common::error::Error;
use super::dns::resolve_txt_record;
use crate::utils::dns::resolve_txt_record;
use super::stun_codec_ext::*;
const DEFAULT_UDP_STUN_SERVERS: &[&str] = &[
+2 -4
View File
@@ -12,10 +12,7 @@ use std::{
};
use crate::{
common::{
PeerId, dns::socket_addrs, error::Error, global_ctx::ArcGlobalCtx,
stun::StunInfoCollectorTrait,
},
common::{PeerId, error::Error, global_ctx::ArcGlobalCtx, stun::StunInfoCollectorTrait},
connector::udp_hole_punch::handle_rpc_result,
peers::{
peer_conn::PeerConnId,
@@ -40,6 +37,7 @@ use super::{
udp_hole_punch,
};
use crate::tunnel::{FromUrl, IpScheme, TunnelScheme, matches_scheme};
use crate::utils::dns::socket_addrs;
use anyhow::Context;
use rand::Rng;
use socket2::Protocol;
+2 -2
View File
@@ -3,7 +3,6 @@ use std::{net::SocketAddr, sync::Arc};
use super::{create_connector_by_url, http_connector::TunnelWithInfo};
use crate::{
common::{
dns::{RESOLVER, resolve_txt_record},
error::Error,
global_ctx::ArcGlobalCtx,
log,
@@ -15,8 +14,9 @@ use anyhow::Context;
use dashmap::DashSet;
use hickory_proto::rr::RData;
use hickory_resolver::proto::rr::rdata::SRV;
use rand::{Rng as _, seq::SliceRandom};
use rand::{seq::SliceRandom, Rng as _};
use strum::VariantArray;
use crate::utils::dns::{resolve_txt_record, RESOLVER};
fn weighted_choice<T>(options: &[(T, u64)]) -> Option<&T> {
let total_weight = options.iter().map(|(_, weight)| *weight).sum();
+3 -3
View File
@@ -7,7 +7,7 @@ use dashmap::DashSet;
use tokio::{sync::mpsc, task::JoinSet, time::timeout};
use crate::{
common::{PeerId, dns::socket_addrs, join_joinset_background},
common::{PeerId, join_joinset_background},
peers::peer_conn::PeerConnId,
proto::{
api::instance::{
@@ -20,6 +20,8 @@ use crate::{
utils::weak_upgrade,
};
use super::create_connector_by_url;
use crate::utils::dns::socket_addrs;
use crate::{
common::{
error::Error,
@@ -30,8 +32,6 @@ use crate::{
use_global_var,
};
use super::create_connector_by_url;
type ConnectorMap = Arc<DashSet<url::Url>>;
#[derive(Debug, Clone)]
+1 -1
View File
@@ -1,4 +1,4 @@
use crate::common::dns::get_default_resolver_config;
use crate::utils::dns::get_default_resolver_config;
use crate::dns::utils::addr::{NameServerAddr, NameServerAddrGroup};
use crate::dns::utils::zone_handler::{ArcZoneHandler, ChainedZoneHandler};
use crate::proto;
+2 -4
View File
@@ -2,10 +2,7 @@ use std::{
collections::hash_map::DefaultHasher, hash::Hasher, net::SocketAddr, pin::Pin, sync::Arc,
};
use crate::{
common::{dns::socket_addrs, error::Error},
proto::common::TunnelInfo,
};
use crate::{common::error::Error, proto::common::TunnelInfo};
use async_trait::async_trait;
use derive_more::{From, TryInto};
use futures::{Sink, Stream};
@@ -392,4 +389,5 @@ macro_rules! __matches_protocol__ {
};
}
use crate::utils::dns::socket_addrs;
pub(crate) use __matches_protocol__ as matches_protocol;
+1
View File
@@ -1,4 +1,5 @@
pub mod dirty;
pub mod dns;
pub mod panic;
pub mod string;
pub mod task;