mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 16:41:01 +00:00
Make manager references immutable
This commit is contained in:
parent
072701c379
commit
c1aaec6159
3 changed files with 6 additions and 6 deletions
|
@ -163,14 +163,14 @@ impl ConnectionManager for HttpManager {
|
||||||
connection.proto == smoltcp::wire::IpProtocol::Tcp.into()
|
connection.proto == smoltcp::wire::IpProtocol::Tcp.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_connection(&mut self, connection: &Connection) -> Option<std::boxed::Box<dyn TcpProxy>> {
|
fn new_connection(&self, connection: &Connection) -> Option<std::boxed::Box<dyn TcpProxy>> {
|
||||||
if connection.proto != smoltcp::wire::IpProtocol::Tcp.into() {
|
if connection.proto != smoltcp::wire::IpProtocol::Tcp.into() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(std::boxed::Box::new(HttpConnection::new(connection)))
|
Some(std::boxed::Box::new(HttpConnection::new(connection)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close_connection(&mut self, _: &Connection) {}
|
fn close_connection(&self, _: &Connection) {}
|
||||||
|
|
||||||
fn get_server(&self) -> SocketAddr {
|
fn get_server(&self) -> SocketAddr {
|
||||||
self.server
|
self.server
|
||||||
|
|
|
@ -233,14 +233,14 @@ impl ConnectionManager for Socks5Manager {
|
||||||
connection.proto == smoltcp::wire::IpProtocol::Tcp.into()
|
connection.proto == smoltcp::wire::IpProtocol::Tcp.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_connection(&mut self, connection: &Connection) -> Option<std::boxed::Box<dyn TcpProxy>> {
|
fn new_connection(&self, connection: &Connection) -> Option<std::boxed::Box<dyn TcpProxy>> {
|
||||||
if connection.proto != smoltcp::wire::IpProtocol::Tcp.into() {
|
if connection.proto != smoltcp::wire::IpProtocol::Tcp.into() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(std::boxed::Box::new(SocksConnection::new(connection)))
|
Some(std::boxed::Box::new(SocksConnection::new(connection)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close_connection(&mut self, _: &Connection) {}
|
fn close_connection(&self, _: &Connection) {}
|
||||||
|
|
||||||
fn get_server(&self) -> SocketAddr {
|
fn get_server(&self) -> SocketAddr {
|
||||||
self.server
|
self.server
|
||||||
|
|
|
@ -171,8 +171,8 @@ pub(crate) trait TcpProxy {
|
||||||
|
|
||||||
pub(crate) trait ConnectionManager {
|
pub(crate) trait ConnectionManager {
|
||||||
fn handles_connection(&self, connection: &Connection) -> bool;
|
fn handles_connection(&self, connection: &Connection) -> bool;
|
||||||
fn new_connection(&mut self, connection: &Connection) -> Option<std::boxed::Box<dyn TcpProxy>>;
|
fn new_connection(&self, connection: &Connection) -> Option<std::boxed::Box<dyn TcpProxy>>;
|
||||||
fn close_connection(&mut self, connection: &Connection);
|
fn close_connection(&self, connection: &Connection);
|
||||||
fn get_server(&self) -> SocketAddr;
|
fn get_server(&self) -> SocketAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue