Skip to content

Commit

Permalink
Merge branch '0.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
tickbh committed Jan 17, 2024
2 parents 602882c + 60901ca commit 0cc9c3b
Show file tree
Hide file tree
Showing 31 changed files with 528 additions and 296 deletions.
31 changes: 19 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
[package]
name = "wmproxy"
version = "0.2.3"
version = "0.2.4"
edition = "2021"
authors = [ "tickbh <[email protected]>" ]
authors = ["tickbh <[email protected]>"]
description = " http https proxy by rust"
repository = "https://github.com/tickbh/wmproxy"
license = "Apache-2.0"
keywords = ["http2", "socks5", "websocket", "nginx","proxy"]
keywords = ["http2", "socks5", "websocket", "nginx", "proxy"]

[dependencies]

tokio = { version = "1.32.0", features = ["full", "tracing"] }
commander = "0.1.3"
forever-rs = { version = "0.1.0" }
log = "0.4.19"
bitflags="2.4"
bitflags = "2.4"

tokio-util = "0.7"
rustls = { version = "0.21.7", default-features = false }
webpki-roots = "0.25"
rustls-pemfile = "1.0.3"
webpki = { version = "0.22", features = ["alloc", "std"] }
tokio-rustls="0.24"
tokio-rustls = "0.24"
futures-core = { version = "0.3", default-features = false }
futures = "0.3.28"

env_logger = "0.10.0"
serde = { version = "1.0", features = ["derive"] }
serde_with="3.4.0"
serde_with = "3.4.0"
serde_yaml = "0.9"
serde_json = "1.0.107"
toml = "0.8.2"
lazy_static = "1.4.0"
rand = "0.8.5"
socket2 = "0.5.5"

log4rs="1.2.0"
log4rs = "1.2.0"

chrono = "0.4.31"

Expand All @@ -48,12 +47,20 @@ async-std = "1.12.0"

base64 = "0.21.4"
async-recursion = "1.0.5"

webparse = { version = "0.2.3"}
# wenmeng={version="0.2.3"}
wenmeng={git="https://github.com/tickbh/wenmeng.git"}
bpaf = { version = "0.9.8", features = [
"derive",
"extradocs",
"batteries",
"autocomplete",
] }
webparse = { version = "0.2.4" }
wenmeng = { version = "0.2.4" }
# wenmeng={git="https://github.com/tickbh/wenmeng.git"}
# [dependencies.webparse]
# path = "../webparse"

[features]
bright-color = ["bpaf/bright-color"]
dull-color = ["bpaf/dull-color"]
# [dependencies.wenmeng]
# path = "../wenmeng"
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,33 @@ cargo install --path .

```docker
docker pull dreamwhat/wmproxy
docker run -p 82:82 -p 8090:8090 -p 127.0.0.1:8837:8837 --name proxy_bash dreamwhat/wmproxy /bin/./wmproxy -b -b 0.0.0.0:8090
docker run -p 82:82 -p 8090:8090 -p 127.0.0.1:8837:8837 --name proxy_bash dreamwhat/wmproxy /bin/./wmproxy proxy -b 0.0.0.0:8090
```

### 使用
默认端口为8090端口,默认监听地址为127.0.0.1
```bash
# 直接通用默认参数
wmproxy
wmproxy proxy

# 设置账号密码
wmproxy -b 0.0.0.0:8090 --user wmproxy --pass wmproxy
wmproxy proxy -b 0.0.0.0:8090 --user wmproxy --pass wmproxy

# 其它指令
wmproxy --help

#配置文件版启动
wmproxy -c config/client.toml
wmproxy config -c config/client.toml
```

##### 启动二级代理
1. 在本地启动代理
```bash
wmproxy -b 127.0.0.1 -p 8090 -S 127.0.0.1:8091 --ts
wmproxy proxy -b 127.0.0.1:8090 -S 127.0.0.1:8091 --ts
```
或者
```bash
wmproxy -c config/client.toml
wmproxy config -c config/client.toml
```
配置文件如下:
```toml
Expand Down Expand Up @@ -88,11 +88,11 @@ domain = ""

2. 在远程启动代理
```bash
wmproxy --user proxy --pass proxy -b 0.0.0.0:8091 --tc
wmproxy proxy --user proxy --pass proxy -b 0.0.0.0:8091 --tc
```
或者
```bash
wmproxy -c config/server.toml
wmproxy config -c config/server.toml
```
配置文件如下:
```toml
Expand Down
2 changes: 0 additions & 2 deletions config/server.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#绑定的ip地址
bind_addr = "0.0.0.0:8091"

#代理支持的功能,1为http,2为https,4为socks5
# flag = "7"
username = "wmproxy"
password = "wmproxy"

Expand Down
17 changes: 0 additions & 17 deletions docker-compose.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions docker/mapping_client/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.5'
services:

wmproxy_client:
container_name: wmproxy_client_docker # 指定容器的名称
image: dreamwhat/wmproxy:0.2.4
# image: wmproxy
command:
- sh
- -c
- |
wmproxy config -c /etc/config/mapping_client.toml
ports:
- "127.0.0.1:8838:8838"
- "8090:8090"
volumes:
- ./mapping_client.toml/:/etc/config/mapping_client.toml:r

networks:
default:
name: wmproxy-network
35 changes: 35 additions & 0 deletions docker/mapping_client/mapping_client.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
control = "0.0.0.0:8838"

[proxy]
# 连接服务端地址
server = "wmproxy_server_docker:8091"
bind_addr = "0.0.0.0:8090"
flag = "http https socks5"
# 连接服务端是否加密
# ts = true
# two_way_tls = true
username = "wmproxy"
password = "wmproxy"

