Skip to content

Commit

Permalink
tbd
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigbug committed Sep 2, 2023
1 parent 02232ea commit 13a4dbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions clash_lib/src/app/dns/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use async_trait::async_trait;
use trust_dns_proto::xfer::DnsResponse;

use std::fmt::Debug;

Expand Down Expand Up @@ -82,6 +83,12 @@ pub trait ClashResolver: Sync + Send {
async fn reverse_lookup(&self, ip: std::net::IpAddr) -> Option<String>;
async fn is_fake_ip(&self, ip: std::net::IpAddr) -> bool;
async fn fake_ip_exists(&self, ip: std::net::IpAddr) -> bool;
async fn lookup_fake_ip(&self, host: &str) -> Option<std::net::IpAddr> {
todo!();
}
async fn generate_fake_ip_packet(&self, data: Vec<u8>) -> anyhow::Result<DnsResponse> {
todo!();
}

fn ipv6(&self) -> bool;
fn set_ipv6(&self, enable: bool);
Expand Down
11 changes: 9 additions & 2 deletions clash_lib/src/proxy/tun/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,15 @@ async fn handle_inbound_datagram(
while let Ok((data, src_addr, dst_addr)) = lr.recv_from().await {
if dst_addr.port() == 53 {
match resolver.generate_fake_ip_packet(data).await {
Ok(pkt) => {
if let Err(e) = l_tx.send(pkt).await {
Ok(resp) => {
if let Err(e) = l_tx
.send(UdpPacket::new(
data,
SocksAddr::any_ipv4(),
SocksAddr::any_ipv4(),
))
.await
{
warn!("failed to send udp packet to proxy: {}", e);
}
continue;
Expand Down

0 comments on commit 13a4dbf

Please sign in to comment.