Exemple #1
0
        private void InstallXrayWithCert()
        {
            RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install");

            if (!FileExists("/usr/local/bin/xray"))
            {
                WriteOutput("Xray-Core安装失败,请联系开发者");
                throw new Exception("Xray-Core安装失败,请联系开发者");
            }

            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");

            if (FileExists("/usr/local/etc/xray/config.json"))
            {
                RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1");
            }

            WriteOutput("安装TLS证书");
            InstallCertToXray();
            WriteOutput("TLS证书安装完成");


            var configJson = ConfigBuilder.BuildXrayConfig(Parameters);
            var stream     = new MemoryStream(Encoding.UTF8.GetBytes(configJson));

            RunCmd("rm -rf /usr/local/etc/xray/config.json");
            UploadFile(stream, "/usr/local/etc/xray/config.json");
            RunCmd("systemctl restart xray");
        }
Exemple #2
0
        private void UploadCaddyFile(bool useCustomWeb = false)
        {
            var configJson = ConfigBuilder.BuildCaddyConfig(Parameters, useCustomWeb);
            var stream     = new MemoryStream(Encoding.UTF8.GetBytes(configJson));

            RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
            UploadFile(stream, "/etc/caddy/Caddyfile");
            RunCmd("systemctl restart caddy");
        }
Exemple #3
0
        /// <summary>
        /// 更新xray配置
        /// </summary>
        public void UpdateXraySettings()
        {
            EnsureRootAuth();
            EnsureSystemEnv();
            var configJson = ConfigBuilder.BuildXrayConfig(Parameters);
            var stream     = new MemoryStream(Encoding.UTF8.GetBytes(configJson));

            RunCmd("rm -rf /usr/local/etc/xray/config.json");
            UploadFile(stream, "/usr/local/etc/xray/config.json");
            RunCmd("systemctl restart xray");
            WriteOutput("************ 更新Xray配置成功,更新配置不包含域名,如果域名更换请重新安装。 ************");
        }