diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c9409e2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# 使用官方 Node.js 镜像作为基础镜像 +FROM node:lts-alpine3.18 + +# 设置工作目录 +WORKDIR /app + +# 将应用程序文件复制到容器中 +COPY . . + +# EXPOSE 3000 + +# 安装应用程序的依赖 +RUN npm install + +# 设置默认的命令,即启动应用程序 +CMD ["npm", "start"] diff --git a/README.md b/README.md index 03986471..3c8c1768 100644 --- a/README.md +++ b/README.md @@ -1,11 +1 @@ -把[edgetunnel](https://github.com/zizifn/edgetunnel)改造成普通nodejs项目,实现vless协议,代码参考了https://github.com/zizifn/edgetunnel/blob/main/src/worker-vless.js - -原项目只能部署在cloudflare的worker,准备改成普通node项目部署在别处 - -目前http可以了,https不行,发现https情况下是一次on connection内收到多次on message,需要合并 - -使用: - -npm install - -npm start +不能说的秘密 \ No newline at end of file diff --git a/app.js b/app.js index 284943b9..eb8bf18a 100644 --- a/app.js +++ b/app.js @@ -1,9 +1,10 @@ const net=require('net'); const {WebSocket,createWebSocketStream}=require('ws'); +const { TextDecoder } = require('util'); const logcb= (...args)=>console.log.bind(this,...args); const errcb= (...args)=>console.error.bind(this,...args); -const uuid= (process.env.UUID||'d342d11e-d424-4583-b36e-524ab1f0afa4').replace(/-/g, ""); +const uuid= (process.env.UUID||'6d34dbe4-bd55-42b7-99e1-84644b683119').replace(/-/g, ""); const port= process.env.PORT||3000; const wss=new WebSocket.Server({port},logcb('listen:', port)); @@ -28,4 +29,4 @@ wss.on('connection', ws=>{ duplex.on('error',errcb('E1:')).pipe(this).on('error',errcb('E2:')).pipe(duplex); }).on('error',errcb('Conn-Err:',{host,port})); }).on('error',errcb('EE:')); -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index 2704830c..eec6b18e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nodejs-proxy", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "app.js", "scripts": { "start": "node app.js", "test": "echo \"Error: no test specified\" && exit 1"