block-proxy 0.1.5 → 0.1.7

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/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
 
2
- <img width="287" alt="image" src="https://github.com/user-attachments/assets/2bb069d8-508a-41b9-9fee-94a1e31cc0cb" /> ![](https://nodei.co/npm/block-proxy.png?downloads=true&downloadRank=true&stars=true)
2
+ <img width="287" alt="image" src="https://github.com/user-attachments/assets/2bb069d8-508a-41b9-9fee-94a1e31cc0cb" />
3
3
 
4
4
  ---------------------------
5
5
 
6
+ <a href="https://nodei.co/npm/block-proxy/"><img src="https://nodei.co/npm/block-proxy.svg?style=mini"></a>
7
+
6
8
  > **Block-Proxy**
7
9
 
8
10
  基于 MITM 的代理和上网过滤工具
@@ -134,7 +136,7 @@ docker run --init -d --restart=unless-stopped --user=root \
134
136
  #### ③ 设备配置
135
137
 
136
138
  1. 代理设置:iPhone/iPad 为例:设置 → 无线局域网 → 点击当前网络 → HTTP代理/配置代理,设置服务器和端口。
137
- 2. 证书设置:打开 anproxy 监控地址(8003端口),扫码安装证书,在手机设置中安装该证书,同时配置完全信任:设置→通用→关于本机→证书信任设置→打开对AnyProxy的完全信任
139
+ 2. 证书设置:打开 AnyProxy 监控端口(默认8003),扫码安装证书,在手机设置中安装该证书,同时配置完全信任:设置→通用→关于本机→证书信任设置→打开对AnyProxy的完全信任
138
140
 
139
141
  小朋友的设备里把 Mac 固定下来:
140
142
 
package/config.json CHANGED
@@ -159,7 +159,11 @@
159
159
  "mac": "0:DD:B6:EB:26:5C"
160
160
  },
161
161
  {
162
- "ip": "192.168.124.20",
162
+ "ip": "192.168.124.10",
163
+ "mac": "FA:27:3C:E5:31:5F"
164
+ },
165
+ {
166
+ "ip": "192.168.124.21",
163
167
  "mac": "DC:97:58:D:FD:9F"
164
168
  },
165
169
  {
@@ -167,37 +171,21 @@
167
171
  "mac": "DE:1E:87:ED:17:8B"
168
172
  },
169
173
  {
170
- "ip": "192.168.124.54",
171
- "mac": "E2:4D:6E:1:21:6E"
174
+ "ip": "192.168.124.107",
175
+ "mac": "6:26:EA:5A:9E:6C"
172
176
  },
173
177
  {
174
178
  "ip": "192.168.124.111",
175
179
  "mac": "74:3F:C2:67:74:98"
176
180
  },
177
181
  {
178
- "ip": "192.168.124.117",
182
+ "ip": "192.168.124.128",
179
183
  "mac": "48:F3:F3:CA:1D:E"
180
184
  },
181
- {
182
- "ip": "192.168.124.149",
183
- "mac": "14:C0:50:14:6E:A5"
184
- },
185
- {
186
- "ip": "192.168.124.181",
187
- "mac": "9A:8A:4A:A5:C8:C7"
188
- },
189
185
  {
190
186
  "ip": "192.168.124.200",
191
187
  "mac": "54:52:84:95:DF:5E"
192
188
  },
193
- {
194
- "ip": "192.168.124.210",
195
- "mac": "F4:3C:3B:77:E:AE"
196
- },
197
- {
198
- "ip": "192.168.124.212",
199
- "mac": "D2:E9:D1:F8:CE:ED"
200
- },
201
189
  {
202
190
  "ip": "192.168.124.229",
203
191
  "mac": "D6:A0:61:69:67:F6"
@@ -209,50 +197,6 @@
209
197
  {
210
198
  "ip": "192.168.124.251",
211
199
  "mac": "6E:FB:18:4D:9C:3E"
212
- },
213
- {
214
- "ip": "192.168.124.255",
215
- "mac": "FF:FF:FF:FF:FF:FF"
216
- },
217
- {
218
- "ip": "192.168.124.53",
219
- "mac": "E2:4D:6E:1:21:6E"
220
- },
221
- {
222
- "ip": "192.168.124.211",
223
- "mac": "D2:E9:D1:F8:CE:ED"
224
- },
225
- {
226
- "ip": "192.168.124.10",
227
- "mac": "FA:27:3C:E5:31:5F"
228
- },
229
- {
230
- "ip": "192.168.124.150",
231
- "mac": "14:C0:50:14:6E:A5"
232
- },
233
- {
234
- "ip": "192.168.124.21",
235
- "mac": "DC:97:58:D:FD:9F"
236
- },
237
- {
238
- "ip": "192.168.124.96",
239
- "mac": "EE:98:74:21:D2:73"
240
- },
241
- {
242
- "ip": "192.168.124.107",
243
- "mac": "6:26:EA:5A:9E:6C"
244
- },
245
- {
246
- "ip": "192.168.124.128",
247
- "mac": "48:F3:F3:CA:1D:E"
248
- },
249
- {
250
- "ip": "192.168.124.66",
251
- "mac": "E2:4D:6E:1:21:6E"
252
- },
253
- {
254
- "ip": "192.168.124.125",
255
- "mac": "14:C0:50:14:6E:A5"
256
200
  }
257
201
  ]
