mirror of
https://github.com/proxysu/ProxySU.git
synced 2025-02-16 22:53:13 +03:00
V2Ray,Trojan\Trojan-Go,Naiveproxy安装优化,全面适配Caddy2
This commit is contained in:
parent
0127ec60dc
commit
d91e6fb667
@ -196,8 +196,8 @@
|
|||||||
<TextBlock Text="密码:" Grid.Column="0" Grid.Row="3"></TextBlock>
|
<TextBlock Text="密码:" Grid.Column="0" Grid.Row="3"></TextBlock>
|
||||||
<TextBox x:Name="TextBoxNaivePassword" Grid.Column="1" Grid.Row="3" Margin="3"></TextBox>
|
<TextBox x:Name="TextBoxNaivePassword" Grid.Column="1" Grid.Row="3" Margin="3"></TextBox>
|
||||||
<Button x:Name="ButtonNaivePassword" Content="更新" Grid.Column="2" Grid.Row="3" Margin="2" Click="ButtonNaivePassword_Click"></Button>
|
<Button x:Name="ButtonNaivePassword" Content="更新" Grid.Column="2" Grid.Row="3" Margin="2" Click="ButtonNaivePassword_Click"></Button>
|
||||||
<TextBlock Text="伪装网站:" Grid.Column="0" Grid.Row="4"></TextBlock>
|
<TextBlock Text="伪装网站:" Grid.Column="0" Grid.Row="4" Visibility="Collapsed"></TextBlock>
|
||||||
<TextBox x:Name="TextBoxNaiveSites" Style="{StaticResource TitleText}" Tag="可以增加代理的隐蔽(可为空)" Grid.Column="1" Grid.Row="4" Margin="3"></TextBox>
|
<TextBox x:Name="TextBoxNaiveSites" Style="{StaticResource TitleText}" Tag="可以增加代理的隐蔽(可为空)" Grid.Column="1" Grid.Row="4" Margin="3" Visibility="Collapsed"></TextBox>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
@ -208,7 +208,7 @@
|
|||||||
<Button x:Name="ButtonNaiveCancel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
|
<Button x:Name="ButtonNaiveCancel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="三合一" Width="100" Height="30">
|
<TabItem Header="三合一" Width="100" Height="30" Visibility="Collapsed">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition></ColumnDefinition>
|
<ColumnDefinition></ColumnDefinition>
|
||||||
@ -410,7 +410,7 @@
|
|||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock Text="程序版本:1.7.3" Grid.Column="0" Grid.Row="0"></TextBlock>
|
<TextBlock Text="程序版本:1.8.0" Grid.Column="0" Grid.Row="0"></TextBlock>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace ProxySU
|
|||||||
public static string[] ReceiveConfigurationParameters { get; set; }
|
public static string[] ReceiveConfigurationParameters { get; set; }
|
||||||
//ReceiveConfigurationParameters[0]----模板类型
|
//ReceiveConfigurationParameters[0]----模板类型
|
||||||
//ReceiveConfigurationParameters[1]----服务端口
|
//ReceiveConfigurationParameters[1]----服务端口
|
||||||
//ReceiveConfigurationParameters[2]----uuid
|
//ReceiveConfigurationParameters[2]----uuid/naive'password
|
||||||
//ReceiveConfigurationParameters[3]----path/naive'user
|
//ReceiveConfigurationParameters[3]----path/naive'user
|
||||||
//ReceiveConfigurationParameters[4]----domain
|
//ReceiveConfigurationParameters[4]----domain
|
||||||
//ReceiveConfigurationParameters[5]----伪装类型
|
//ReceiveConfigurationParameters[5]----伪装类型
|
||||||
@ -332,6 +332,7 @@ namespace ProxySU
|
|||||||
WindowTemplateConfiguration windowTemplateConfiguration = new WindowTemplateConfiguration();
|
WindowTemplateConfiguration windowTemplateConfiguration = new WindowTemplateConfiguration();
|
||||||
windowTemplateConfiguration.ShowDialog();
|
windowTemplateConfiguration.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
//传送V2Ray模板参数,启动V2Ray安装进程
|
//传送V2Ray模板参数,启动V2Ray安装进程
|
||||||
private void Button_Login_Click(object sender, RoutedEventArgs e)
|
private void Button_Login_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
||||||
@ -450,6 +451,7 @@ namespace ProxySU
|
|||||||
//task.Start();
|
//task.Start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//登录远程主机布署V2ray程序
|
//登录远程主机布署V2ray程序
|
||||||
private void StartSetUpV2ray(ConnectionInfo connectionInfo,TextBlock textBlockName, ProgressBar progressBar, string serverConfig,string clientConfig,string upLoadPath)
|
private void StartSetUpV2ray(ConnectionInfo connectionInfo,TextBlock textBlockName, ProgressBar progressBar, string serverConfig,string clientConfig,string upLoadPath)
|
||||||
{
|
{
|
||||||
@ -1133,6 +1135,7 @@ namespace ProxySU
|
|||||||
thread.SetApartmentState(ApartmentState.STA);
|
thread.SetApartmentState(ApartmentState.STA);
|
||||||
thread.Start();
|
thread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
//升级V2ray主程序
|
//升级V2ray主程序
|
||||||
private void UpdateV2ray(ConnectionInfo connectionInfo, TextBlock textBlockName, ProgressBar progressBar)
|
private void UpdateV2ray(ConnectionInfo connectionInfo, TextBlock textBlockName, ProgressBar progressBar)
|
||||||
{
|
{
|
||||||
@ -3217,7 +3220,7 @@ namespace ProxySU
|
|||||||
TextBoxNaiveUser.Text = RandomUserName();
|
TextBoxNaiveUser.Text = RandomUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
//NaiveProxy一键安装开始
|
//NaiveProxy一键安装开始传递参数
|
||||||
private void ButtonNavieSetUp_Click(object sender, RoutedEventArgs e)
|
private void ButtonNavieSetUp_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(TextBoxNaiveHostDomain.Text) == true)
|
if (string.IsNullOrEmpty(TextBoxNaiveHostDomain.Text) == true)
|
||||||
@ -3225,7 +3228,6 @@ namespace ProxySU
|
|||||||
MessageBox.Show("域名不能为空!");
|
MessageBox.Show("域名不能为空!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ReceiveConfigurationParameters[4] = TextBoxNaiveHostDomain.Text;
|
|
||||||
|
|
||||||
ConnectionInfo connectionInfo = GenerateConnectionInfo();
|
ConnectionInfo connectionInfo = GenerateConnectionInfo();
|
||||||
if (connectionInfo == null)
|
if (connectionInfo == null)
|
||||||
@ -3235,7 +3237,7 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
string serverConfig = "TemplateConfg\\Naiveproxy_server_config.json"; //服务端配置文件
|
string serverConfig = "TemplateConfg\\Naiveproxy_server_config.json"; //服务端配置文件
|
||||||
string clientConfig = "TemplateConfg\\Naiveproxy_client_config.json"; //生成的客户端配置文件
|
string clientConfig = "TemplateConfg\\Naiveproxy_client_config.json"; //生成的客户端配置文件
|
||||||
string upLoadPath = "/etc/caddy/Caddyfile"; //Caddy服务端文件位置
|
string upLoadPath = "/etc/caddy/config.json"; //Caddy服务端文件位置
|
||||||
|
|
||||||
//传递参数
|
//传递参数
|
||||||
ReceiveConfigurationParameters[4] = TextBoxNaiveHostDomain.Text;//传递域名
|
ReceiveConfigurationParameters[4] = TextBoxNaiveHostDomain.Text;//传递域名
|
||||||
@ -3316,16 +3318,14 @@ namespace ProxySU
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//检测是否安装有NaiveProxy
|
//检测是否安装有NaiveProxy
|
||||||
currentStatus = "检测系统是否已经安装NaiveProxy......";
|
currentStatus = "检测系统是否已经安装Caddy......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
//string cmdTestTrojanInstalled = @"find / -name trojan";
|
string resultCmdTestTrojanInstalled = client.RunCommand(@"find / -name caddy").Result;
|
||||||
string resultCmdTestTrojanInstalled = client.RunCommand(@"find / -name naive").Result;
|
if (resultCmdTestTrojanInstalled.Contains("/usr/bin/caddy") == true)
|
||||||
|
|
||||||
if (resultCmdTestTrojanInstalled.Contains("/usr/local/bin/naive") == true)
|
|
||||||
{
|
{
|
||||||
MessageBoxResult messageBoxResult = MessageBox.Show("远程主机已安装NaiveProxy,是否强制重新安装?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
MessageBoxResult messageBoxResult = MessageBox.Show("远程主机已安装Caddy,但不确定是否支持forward proxy,是否强制重新安装?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||||
if (messageBoxResult == MessageBoxResult.No)
|
if (messageBoxResult == MessageBoxResult.No)
|
||||||
{
|
{
|
||||||
currentStatus = "安装取消,退出";
|
currentStatus = "安装取消,退出";
|
||||||
@ -3334,6 +3334,13 @@ namespace ProxySU
|
|||||||
client.Disconnect();
|
client.Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentStatus = "正在卸载Caddy";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
//卸载Caddy代码
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测远程主机系统环境是否符合要求
|
//检测远程主机系统环境是否符合要求
|
||||||
@ -3342,11 +3349,6 @@ namespace ProxySU
|
|||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
string resultCmd = client.RunCommand("uname -m").Result;
|
string resultCmd = client.RunCommand("uname -m").Result;
|
||||||
//var result = client.RunCommand("cat /root/test.ver");
|
|
||||||
//string[] linuxKernelVerStr = resultCmd.Split('-');
|
|
||||||
|
|
||||||
//bool detectResult = DetectKernelVersion(linuxKernelVerStr[0]);
|
|
||||||
|
|
||||||
if (resultCmd.Contains("x86_64") == false)
|
if (resultCmd.Contains("x86_64") == false)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"请在x86_64系统中安装NaiveProxy");
|
MessageBox.Show($"请在x86_64系统中安装NaiveProxy");
|
||||||
@ -3355,17 +3357,18 @@ namespace ProxySU
|
|||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测系统是否支持yum 或 apt-get或zypper,且支持Systemd
|
//检测系统是否支持dnf\yum 或 apt或zypper,且支持Systemd
|
||||||
//如果不存在组件,则命令结果为空,string.IsNullOrEmpty值为真,
|
//如果不存在组件,则命令结果为空,string.IsNullOrEmpty值为真,
|
||||||
bool getApt = String.IsNullOrEmpty(client.RunCommand("command -v apt-get").Result);
|
bool getApt = String.IsNullOrEmpty(client.RunCommand("command -v apt").Result);
|
||||||
|
bool getDnf = String.IsNullOrEmpty(client.RunCommand("command -v dnf").Result);
|
||||||
bool getYum = String.IsNullOrEmpty(client.RunCommand("command -v yum").Result);
|
bool getYum = String.IsNullOrEmpty(client.RunCommand("command -v yum").Result);
|
||||||
bool getZypper = String.IsNullOrEmpty(client.RunCommand("command -v zypper").Result);
|
bool getZypper = String.IsNullOrEmpty(client.RunCommand("command -v zypper").Result);
|
||||||
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);
|
||||||
|
|
||||||
//没有安装apt-get,也没有安装yum,也没有安装zypper,或者没有安装systemd的,不满足安装条件
|
//没有安装apt,也没有安装dnf\yum,也没有安装zypper,或者没有安装systemd的,不满足安装条件
|
||||||
//也就是apt-get ,yum, zypper必须安装其中之一,且必须安装Systemd的系统才能安装。
|
//也就是apt,dnf\yum, zypper必须安装其中之一,且必须安装Systemd的系统才能安装。
|
||||||
if ((getApt && getYum && getZypper) || getSystemd)
|
if ((getApt && getDnf && getYum && getZypper) || getSystemd)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"系统缺乏必要的安装组件如:apt-get||yum||zypper||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本");
|
MessageBox.Show($"系统缺乏必要的安装组件如:apt-get||yum||zypper||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本");
|
||||||
currentStatus = "系统环境不满足要求,安装失败!!";
|
currentStatus = "系统环境不满足要求,安装失败!!";
|
||||||
@ -3378,10 +3381,8 @@ namespace ProxySU
|
|||||||
if (getGetenforce == false)
|
if (getGetenforce == false)
|
||||||
{
|
{
|
||||||
string testSELinux = client.RunCommand("getenforce").Result;
|
string testSELinux = client.RunCommand("getenforce").Result;
|
||||||
//MessageBox.Show(testSELinux);
|
|
||||||
if (testSELinux.Contains("Enforcing") == true)
|
if (testSELinux.Contains("Enforcing") == true)
|
||||||
{
|
{
|
||||||
//MessageBox.Show("Enforcing");
|
|
||||||
client.RunCommand("setenforce 0");//不重启改为Permissive模式
|
client.RunCommand("setenforce 0");//不重启改为Permissive模式
|
||||||
client.RunCommand("sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config");//重启也工作在Permissive模式下
|
client.RunCommand("sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config");//重启也工作在Permissive模式下
|
||||||
}
|
}
|
||||||
@ -3390,18 +3391,18 @@ namespace ProxySU
|
|||||||
//安装所需软件
|
//安装所需软件
|
||||||
if (getApt == false)
|
if (getApt == false)
|
||||||
{
|
{
|
||||||
client.RunCommand("apt-get -qq update");
|
client.RunCommand("apt -qq update");
|
||||||
client.RunCommand("apt-get -y -qq install curl libnss3 xz-utils lsof");
|
client.RunCommand("apt -y -qq install curl libnss3 xz-utils lsof unzip");
|
||||||
}
|
}
|
||||||
if (getYum == false)
|
if (getYum == false)
|
||||||
{
|
{
|
||||||
client.RunCommand("yum -q makecache");
|
client.RunCommand("yum -q makecache");
|
||||||
client.RunCommand("yum -y -q install curl nss xz lsof");
|
client.RunCommand("yum -y -q install curl nss xz lsof unzip");
|
||||||
}
|
}
|
||||||
if (getZypper == false)
|
if (getZypper == false)
|
||||||
{
|
{
|
||||||
client.RunCommand("zypper ref");
|
client.RunCommand("zypper ref");
|
||||||
client.RunCommand("zypper -y install curl nss xz lsof");
|
client.RunCommand("zypper -y install curl nss xz lsof unzip");
|
||||||
}
|
}
|
||||||
|
|
||||||
currentStatus = "正在检测域名是否解析到当前VPS的IP上......";
|
currentStatus = "正在检测域名是否解析到当前VPS的IP上......";
|
||||||
@ -3410,11 +3411,8 @@ namespace ProxySU
|
|||||||
|
|
||||||
|
|
||||||
string nativeIp = client.RunCommand("curl -4 ip.sb").Result.ToString();
|
string nativeIp = client.RunCommand("curl -4 ip.sb").Result.ToString();
|
||||||
//MessageBox.Show(nativeIp);
|
|
||||||
string testDomainCmd = "ping " + ReceiveConfigurationParameters[4] + " -c 1 | grep -oE -m1 \"([0-9]{1,3}\\.){3}[0-9]{1,3}\"";
|
string testDomainCmd = "ping " + ReceiveConfigurationParameters[4] + " -c 1 | grep -oE -m1 \"([0-9]{1,3}\\.){3}[0-9]{1,3}\"";
|
||||||
//MessageBox.Show(testDomainCmd);
|
|
||||||
string resultTestDomainCmd = client.RunCommand(testDomainCmd).Result.ToString();
|
string resultTestDomainCmd = client.RunCommand(testDomainCmd).Result.ToString();
|
||||||
//MessageBox.Show(resultTestDomainCmd);
|
|
||||||
if (String.Equals(nativeIp, resultTestDomainCmd) == true)
|
if (String.Equals(nativeIp, resultTestDomainCmd) == true)
|
||||||
{
|
{
|
||||||
currentStatus = "解析正确!";
|
currentStatus = "解析正确!";
|
||||||
@ -3453,12 +3451,9 @@ namespace ProxySU
|
|||||||
|
|
||||||
string cmdTestPort = @"lsof -n -P -i :443 | grep LISTEN";
|
string cmdTestPort = @"lsof -n -P -i :443 | grep LISTEN";
|
||||||
string cmdResult = client.RunCommand(cmdTestPort).Result;
|
string cmdResult = client.RunCommand(cmdTestPort).Result;
|
||||||
//MessageBox.Show(cmdTestPort);
|
|
||||||
if (String.IsNullOrEmpty(cmdResult) == false)
|
if (String.IsNullOrEmpty(cmdResult) == false)
|
||||||
{
|
{
|
||||||
//MessageBox.Show(cmdResult);
|
|
||||||
string[] cmdResultArry443 = cmdResult.Split(' ');
|
string[] cmdResultArry443 = cmdResult.Split(' ');
|
||||||
//MessageBox.Show(cmdResultArry443[3]);
|
|
||||||
client.RunCommand($"systemctl stop {cmdResultArry443[0]}");
|
client.RunCommand($"systemctl stop {cmdResultArry443[0]}");
|
||||||
client.RunCommand($"systemctl disable {cmdResultArry443[0]}");
|
client.RunCommand($"systemctl disable {cmdResultArry443[0]}");
|
||||||
client.RunCommand($"kill -9 {cmdResultArry443[3]}");
|
client.RunCommand($"kill -9 {cmdResultArry443[3]}");
|
||||||
@ -3476,38 +3471,12 @@ namespace ProxySU
|
|||||||
currentStatus = "80/443端口释放完毕!";
|
currentStatus = "80/443端口释放完毕!";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
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);
|
||||||
|
|
||||||
//下载安装脚本安装
|
|
||||||
|
|
||||||
client.RunCommand("curl -o /tmp/naive-quickstart.sh https://raw.githubusercontent.com/proxysu/shellscript/master/naive-quickstart.sh");
|
|
||||||
client.RunCommand("yes | bash /tmp/naive-quickstart.sh");
|
|
||||||
|
|
||||||
string installResult = client.RunCommand("find / -name naive").Result.ToString();
|
|
||||||
|
|
||||||
if (!installResult.Contains("/usr/local/bin/naive"))
|
|
||||||
{
|
|
||||||
MessageBox.Show("安装NaiveProxy失败(脚本运行出错!");
|
|
||||||
client.Disconnect();
|
|
||||||
currentStatus = "安装NaiveProxy失败(脚本运行出错!";
|
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
client.Disconnect();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//上传配置文件
|
|
||||||
currentStatus = "NaiveProxy程序安装完毕......";
|
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//打开防火墙端口
|
//打开防火墙端口
|
||||||
string openFireWallPort = "443";//ReceiveConfigurationParameters[1];
|
string openFireWallPort = "443";//ReceiveConfigurationParameters[1];
|
||||||
if (String.IsNullOrEmpty(client.RunCommand("command -v firewall-cmd").Result) == false)
|
if (String.IsNullOrEmpty(client.RunCommand("command -v firewall-cmd").Result) == false)
|
||||||
@ -3541,72 +3510,118 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentStatus = "正在启动NaiveProxy......";
|
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
//启动V2ray服务
|
|
||||||
client.RunCommand("systemctl restart naive");
|
|
||||||
|
|
||||||
currentStatus = "NaivePrxoy启动成功!";
|
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
|
|
||||||
|
|
||||||
currentStatus = "正在安装Caddy";
|
currentStatus = "正在安装Caddy";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
client.RunCommand("curl https://getcaddy.com -o getcaddy");
|
//安装Caddy
|
||||||
client.RunCommand("bash getcaddy personal hook.service,http.forwardproxy");
|
//为假则表示系统有相应的组件。
|
||||||
client.RunCommand("mkdir -p /etc/caddy");
|
if (getApt == false)
|
||||||
client.RunCommand("mkdir -p /var/www");
|
{
|
||||||
|
client.RunCommand(@"echo ""deb [trusted=yes] https://apt.fury.io/caddy/ /"" | tee -a /etc/apt/sources.list.d/caddy-fury.list");
|
||||||
|
client.RunCommand("apt install -y apt-transport-https");
|
||||||
|
client.RunCommand("apt -qq update");
|
||||||
|
client.RunCommand("apt -y -qq install caddy");
|
||||||
|
}
|
||||||
|
else if (getDnf == false)
|
||||||
|
{
|
||||||
|
client.RunCommand(@"dnf install 'dnf-command(copr)' -y");
|
||||||
|
client.RunCommand(@"dnf copr enable @caddy/caddy -y");
|
||||||
|
//client.RunCommand("dnf -q makecache");
|
||||||
|
client.RunCommand("dnf -y -q install caddy");
|
||||||
|
}
|
||||||
|
else if (getYum == false)
|
||||||
|
{
|
||||||
|
client.RunCommand(@"yum install yum-plugin-copr -y");
|
||||||
|
client.RunCommand(@"yum copr enable @caddy/caddy -y");
|
||||||
|
//client.RunCommand("yum -q makecache");
|
||||||
|
client.RunCommand("yum -y -q install caddy");
|
||||||
|
}
|
||||||
|
//else if (getZypper == false)
|
||||||
|
//{
|
||||||
|
// client.RunCommand("zypper ref");
|
||||||
|
// client.RunCommand("zypper -y install curl");
|
||||||
|
//}
|
||||||
|
string installResult = client.RunCommand("find / -name caddy").Result.ToString();
|
||||||
|
|
||||||
|
if (!installResult.Contains("/usr/bin/caddy"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("安装Caddy失败!");
|
||||||
|
|
||||||
|
currentStatus = "安装Caddy失败!退出";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
client.Disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentStatus = "Caddy安装成功!";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
client.RunCommand("systemctl enable caddy");
|
||||||
|
}
|
||||||
|
|
||||||
|
//使用带插件的Caddy替换
|
||||||
|
currentStatus = "正在为NaiveProxy升级服务端!";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
client.RunCommand(@"curl -o /tmp/caddy.zip https://raw.githubusercontent.com/proxysu/Resources/master/Caddy2/caddy20200816.zip");
|
||||||
|
client.RunCommand(@"unzip /tmp/caddy.zip"); //解压到当前目录 ~/
|
||||||
|
client.RunCommand(@"chmod +x caddy");
|
||||||
|
client.RunCommand(@"systemctl stop caddy;rm -f /usr/bin/caddy");
|
||||||
|
client.RunCommand(@"cp ./caddy /usr/bin/");
|
||||||
|
|
||||||
|
|
||||||
currentStatus = "上传Caddy配置文件......";
|
currentStatus = "上传Caddy配置文件......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
string caddyConfig = "TemplateConfg\\Naiveproxy_server_config.caddyfile";
|
//生成服务端配置
|
||||||
upLoadPath = "/etc/caddy/Caddyfile";
|
|
||||||
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
|
|
||||||
|
|
||||||
//设置Caddyfile文件中的tls 邮箱
|
//string email = $"user@{ReceiveConfigurationParameters[4]}";//生成Caddyfile文件中的tls 邮箱
|
||||||
string email = $"user@{ReceiveConfigurationParameters[4]}";
|
string caddyConfig = "TemplateConfg\\Naiveproxy_server_config.json";
|
||||||
|
using (StreamReader reader = File.OpenText(caddyConfig))
|
||||||
//设置域名
|
|
||||||
string sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}";
|
|
||||||
client.RunCommand(sshCmd);
|
|
||||||
//MessageBox.Show(sshCmd);
|
|
||||||
|
|
||||||
//设置TLS邮箱
|
|
||||||
sshCmd = $"sed -i 's/off/{email}/' {upLoadPath}";
|
|
||||||
client.RunCommand(sshCmd);
|
|
||||||
//设置用户名密码
|
|
||||||
sshCmd = $"sed -i 's/##basicauth##/basicauth {ReceiveConfigurationParameters[3]} {ReceiveConfigurationParameters[2]}/' {upLoadPath}";
|
|
||||||
client.RunCommand(sshCmd);
|
|
||||||
//设置伪装网站
|
|
||||||
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
|
|
||||||
{
|
{
|
||||||
sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
|
JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
|
||||||
//MessageBox.Show(sshCmd);
|
serverJson["apps"]["http"]["servers"]["srv0"]["routes"][0]["handle"][0]["auth_user"] = ReceiveConfigurationParameters[3];//----用户名
|
||||||
client.RunCommand(sshCmd);
|
serverJson["apps"]["http"]["servers"]["srv0"]["routes"][0]["handle"][0]["auth_pass"] = ReceiveConfigurationParameters[2]; //----密码
|
||||||
|
|
||||||
|
serverJson["apps"]["http"]["servers"]["srv0"]["routes"][1]["match"][0]["host"][0] = ReceiveConfigurationParameters[4]; //----域名
|
||||||
|
|
||||||
|
serverJson["apps"]["http"]["servers"]["srv0"]["tls_connection_policies"][0]["match"]["sni"][0] = ReceiveConfigurationParameters[4]; //----域名
|
||||||
|
|
||||||
|
serverJson["apps"]["tls"]["automation"]["policies"][0]["subjects"][0] = ReceiveConfigurationParameters[4]; //-----域名
|
||||||
|
serverJson["apps"]["tls"]["automation"]["policies"][0]["issuer"]["email"] = $"user@{ReceiveConfigurationParameters[4]}"; //-----邮箱
|
||||||
|
//保存配置文件
|
||||||
|
using (StreamWriter sw = new StreamWriter(@"config.json"))
|
||||||
|
{
|
||||||
|
sw.Write(serverJson.ToString());
|
||||||
}
|
}
|
||||||
Thread.Sleep(2000);
|
}
|
||||||
|
upLoadPath = "/etc/caddy/config.json";
|
||||||
|
UploadConfig(connectionInfo, @"config.json", upLoadPath);
|
||||||
|
|
||||||
//安装Caddy服务
|
File.Delete(@"config.json");
|
||||||
sshCmd = $"caddy -service install -agree -conf /etc/caddy/Caddyfile -email {email}";
|
|
||||||
//MessageBox.Show(sshCmd);
|
|
||||||
client.RunCommand(sshCmd);
|
|
||||||
|
|
||||||
//启动Caddy服务
|
client.RunCommand(@"sed -i 's/Caddyfile/config.json/' /lib/systemd/system/caddy.service");
|
||||||
client.RunCommand("caddy -service restart");
|
client.RunCommand("systemctl daemon-reload");
|
||||||
|
client.RunCommand("systemctl restart caddy"); //启动Caddy服务
|
||||||
|
////设置伪装网站
|
||||||
|
//if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
|
||||||
|
//{
|
||||||
|
// sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
|
||||||
|
// //MessageBox.Show(sshCmd);
|
||||||
|
// client.RunCommand(sshCmd);
|
||||||
|
//}
|
||||||
|
//Thread.Sleep(2000);
|
||||||
|
|
||||||
currentStatus = "正在优化网络参数......";
|
currentStatus = "正在优化网络参数......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
//优化网络参数
|
//优化网络参数
|
||||||
sshCmd = @"bash -c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'";
|
string sshCmd = @"bash -c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'";
|
||||||
client.RunCommand(sshCmd);
|
client.RunCommand(sshCmd);
|
||||||
sshCmd = @"bash -c 'echo ""net.core.rmem_max = 67108864"" >> /etc/sysctl.conf'";
|
sshCmd = @"bash -c 'echo ""net.core.rmem_max = 67108864"" >> /etc/sysctl.conf'";
|
||||||
client.RunCommand(sshCmd);
|
client.RunCommand(sshCmd);
|
||||||
@ -3651,7 +3666,6 @@ namespace ProxySU
|
|||||||
|
|
||||||
//测试BBR条件,若满足提示是否启用
|
//测试BBR条件,若满足提示是否启用
|
||||||
var result = client.RunCommand("uname -r");
|
var result = client.RunCommand("uname -r");
|
||||||
//var result = client.RunCommand("cat /root/test.ver");
|
|
||||||
string[] linuxKernelVerStr = result.Result.Split('-');
|
string[] linuxKernelVerStr = result.Result.Split('-');
|
||||||
|
|
||||||
bool detectResult = DetectKernelVersionBBR(linuxKernelVerStr[0]);
|
bool detectResult = DetectKernelVersionBBR(linuxKernelVerStr[0]);
|
||||||
|
@ -8,7 +8,7 @@ using System.Windows;
|
|||||||
// 控制。更改这些特性值可修改
|
// 控制。更改这些特性值可修改
|
||||||
// 与程序集关联的信息。
|
// 与程序集关联的信息。
|
||||||
[assembly: AssemblyTitle("ProxySU")]
|
[assembly: AssemblyTitle("ProxySU")]
|
||||||
[assembly: AssemblyDescription("V2ray,Trojan,NaiveProxy一键安装工具")]
|
[assembly: AssemblyDescription("V2ray,Trojan,NaiveProxy,Trojan-Go一键安装工具")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("ProxySU")]
|
[assembly: AssemblyCompany("ProxySU")]
|
||||||
[assembly: AssemblyProduct("ProxySU")]
|
[assembly: AssemblyProduct("ProxySU")]
|
||||||
@ -51,5 +51,5 @@ using System.Windows;
|
|||||||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||||
// 方法是按如下所示使用“*”: :
|
// 方法是按如下所示使用“*”: :
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.7.3.0")]
|
[assembly: AssemblyVersion("1.8.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.7.3.0")]
|
[assembly: AssemblyFileVersion("1.8.0.0")]
|
||||||
|
Binary file not shown.
@ -1,14 +0,0 @@
|
|||||||
##domain## {
|
|
||||||
log stdout
|
|
||||||
errors stderr
|
|
||||||
root /var/www
|
|
||||||
tls off
|
|
||||||
##sites##
|
|
||||||
forwardproxy {
|
|
||||||
##basicauth##
|
|
||||||
probe_resistance
|
|
||||||
hide_ip
|
|
||||||
hide_via
|
|
||||||
upstream http://127.0.0.1:8383
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,69 @@
|
|||||||
{
|
{
|
||||||
"listen": "http://127.0.0.1:8383",
|
"apps": {
|
||||||
"padding": true
|
"http": {
|
||||||
|
"servers": {
|
||||||
|
"srv0": {
|
||||||
|
"listen": [
|
||||||
|
":443"
|
||||||
|
],
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"handle": [
|
||||||
|
{
|
||||||
|
"handler": "forward_proxy",
|
||||||
|
"hide_ip": true,
|
||||||
|
"hide_via": true,
|
||||||
|
"auth_user": "",
|
||||||
|
"auth_pass": "",
|
||||||
|
"probe_resistance": {
|
||||||
|
"domain": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": [
|
||||||
|
{
|
||||||
|
"host": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"handle": [
|
||||||
|
{
|
||||||
|
"handler": "file_server",
|
||||||
|
"root": "/usr/share/caddy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"terminal": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tls_connection_policies": [
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
"sni": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tls": {
|
||||||
|
"automation": {
|
||||||
|
"policies": [
|
||||||
|
{
|
||||||
|
"subjects": [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"issuer": {
|
||||||
|
"email": "",
|
||||||
|
"module": "acme"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user