mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-22 06:49:08 +00:00
Bump version 0.2.5
This commit is contained in:
parent
8a67915388
commit
ea5ffff82c
3 changed files with 45 additions and 21 deletions
11
Cargo.toml
11
Cargo.toml
|
@ -1,8 +1,13 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tun2proxy"
|
name = "tun2proxy"
|
||||||
version = "0.2.4"
|
version = "0.2.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
license = "MIT"
|
||||||
|
repository = "https://github.com/blechschmidt/tun2proxy"
|
||||||
|
homepage = "https://github.com/blechschmidt/tun2proxy"
|
||||||
|
authors = ["B. Blechschmidt", "ssrlive"]
|
||||||
|
description = "Tunnel interface to proxy"
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["staticlib", "cdylib", "lib"]
|
crate-type = ["staticlib", "cdylib", "lib"]
|
||||||
|
@ -12,7 +17,7 @@ async-recursion = "1.0"
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
base64 = { version = "0.21" }
|
base64 = { version = "0.21" }
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
clap = { version = "4.4", features = ["derive", "wrap_help", "color"] }
|
clap = { version = "4.5", features = ["derive", "wrap_help", "color"] }
|
||||||
ctrlc2 = { version = "3.5", features = ["tokio", "termination"] }
|
ctrlc2 = { version = "3.5", features = ["tokio", "termination"] }
|
||||||
digest_auth = "0.3"
|
digest_auth = "0.3"
|
||||||
dotenvy = "0.15"
|
dotenvy = "0.15"
|
||||||
|
|
53
README.md
53
README.md
|
@ -1,5 +1,11 @@
|
||||||
# tun2proxy
|
# tun2proxy
|
||||||
A tunnel interface for HTTP and SOCKS proxies on Linux based on [smoltcp](https://github.com/smoltcp-rs/smoltcp).
|
A tunnel interface for HTTP and SOCKS proxies on Linux, Android, macOS, iOS and Windows.
|
||||||
|
|
||||||
|
[](https://crates.io/crates/tun2proxy)
|
||||||
|

|
||||||
|
[](https://docs.rs/tun2proxy)
|
||||||
|
[](https://crates.io/crates/tun2proxy)
|
||||||
|
[](https://github.com/blechschmidt/tun2proxy/blob/master/LICENSE)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- HTTP proxy support (unauthenticated, basic and digest auth)
|
- HTTP proxy support (unauthenticated, basic and digest auth)
|
||||||
|
@ -17,22 +23,37 @@ Clone the repository and `cd` into the project folder. Then run the following:
|
||||||
cargo build --release
|
cargo build --release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Install from binary
|
||||||
|
|
||||||
|
Download the binary from [releases](https://github.com/blechschmidt/tun2proxy/releases) and put it in your `PATH`.
|
||||||
|
|
||||||
|
### Install from source
|
||||||
|
|
||||||
|
If you have [rust](https://rustup.rs/) toolchain installed, this should work:
|
||||||
|
```shell
|
||||||
|
cargo install tun2proxy
|
||||||
|
```
|
||||||
|
> Note: In Windows, you need to copy [wintun](https://www.wintun.net/) DLL to the same directory as the binary.
|
||||||
|
> It's `%USERPROFILE%\.cargo\bin` by default.
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
## Automated Setup
|
## Automated Setup
|
||||||
Using `--setup auto`, you can have tun2proxy configure your system to automatically route all traffic through the
|
Using `--setup`, you can have tun2proxy configure your system to automatically route all traffic through the
|
||||||
specified proxy. This requires running the tool as root and will roughly perform the steps outlined in the section
|
specified proxy. This requires running the tool as root and will roughly perform the steps outlined in the section
|
||||||
describing the manual setup, except that a bind mount is used to overlay the `/etc/resolv.conf` file.
|
describing the manual setup, except that a bind mount is used to overlay the `/etc/resolv.conf` file.
|
||||||
|
|
||||||
You would then run the tool as follows:
|
You would then run the tool as follows:
|
||||||
```bash
|
```bash
|
||||||
sudo ./target/release/tun2proxy --setup auto --proxy "socks5://1.2.3.4:1080"
|
sudo ./target/release/tun2proxy --setup --proxy "socks5://1.2.3.4:1080"
|
||||||
```
|
```
|
||||||
|
|
||||||
Apart from SOCKS5, SOCKS4 and HTTP are supported.
|
Apart from SOCKS5, SOCKS4 and HTTP are supported.
|
||||||
|
|
||||||
Note that if your proxy is a non-global IP address (e.g. because the proxy is provided by some tunneling tool running
|
Note that if your proxy is a non-global IP address (e.g. because the proxy is provided by some tunneling tool running
|
||||||
locally), you will additionally need to provide the public IP address of the server through which the traffic is
|
locally), you will additionally need to provide the public IP address of the server through which the traffic is
|
||||||
actually tunneled. In such a case, the tool will tell you to specify the address through `--bypass-ip <address>` if you
|
actually tunneled. In such a case, the tool will tell you to specify the address through `--bypass <IP>` if you
|
||||||
wish to make use of the automated setup feature.
|
wish to make use of the automated setup feature.
|
||||||
|
|
||||||
## Manual Setup
|
## Manual Setup
|
||||||
|
@ -44,9 +65,9 @@ PROXY_IP=1.2.3.4
|
||||||
PROXY_PORT=1080
|
PROXY_PORT=1080
|
||||||
BYPASS_IP=123.45.67.89
|
BYPASS_IP=123.45.67.89
|
||||||
|
|
||||||
# Create a tunnel interface named tun0 which your user can bind to,
|
# Create a tunnel interface named tun0 which you can bind to,
|
||||||
# so we don't need to run tun2proxy as root.
|
# so we don't need to run tun2proxy as root.
|
||||||
sudo ip tuntap add name tun0 mode tun user $USER
|
sudo ip tuntap add name tun0 mode tun
|
||||||
sudo ip link set tun0 up
|
sudo ip link set tun0 up
|
||||||
|
|
||||||
# To prevent a routing loop, we add a route to the proxy server that behaves
|
# To prevent a routing loop, we add a route to the proxy server that behaves
|
||||||
|
@ -67,14 +88,11 @@ sudo sh -c "echo nameserver 198.18.0.1 > /etc/resolv.conf"
|
||||||
./target/release/tun2proxy --tun tun0 --proxy "$PROXY_TYPE://$PROXY_IP:$PROXY_PORT"
|
./target/release/tun2proxy --tun tun0 --proxy "$PROXY_TYPE://$PROXY_IP:$PROXY_PORT"
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that if you paste these commands into a shell script, which you then run with `sudo`, you might want to replace
|
This tool implements a virtual DNS feature that is used by switch `--dns virtual`. When a DNS packet to port 53 is detected, an IP
|
||||||
`$USER` with `$SUDO_USER`.
|
|
||||||
|
|
||||||
This tool implements a virtual DNS feature that is used by default. When a DNS packet to port 53 is detected, an IP
|
|
||||||
address from `198.18.0.0/15` is chosen and mapped to the query name. Connections destined for an IP address from that
|
address from `198.18.0.0/15` is chosen and mapped to the query name. Connections destined for an IP address from that
|
||||||
range will supply the proxy with the mapped query name instead of the IP address. Since many proxies do not support UDP,
|
range will supply the proxy with the mapped query name instead of the IP address. Since many proxies do not support UDP,
|
||||||
this enables an out-of-the-box experience in most cases, without relying on third-party resolvers or applications.
|
this enables an out-of-the-box experience in most cases, without relying on third-party resolvers or applications.
|
||||||
Depending on your use case, you may want to disable this feature using `--dns none`.
|
Depending on your use case, you may want to disable this feature using `--dns direct`.
|
||||||
In that case, you might need an additional tool like [dnsproxy](https://github.com/AdguardTeam/dnsproxy) that is
|
In that case, you might need an additional tool like [dnsproxy](https://github.com/AdguardTeam/dnsproxy) that is
|
||||||
configured to listen on a local UDP port and communicates with a third-party upstream DNS server via TCP.
|
configured to listen on a local UDP port and communicates with a third-party upstream DNS server via TCP.
|
||||||
|
|
||||||
|
@ -91,15 +109,16 @@ Tunnel interface to proxy.
|
||||||
Usage: tun2proxy [OPTIONS] --proxy <URL>
|
Usage: tun2proxy [OPTIONS] --proxy <URL>
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
-p, --proxy <URL> Proxy URL in the form proto://[username[:password]@]host:port, where proto is one of socks4,
|
||||||
|
socks5, http. For example: socks5://myname:password@127.0.0.1:1080
|
||||||
-t, --tun <name> Name of the tun interface [default: tun0]
|
-t, --tun <name> Name of the tun interface [default: tun0]
|
||||||
--tun-fd <fd> File descriptor of the tun interface
|
--tun-fd <fd> File descriptor of the tun interface
|
||||||
--tun-mtu <mtu> MTU of the tun interface (only with tunnel file descriptor) [default: 1500]
|
|
||||||
-p, --proxy <URL> Proxy URL in the form proto://[username[:password]@]host:port
|
|
||||||
-d, --dns <strategy> DNS handling strategy [default: virtual] [possible values: virtual, over-tcp, direct]
|
|
||||||
--dns-addr <IP> DNS resolver address [default: 8.8.8.8]
|
|
||||||
-6, --ipv6-enabled IPv6 enabled
|
-6, --ipv6-enabled IPv6 enabled
|
||||||
-s, --setup <method> Routing and system setup [default: none] [possible values: none, auto]
|
-s, --setup Routing and system setup, which decides whether to setup the routing and system configuration,
|
||||||
-b, --bypass <IP|CIDR> IPs and CIDRs used in routing setup which should bypass the tunnel
|
this option requires root privileges
|
||||||
|
-d, --dns <strategy> DNS handling strategy [default: direct] [possible values: virtual, over-tcp, direct]
|
||||||
|
--dns-addr <IP> DNS resolver address [default: 8.8.8.8]
|
||||||
|
-b, --bypass <IP> IPs used in routing setup which should bypass the tunnel
|
||||||
-v, --verbosity <level> Verbosity level [default: info] [possible values: off, error, warn, info, debug, trace]
|
-v, --verbosity <level> Verbosity level [default: info] [possible values: off, error, warn, info, debug, trace]
|
||||||
-h, --help Print help
|
-h, --help Print help
|
||||||
-V, --version Print version
|
-V, --version Print version
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
|
||||||
use tproxy_config::TUN_NAME;
|
use tproxy_config::TUN_NAME;
|
||||||
|
|
||||||
#[derive(Debug, Clone, clap::Parser)]
|
#[derive(Debug, Clone, clap::Parser)]
|
||||||
#[command(author, version, about = "tun2proxy application.", long_about = None)]
|
#[command(author, version, about = "Tunnel interface to proxy.", long_about = None)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
/// Proxy URL in the form proto://[username[:password]@]host:port,
|
/// Proxy URL in the form proto://[username[:password]@]host:port,
|
||||||
/// where proto is one of socks4, socks5, http. For example:
|
/// where proto is one of socks4, socks5, http. For example:
|
||||||
|
|
Loading…
Add table
Reference in a new issue