File tree 3 files changed +12
-2
lines changed
3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,8 @@ services:
259
259
| `API_REVERSE_PROXY` | 可选,`Web API` 时可用 | `Web API` 反向代理地址 [详情](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) |
260
260
| `SOCKS_PROXY_HOST` | 可选,和 `SOCKS_PROXY_PORT` 一起时生效 | Socks代理 |
261
261
| `SOCKS_PROXY_PORT` | 可选,和 `SOCKS_PROXY_HOST` 一起时生效 | Socks代理端口 |
262
+ | `SOCKS_PROXY_USERNAME` | 可选,和 `SOCKS_PROXY_HOST` 一起时生效 | Socks代理用户名 |
263
+ | `SOCKS_PROXY_PASSWORD` | 可选,和 `SOCKS_PROXY_HOST` 一起时生效 | Socks代理密码 |
262
264
| `HTTPS_PROXY` | 可选 | HTTPS 代理,支持 http,https, socks5 |
263
265
| `ALL_PROXY` | 可选 | 所有代理 代理,支持 http,https, socks5 |
264
266
Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ SOCKS_PROXY_HOST=
31
31
# Socks Proxy Port
32
32
SOCKS_PROXY_PORT =
33
33
34
+ # Socks Proxy Username
35
+ SOCKS_PROXY_USERNAME =
36
+
37
+ # Socks Proxy Password
38
+ SOCKS_PROXY_PASSWORD =
39
+
34
40
# HTTPS PROXY
35
41
HTTPS_PROXY =
36
42
Original file line number Diff line number Diff line change @@ -159,17 +159,19 @@ async function chatConfig() {
159
159
}
160
160
161
161
function setupProxy ( options : ChatGPTAPIOptions | ChatGPTUnofficialProxyAPIOptions ) {
162
- if ( process . env . SOCKS_PROXY_HOST && process . env . SOCKS_PROXY_PORT ) {
162
+ if ( isNotEmptyString ( process . env . SOCKS_PROXY_HOST ) && isNotEmptyString ( process . env . SOCKS_PROXY_PORT ) ) {
163
163
const agent = new SocksProxyAgent ( {
164
164
hostname : process . env . SOCKS_PROXY_HOST ,
165
165
port : process . env . SOCKS_PROXY_PORT ,
166
+ userId : isNotEmptyString ( process . env . SOCKS_PROXY_USERNAME ) ? process . env . SOCKS_PROXY_USERNAME : undefined ,
167
+ password : isNotEmptyString ( process . env . SOCKS_PROXY_PASSWORD ) ? process . env . SOCKS_PROXY_PASSWORD : undefined ,
166
168
} )
167
169
options . fetch = ( url , options ) => {
168
170
return fetch ( url , { agent, ...options } )
169
171
}
170
172
}
171
173
else {
172
- if ( process . env . HTTPS_PROXY || process . env . ALL_PROXY ) {
174
+ if ( isNotEmptyString ( process . env . HTTPS_PROXY ) || isNotEmptyString ( process . env . ALL_PROXY ) ) {
173
175
const httpsProxy = process . env . HTTPS_PROXY || process . env . ALL_PROXY
174
176
if ( httpsProxy ) {
175
177
const agent = new HttpsProxyAgent ( httpsProxy )
You can’t perform that action at this time.
0 commit comments