Ejemplo n.º 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安装成功");
            }

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

            InstallCertToXray();


            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");
        }
Ejemplo n.º 2
0
        private void UploadCaddyFile()
        {
            var configJson = ConfigBuilder.BuildCaddyConfig(Parameters);
            var stream     = new MemoryStream(Encoding.UTF8.GetBytes(configJson));

            RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
            UploadFile(stream, "/etc/caddy/Caddyfile");
            RunCmd("systemctl reload caddy");
        }
Ejemplo n.º 3
0
        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配置成功,更新配置不包含域名,如果域名更换请重新安装。 ************");
        }