Skip to content

Commit

Permalink
refactor: remove unnecessary param
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemeowx2 committed Feb 7, 2022
1 parent c8898d4 commit 24723c3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion protocol/raw/src/forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Forward {
async fn serve_udp(&self, raw: RawSocket) -> Result<()> {
let source = source::Source::new(raw, self.ip_cidr);

forward_udp::forward_udp(source, self.net.clone()).await?;
forward_udp::forward_udp(source, self.net.clone(), None).await?;

Ok(())
}
Expand Down
7 changes: 5 additions & 2 deletions protocol/raw/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ pub struct GatewayDevice<I> {
layer: Layer,
}

impl<I> GatewayDevice<I> {
impl<I> GatewayDevice<I>
where
I: AsyncDevice,
{
pub fn new(
inner: I,
ethernet_addr: EthernetAddress,
lru_size: usize,
ip_cidr: IpCidr,
override_v4: SocketAddrV4,
layer: Layer,
) -> GatewayDevice<I> {
let layer = inner.capabilities().medium.into();
GatewayDevice {
inner,
ethernet_addr,
Expand Down
4 changes: 1 addition & 3 deletions protocol/raw/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use rd_interface::{
};
use tokio::{sync::Mutex, task::JoinHandle};
use tokio_smoltcp::{
device::AsyncDevice,
smoltcp::wire::{IpAddress, IpCidr},
BufferSize, Net as SmoltcpNet, NetConfig,
};
Expand Down Expand Up @@ -63,8 +62,7 @@ impl RawNet {
let mut forward_handle = None;

let smoltcp_net = if config.forward {
let layer = device.capabilities().medium.into();
let device = GatewayDevice::new(device, ethernet_addr, 100, ip_cidr, ip_addr, layer);
let device = GatewayDevice::new(device, ethernet_addr, 100, ip_cidr, ip_addr);
let map = device.get_map();
let smoltcp_net = Arc::new(SmoltcpNet::new(device, net_config));

Expand Down
1 change: 1 addition & 0 deletions protocol/ss/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl SSServer {
udp_listener,
),
self.net.clone(),
None,
)
.await?;

Expand Down

0 comments on commit 24723c3

Please sign in to comment.