# 内网映射配置的数组

#将localhost的域名转发到本地的0.0.0.0:8080
[[proxy.mappings]]
name = "web"
mode = "http"
local_addr = "192.168.17.22:8080"
domain = "localhost"

headers = [
"proxy x-forward-for {client_ip}",
"proxy + from $url",
"+ last-modified 'from proxy'",
"- etag",
]

#将tcp的流量无条件转到0.0.0.0:8080
[[proxy.mappings]]
name = "tcp"
mode = "tcp"
local_addr = "192.168.17.22:8080"
domain = ""
24 changes: 24 additions & 0 deletions docker/mapping_server/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.5'
services:

wmproxy_server:
container_name: wmproxy_server_docker # 指定容器的名称
image: dreamwhat/wmproxy:0.2.3.2
# image: wmproxy
command:
- sh
- -c
- |
wmproxy config -c /etc/config/mapping_server.toml
ports:
- "127.0.0.1:8837:8837"
- "8091:8091"
- "8001:8001" #http映射
- "8002:8002" #tcp映射
- "8003:8003" #https映射
volumes:
- ./mapping_server.toml/:/etc/config/mapping_server.toml:r

networks:
default:
name: wmproxy-network
24 changes: 24 additions & 0 deletions docker/mapping_server/mapping_server.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
default_level = "trace"
[proxy]
#绑定的ip地址
bind_addr = "0.0.0.0:8091"

username = "wmproxy"
password = "wmproxy"

#内网映射http绑定地址
map_http_bind = "0.0.0.0:8001"
#内网映射tcp绑定地址
map_tcp_bind = "0.0.0.0:8002"
#内网映射https绑定地址
map_https_bind = "0.0.0.0:8003"
#内网映射的公钥证书,为空则是默认证书
# map_cert =
#内网映射的私钥证书,为空则是默认证书
# map_key =
# 双向认证
# two_way_tls = true
# #接收客户端是为是加密客户端
# tc = true
#当前服务模式,server为服务端,client为客户端
mode = "server"
129 changes: 129 additions & 0 deletions examples/arg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@

// use bpaf::*;

// #[derive(Debug, Clone, Bpaf)]
// #[allow(dead_code)]
// #[bpaf(options("hackerman"))]
// struct All {
// #[bpaf(long, short, argument("CRATE"))]
// pub fff: String,
// /// aaaaaaaaaaaaadfwerwe
// #[bpaf(long, short, argument("SPEC fddsa"))]
// pub xxx: Option<String>,
// }

// #[derive(Debug, Clone, Bpaf)]
// #[bpaf(options("hackerman"))]
// pub enum Action {
// #[bpaf(command("explain"))]
// Explain {
// #[bpaf(long, short, argument("CRATE"))]
// krate: String,
// /// aaaaaaaaaaaaadfwerwe
// #[bpaf(long, short, argument("SPEC fddsa"))]
// feature: Option<String>,
// #[bpaf(external(version_if))]
// version: Option<String>,
// },
// #[bpaf(command("global"))]
// Global {
// #[bpaf(positional("CRATE"))]
// krate: String,
// }
// }

// fn feature_if() -> impl Parser<Option<String>> {
// // here feature starts as any string on a command line that does not start with a dash
// positional::<String>("FEATURE")
// // guard restricts it such that it can't be a valid version
// .guard(move |s| !is_version(s), "")
// // last two steps describe what to do with strings in this position but are actually
// // versions.
// // optional allows parser to represent an ignored value with None
// .optional()
// // and catch lets optional to handle parse failures coming from guard
// .catch()
// }

// fn version_if() -> impl Parser<Option<String>> {
// positional::<String>("VERSION")
// .guard(move |s| is_version(s), "")
// .optional()
// .catch()
// }

// fn is_version(v: &str) -> bool {
// v.chars().all(|c| c.is_numeric())
// }


// fn parse_command() -> impl Parser<(Action, All)> {
// let action = action().map(Action::Explain);
// let action = construct!(action, shared()).to_options().command("action");
// let build = build().map(Command::Build);
// let build = construct!(build, shared()).to_options().command("build");
// construct!([action, build])
// }

// fn main() {
// let action = action().map(Command::Action);
// let action = construct!(action, shared()).to_options().command("action");

// let vals = construct!(action(), all());
// println!("{:?}", action().fallback_to_usage().run());
// }



use bpaf::*;

#[derive(Debug, Clone, Bpaf)]
#[allow(dead_code)]
#[bpaf(options("hackerman"))]
struct All {
#[bpaf(long, short, argument("CRATE"))]
pub fff: String,
/// aaaaaaaaaaaaadfwerwe
#[bpaf(long, short, argument("SPEC fddsa"))]
pub xxx: Option<String>,
}

#[derive(Debug, Clone, Bpaf)]
#[allow(dead_code)]
struct Action {
verbose: bool,
number: u32,
}

#[derive(Debug, Clone, Bpaf)]
#[allow(dead_code)]
struct Build {
verbose: bool,
}

#[derive(Debug, Clone)]
enum Command {
Action(Action),
Build(Build),
}

fn speed() -> impl Parser<f64> {
long("speed")
.help("Speed in KPH")
.argument::<f64>("SPEED")
}

fn parse_command() -> impl Parser<(Command, f64)> {
let action = action().map(Command::Action);
let _val = all().command("all");
let action = construct!(action, speed()).to_options().command("action");
let build = build().map(Command::Build);
let build = construct!(build, speed()).to_options().command("");
construct!([action, build])
}

fn main() {
let opts = parse_command().to_options().run();

println!("{:?}", opts);
}
Loading

0 comments on commit 0cc9c3b

Please sign in to comment.