clash-linux commited on
Commit
15296c6
·
verified ·
1 Parent(s): 8c0c410

Upload 17 files

Browse files
Files changed (3) hide show
  1. Dockerfile +3 -6
  2. proxychains.conf +0 -14
  3. src/ProxyServer.js +6 -39
Dockerfile CHANGED
@@ -22,6 +22,9 @@ USER root
22
  # Install proxychains4
23
  RUN apt-get update && apt-get install -y proxychains4 && rm -rf /var/lib/apt/lists/*
24
 
 
 
 
25
  # Grant execute permission to the proxy server binary for the root user
26
  RUN chmod +x /app/src/proxy/chrome_proxy_server_linux_amd64
27
 
@@ -34,11 +37,5 @@ USER node
34
  # Make port 7860 available to the world outside this container
35
  EXPOSE 7860
36
 
37
- # 确认proxychains配置可用
38
- RUN echo '检查文件存在:' && ls -l /app/proxychains.conf || echo '文件不存在' && \
39
- echo 'proxychains.conf 内容:' && cat /app/proxychains.conf || echo '无法读取文件' && \
40
- mkdir -p /etc/proxychains && cp /app/proxychains.conf /etc/proxychains/ && \
41
- echo '复制配置到全局目录'
42
-
43
  # Define the command to run the app
44
  CMD ["npm", "start"]
 
22
  # Install proxychains4
23
  RUN apt-get update && apt-get install -y proxychains4 && rm -rf /var/lib/apt/lists/*
24
 
25
+ # Check if the binary is dynamically linked. If it is statically linked, ldd will fail.
26
+ RUN ldd /app/src/proxy/chrome_proxy_server_linux_amd64 || echo "ldd check failed, the binary is likely statically linked."
27
+
28
  # Grant execute permission to the proxy server binary for the root user
29
  RUN chmod +x /app/src/proxy/chrome_proxy_server_linux_amd64
30
 
 
37
  # Make port 7860 available to the world outside this container
38
  EXPOSE 7860
39
 
 
 
 
 
 
 
40
  # Define the command to run the app
41
  CMD ["npm", "start"]
proxychains.conf CHANGED
@@ -1,20 +1,6 @@
1
- # 严格模式:强制所有流量通过代理
2
  strict_chain
3
-
4
- # 代理 DNS 查询
5
  proxy_dns
6
-
7
- # 超时设置
8
  tcp_read_time_out 15000
9
  tcp_connect_time_out 8000
10
-
11
- # 禁用通配符和远程DNS解析(增强匿名性)
12
- localnet 127.0.0.0/255.0.0.0
13
-
14
- # 强制 proxy_dns
15
- proxy_dns_old_mode
16
-
17
- # 代理服务器列表
18
  [ProxyList]
19
- # 添加您的代理服务器
20
  http 34.55.224.190 8080
 
 
1
  strict_chain
 
 
2
  proxy_dns
 
 
3
  tcp_read_time_out 15000
4
  tcp_connect_time_out 8000
 
 
 
 
 
 
 
 
5
  [ProxyList]
 
6
  http 34.55.224.190 8080
src/ProxyServer.js CHANGED
@@ -92,28 +92,6 @@ class ProxyServer {
92
  logger.error('无法获取代理服务器路径');
93
  return;
94
  }
95
-
96
- // 检查proxychains.conf文件是否存在
97
- const proxyChainsConfigPath = join(dirname(__dirname), 'proxychains.conf');
98
- try {
99
- if (fs.existsSync(proxyChainsConfigPath)) {
100
- logger.info(`找到proxychains配置文件: ${proxyChainsConfigPath}`);
101
- // 输出配置文件内容
102
- const configContent = fs.readFileSync(proxyChainsConfigPath, 'utf8');
103
- logger.info(`proxychains配置内容: ${configContent}`);
104
- } else {
105
- logger.error(`proxychains配置文件不存在: ${proxyChainsConfigPath}`);
106
- // 尝试在标准位置查找
107
- const altConfigPath = '/etc/proxychains/proxychains.conf';
108
- if (fs.existsSync(altConfigPath)) {
109
- logger.info(`找到备用proxychains配置: ${altConfigPath}`);
110
- } else {
111
- logger.error('找不到任何可用的proxychains配置');
112
- }
113
- }
114
- } catch (error) {
115
- logger.error(`检查proxychains配置时出错: ${error.message}`);
116
- }
117
 
118
  try {
119
  // 确保可执行文件有执行权限(在Linux/Android上)
@@ -128,30 +106,19 @@ class ProxyServer {
128
  // 创建日志文件
129
  this.logStream = fs.createWriteStream(this.logPath, { flags: 'a' });
130
 
131
- // 获取 proxy.conf 路径
132
  const proxyChainsConfigPath = join(dirname(__dirname), 'proxychains.conf');
133
-
134
- // 环境变量方式设置代理
135
- const env = {
136
- ...process.env,
137
- HTTP_PROXY: 'http://34.55.224.190:8080',
138
- HTTPS_PROXY: 'http://34.55.224.190:8080',
139
- http_proxy: 'http://34.55.224.190:8080',
140
- https_proxy: 'http://34.55.224.190:8080',
141
- PROXYCHAINS_CONF_FILE: proxyChainsConfigPath,
142
- LD_PRELOAD: '/usr/lib/x86_64-linux-gnu/libproxychains.so.4'
143
- };
144
-
145
- // 尝试使用 proxychains + 环境变量的组合方式
146
  this.proxyProcess = spawn('proxychains4', [
147
- '-f', proxyChainsConfigPath,
 
148
  proxyServerPath,
149
  '--port', this.port.toString(),
150
  '--token', this.proxyAuthToken
151
  ], {
152
  stdio: ['ignore', 'pipe', 'pipe'], // 使用pipe而不是直接传递流
153
- detached: false,
154
- env: env
155
  });
156
 
157
  // 将进程的输出重定向到日志文件
 
92
  logger.error('无法获取代理服务器路径');
93
  return;
94
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  try {
97
  // 确保可执行文件有执行权限(在Linux/Android上)
 
106
  // 创建日志文件
107
  this.logStream = fs.createWriteStream(this.logPath, { flags: 'a' });
108
 
 
109
  const proxyChainsConfigPath = join(dirname(__dirname), 'proxychains.conf');
110
+
111
+ // 修复 stdio 参数问题
112
+ // 启动代理服务器进程
 
 
 
 
 
 
 
 
 
 
113
  this.proxyProcess = spawn('proxychains4', [
114
+ '-f',
115
+ proxyChainsConfigPath,
116
  proxyServerPath,
117
  '--port', this.port.toString(),
118
  '--token', this.proxyAuthToken
119
  ], {
120
  stdio: ['ignore', 'pipe', 'pipe'], // 使用pipe而不是直接传递流
121
+ detached: false
 
122
  });
123
 
124
  // 将进程的输出重定向到日志文件