mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-15 14:17:24 +08:00
fix incorrect config check (#1086)
This commit is contained in:
@@ -168,13 +168,23 @@ impl DNSTunnelConnector {
|
||||
impl super::TunnelConnector for DNSTunnelConnector {
|
||||
async fn connect(&mut self) -> Result<Box<dyn Tunnel>, TunnelError> {
|
||||
let mut conn = if self.addr.scheme() == "txt" {
|
||||
self.handle_txt_record(self.addr.host_str().as_ref().unwrap())
|
||||
.await
|
||||
.with_context(|| "get txt record url failed")?
|
||||
self.handle_txt_record(
|
||||
self.addr
|
||||
.host_str()
|
||||
.as_ref()
|
||||
.ok_or(anyhow::anyhow!("host should not be empty in txt url"))?,
|
||||
)
|
||||
.await
|
||||
.with_context(|| "get txt record url failed")?
|
||||
} else if self.addr.scheme() == "srv" {
|
||||
self.handle_srv_record(self.addr.host_str().as_ref().unwrap())
|
||||
.await
|
||||
.with_context(|| "get srv record url failed")?
|
||||
self.handle_srv_record(
|
||||
self.addr
|
||||
.host_str()
|
||||
.as_ref()
|
||||
.ok_or(anyhow::anyhow!("host should not be empty in srv url"))?,
|
||||
)
|
||||
.await
|
||||
.with_context(|| "get srv record url failed")?
|
||||
} else {
|
||||
return Err(anyhow::anyhow!(
|
||||
"unsupported dns scheme: {}, expecting txt or srv",
|
||||
|
||||
@@ -147,6 +147,12 @@ pub async fn create_connector_by_url(
|
||||
Box::new(connector)
|
||||
}
|
||||
"txt" | "srv" => {
|
||||
if url.host_str().is_none() {
|
||||
return Err(Error::InvalidUrl(format!(
|
||||
"host should not be empty in txt or srv url: {}",
|
||||
url
|
||||
)));
|
||||
}
|
||||
let connector = dns_connector::DNSTunnelConnector::new(url, global_ctx.clone());
|
||||
Box::new(connector)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user