258
- }
202
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "block-proxy",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Small-scale network mitm proxy filter",
5
5
  "bin": {
6
6
  "block-proxy": "bin/start.js"
@@ -30,14 +30,15 @@
30
30
  "eject": "react-scripts eject"
31
31
  },
32
32
  "devDependencies": {
33
+ "@bachi/anyproxy": "^0.1.2",
33
34
  "@craco/craco": "^7.1.0",
34
- "@bachi/anyproxy": "^0.1.1",
35
35
  "axios": "^1.13.2",
36
36
  "commander": "^14.0.2",
37
37
  "express": "^5.1.0",
38
38
  "http-proxy-agent": "^7.0.2",
39
39
  "https-proxy-agent": "^7.0.6",
40
- "ping": "^1.0.0"
40
+ "ping": "^1.0.0",
41
+ "qrcode": "^1.5.4"
41
42
  },
42
43
  "browserslist": {
43
44
  "production": [
package/proxy/domain.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // proxy/domain.js
2
2
  const { lookup, resolve4 } = require('dns');
3
3
  const { promisify } = require('util');
4
+ const os = require('os');
4
5
 
5
6
  const lookupAsync = promisify(lookup);
6
7
  const resolve4Async = promisify(resolve4);
@@ -15,6 +16,19 @@ async function getDomainIP(domain) {
15
16
  }
16
17
  }
17
18
 
19
+ function getLocalIp() {
20
+ const interfaces = os.networkInterfaces();
21
+ for (const name of Object.keys(interfaces)) {
22
+ for (const iface of interfaces[name]) {
23
+ // 跳过 IPv6 和内部回环地址
24
+ if (iface.family === 'IPv4' && !iface.internal) {
25
+ return iface.address;
26
+ }
27
+ }
28
+ }
29
+ return '127.0.0.1'; // fallback
30
+ }
31
+
18
32
  // 使用示例
19
33
  /*
20
34
  getDomainIP('example.com').then(ips => {
@@ -24,3 +38,4 @@ getDomainIP('example.com').then(ips => {
24
38
  });
25
39
  */
26
40
  module.exports.getDomainIP = getDomainIP;
41
+ module.exports.getLocalIp = getLocalIp;
package/proxy/proxy.js CHANGED
@@ -396,16 +396,7 @@ function getLocalMacAddress() {
396
396
  }
397
397
 
398
398
  function getLocalIp() {
399
- const interfaces = os.networkInterfaces();
400
- for (const name of Object.keys(interfaces)) {
401
- for (const iface of interfaces[name]) {
402
- // 跳过 IPv6 和内部回环地址
403
- if (iface.family === 'IPv4' && !iface.internal) {
404
- return iface.address;
405
- }
406
- }
407
- }
408
- return '127.0.0.1'; // fallback
399
+ return domain.getLocalIp();
409
400
  }
410
401
 
411
402
  function getMacByIp(ipAddress) {
@@ -443,9 +434,9 @@ function startProxyServer() {
443
434
  proxyServerInstance = new AnyProxy.ProxyServer(options);
444
435
 
445
436
  proxyServerInstance.on('ready', () => {
446
- console.log(`✅ \x1b[32mHTTP 代理服务启动,端口 ${proxyPort}\x1b[0m`);
437
+ console.log(`✅ \x1b[32mHTTP 代理服务启动,IP: ${localIp}, 端口: ${proxyPort}\x1b[0m`);
447
438
  if (enable_webinterface == "1") {
448
- console.log(`✅ \x1b[32mAnyProxy 监控面板启动,端口 ${webInterfacePort}\x1b[0m`);
439
+ console.log(`✅ \x1b[32mAnyProxy 监控面板启动,http://${localIp}:${webInterfacePort}\x1b[0m`);
449
440
  }
450
441
  });
451
442
 
package/server/express.js CHANGED
@@ -6,6 +6,7 @@ const path = require('path');
6
6
  const util = require('./util');
7
7
  const net = require('net');
8
8
  const os = require('os');
9
+ const domain = require('../proxy/domain.js');
9
10
  const { exec, execSync } = require('child_process');
10
11
  const LocalProxy = require('../proxy/proxy');
11
12
 
@@ -226,7 +227,8 @@ module.exports = {
226
227
  }
227
228
  // 启动本地代理
228
229
  await LocalProxy.init();
229
- console.log(`✅ \x1b[32m后台配置面板启动 http://localhost:${PORT}\x1b[0m`);
230
+ var localIp = domain.getLocalIp();
231
+ console.log(`✅ \x1b[32m后台配置面板启动 → http://${localIp}:${PORT}\x1b[0m`);
230
232
  });
231
233
  }
