Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Jan 1, 2025
1 parent 9b7cf39 commit 84d1b2d
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 164 deletions.
5 changes: 4 additions & 1 deletion src/network/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::fmt;
use anyhow::Result;

use std::time::Duration;
use tokio::sync::{mpsc, mpsc::{Permit, Receiver, Sender, UnboundedReceiver}};
use tokio::sync::{
mpsc,
mpsc::{Permit, Receiver, Sender, UnboundedReceiver},
};
use tokio::task::JoinHandle;

use crate::messages::{NetworkCommand, NetworkEvent, TransportCommand, TransportEvent};
Expand Down
12 changes: 6 additions & 6 deletions src/network/tests.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
use std::net::{Ipv6Addr, SocketAddr};

use super::task::NetworkTask;
use crate::messages::{
NetworkCommand, NetworkEvent, SmolPacket, TransportCommand, TransportEvent, TunnelInfo,
};
use crate::shutdown;
use anyhow::{anyhow, Result};
use internet_packet::InternetPacket;
use smoltcp::{phy::ChecksumCapabilities, wire::*};
use tokio::sync::watch;
use tokio::{
sync::{
mpsc::{channel, unbounded_channel, Receiver, Sender, UnboundedSender},
oneshot,
},
task::JoinHandle,
};
use tokio::sync::watch;
use crate::messages::{
NetworkCommand, NetworkEvent, SmolPacket, TransportCommand, TransportEvent, TunnelInfo,
};
use crate::shutdown;
use super::task::NetworkTask;

struct MockNetwork {
wg_to_smol_tx: Sender<NetworkEvent>,
Expand Down
2 changes: 1 addition & 1 deletion src/network/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ mod tests {
use super::*;
use crate::packet_sources::udp::UdpConf;
use crate::packet_sources::{PacketSourceConf, PacketSourceTask};
use crate::shutdown;
use std::net::{IpAddr, Ipv4Addr};
use tokio::net::UdpSocket;
use crate::shutdown;

#[test]
fn test_connection_state_recv_recv_read_read() {
Expand Down
17 changes: 9 additions & 8 deletions src/packet_sources/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
use crate::intercept_conf::InterceptConf;
use crate::messages::{TransportCommand, TransportEvent};
use crate::packet_sources::{forward_packets, PacketSourceConf, PacketSourceTask};
use crate::shutdown;
use tempfile::{tempdir, TempDir};
use tokio::net::UnixDatagram;
use tokio::process::Command;
use tokio::time::timeout;
use crate::shutdown;

async fn start_redirector(
executable: &Path,
Expand Down Expand Up @@ -62,7 +62,7 @@ async fn start_redirector(
if shutdown2.is_shutting_down() {
// We don't want to log during exit, https://github.com/vorner/pyo3-log/issues/30
eprintln!("{}", line);
continue
continue;
}

let new_level = line
Expand Down Expand Up @@ -104,11 +104,11 @@ async fn start_redirector(
Duration::from_secs(5),
BufReader::new(stdout).lines().next_line(),
)
.await
.context("failed to establish connection to Linux redirector")?
.context("failed to read redirector stdout")?
.map(PathBuf::from)
.context("redirector did not produce stdout")
.await
.context("failed to establish connection to Linux redirector")?
.context("failed to read redirector stdout")?
.map(PathBuf::from)
.context("redirector did not produce stdout")
}

pub struct LinuxConf {
Expand Down Expand Up @@ -169,7 +169,8 @@ impl PacketSourceConf for LinuxConf {
let datagram_dir = tempdir().context("failed to create temp dir")?;

let channel = UnixDatagram::bind(datagram_dir.path().join("mitmproxy"))?;
let dst = start_redirector(&self.executable_path, datagram_dir.path(), shutdown.clone()).await?;
let dst =
start_redirector(&self.executable_path, datagram_dir.path(), shutdown.clone()).await?;

channel
.connect(&dst)
Expand Down
2 changes: 1 addition & 1 deletion src/packet_sources/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::network::udp::ConnectionState;
use tokio::process::Command;
use tokio::sync::mpsc::Sender;
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
use tokio::sync::{watch, oneshot};
use tokio::sync::{oneshot, watch};

Check warning on line 28 in src/packet_sources/macos.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest, 1.80, --exclude mitmproxy-linux-ebpf)

unused import: `watch`
use tokio::task::JoinSet;
use tokio::time::timeout;
use tokio_util::codec::{Framed, LengthDelimitedCodec};
Expand Down
2 changes: 1 addition & 1 deletion src/packet_sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use prost::bytes::{Bytes, BytesMut};
use prost::Message;
use std::future::Future;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::sync::mpsc::{Sender, UnboundedReceiver};
use tokio::sync::mpsc;
use tokio::sync::mpsc::{Sender, UnboundedReceiver};

#[cfg(target_os = "linux")]
pub mod linux;
Expand Down
4 changes: 2 additions & 2 deletions src/packet_sources/tun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use crate::messages::{
};
use crate::network::{add_network_layer, MAX_PACKET_SIZE};
use crate::packet_sources::{PacketSourceConf, PacketSourceTask};
use crate::shutdown;
use anyhow::{Context, Result};
use std::cmp::max;
use std::fs;
use tokio::sync::mpsc::{Permit, Receiver, UnboundedReceiver};
use tokio::sync::mpsc::Sender;
use tokio::sync::mpsc::{Permit, Receiver, UnboundedReceiver};
use tun::AbstractDevice;
use crate::shutdown;

pub struct TunConf {
pub tun_name: Option<String>,
Expand Down
6 changes: 3 additions & 3 deletions src/packet_sources/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use std::str::FromStr;

use anyhow::{Context, Result};

use socket2::{Domain, Protocol, Socket, Type};
use tokio::sync::mpsc::{Permit, UnboundedReceiver, Sender};
use tokio::net::UdpSocket;
use crate::messages::{TransportCommand, TransportEvent, TunnelInfo};
use crate::network::udp::{UdpHandler, UdpPacket};
use crate::network::MAX_PACKET_SIZE;
use crate::packet_sources::{PacketSourceConf, PacketSourceTask};
use crate::shutdown;
use socket2::{Domain, Protocol, Socket, Type};
use tokio::net::UdpSocket;
use tokio::sync::mpsc::{Permit, Sender, UnboundedReceiver};

pub fn remote_host_closed_conn<T>(_res: &Result<T, std::io::Error>) -> bool {
#[cfg(windows)]
Expand Down
Loading

0 comments on commit 84d1b2d

Please sign in to comment.