注册 登录
n/website · 8 个月前 · 1567 次浏览
u/cs9u钻石钻石会员
n/websiteu/cs9u 钻石会员 · 8 个月前

https://rustix.me/ 的容器建一个网站不行哇?

https://rustix.me/ 的容器建一个网站不行哇? 有点玩不来。

4
52
登录后参与讨论。
最佳答案楼主采纳 · 回答者获得 20 声望
linying233338 个月前2 赞同

cs9u: 运行后提示 const { spawn } = require(‘child_process’); SyntaxError: Invalid or unexpected token at internalCompileFunction (node:internal/vm:128:18) at wrapSafe (node:internal/modules/cjs/loader:1279:20) at Module._compile (node:internal/m…

52 条回复

排序
  1. lixi 黄金 8 个月前 #2

    你的机器跑起来来了吗,我的跑不起来

    1
  2. cs9u 钻石 楼主 钻石会员 8 个月前 #3
    回复 @lixi:你的机器跑起来来了吗,我的跑不起来

    你要弄好对应的文件才运行的起来。

    1
  3. lixi 黄金 8 个月前 #4
    回复 @cs9u:你要弄好对应的文件才运行的起来。

    原来如此,我以为是带操作系统的,我建立了一个拍死他脚本,已经跑起来了

    1
  4. w-d 钻石 8 个月前 #5

    是长久的吗

    1
  5. lixi 黄金 8 个月前 #7
    回复 @wxk:脚本分享下

    测试脚本,没有实际功能

    0
  6. azhaoyihao 荣耀 水王 8 个月前 #8

    大佬有教程吗?不会玩

    0
  7. dutong0321 黄金 8 个月前 #9

    可以啊 还是挺好玩的 在这种面板下属于可玩性比较高的了

    0
  8. yealo 黄金 3 YEARS 8 个月前 #10

    我搞了个python的留言板,让AI写的,hi.80h.fun:,用欧美代理,不然显示403报错。封IP了应该

    0
  9. wxk 💯 钻石 8 个月前 #11

    上传了文件依然无法运行

    0
  10. JinMukun 钻石 3 YEARS 8 个月前 #12

    有效期多久

    0
  11. dutong0321 黄金 8 个月前 #13
    回复 @JinMukun:有效期多久

    可以0元续,2天了,我的没中断

    0
  12. dutong0321 黄金 8 个月前 #14

    感觉比wispbyte好

    1
  13. dutong0321 黄金 8 个月前 #15

    不能改启动命令,但也不错

    0
  14. linying23333 😇 钻石 2 YEARS 8 个月前 #16
    回复 @dutong0321:感觉比wispbyte好

    我也觉得, 那个太不稳定了, 本来就超开,结果给的配置也低. 没事就会批量关机...

    0
  15. linying23333 😇 钻石 2 YEARS 8 个月前 #17
    回复 @dutong0321:不能改启动命令,但也不错

    虽然是不能改,但是你可以用ai撸个启动器劫持一下就可以自由执行了(没有特权, 用户组是997)

    0
  16. crazzzzzysnail 黄金 3 YEARS 8 个月前 #18

    这个除了没有UDP还有其他限制吗

    0
  17. GeorgeXie 💬 王者 不离不弃 8 个月前 #19

    可以续吗?

    2
  18. dutong0321 黄金 8 个月前 #20
    回复 @linying23333:虽然是不能改,但是你可以用ai撸个启动器劫持一下就可以自由执行了(没有特权, 用户组是997)

    我傻了,我花了一上午自己写的,忘了AI了 :ac01:

    0
  19. sydney1 钻石 8 个月前 #21

    可以的,具体方法如下:
    选择免费的game server,然后环境选择other games--nodejs
    选择开免费的虽然它管理面板不支持shell,但可以通过以下方法进入shell:
    左侧栏选择文件管理,新建,粘贴以下内容:
    // shell.js
    const { spawn } = require('child_process');

    // 获取通过 NODE_ARGS 传递进来的参数
    const args = process.argv.slice(2);

    console.log("--- 正在进入透明 Bash 转发模式 ---");

    // 启动 bash 进程
    // 如果 args 为空,则进入交互模式;如果有参数(如 -c "ls"),则执行命令
    const shell = spawn('/bin/bash', args, {
    stdio: 'inherit', // 关键:将 Node 的 stdin, stdout, stderr 直接绑定给 bash
    shell: true,
    env: { ...process.env, TERM: 'xterm' } // 注入环境变量确保一些命令能正常显示颜色
    });

    // 当 bash 退出时,Node 进程也同步退出
    shell.on('exit', (code) => {
    console.log(\n--- Bash 已退出 (退出码: ${code}) ---);
    process.exit(code);
    });
    命名为shell.js,保存
    然后去左侧栏最底部有一个启动选项,把启动js改为shell.js
    再去终端启动,在下面的输入栏输入就能执行shell指令了,现在它就跟一个debian容器一样,允许开两个端口映射,想搭建网站或梯子都行
    还有什么问题可以回复,如果解决了你的问题就给个最佳答案吧 :ac01:

    3
  20. trial 王者 钻石会员 8 个月前 #22

    不玩容器了

    0
  21. sydney1 钻石 8 个月前 #23

    如果不喜欢容器的端口,可以配合cloudflare代理转换端口,在cf里自定义规则就能把容器的端口转到任意的,而且这个容器连接cf速度很快

    0
  22. yybbtech 🎧 黄金 8 个月前 #24
    回复 @sydney1:可以的,具体方法如下: 选择免费的game server,然后环境选择other games--nodejs 选择开免费…

    甬哥的mkdir: cannot create directory '/etc/s-box': Read-only file system
    老王的装上也不行全-1
    佬带带呗?教搭个节点哈,谢谢!

    1
  23. sydney1 钻石 8 个月前 #25
    回复 @yybbtech:甬哥的mkdir: cannot create directory '/etc/s-box': Read…

    脚本不知道,用sing-box内核二进制版本,让AI写个vless over httpupgrade的配置,然后用cloudflare转发,再用cloudflare优选(如果没用过cf也可以跳过)详细过程问AI

    0
  24. bashell 钻石 8 个月前 #26

    城会玩

    2
  25. cs9u 钻石 楼主 钻石会员 8 个月前 #27
    回复 @sydney1:可以的,具体方法如下: 选择免费的game server,然后环境选择other games--nodejs 选择开免费…

    1,other games下面没有nodejs,coding and web 下面才有node.js
    2,运行后提示 const { spawn } = require(‘child_process’);

    SyntaxError: Invalid or unexpected token
    at internalCompileFunction (node:internal/vm:128:18)
    at wrapSafe (node:internal/modules/cjs/loader:1279:20)
    at Module._compile (node:internal/modules/cjs/loader:1331:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Object.require.extensions. [as .js] (/usr/local/lib/node_modules/ts-node/src/index.ts:1608:43)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
    at cjsLoader (node:internal/modules/esm/translators:366:17)
    at ModuleWrap. (node:internal/modules/esm/translators:315:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    root@rustix~ Server marked as offline

    0
  26. linying23333 😇 钻石 最佳答案最佳 2 YEARS 8 个月前 已编辑 #28
    回复 @cs9u:1,other games下面没有nodejs,coding and web 下面才有node.js 2,运行后提示 c…

    cs9u:
    运行后提示 const { spawn } = require(‘child_process’);

    SyntaxError: Invalid or unexpected token
    at internalCompileFunction (node:internal/vm:128:18)
    at wrapSafe (node:internal/modules/cjs/loader:1279:20)
    at Module._compile (node:internal/modules/cjs/loader:1331:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Object.require.extensions. [as .js] (/usr/local/lib/node_modules/ts-node/src/index.ts:1608:43)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
    at cjsLoader (node:internal/modules/esm/translators:366:17)
    at ModuleWrap. (node:internal/modules/esm/translators:315:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)

    这人给的代码偷懒没放代码块里你也没改吗?

    const { exec, spawn } = require('child_process');
    const http = require('http');
    
    // 优先读取面板提供的环境变量,若无则默认
    const HOST = process.env.SERVER_HOST || "0.0.0.0";
    const PORT = process.env.SERVER_PORT || 8080;
    
    console.log("[INFO] Starting Web Terminal Server...");
    /**
     * 启动交互式 Bash 并接管面板的标准流
     */
    const shell = spawn('bash', ['-i'], {
        stdio: 'inherit', // 直接将输入输出对接到面板控制台
        shell: true,
        env: { 
            ...process.env, 
            TERM: 'xterm-256color', 
            HOME: '/home/container',
            LANG: 'C.UTF-8',
            TZ: 'GMT-8',
            timezone: 'Asia/Taipei'
        }
    });
    // 监听退出,防止进程静默挂掉
    shell.on('exit', (code) => {
        console.log(`\n[CARSH] Shell Exit End, Code: ${code}`);
        process.exit(code);
    });
    
    // 创建服务
    const server = http.createServer((req, res) => {
        // 设置响应头,支持中文输出
        res.setHeader('Content-Type', 'text/plain; charset=utf-8');
    
        if (req.method === 'POST') {
            let body = '';
            
            // 接收 POST 数据流
            req.on('data', chunk => {
                body += chunk.toString();
            });
    
            req.on('end', () => {
                if (!body) {
                    return res.end('Error: Empty command body');
                }
    
                // 执行从 Body 传入的命令
                exec(body, (err, stdout, stderr) => {
                    // 合并输出结果
                    const output = stdout || '';
                    const error = stderr || (err ? err.message : '');
                    res.end(output + error);
                });
            });
        } else {
            res.statusCode = 405;
            res.end('Please use POST method to send commands in the request body.');
        }
    });
    // 监听端口
    server.listen(PORT, HOST, () => {
        console.log(`[INFO] Web Terminal Server running on ${HOST}:${PORT}`);
    });
    

    两种执行方式

    1. 直接在面板执行shell命令
    2. 用curl远程执行
    curl -X POST http://f1.rustix.me:<上面打印的端口号> -d '这里面放命令'
    

    完整示例

    curl -X POST http://f1.rustix.me:12345 -d 'pwd'
    

    (当然,这个远程执行的实现是不安全的.既不鉴权又用http.不过拿来方便一下部署还是可以的,部署完了拆掉远程shell.)

    2
  27. sydney1 钻石 8 个月前 #29
    回复 @bashell:城会玩

    对,记错了QAQ
    代码是

    // shell.js
    const { spawn } = require('child_process');
    
    // 获取通过 NODE_ARGS 传递进来的参数
    const args = process.argv.slice(2);
    
    console.log("--- 正在进入透明 Bash 转发模式 ---");
    
    // 启动 bash 进程
    // 如果 args 为空,则进入交互模式;如果有参数(如 -c "ls"),则执行命令
    const shell = spawn('/bin/bash', args, {
        stdio: 'inherit', // 关键:将 Node 的 stdin, stdout, stderr 直接绑定给 bash
        shell: true,
        env: { ...process.env, TERM: 'xterm' } // 注入环境变量确保一些命令能正常显示颜色
    });
    
    // 当 bash 退出时,Node 进程也同步退出
    shell.on('exit', (code) => {
        console.log(`\n--- Bash 已退出 (退出码: ${code}) ---`);
        process.exit(code);
    });
    

    这样是在管理面板中连接的,安全

    0
  28. cs9u 钻石 楼主 钻石会员 8 个月前 #30
    回复 @linying23333:cs9u: 运行后提示 const { spawn } = require(‘child_process’); Synt…

    我用node.js容量,ai写了shell.js,运行目录下的index.html建了一个http 服务器。选择运行起来了。

    0