pac-proxy-cli 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/proxy.js +1 -1
- package/package.json +1 -1
- package/src/cli/start.js +1 -1
- package/src/panel/server.js +6 -6
package/bin/proxy.js
CHANGED
|
@@ -16,7 +16,7 @@ program
|
|
|
16
16
|
.option('-p, --port <number>', 'HTTP 代理端口', '3893')
|
|
17
17
|
.option('--panel-port <number>', 'Web 面板端口', '3892')
|
|
18
18
|
.option('-s, --socks <host:port>', '上游 SOCKS5 地址,如 127.0.0.1:1080(与远程服务器二选一)')
|
|
19
|
-
.option('--server
|
|
19
|
+
.option('--server [url]', '上游远程代理服务器地址;可为空,为空时使用默认的上游远程服务器地址')
|
|
20
20
|
.option('--no-open', '不自动打开浏览器')
|
|
21
21
|
.action(startProxyAndPanel);
|
|
22
22
|
|
package/package.json
CHANGED
package/src/cli/start.js
CHANGED
|
@@ -11,7 +11,7 @@ export async function startProxyAndPanel(options) {
|
|
|
11
11
|
const proxyPort = Number(options.port) || DEFAULT_PROXY_PORT;
|
|
12
12
|
const panelPort = Number(options.panelPort) || DEFAULT_PANEL_PORT;
|
|
13
13
|
const socks = options.socks;
|
|
14
|
-
const serverUrl = (options.server || process.env.PROXY_SERVER_URL || '').trim();
|
|
14
|
+
const serverUrl = String(options.server === true ? (process.env.PROXY_SERVER_URL || '') : (options.server || process.env.PROXY_SERVER_URL || '')).trim();
|
|
15
15
|
const shouldOpen = options.open !== false;
|
|
16
16
|
|
|
17
17
|
if (!socks && !serverUrl) {
|
package/src/panel/server.js
CHANGED
|
@@ -38,15 +38,15 @@ export async function createPanelServer(port, opts = {}) {
|
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
/**
|
|
41
|
+
/** 前端同步登录 token(上游为 server 时由代理带给远程);上游为 SOCKS5 时无操作,避免 404 */
|
|
42
42
|
const setProxyToken = opts.setProxyToken;
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
app.post('/api/upstream/token', (req, res) => {
|
|
44
|
+
if (typeof setProxyToken === 'function') {
|
|
45
45
|
const token = req.body?.token != null ? String(req.body.token).trim() : '';
|
|
46
46
|
setProxyToken(token || null);
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
}
|
|
47
|
+
}
|
|
48
|
+
res.json({ ok: true });
|
|
49
|
+
});
|
|
50
50
|
|
|
51
51
|
app.post('/api/sysproxy/apply', (req, res) => {
|
|
52
52
|
const mode = req.body?.mode === 'global' ? 'global' : 'pac';
|