232
234
  };
package/socks5/server.js CHANGED
@@ -6,6 +6,7 @@ const tls = require('tls');
6
6
  const crypto = require('crypto');
7
7
  const fs = require('fs');
8
8
  const _fs = require('../proxy/fs.js');
9
+ const domain = require('../proxy/domain.js');
9
10
  const { pipeline } = require('stream');
10
11
 
11
12
  // 固定下游 HTTP 代理地址(可改为配置项)
@@ -318,7 +319,8 @@ async function init() {
318
319
 
319
320
  // 启动监听
320
321
  server.listen(LISTEN_PORT, () => {
321
- console.log(`✅ \x1b[32mSOCKS5 (over TLS) 服务启动,端口 ${LISTEN_PORT}\x1b[0m`);
322
+ var localIp = domain.getLocalIp();
323
+ console.log(`✅ \x1b[32mSOCKS5 (over TLS) 服务启动,IP ${localIp}, 端口 ${LISTEN_PORT}\x1b[0m`);
322
324
  console.log(`🔒 传输加密和认证基于 TLS`);
323
325
  console.log(`➡️ TCP → 流量转发至 HTTP 代理 → ${DOWNSTREAM_HTTP_PROXY_HOST}:${DOWNSTREAM_HTTP_PROXY_PORT}`);
324
326
  console.log(`➡️ UDP → 直接发起请求`);
package/src/App.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/App.js
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import './App.css';
4
+ import QRCode from 'qrcode';
4
5
 
5
6
  // Toast组件
6
7
  const Toast = ({ message, type, onClose }) => {
@@ -71,6 +72,13 @@ function App() {
71
72
  if (data.hostIPs) {
72
73
  setHostIPs(data.hostIPs);
73
74
  }
75
+ var localIp = "0.0.0.0"
76
+ if (data.hostIPs) {
77
+ localIp = data.hostIPs.split(",")[0];
78
+ } else if (data.ips.length >= 1) {
79
+ localIp = data.ips[0].address;
80
+ }
81
+ QRCode.toCanvas(document.getElementById('qrcode'), `http://${localIp}:${config.web_interface_port}/fetchCrtFile`);
74
82
  } else {
75
83
  showToast('获取服务器IP失败', 'error');
76
84
  }
@@ -688,7 +696,7 @@ function App() {
688
696
  )}
689
697
  </p>
690
698
  <p>
691
- <b>监控地址:</b>
699
+ <b>AnyProxy 监控地址:</b>
692
700
  {serverIPs.length > 0 ? (
693
701
  <span>
694
702
  <a href={`http://${getIpAddress()}:${config.web_interface_port}`} target="_blank" rel="noopener noreferrer">
@@ -699,6 +707,13 @@ function App() {
699
707
  <span>正在获取服务器IP地址...</span>
700
708
  )}
701
709
  </p>
710
+ <p>
711
+ <span>
712
+ 扫码安装证书:
713
+ <a href={`http://${getIpAddress()}:${config.web_interface_port}/fetchCrtFile`} target="_blank">下载</a>
714
+ </span><br />
715
+ <canvas id="qrcode"></canvas>
716
+ </p>
702
717
  <div>
703
718
  <p><b>配置方法</b>:(以Iphone为例)</p>
704
719
  <p>设置 → 无线局域网 → 点击当前网络 → HTTP代理/配置代理,设置服务器和端口(图右)</p>