diff --git a/doc/readme.md b/doc/readme.md index 7bedcc2b9..ab9dd4e95 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -181,7 +181,7 @@ Recently, `OpenAI` has canceled the `Arkose` verification for `GPT-3.5`. It can ##### Advanced proxy usage -The built-in protocols and proxy types of agents are divided into built-in protocols: `all/api/auth/arkose`, where `all` is for all clients, `api` is for all `OpenAI API`, `auth` is for authorization/login, `arkose` For ArkoseLabs; proxy type: `interface/proxy/ipv6_subnet`, where `interface` represents the bound export `IP` address, `proxy` represents the upstream proxy protocol: `http/https/socks5`, `ipv6_subnet` represents the A random IP address within the IPv6 subnet acts as a proxy. The format is `proto|proxy`, example: **`all|socks5://192.168.1.1:1080, api|10.0.0.1, auth|2001:db8::/32, http://192.168.1.1:1081`**, without built-in protocol, the protocol defaults to `all`. +The built-in protocols and proxy types of agents are divided into built-in protocols: `all/api/auth/arkose`, where `all` is for all clients, `api` is for all `OpenAI API`, `auth` is for authorization/login, `arkose` For ArkoseLabs; proxy type: `interface/proxy/ipv6_subnet`, where `interface` represents the bound export `IP` address, `proxy` represents the upstream proxy protocol: `http/https/socks5/socks5h`, `ipv6_subnet` represents the A random IP address within the IPv6 subnet acts as a proxy. The format is `proto|proxy`, example: **`all|socks5://192.168.1.1:1080, api|10.0.0.1, auth|2001:db8::/32, http://192.168.1.1:1081`**, without built-in protocol, the protocol defaults to `all`. ##### Agent usage rules @@ -313,7 +313,7 @@ Options: -B, --pbind Preauth MITM server bind address [env: PREAUTH_BIND=] -X, --pupstream - Preauth MITM server upstream proxy, Only support http/https/socks5 protocol [env: PREAUTH_UPSTREAM=] + Preauth MITM server upstream proxy, Only support http/https/socks5/socks5h protocol [env: PREAUTH_UPSTREAM=] --pcert Preauth MITM server CA certificate file path [default: ca/cert.crt] --pkey diff --git a/doc/readme_zh.md b/doc/readme_zh.md index a8ba649c0..ced93da94 100644 --- a/doc/readme_zh.md +++ b/doc/readme_zh.md @@ -181,7 +181,7 @@ services: ##### 代理高阶用法 -分代理内置协议和代理类型,内置协议: `all/api/auth/arkose`,其中`all`针对所有客户端,`api`针对所有`OpenAI API`,`auth`针对授权/登录,`arkose`针对ArkoseLabs;代理类型: `interface/proxy/ipv6_subnet`,其中`interface`表示绑定的出口`IP`地址,`proxy`表示上游代理协议: `http/https/socks5`,`ipv6_subnet`表示用Ipv6子网段内随机IP地址作为代理。格式为`proto|proxy`,例子: **`all|socks5://192.168.1.1:1080, api|10.0.0.1, auth|2001:db8::/32, http://192.168.1.1:1081`**,不带内置协议,协议默认为`all`。 +分代理内置协议和代理类型,内置协议: `all/api/auth/arkose`,其中`all`针对所有客户端,`api`针对所有`OpenAI API`,`auth`针对授权/登录,`arkose`针对ArkoseLabs;代理类型: `interface/proxy/ipv6_subnet`,其中`interface`表示绑定的出口`IP`地址,`proxy`表示上游代理协议: `http/https/socks5/socks5h`,`ipv6_subnet`表示用Ipv6子网段内随机IP地址作为代理。格式为`proto|proxy`,例子: **`all|socks5://192.168.1.1:1080, api|10.0.0.1, auth|2001:db8::/32, http://192.168.1.1:1081`**,不带内置协议,协议默认为`all`。 ##### 代理使用规则 @@ -313,7 +313,7 @@ Options: -B, --pbind Preauth MITM server bind address [env: PREAUTH_BIND=] -X, --pupstream - Preauth MITM server upstream proxy, Only support http/https/socks5 protocol [env: PREAUTH_UPSTREAM=] + Preauth MITM server upstream proxy, Only support http/https/socks5/socks5h protocol [env: PREAUTH_UPSTREAM=] --pcert Preauth MITM server CA certificate file path [default: ca/cert.crt] --pkey diff --git a/examples/har.rs b/examples/har.rs index f4a3a37ea..eae18bf2f 100644 --- a/examples/har.rs +++ b/examples/har.rs @@ -4,7 +4,7 @@ use openai::arkose::ArkoseToken; async fn main() { for _ in 0..100 { let token = - ArkoseToken::new_from_har("/Users/gngpp/VSCode/ninja/auth0.openai.com_Archive.har") + ArkoseToken::new_from_har("/Users/gngpp/VSCode/ninja/har/6.login.chat.openai.com.har") .await .unwrap(); println!("{}", token.value()); diff --git a/openai/Cargo.toml b/openai/Cargo.toml index 3bc29fb24..f170c908b 100644 --- a/openai/Cargo.toml +++ b/openai/Cargo.toml @@ -10,7 +10,7 @@ log = "0.4.20" anyhow = "1.0.75" thiserror = "1.0.48" reqwest = { package = "reqwest-impersonate", version ="0.11.30", default-features = false, features = [ - "boring-tls", "impersonate","json", "cookies", "stream", "multipart", "socks" + "boring-tls", "impersonate","json", "cookies", "stream", "multipart", "socks", "trust-dns" ] } tokio = { version = "1.32.0", features = ["fs", "sync", "signal", "rt-multi-thread"] } serde_json = "1.0.107" diff --git a/openai/src/proxy.rs b/openai/src/proxy.rs index a5b0ed093..4f776f4f0 100644 --- a/openai/src/proxy.rs +++ b/openai/src/proxy.rs @@ -83,7 +83,7 @@ impl TryFrom<(&str, Url)> for Proxy { fn try_from((proto, url): (&str, Url)) -> Result { match url.scheme() { - "http" | "https" | "socks5" => { + "http" | "https" | "socks5" | "socks5h" => { let inner_proxy = InnerProxy::Proxy(url); make_proxy(inner_proxy, proto) } diff --git a/openai/src/serve/mod.rs b/openai/src/serve/mod.rs index f3d7071d2..87d57fcce 100644 --- a/openai/src/serve/mod.rs +++ b/openai/src/serve/mod.rs @@ -169,15 +169,12 @@ impl Serve { let router = route::config(router, &self.0).layer(global_layer); let http_config = HttpConfig::new() - .http1_keep_alive(true) - .http1_header_read_timeout(Duration::from_secs(self.0.tcp_keepalive as u64)) - .http2_keep_alive_timeout(Duration::from_secs(self.0.tcp_keepalive as u64)) - .http2_keep_alive_interval(Some(Duration::from_secs(self.0.tcp_keepalive as u64))) + .http1_title_case_headers(true) + .http1_preserve_header_case(true) .build(); let incoming_config = AddrIncomingConfig::new() .tcp_sleep_on_accept_errors(true) - .tcp_keepalive_interval(Some(Duration::from_secs(self.0.tcp_keepalive as u64))) .tcp_keepalive(Some(Duration::from_secs(self.0.tcp_keepalive as u64))) .build(); diff --git a/openwrt/luci-app-ninja/luasrc/model/cbi/ninja/client.lua b/openwrt/luci-app-ninja/luasrc/model/cbi/ninja/client.lua index 67413f22b..e5ecf963e 100644 --- a/openwrt/luci-app-ninja/luasrc/model/cbi/ninja/client.lua +++ b/openwrt/luci-app-ninja/luasrc/model/cbi/ninja/client.lua @@ -12,7 +12,7 @@ s.anonymous = true o = s:option(Flag, "enabled", translate("Enabled")) o.rmempty = false -o = s:option(Value, "proxies", translate("Proxies"), translate("Supports http/https/socks5, format: protocol://user:pass@ip:port")) +o = s:option(Value, "proxies", translate("Proxies"), translate("Supports http/https/socks5/socks5h, format: protocol://user:pass@ip:port")) o = s:option(Flag, "enable_direct", translate("Turn on direct connection"), translate("Turn on direct connection using proxy")) @@ -101,7 +101,7 @@ o.default = "86400" o = s:option(Value, "pbind", translate("Preauth MITM server bind address")) -o = s:option(Value, "pupstream", translate("MITM Upstream proxy"), translate("Supports http/https/socks5, format: protocol://user:pass@ip:port")) +o = s:option(Value, "pupstream", translate("MITM Upstream proxy"), translate("Supports http/https/socks5/socks5h, format: protocol://user:pass@ip:port")) o = s:option(Value, "pcert", translate("Preauth MITM server CA certificate file path")) diff --git a/openwrt/luci-app-ninja/po/zh-cn/ninja.po b/openwrt/luci-app-ninja/po/zh-cn/ninja.po index e510b0167..af5512b92 100644 --- a/openwrt/luci-app-ninja/po/zh-cn/ninja.po +++ b/openwrt/luci-app-ninja/po/zh-cn/ninja.po @@ -91,8 +91,8 @@ msgstr "默认监听端口: 7999" msgid "Default 1 worker thread" msgstr "默认 1 个工作线程" -msgid "Supports http/https/socks5, format: protocol://user:pass@ip:port" -msgstr "支持http/https/socks5,格式: protocol://user:pass@ip:port" +msgid "Supports http/https/socks5/socks5h, format: protocol://user:pass@ip:port" +msgstr "支持http/https/socks5/socks5h,格式: protocol://user:pass@ip:port" msgid "Default 60 seconds" msgstr "默认 60 秒" @@ -223,8 +223,8 @@ msgstr "Preauth MITM 服务绑定地址" msgid "MITM Upstream proxy" msgstr "MITM 上游代理" -msgid "Supports http/https/socks5, format: protocol://user:pass@ip:port" -msgstr "支持http/https/socks5,格式: protocol://user:pass@ip:port" +msgid "Supports http/https/socks5/socks5h, format: protocol://user:pass@ip:port" +msgstr "支持http/https/socks5/socks5h,格式: protocol://user:pass@ip:port" msgid "Preauth MITM server CA certificate file path" msgstr "Preauth MITM 服务 CA 证书文件路径" diff --git a/src/args.rs b/src/args.rs index 4c4437ff7..5cf2a3daf 100644 --- a/src/args.rs +++ b/src/args.rs @@ -113,7 +113,7 @@ pub struct ServeArgs { pub(super) timeout: usize, /// Client connect timeout (seconds) - #[clap(long, default_value = "20")] + #[clap(long, default_value = "5")] pub(super) connect_timeout: usize, /// TCP keepalive (seconds) @@ -232,7 +232,7 @@ pub struct ServeArgs { )] pub(super) pbind: Option, - /// Preauth MITM server upstream proxy, Only support http/https/socks5 protocol + /// Preauth MITM server upstream proxy, Only support http/https/socks5/socks5h protocol #[clap( short = 'X', long,