mirror of
https://github.com/proxysu/ProxySU.git
synced 2025-02-21 08:53:17 +03:00
添加NaiveProxy一键安装03
This commit is contained in:
parent
409f717db7
commit
4217d11c43
@ -1958,7 +1958,7 @@ namespace ProxySU
|
|||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
//检测是否安装有Trojan
|
//检测是否安装有NaiveProxy
|
||||||
currentStatus = "检测系统是否已经安装NaiveProxy......";
|
currentStatus = "检测系统是否已经安装NaiveProxy......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
@ -2005,23 +2005,6 @@ namespace ProxySU
|
|||||||
bool getSystemd = String.IsNullOrEmpty(client.RunCommand("command -v systemctl").Result);
|
bool getSystemd = String.IsNullOrEmpty(client.RunCommand("command -v systemctl").Result);
|
||||||
bool getGetenforce = String.IsNullOrEmpty(client.RunCommand("command -v getenforce").Result);
|
bool getGetenforce = String.IsNullOrEmpty(client.RunCommand("command -v getenforce").Result);
|
||||||
|
|
||||||
//安装所需软件
|
|
||||||
if (getApt == false)
|
|
||||||
{
|
|
||||||
client.RunCommand("apt-get -qq update");
|
|
||||||
client.RunCommand("apt-get -y -qq install curl libnss3 xz-utils lsof");
|
|
||||||
}
|
|
||||||
if (getYum == false)
|
|
||||||
{
|
|
||||||
client.RunCommand("yum -q makecache");
|
|
||||||
client.RunCommand("yum -y -q install curl libnss3 xz-utils lsof");
|
|
||||||
}
|
|
||||||
if (getZypper == false)
|
|
||||||
{
|
|
||||||
client.RunCommand("zypper ref");
|
|
||||||
client.RunCommand("zypper -y install curl libnss3 xz-utils lsof");
|
|
||||||
}
|
|
||||||
|
|
||||||
//没有安装apt-get,也没有安装yum,也没有安装zypper,或者没有安装systemd的,不满足安装条件
|
//没有安装apt-get,也没有安装yum,也没有安装zypper,或者没有安装systemd的,不满足安装条件
|
||||||
//也就是apt-get ,yum, zypper必须安装其中之一,且必须安装Systemd的系统才能安装。
|
//也就是apt-get ,yum, zypper必须安装其中之一,且必须安装Systemd的系统才能安装。
|
||||||
if ((getApt && getYum && getZypper) || getSystemd)
|
if ((getApt && getYum && getZypper) || getSystemd)
|
||||||
@ -2045,34 +2028,27 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//安装所需软件
|
||||||
|
if (getApt == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("apt-get -qq update");
|
||||||
|
client.RunCommand("apt-get -y -qq install curl libnss3 xz-utils lsof");
|
||||||
|
}
|
||||||
|
if (getYum == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("yum -q makecache");
|
||||||
|
client.RunCommand("yum -y -q install curl nss xz lsof");
|
||||||
|
}
|
||||||
|
if (getZypper == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("zypper ref");
|
||||||
|
client.RunCommand("zypper -y install curl nss xz lsof");
|
||||||
|
}
|
||||||
|
|
||||||
//如果使用如果是WebSocket + TLS + Web/http2/Http2Web/tcp_TLS/WebSocket_TLS模式,需要检测域名解析是否正确
|
|
||||||
//if (serverConfig.Contains("Naiveproxy") == true)
|
|
||||||
//{
|
|
||||||
currentStatus = "正在检测域名是否解析到当前VPS的IP上......";
|
currentStatus = "正在检测域名是否解析到当前VPS的IP上......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
//在相应系统内安装curl(如果没有安装curl)
|
|
||||||
//if (string.IsNullOrEmpty(client.RunCommand("command -v curl").Result) == true)
|
|
||||||
//{
|
|
||||||
// //为假则表示系统有相应的组件。
|
|
||||||
// if (getApt == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("apt-get -qq update");
|
|
||||||
// client.RunCommand("apt-get -y -qq install curl");
|
|
||||||
// }
|
|
||||||
// if (getYum == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("yum -q makecache");
|
|
||||||
// client.RunCommand("yum -y -q install curl");
|
|
||||||
// }
|
|
||||||
// if (getZypper == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("zypper ref");
|
|
||||||
// client.RunCommand("zypper -y install curl");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
string nativeIp = client.RunCommand("curl -4 ip.sb").Result.ToString();
|
string nativeIp = client.RunCommand("curl -4 ip.sb").Result.ToString();
|
||||||
//MessageBox.Show(nativeIp);
|
//MessageBox.Show(nativeIp);
|
||||||
@ -2095,34 +2071,10 @@ namespace ProxySU
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
|
||||||
//if (serverConfig.Contains("Naiveproxy") == true)
|
|
||||||
//{
|
|
||||||
//检测是否安装lsof
|
|
||||||
//if (string.IsNullOrEmpty(client.RunCommand("command -v lsof").Result) == true)
|
|
||||||
//{
|
|
||||||
// //为假则表示系统有相应的组件。
|
|
||||||
// if (getApt == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("apt-get -qq update");
|
|
||||||
// client.RunCommand("apt-get -y -qq install lsof");
|
|
||||||
// }
|
|
||||||
// if (getYum == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("yum -q makecache");
|
|
||||||
// client.RunCommand("yum -y -q install lsof");
|
|
||||||
// }
|
|
||||||
// if (getZypper == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("zypper ref");
|
|
||||||
// client.RunCommand("zypper -y install lsof");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
currentStatus = "正在检测端口占用情况......";
|
currentStatus = "正在检测端口占用情况......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
//MessageBox.Show(@"lsof -n -P -i :80 | grep LISTEN");
|
|
||||||
//MessageBox.Show(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result);
|
|
||||||
if (String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result) == false || String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :443 | grep LISTEN").Result) == false)
|
if (String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result) == false || String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :443 | grep LISTEN").Result) == false)
|
||||||
{
|
{
|
||||||
MessageBoxResult dialogResult = MessageBox.Show("80/443端口之一,或全部被占用,将强制停止占用80/443端口的程序?", "Stop application", MessageBoxButton.YesNo);
|
MessageBoxResult dialogResult = MessageBox.Show("80/443端口之一,或全部被占用,将强制停止占用80/443端口的程序?", "Stop application", MessageBoxButton.YesNo);
|
||||||
@ -2165,33 +2117,11 @@ namespace ProxySU
|
|||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
currentStatus = "符合安装要求,布署中......";
|
currentStatus = "符合安装要求,布署中......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
//在相应系统内安装curl(如果没有安装curl)
|
|
||||||
//if (string.IsNullOrEmpty(client.RunCommand("command -v curl").Result) == true)
|
|
||||||
//{
|
|
||||||
// //为假则表示系统有相应的组件。
|
|
||||||
// if (getApt == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("apt-get -qq update");
|
|
||||||
// client.RunCommand("apt-get -y -qq install curl");
|
|
||||||
// }
|
|
||||||
// if (getYum == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("yum -q makecache");
|
|
||||||
// client.RunCommand("yum -y -q install curl");
|
|
||||||
// }
|
|
||||||
// if (getZypper == false)
|
|
||||||
// {
|
|
||||||
// client.RunCommand("zypper ref");
|
|
||||||
// client.RunCommand("zypper -y install curl");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//下载安装脚本安装
|
//下载安装脚本安装
|
||||||
|
|
||||||
client.RunCommand("curl -o /tmp/naive-quickstart.sh https://raw.githubusercontent.com/proxysu/shellscript/master/naive-quickstart.sh");
|
client.RunCommand("curl -o /tmp/naive-quickstart.sh https://raw.githubusercontent.com/proxysu/shellscript/master/naive-quickstart.sh");
|
||||||
@ -2207,30 +2137,14 @@ namespace ProxySU
|
|||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//client.RunCommand("mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.1");
|
|
||||||
|
|
||||||
//上传配置文件
|
//上传配置文件
|
||||||
currentStatus = "NaiveProxy程序安装完毕......";
|
currentStatus = "NaiveProxy程序安装完毕......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
//生成服务端配置
|
|
||||||
//using (StreamReader reader = File.OpenText(serverConfig))
|
|
||||||
//{
|
|
||||||
// JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
|
|
||||||
// //设置密码
|
|
||||||
// serverJson["password"][0] = ReceiveConfigurationParameters[2];
|
|
||||||
// //设置监听端口
|
|
||||||
// //serverJson["inbounds"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]);
|
|
||||||
|
|
||||||
// using (StreamWriter sw = new StreamWriter(@"config.json"))
|
|
||||||
// {
|
|
||||||
// sw.Write(serverJson.ToString());
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//UploadConfig(connectionInfo, @"config.json", upLoadPath);
|
|
||||||
|
|
||||||
//File.Delete(@"config.json");
|
|
||||||
|
|
||||||
//打开防火墙端口
|
//打开防火墙端口
|
||||||
string openFireWallPort = ReceiveConfigurationParameters[1];
|
string openFireWallPort = ReceiveConfigurationParameters[1];
|
||||||
@ -2265,46 +2179,6 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if (serverConfig.Contains("Naiveproxy") == true)
|
|
||||||
//{
|
|
||||||
// currentStatus = "使用Trojan+TLS+Web模式,正在安装acme.sh......";
|
|
||||||
// textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
// Thread.Sleep(1000);
|
|
||||||
|
|
||||||
// if (getApt == false)
|
|
||||||
// {
|
|
||||||
// //client.RunCommand("apt-get -qq update");
|
|
||||||
// client.RunCommand("apt-get -y -qq install socat");
|
|
||||||
// }
|
|
||||||
// if (getYum == false)
|
|
||||||
// {
|
|
||||||
// //client.RunCommand("yum -q makecache");
|
|
||||||
// client.RunCommand("yum -y -q install socat");
|
|
||||||
// }
|
|
||||||
// if (getZypper == false)
|
|
||||||
// {
|
|
||||||
// // client.RunCommand("zypper ref");
|
|
||||||
// client.RunCommand("zypper -y install socat");
|
|
||||||
// }
|
|
||||||
// client.RunCommand("curl https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh | INSTALLONLINE=1 sh");
|
|
||||||
// client.RunCommand("cd ~/.acme.sh/");
|
|
||||||
// client.RunCommand("alias acme.sh=~/.acme.sh/acme.sh");
|
|
||||||
|
|
||||||
// currentStatus = "申请域名证书......";
|
|
||||||
// textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
// Thread.Sleep(1000);
|
|
||||||
|
|
||||||
// //client.RunCommand("mkdir -p /etc/v2ray/ssl");
|
|
||||||
// client.RunCommand($"/root/.acme.sh/acme.sh --issue --standalone -d {ReceiveConfigurationParameters[4]}");
|
|
||||||
|
|
||||||
// currentStatus = "安装证书到Trojan......";
|
|
||||||
// textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
// Thread.Sleep(1000);
|
|
||||||
// client.RunCommand($"/root/.acme.sh/acme.sh --installcert -d {ReceiveConfigurationParameters[4]} --certpath /usr/local/etc/trojan/trojan_ssl.crt --keypath /usr/local/etc/trojan/trojan_ssl.key --capath /usr/local/etc/trojan/trojan_ssl.crt --reloadcmd \"systemctl restart trojan\"");
|
|
||||||
//}
|
|
||||||
|
|
||||||
currentStatus = "正在启动NaiveProxy......";
|
currentStatus = "正在启动NaiveProxy......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
@ -2315,9 +2189,7 @@ namespace ProxySU
|
|||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
//安装Caddy
|
|
||||||
//if (serverConfig.Contains("Naiveproxy") == true)
|
|
||||||
//{
|
|
||||||
currentStatus = "正在安装Caddy";
|
currentStatus = "正在安装Caddy";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
@ -2332,21 +2204,15 @@ namespace ProxySU
|
|||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
|
||||||
//if (serverConfig.Contains("Naiveproxy") == true)
|
|
||||||
//{
|
|
||||||
string caddyConfig = "TemplateConfg\\Naiveproxy_server_config.caddyfile";
|
string caddyConfig = "TemplateConfg\\Naiveproxy_server_config.caddyfile";
|
||||||
//}
|
|
||||||
|
|
||||||
upLoadPath = "/etc/caddy/Caddyfile";
|
upLoadPath = "/etc/caddy/Caddyfile";
|
||||||
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
|
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
|
||||||
|
|
||||||
//设置Caddyfile文件中的tls 邮箱
|
//设置Caddyfile文件中的tls 邮箱
|
||||||
|
|
||||||
string email = $"user@{ReceiveConfigurationParameters[4]}";
|
string email = $"user@{ReceiveConfigurationParameters[4]}";
|
||||||
string sshCmd;
|
|
||||||
//设置域名
|
//设置域名
|
||||||
sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}";
|
string sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}";
|
||||||
//MessageBox.Show(sshCmd);
|
//MessageBox.Show(sshCmd);
|
||||||
client.RunCommand(sshCmd);
|
client.RunCommand(sshCmd);
|
||||||
//设置用户名密码
|
//设置用户名密码
|
||||||
@ -2365,10 +2231,8 @@ namespace ProxySU
|
|||||||
//MessageBox.Show(sshCmd);
|
//MessageBox.Show(sshCmd);
|
||||||
client.RunCommand(sshCmd);
|
client.RunCommand(sshCmd);
|
||||||
|
|
||||||
|
|
||||||
//启动Caddy服务
|
//启动Caddy服务
|
||||||
client.RunCommand("caddy -service restart");
|
client.RunCommand("caddy -service restart");
|
||||||
//}
|
|
||||||
|
|
||||||
//生成客户端配置
|
//生成客户端配置
|
||||||
currentStatus = "生成客户端配置......";
|
currentStatus = "生成客户端配置......";
|
||||||
@ -2378,21 +2242,17 @@ namespace ProxySU
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory("naive_config");//创建该文件夹
|
Directory.CreateDirectory("naive_config");//创建该文件夹
|
||||||
}
|
}
|
||||||
//string clientConfig = "TemplateConfg\\tcp_client_config.json";
|
|
||||||
using (StreamReader reader = File.OpenText(clientConfig))
|
using (StreamReader reader = File.OpenText(clientConfig))
|
||||||
{
|
{
|
||||||
JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
|
JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
|
||||||
|
|
||||||
clientJson["proxy"] = $"https://{ReceiveConfigurationParameters[3]}:{ReceiveConfigurationParameters[2]}@{ReceiveConfigurationParameters[4]}";
|
clientJson["proxy"] = $"https://{ReceiveConfigurationParameters[3]}:{ReceiveConfigurationParameters[2]}@{ReceiveConfigurationParameters[4]}";
|
||||||
//clientJson["remote_port"] = int.Parse(ReceiveConfigurationParameters[1]);
|
|
||||||
//clientJson["password"][0] = ReceiveConfigurationParameters[2];
|
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(@"naive_config\config.json"))
|
using (StreamWriter sw = new StreamWriter(@"naive_config\config.json"))
|
||||||
{
|
{
|
||||||
sw.Write(clientJson.ToString());
|
sw.Write(clientJson.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client.Disconnect();
|
client.Disconnect();
|
||||||
|
|
||||||
currentStatus = "安装成功";
|
currentStatus = "安装成功";
|
||||||
@ -2403,7 +2263,6 @@ namespace ProxySU
|
|||||||
//MessageBox.Show("用于Trojan官方客户端的配置文件已保存在config文件夹中");
|
//MessageBox.Show("用于Trojan官方客户端的配置文件已保存在config文件夹中");
|
||||||
NaiveProxyResultInfoWindow resultClientInformation = new NaiveProxyResultInfoWindow();
|
NaiveProxyResultInfoWindow resultClientInformation = new NaiveProxyResultInfoWindow();
|
||||||
resultClientInformation.ShowDialog();
|
resultClientInformation.ShowDialog();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user