Make manager references immutable

This commit is contained in:
B. Blechschmidt 2023-03-21 01:08:44 +01:00
parent 072701c379
commit c1aaec6159
3 changed files with 6 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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;
} }