support exit node (#121)

support exit node, proxy all traffic via one of node
NOTE: this patch has not implemented automatically route management.
This commit is contained in:
Sijie.Sun
2024-05-18 20:32:42 +08:00
committed by GitHub
parent 6efbb5cb3d
commit f64f58e2ae
8 changed files with 88 additions and 8 deletions

View File

@@ -248,6 +248,7 @@ impl IcmpProxy {
async fn try_handle_peer_packet(&self, packet: &ZCPacket) -> Option<()> {
let _ = self.global_ctx.get_ipv4()?;
let hdr = packet.peer_manager_header().unwrap();
let is_exit_node = hdr.is_exit_node();
if hdr.packet_type != PacketType::Data as u8 {
return None;
@@ -260,7 +261,7 @@ impl IcmpProxy {
return None;
}
if !self.cidr_set.contains_v4(ipv4.get_destination()) {
if !self.cidr_set.contains_v4(ipv4.get_destination()) && !is_exit_node {
return None;
}

View File

@@ -358,6 +358,7 @@ impl TcpProxy {
async fn try_handle_peer_packet(&self, packet: &mut ZCPacket) -> Option<()> {
let ipv4_addr = self.global_ctx.get_ipv4()?;
let hdr = packet.peer_manager_header().unwrap();
let is_exit_node = hdr.is_exit_node();
if hdr.packet_type != PacketType::Data as u8 {
return None;
@@ -370,7 +371,7 @@ impl TcpProxy {
return None;
}
if !self.cidr_set.contains_v4(ipv4.get_destination()) {
if !self.cidr_set.contains_v4(ipv4.get_destination()) && !is_exit_node {
return None;
}

View File

@@ -233,6 +233,7 @@ impl UdpProxy {
let _ = self.global_ctx.get_ipv4()?;
let hdr = packet.peer_manager_header().unwrap();
let is_exit_node = hdr.is_exit_node();
if hdr.packet_type != PacketType::Data as u8 {
return None;
};
@@ -242,7 +243,7 @@ impl UdpProxy {
return None;
}
if !self.cidr_set.contains_v4(ipv4.get_destination()) {
if !self.cidr_set.contains_v4(ipv4.get_destination()) && !is_exit_node {
return None;
}