pac-proxy-cli 0.1.0 → 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/.env CHANGED
@@ -1,3 +1,3 @@
1
1
  # 远程代理服务器地址(用于登录、PAC 同步等)
2
2
  # 面板通过 /api/config 读取此配置,前端不展示该地址
3
- PROXY_SERVER_URL=http://127.0.0.1:3890
3
+ PROXY_SERVER_URL=http://proxy.ah.lonae.com
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 <url>', '上游远程代理服务器地址;未指定时使用 .env 的 PROXY_SERVER_URL')
19
+ .option('--server [url]', '上游远程代理服务器地址;可为空,为空时使用默认的上游远程服务器地址')
20
20
  .option('--no-open', '不自动打开浏览器')
21
21
  .action(startProxyAndPanel);
22
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pac-proxy-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "HTTP 代理与隧道 CLI + Web 管理面板",
5
5
  "type": "module",
6
6
  "files": [
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) {
@@ -38,15 +38,15 @@ export async function createPanelServer(port, opts = {}) {
38
38
  });
39
39
  });
40
40
 
41
- /** 使用 PROXY_SERVER_URL 时:前端同步登录 token,由本地面板传给代理;实际是否允许走代理由私有 server 校验 */
41
+ /** 前端同步登录 token(上游为 server 时由代理带给远程);上游为 SOCKS5 时无操作,避免 404 */
42
42
  const setProxyToken = opts.setProxyToken;
43
- if (typeof setProxyToken === 'function') {
44
- app.post('/api/upstream/token', (req, res) => {
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
- res.json({ ok: true });
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';