Пример #1
0
        private void UploadTrojanGoSettings()
        {
            // 上传配置
            var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Parameters);
            var stream   = new MemoryStream(Encoding.UTF8.GetBytes(settings));

            UploadFile(stream, "/usr/local/etc/trojan-go/config.json");
            RunCmd("systemctl restart trojan-go");
        }
Пример #2
0
        private void UploadTrojanGoSettings()
        {
            // 上传配置
            Progress.Desc = "生成配置文件";
            var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Settings);
            var stream   = new MemoryStream(Encoding.UTF8.GetBytes(settings));

            Progress.Desc = "正在上传配置文件";
            UploadFile(stream, "/usr/local/etc/trojan-go/config.json");
        }
Пример #3
0
        private void UploadCaddySettings(bool useCustomWeb = false)
        {
            var config = TrojanGoConfigBuilder.BuildCaddyConfig(Settings, useCustomWeb);
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(config));

            if (FileExists("/etc/caddy/Caddyfile"))
            {
                RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
            }
            UploadFile(stream, "/etc/caddy/Caddyfile");
        }
Пример #4
0
        private void InstallTrojanGo()
        {
            WriteOutput("安装Trojan-Go");
            RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh yes | bash");
            var success = FileExists("/usr/local/etc/trojan-go");

            if (success == false)
            {
                throw new Exception("trojan-go 安装失败,请联系开发者!");
            }

            RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/xray.service");
            RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/xray.service");
            RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/xray.service");
            RunCmd($"systemctl daemon-reload");

            RunCmd("systemctl enable trojan-go");
            RunCmd("systemctl start trojan-go");
            WriteOutput("Trojan-Go 安装完成");

            InstallCert(
                dirPath: "/usr/local/etc/trojan-go",
                certName: "trojan-go.crt",
                keyName: "trojan-go.key");

            if (FileExists("/usr/local/etc/trojan-go/config.json"))
            {
                RunCmd("mv /usr/local/etc/trojan-go/config.json config.json.old");
            }

            // 上传配置
            var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Parameters);
            var stream   = new MemoryStream(Encoding.UTF8.GetBytes(settings));

            UploadFile(stream, "/usr/local/etc/trojan-go/config.json");
            RunCmd("systemctl restart trojan-go");
        }