cdp-tunnel 3.0.5 → 3.0.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "3.0.5",
4
+ "version": "3.0.6",
5
5
  "description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
6
6
  "permissions": [
7
7
  "debugger",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "Bridge Chrome's debugger API to WebSocket — control your existing browser with Playwright/Puppeteer via CDP",
5
5
  "main": "server/proxy-server.js",
6
6
  "bin": "./cli/index.js",
@@ -64,28 +64,27 @@ class PortPoolManager {
64
64
  const session = new PortPoolManager.PortSession(portIndex, port);
65
65
  this.portSessions[portIndex] = session;
66
66
 
67
- const server = http.createServer((req, res) => {
68
- this._handleHttp(req, res, session);
69
- });
70
-
71
- // 每个 create 端口用独立的 wss(不复用主 proxy 的 wss)
67
+ const server = http.createServer();
72
68
  const wss = new WebSocket.Server({ noServer: true });
73
69
  this.createWss[portIndex] = wss;
74
70
 
71
+ // HTTP 请求(非 upgrade)
72
+ server.on('request', (req, res) => {
73
+ this._handleHttp(req, res, session);
74
+ });
75
+
76
+ // WebSocket upgrade
75
77
  server.on('upgrade', (req, socket, head) => {
76
78
  const url = new URL(req.url, `http://localhost:${port}`);
77
79
  const path = url.pathname;
78
-
79
- // 只允许 client 连接(plugin 连的是主 proxy 的 9221)
80
80
  if (path !== '/client' && !path.startsWith('/client/') &&
81
81
  !path.startsWith('/devtools/browser/') && !path.startsWith('/devtools/page/')) {
82
82
  socket.destroy();
83
83
  return;
84
84
  }
85
-
86
- wss.handleUpgrade(req, socket, head, (ws) => {
87
- this._handleClientConnect(ws, req, session);
88
- });
85
+ wss.handleUpgrade(req, socket, head, (ws) => {
86
+ this._handleClientConnect(ws, req, session);
87
+ });
89
88
  });
90
89
 
91
90
  server.on('error', (err) => {
@@ -174,7 +173,6 @@ class PortPoolManager {
174
173
  */
175
174
  _handleClientConnect(ws, req, session) {
176
175
  session.clients.add(ws);
177
- console.log(`[PORT ${session.port}] Client connected (total: ${session.clients.size})`);
178
176
 
179
177
  // 找到 plugin 连接(从主 proxy 获取)
180
178
  const pluginWs = this.mainProxy.getPluginConnection();
@@ -812,7 +812,7 @@ function handlePluginConnection(ws, clientInfo, request) {
812
812
 
813
813
  // v3.0 端口池 hook:先让 PortPoolManager 处理端口池的消息
814
814
  if (parsed && portPool && portPool.handlePluginMessage(parsed, ws)) {
815
- return; // 已被端口池处理
815
+ return;
816
816
  }
817
817
 
818
818
  // 处理 keepalive 消息