فهرست منبع

Checkpoint: Update files: server2.js

zyh 1 سال پیش
والد
کامیت
2e7c42000e
1فایلهای تغییر یافته به همراه12 افزوده شده و 12 حذف شده
  1. 12 12
      server2.js

+ 12 - 12
server2.js

@@ -1,4 +1,4 @@
-const { SocketTunnel } = require('@d8d-socket-tunnel/client');
+// const { SocketTunnel } = require('@d8d-socket-tunnel/client');
 
 const http = require("http");
 const debug = require('debug')('tunnel:local');
@@ -12,14 +12,14 @@ const server = http.createServer((req, res) => {
 
 const port = process.env.LOCAL_PORT;
 
-// 创建隧道实例,使用环境变量或默认值
-const tunnel = new SocketTunnel({
-  serverUrl: process.env.TUNNEL_SERVER,  // 如果未设置,将使用默认值
-  localPort: port      // 如果未设置,将使用默认值
-});
+// // 创建隧道实例,使用环境变量或默认值
+// const tunnel = new SocketTunnel({
+//   serverUrl: process.env.TUNNEL_SERVER,  // 如果未设置,将使用默认值
+//   localPort: port      // 如果未设置,将使用默认值
+// });
 
-// 连接到隧道服务器
-tunnel.connect();
+// // 连接到隧道服务器
+// tunnel.connect();
 
 // 启动 HTTP 服务器
 server.listen(port, async () => {
@@ -28,10 +28,10 @@ server.listen(port, async () => {
   // 优雅退出
   process.on("SIGINT", () => {
     debug('收到退出信号');
-    if (tunnel) {
-      tunnel.close();
-      debug('隧道已主动关闭');
-    }
+    // if (tunnel) {
+    //   tunnel.close();
+    //   debug('隧道已主动关闭');
+    // }
     server.close(() => {
       debug('服务器已关闭');
       process.exit(0);