diff --git a/src/http.rs b/src/http.rs index 9ed5679..ca31b50 100644 --- a/src/http.rs +++ b/src/http.rs @@ -4,6 +4,7 @@ use crate::tun2proxy::{ OutgoingDataEvent, OutgoingDirection, TcpProxy, }; use base64::Engine; +use smoltcp::wire::IpProtocol; use std::collections::VecDeque; use std::net::SocketAddr; use std::rc::Rc; @@ -170,7 +171,7 @@ pub struct HttpManager { impl ConnectionManager for HttpManager { fn handles_connection(&self, connection: &Connection) -> bool { - connection.proto == smoltcp::wire::IpProtocol::Tcp.into() + connection.proto == IpProtocol::Tcp.into() } fn new_connection( @@ -178,7 +179,7 @@ impl ConnectionManager for HttpManager { connection: &Connection, manager: Rc, ) -> Option> { - if connection.proto != smoltcp::wire::IpProtocol::Tcp.into() { + if connection.proto != IpProtocol::Tcp.into() { return None; } Some(Box::new(HttpConnection::new(connection, manager))) diff --git a/src/socks5.rs b/src/socks5.rs index 640b006..cb109fd 100644 --- a/src/socks5.rs +++ b/src/socks5.rs @@ -3,6 +3,7 @@ use crate::tun2proxy::{ Connection, ConnectionManager, Credentials, DestinationHost, IncomingDataEvent, IncomingDirection, OutgoingDataEvent, OutgoingDirection, TcpProxy, }; +use smoltcp::wire::IpProtocol; use std::collections::VecDeque; use std::net::{IpAddr, SocketAddr}; use std::rc::Rc; @@ -297,7 +298,7 @@ pub struct Socks5Manager { impl ConnectionManager for Socks5Manager { fn handles_connection(&self, connection: &Connection) -> bool { - connection.proto == smoltcp::wire::IpProtocol::Tcp.into() + connection.proto == IpProtocol::Tcp.into() } fn new_connection( @@ -305,7 +306,7 @@ impl ConnectionManager for Socks5Manager { connection: &Connection, manager: Rc, ) -> Option> { - if connection.proto != smoltcp::wire::IpProtocol::Tcp.into() { + if connection.proto != IpProtocol::Tcp.into() { return None; } Some(Box::new(SocksConnection::new(connection, manager))) diff --git a/src/tun2proxy.rs b/src/tun2proxy.rs index 48c85de..bd0a985 100644 --- a/src/tun2proxy.rs +++ b/src/tun2proxy.rs @@ -10,7 +10,8 @@ use smoltcp::phy::{Device, Medium, RxToken, TunTapInterface, TxToken}; use smoltcp::socket::tcp; use smoltcp::time::Instant; use smoltcp::wire::{ - IpAddress, IpCidr, Ipv4Address, Ipv4Packet, Ipv6Address, Ipv6Packet, TcpPacket, UdpPacket, + IpAddress, IpCidr, IpProtocol, Ipv4Address, Ipv4Packet, Ipv6Address, Ipv6Packet, TcpPacket, + UdpPacket, }; use std::collections::HashMap; use std::convert::From; @@ -115,7 +116,7 @@ fn get_transport_info( transport_offset: usize, packet: &[u8], ) -> Option<((u16, u16), bool, usize, usize)> { - if proto == smoltcp::wire::IpProtocol::Udp.into() { + if proto == IpProtocol::Udp.into() { match UdpPacket::new_checked(packet) { Ok(result) => Some(( (result.src_port(), result.dst_port()), @@ -125,7 +126,7 @@ fn get_transport_info( )), Err(_) => None, } - } else if proto == smoltcp::wire::IpProtocol::Tcp.into() { + } else if proto == IpProtocol::Tcp.into() { match TcpPacket::new_checked(packet) { Ok(result) => Some(( (result.src_port(), result.dst_port()), @@ -380,7 +381,7 @@ impl<'a> TunToProxy<'a> { if let Some((connection, first_packet, _payload_offset, _payload_size)) = connection_tuple(frame) { - if connection.proto == smoltcp::wire::IpProtocol::Tcp.into() { + if connection.proto == IpProtocol::Tcp.into() { let cm = self.get_connection_manager(&connection); if cm.is_none() { return; @@ -447,7 +448,7 @@ impl<'a> TunToProxy<'a> { // The connection handler builds up the connection or encapsulates the data. // Therefore, we now expect it to write data to the server. self.write_to_server(&connection); - } else if connection.proto == smoltcp::wire::IpProtocol::Udp.into() { + } else if connection.proto == IpProtocol::Udp.into() { // UDP is not yet supported /*if _payload_offset > frame.len() || _payload_offset + _payload_offset > frame.len() { return;