-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
528 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
||
|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.