Allow host communication (#7)

* Allow communication with host

* Clarify missing root privileges message
This commit is contained in:
Nikolay Edigaryev 2022-08-12 17:50:10 +03:00 committed by GitHub
parent c231fd5e68
commit ce129ba5cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -68,6 +68,11 @@ impl Proxy {
}
}
// Allow communication with host
if ipv4_pkt.dst_addr() == self.host.gateway_ip {
return Some(());
}
if ipv4_pkt.protocol() == IpProtocol::Udp {
let udp_pkt = UdpPacket::new_checked(ipv4_pkt.payload()).ok()?;
@ -77,11 +82,8 @@ impl Proxy {
return Some(());
}
// Allow DHCP communication with the bootpd(8) on host
let allowed_dhcp_target =
ipv4_pkt.dst_addr().is_broadcast() || ipv4_pkt.dst_addr() == self.host.gateway_ip;
if udp_pkt.is_dhcp_request() && allowed_dhcp_target {
// Allow DHCP communication with the bootpd(8) on host via broadcast address
if udp_pkt.is_dhcp_request() && ipv4_pkt.dst_addr().is_broadcast() {
return Some(());
}
}

View File

@ -92,7 +92,7 @@ fn try_main() -> Result<(), Box<dyn std::error::Error>> {
.exec();
}
return Err("root privileges are required to run".into());
return Err("root privileges are required to run and passwordless sudo was not available".into());
}
// Set bootpd(8) min/max lease time while still having the root privileges