Browse Source

Make manager references immutable

pull/10/head
B. Blechschmidt 3 years ago
parent
commit
c1aaec6159
  1. 4
      src/http.rs
  2. 4
      src/socks5.rs
  3. 4
      src/tun2proxy.rs

4
src/http.rs

@ -163,14 +163,14 @@ impl ConnectionManager for HttpManager {
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() {
return None;
}
Some(std::boxed::Box::new(HttpConnection::new(connection)))
}
fn close_connection(&mut self, _: &Connection) {}
fn close_connection(&self, _: &Connection) {}
fn get_server(&self) -> SocketAddr {
self.server

4
src/socks5.rs

@ -233,14 +233,14 @@ impl ConnectionManager for Socks5Manager {
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() {
return None;
}
Some(std::boxed::Box::new(SocksConnection::new(connection)))
}
fn close_connection(&mut self, _: &Connection) {}
fn close_connection(&self, _: &Connection) {}
fn get_server(&self) -> SocketAddr {
self.server

4
src/tun2proxy.rs

@ -171,8 +171,8 @@ pub(crate) trait TcpProxy {
pub(crate) trait ConnectionManager {
fn handles_connection(&self, connection: &Connection) -> bool;
fn new_connection(&mut self, connection: &Connection) -> Option<std::boxed::Box<dyn TcpProxy>>;
fn close_connection(&mut self, connection: &Connection);
fn new_connection(&self, connection: &Connection) -> Option<std::boxed::Box<dyn TcpProxy>>;
fn close_connection(&self, connection: &Connection);
fn get_server(&self) -> SocketAddr;
}

Loading…
Cancel
Save