Skip to content

Commit

Permalink
rename: osproxy -> local redirector (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils authored Nov 4, 2023
1 parent 3438058 commit 172b98a
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
"Fabio Valentini <[email protected]>",
"Maximilian Hils <[email protected]>",
]
version = "0.3.11"
version = "0.4.0"
publish = false
repository = "https://github.com/mitmproxy/mitmproxy-rs"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion mitmproxy-macos/redirector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

When starting transparent interception on macOS, the following things happen:

1. mitmproxy-rs' `start_os_proxy` copies the redirector application into `/Applications`,
1. mitmproxy-rs' `start_local_redirector` copies the redirector application into `/Applications`,
which is a prerequisite for installing system extensions.
2. mitmproxy-rs opens a unix socket listener.
2. mitmproxy-rs starts the `macos-redirector` app, passing the unix socket as an argument.
Expand Down
6 changes: 3 additions & 3 deletions mitmproxy-rs/mitmproxy_rs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def pubkey(private_key: str) -> str: ...

# Windows

async def start_os_proxy(
async def start_local_redirector(
handle_connection: Callable[[TcpStream], Awaitable[None]],
receive_datagram: Callable[[DatagramTransport, bytes, tuple[str, int], tuple[str, int]], None],
) -> OsProxy: ...
) -> LocalRedirector: ...

@final
class OsProxy:
class LocalRedirector:
@staticmethod
def describe_spec(spec: str) -> None: ...
def set_intercept(self, spec: str) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions mitmproxy-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ pub fn mitmproxy_rs(py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(util::add_cert, m)?)?;
m.add_function(wrap_pyfunction!(util::remove_cert, m)?)?;

m.add_function(wrap_pyfunction!(server::start_os_proxy, m)?)?;
m.add_class::<server::OsProxy>()?;
m.add_function(wrap_pyfunction!(server::start_local_redirector, m)?)?;
m.add_class::<server::LocalRedirector>()?;

m.add_function(wrap_pyfunction!(process_info::active_executables, m)?)?;
m.add_class::<process_info::Process>()?;
Expand Down
10 changes: 5 additions & 5 deletions mitmproxy-rs/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ impl Drop for Server {

#[pyclass(module = "mitmproxy_rs")]
#[derive(Debug)]
pub struct OsProxy {
pub struct LocalRedirector {
server: Server,
conf_tx: mpsc::UnboundedSender<InterceptConf>,
}

#[pymethods]
impl OsProxy {
impl LocalRedirector {
/// Return a textual description of the given spec,
/// or raise a ValueError if the spec is invalid.
#[staticmethod]
Expand Down Expand Up @@ -266,7 +266,7 @@ pub fn start_wireguard_server(
/// *Availability: Windows*
#[pyfunction]
#[allow(unused_variables)]
pub fn start_os_proxy(
pub fn start_local_redirector(
py: Python<'_>,
handle_connection: PyObject,
receive_datagram: PyObject,
Expand All @@ -284,7 +284,7 @@ pub fn start_os_proxy(
pyo3_asyncio::tokio::future_into_py(py, async move {
let (server, conf_tx) = Server::init(conf, handle_connection, receive_datagram).await?;

Ok(OsProxy { server, conf_tx })
Ok(LocalRedirector { server, conf_tx })
})
}
#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -312,7 +312,7 @@ pub fn start_os_proxy(
let conf = MacosConf;
pyo3_asyncio::tokio::future_into_py(py, async move {
let (server, conf_tx) = Server::init(conf, handle_connection, receive_datagram).await?;
Ok(OsProxy { server, conf_tx })
Ok(LocalRedirector { server, conf_tx })
})
}
#[cfg(not(any(windows, target_os = "macos")))]
Expand Down
2 changes: 1 addition & 1 deletion mitmproxy-rs/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub(crate) fn get_tunnel_info(
"original_dst" => return Ok(socketaddr_to_py(py, *dst_addr)),
_ => (),
},
TunnelInfo::OsProxy {
TunnelInfo::LocalRedirector {
pid,
process_name,
remote_endpoint,
Expand Down
2 changes: 1 addition & 1 deletion mitmproxy-windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ This package contains the following precompiled binaries for Windows:
## Redirector Development Setup

1. Run `pip install -e .` to install `mitmproxy_windows` as editable.
2. Run something along the lines of `mitmdump --mode osproxy:curl`.
2. Run something along the lines of `mitmdump --mode local:curl`.
You should see a `Development mode: Compiling windows-redirector.exe...` message.
2 changes: 1 addition & 1 deletion src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum TunnelInfo {
src_addr: SocketAddr,
dst_addr: SocketAddr,
},
OsProxy {
LocalRedirector {
pid: u32,
process_name: Option<String>,
/// macOS TCP connections may not have a valid sockname, but
Expand Down
4 changes: 2 additions & 2 deletions src/packet_sources/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl ConnectionTask {
let Some(tun) = flow.tunnel_info else {
bail!("no tunnel info")
};
TunnelInfo::OsProxy {
TunnelInfo::LocalRedirector {
pid: tun.pid,
process_name: tun.process_name,
remote_endpoint: None,
Expand Down Expand Up @@ -374,7 +374,7 @@ impl ConnectionTask {
connection_id: self.id,
src_addr,
dst_addr,
tunnel_info: TunnelInfo::OsProxy {
tunnel_info: TunnelInfo::LocalRedirector {
pid: flow.tunnel_info.as_ref().map(|t| t.pid).unwrap_or(0),
process_name: flow.tunnel_info.and_then(|t| t.process_name),
remote_endpoint,
Expand Down
2 changes: 1 addition & 1 deletion src/packet_sources/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl PacketSourceTask for WindowsTask {

let event = NetworkEvent::ReceivePacket {
packet,
tunnel_info: TunnelInfo::OsProxy {
tunnel_info: TunnelInfo::LocalRedirector {
pid,
process_name,
remote_endpoint: None,
Expand Down

0 comments on commit 172b98a

Please sign in to comment.