Skip to main content

sing-box-shadow-tls-v2

  1. 编译安装

    snap install go --classic
    git clone -b dev-next https://github.com/sagernet/sing-box
    cd sing-box/cmd/sing-box
    GOOS=linux GOARCH=amd64 go build -tags with_quic,with_acme -trimpath -ldflags "-s -w -buildid=" -o /usr/local/bin/ycycxz-sing-box
    chmod +x /usr/local/bin/ycycxz-sing-box
    mkdir -p /etc/ycycxz-sing-box
    cd;ycycxz-sing-box version
  2. 服务器端配置

    /etc/ycycxz-sing-box/ycycxz.json
    cat <<EOF > /etc/ycycxz-sing-box/ycycxz.json
    {
    "inbounds": [
    {
    "type": "shadowtls",
    "listen_port": 42324,
    "version": 2,
    "password": "ycycxz",
    "handshake": {
    "server": "tesla.com",
    "server_port": 443
    },
    "detour": "trojan-in"
    },
    {
    "type": "trojan",
    "tag": "trojan-in",
    "listen": "127.0.0.1",
    "users": [
    {
    "password": "ycycxz"
    }
    ]
    }
    ]
    }
    EOF
  3. systemd

    cat <<EOF > /etc/systemd/system/ycycxz-sing-box.service
    [Unit]
    Description=ycycxz-sing-box
    After=network-online.target

    [Service]
    LimitAS=infinity
    LimitNOFILE=infinity
    LimitNPROC=infinity
    TasksMax=infinity
    ExecStart=/usr/local/bin/ycycxz-sing-box run -c /etc/ycycxz-sing-box/ycycxz.json

    [Install]
    WantedBy=multi-user.target
    EOF
    systemctl daemon-reload
    systemctl enable ycycxz-sing-box
  4. 启动

    systemctl start ycycxz-sing-box
    #systemctl status ycycxz-sing-box
  5. 客户端

    {
    "inbounds": [
    {
    "type": "mixed",
    "listen": "127.0.0.1",
    "listen_port": 1080
    }
    ],
    "outbounds": [
    {
    "type": "trojan",
    "password": "ycycxz",
    "detour": "shadowtls-out"
    },
    {
    "type": "shadowtls",
    "tag": "shadowtls-out",
    "server": "4.2.3.24",
    "server_port": 42324,
    "version": 2,
    "password": "ycycxz",
    "tls": {
    "enabled": true,
    "server_name": "tesla.com"
    }
    }
    ]
    }
  6. 卸载

    systemctl stop ycycxz-sing-box
    rm /etc/systemd/system/ycycxz-sing-box.service
    systemctl daemon-reload
    rm -rf /etc/ycycxz-sing-box
    rm -f /usr/local/bin/ycycxz-sing-box
  7. 视频教程