block-proxy 0.1.5 → 0.1.6

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
@@ -253,6 +253,10 @@
253
253
  {
254
254
  "ip": "192.168.124.125",
255
255
  "mac": "14:C0:50:14:6E:A5"
256
+ },
257
+ {
258
+ "ip": "192.168.124.72",
259
+ "mac": "26:B4:7A:26:1C:23"
256
260
  }
257
261
  ]
258
- }
262
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "block-proxy",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Small-scale network mitm proxy filter",
5
5
  "bin": {
6
6
  "block-proxy": "bin/start.js"
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@craco/craco": "^7.1.0",
34
- "@bachi/anyproxy": "^0.1.1",
34
+ "@bachi/anyproxy": "^0.1.2",
35
35
  "axios": "^1.13.2",
36
36
  "commander": "^14.0.2",
37
37
  "express": "^5.1.0",
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 → 直接发起请求`);