1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-25 14:46:08 +03:00

添加Trojan-Go一键安装

This commit is contained in:
ProxySU 2020-06-05 23:27:53 +08:00
parent 8b45bdd222
commit db1ccfed9b
16 changed files with 1033 additions and 166 deletions

View File

@ -134,7 +134,7 @@
<Button x:Name="Button_canel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
</Grid>
</TabItem>
<TabItem Header="Trojan/Trojan-Go" Width="120" Height="30">
<TabItem Header="Trojan" Width="100" Height="30">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
@ -152,7 +152,7 @@
<Button x:Name="ButtonUpdateTrojan" Content="检测/升级Trojan版本" Grid.Column="0" Grid.Row="0" Margin="5" Click="ButtonUpdateTrojan_Click"></Button>
<Button x:Name="ButtonTrojanTemplate" Content="Trojan参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanTemplate_Click"/>
<!--<TextBlock Text="Trojan参数设置" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>-->
<Button x:Name="ButtonTrojanGoTemplate" Content="Trojan-Go参数设置" Grid.Column="2" Grid.Row="0" Margin="5" Click="ButtonTrojanGoTemplate_Click"/>
<!--<Button x:Name="ButtonTrojanGoTemplate" Content="Trojan-Go参数设置" Grid.Column="2" Grid.Row="0" Margin="5" Click="ButtonTrojanGoTemplate_Click"/>-->
<Button x:Name="ButtonTrojanSetUp" Content="Trojan一键安装" Grid.ColumnSpan="1" Margin="10" Grid.Column="0" Grid.Row="2" Click="ButtonTrojanSetUp_Click"/>
@ -277,6 +277,30 @@
<Button x:Name="Button_canel3in1" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
</Grid>
</TabItem>
<TabItem Header="Trojan-Go" Width="100" Height="30">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Button x:Name="ButtonUpdateTrojanGo" Content="检测/升级Trojan-Go版本" Grid.Column="0" Grid.Row="0" Margin="5" Click="ButtonUpdateTrojanGo_Click"></Button>
<!--<Button x:Name="ButtonTrojanTemplate" Content="Trojan参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanTemplate_Click"/>-->
<!--<TextBlock Text="Trojan参数设置" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>-->
<Button x:Name="ButtonTrojanGoTemplate" Content="Trojan-Go参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanGoTemplate_Click"/>
<Button x:Name="ButtonTrojanGoSetUp" Content="Trojan-Go一键安装" Grid.ColumnSpan="1" Margin="10" Grid.Column="0" Grid.Row="2" Click="ButtonTrojanGoSetUp_Click"/>
<Button x:Name="ButtonTrojanGoCancel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
</Grid>
</TabItem>
<TabItem Header="系统工具" Width="100" Height="30">
<Grid>
<Grid.ColumnDefinitions>
@ -387,7 +411,7 @@
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="程序版本1.6.4" Grid.Column="0" Grid.Row="0"></TextBlock>
<TextBlock Text="程序版本1.7.0" Grid.Column="0" Grid.Row="0"></TextBlock>
</Grid>

View File

@ -951,8 +951,8 @@ namespace ProxySU
//如果内核满足大于等于4.9且还未启用BBR则启用BBR
if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false)
{
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"sysctl -p");
}
@ -1363,7 +1363,6 @@ namespace ProxySU
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
//登录远程主机布署Trojan程序
private void StartSetUpTrojan(ConnectionInfo connectionInfo, TextBlock textBlockName, ProgressBar progressBar, string serverConfig, string clientConfig, string upLoadPath)
{
@ -1827,8 +1826,8 @@ namespace ProxySU
//如果内核满足大于等于4.9且还未启用BBR则启用BBR
if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false)
{
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"sysctl -p");
}
@ -1907,7 +1906,8 @@ namespace ProxySU
}
//打开设置TrojanGo的窗口
//打开设置TrojanGo参数窗口
private void ButtonTrojanGoTemplate_Click(object sender, RoutedEventArgs e)
{
for (int i = 0; i != ReceiveConfigurationParameters.Length; i++)
@ -1915,10 +1915,9 @@ namespace ProxySU
{
ReceiveConfigurationParameters[i] = "";
}
TrojanTemplateWindow windowTrojanTemplateConfiguration = new TrojanTemplateWindow();
windowTrojanTemplateConfiguration.ShowDialog();
TrojanGoTemplateWindow windowTrojanGoTemplateConfiguration = new TrojanGoTemplateWindow();
windowTrojanGoTemplateConfiguration.ShowDialog();
}
//Trojan一键安装
private void ButtonTrojanGoSetUp_Click(object sender, RoutedEventArgs e)
{
ConnectionInfo connectionInfo = GenerateConnectionInfo();
@ -1927,29 +1926,48 @@ namespace ProxySU
MessageBox.Show("远程主机连接信息有误,请检查");
return;
}
string serverConfig = ""; //服务端配置文件
string clientConfig = ""; //生成的客户端配置文件
string upLoadPath = "/usr/local/etc/trojan/config.json"; //服务端文件位置
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true)
{
ReceiveConfigurationParameters[4] = TextBoxHost.Text.ToString();
}
string serverConfig = "TemplateConfg\\trojan-go_all_config.json"; //服务端配置文件
string clientConfig = "TemplateConfg\\trojan-go_all_config.json"; //生成的客户端配置文件
string upLoadPath = "/etc/trojan-go/config.json"; //服务端文件位置
//if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == false)
//if(ReceiveConfigurationParameters[0].Contains("TrojanGo")==true)
//{
// serverConfig = "TemplateConfg\\trojan-go_all_config.json";
// clientConfig = "TemplateConfg\\trojan-go_all_config.json";
//}
//else if (String.Equals(ReceiveConfigurationParameters[0], "TrojanGoTLS2Web"))
//{
// serverConfig = "TemplateConfg\\trojan-go_all_config.json";
// clientConfig = "TemplateConfg\\trojan-go_all_config.json";
//}
//else if (String.Equals(ReceiveConfigurationParameters[0], "TrojanGoWebSocketTLS2Web"))
//{
// serverConfig = "TemplateConfg\\trojan-go_all_config.json";
// clientConfig = "TemplateConfg\\trojan-go_all_config.json";
//}
//else
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true)
{
MessageBox.Show("请先选择配置模板!");
MessageBox.Show("未选择配置模板或模板选择错误");
return;
}
else if (String.Equals(ReceiveConfigurationParameters[0], "TrojanTLS2Web"))
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true)
{
serverConfig = "TemplateConfg\\trojan_server_config.json";
clientConfig = "TemplateConfg\\trojan_client_config.json";
MessageBox.Show("空域名,请检查相关参数设置!");
return;
//ReceiveConfigurationParameters[4] = TextBoxHost.Text.ToString();
}
Thread thread = new Thread(() => StartSetUpTrojan(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath));
//else
//{
// MessageBox.Show("空域名,请检查相关参数设置!");
// return;
//}
Thread thread = new Thread(() => StartSetUpTrojanGo(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
//登录远程主机布署Trojan程序
//登录远程主机布署Trojan-Go程序
private void StartSetUpTrojanGo(ConnectionInfo connectionInfo, TextBlock textBlockName, ProgressBar progressBar, string serverConfig, string clientConfig, string upLoadPath)
{
string currentStatus = "正在登录远程主机......";
@ -2004,15 +2022,15 @@ namespace ProxySU
client.Disconnect();
return;
}
//检测是否安装有Trojan
currentStatus = "检测系统是否已经安装Trojan......";
//检测是否安装有Trojan-Go
currentStatus = "检测系统是否已经安装Trojan-Go......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//string cmdTestTrojanInstalled = @"find / -name trojan";
string resultCmdTestTrojanInstalled = client.RunCommand(@"find / -name trojan").Result;
string resultCmdTestTrojanInstalled = client.RunCommand(@"find / -name trojan-go").Result;
if (resultCmdTestTrojanInstalled.Contains("/usr/local/bin/trojan") == true)
if (resultCmdTestTrojanInstalled.Contains("/usr/bin/trojan-go/trojan-go") == true)
{
MessageBoxResult messageBoxResult = MessageBox.Show("远程主机已安装Trojan,是否强制重新安装?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (messageBoxResult == MessageBoxResult.No)
@ -2030,19 +2048,19 @@ namespace ProxySU
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
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)
{
MessageBox.Show($"请在x86_64系统中安装Trojan");
currentStatus = "系统不符合要求,安装失败!!";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
}
//if (resultCmd.Contains("x86_64") == false)
//{
// MessageBox.Show($"请在x86_64系统中安装Trojan");
// currentStatus = "系统不符合要求,安装失败!!";
// textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
// Thread.Sleep(1000);
//}
//检测系统是否支持yum 或 apt-get或zypper且支持Systemd
//如果不存在组件则命令结果为空string.IsNullOrEmpty值为真
@ -2077,9 +2095,9 @@ namespace ProxySU
}
//如果使用如果是WebSocket + TLS + Web/http2/Http2Web/tcp_TLS/WebSocket_TLS模式需要检测域名解析是否正确
if (serverConfig.Contains("trojan_server") == true)
{
//检测域名解析是否正确
//if (serverConfig.Contains("trojan_server") == true)
//{
currentStatus = "正在检测域名是否解析到当前VPS的IP上......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
@ -2127,9 +2145,9 @@ namespace ProxySU
return;
}
}
if (serverConfig.Contains("trojan_server") == true)
{
//}
//if (serverConfig.Contains("trojan_server") == true)
//{
//检测是否安装lsof
if (string.IsNullOrEmpty(client.RunCommand("command -v lsof").Result) == true)
{
@ -2198,7 +2216,7 @@ namespace ProxySU
Thread.Sleep(1000);
}
}
//}
currentStatus = "符合安装要求,布署中......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
@ -2227,24 +2245,24 @@ namespace ProxySU
//下载官方安装脚本安装
client.RunCommand("curl -o /tmp/trojan-quickstart.sh https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh");
client.RunCommand("yes | bash /tmp/trojan-quickstart.sh");
client.RunCommand("curl -o /tmp/trojan-go.sh https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh");
client.RunCommand("bash /tmp/trojan-go.sh -f");
string installResult = client.RunCommand("find / -name trojan").Result.ToString();
string installResult = client.RunCommand("find / -name trojan-go").Result.ToString();
if (!installResult.Contains("/usr/local/bin/trojan"))
if (!installResult.Contains("/usr/bin/trojan-go/trojan-go"))
{
MessageBox.Show("安装Trojan失败(官方脚本运行出错!");
client.Disconnect();
currentStatus = "安装Trojan失败(官方脚本运行出错!";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
client.Disconnect();
return;
}
client.RunCommand("mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.1");
client.RunCommand("mv /etc/trojan-go/config.json /etc/trojan-go/config.json.1");
//上传配置文件
currentStatus = "Trojan程序安装完毕,配置文件上传中......";
currentStatus = "Trojan-Go程序安装完毕,配置文件上传中......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
@ -2252,16 +2270,25 @@ namespace ProxySU
using (StreamReader reader = File.OpenText(serverConfig))
{
JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
serverJson["run_type"] = "server";
serverJson["local_addr"] = "0.0.0.0";
serverJson["local_port"] = 443;
serverJson["remote_addr"] = "127.0.0.1";
serverJson["remote_port"] = 80;
//设置密码
serverJson["password"][0] = ReceiveConfigurationParameters[2];
//设置监听端口
//serverJson["inbounds"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]);
//设置证书
serverJson["ssl"]["cert"] = "/etc/trojan-go/trojan-go.crt";
serverJson["ssl"]["key"] = "/etc/trojan-go/trojan-go.key";
serverJson["ssl"]["cert"] = "/etc/trojan-go/trojan-go.crt";
serverJson["ssl"]["sni"] = ReceiveConfigurationParameters[4];
using (StreamWriter sw = new StreamWriter(@"config.json"))
{
sw.Write(serverJson.ToString());
}
}
upLoadPath = "/etc/trojan-go/config.json";
UploadConfig(connectionInfo, @"config.json", upLoadPath);
File.Delete(@"config.json");
@ -2270,40 +2297,38 @@ namespace ProxySU
string openFireWallPort = ReceiveConfigurationParameters[1];
if (String.IsNullOrEmpty(client.RunCommand("command -v firewall-cmd").Result) == false)
{
if (String.Equals(openFireWallPort, "443"))
{
//if (String.Equals(openFireWallPort, "443"))
//{
client.RunCommand("firewall-cmd --zone=public --add-port=80/tcp --permanent");
client.RunCommand("firewall-cmd --zone=public --add-port=443/tcp --permanent");
client.RunCommand("firewall-cmd --reload");
}
else
{
client.RunCommand($"firewall-cmd --zone=public --add-port={openFireWallPort}/tcp --permanent");
client.RunCommand($"firewall-cmd --zone=public --add-port={openFireWallPort}/udp --permanent");
client.RunCommand("firewall-cmd --reload");
}
//}
//else
//{
// client.RunCommand($"firewall-cmd --zone=public --add-port={openFireWallPort}/tcp --permanent");
// client.RunCommand($"firewall-cmd --zone=public --add-port={openFireWallPort}/udp --permanent");
// client.RunCommand("firewall-cmd --reload");
//}
}
if (String.IsNullOrEmpty(client.RunCommand("command -v ufw").Result) == false)
{
if (String.Equals(openFireWallPort, "443"))
{
//if (String.Equals(openFireWallPort, "443"))
//{
client.RunCommand("ufw allow 80");
client.RunCommand("ufw allow 443");
client.RunCommand("yes | ufw reset");
}
else
{
client.RunCommand($"ufw allow {openFireWallPort}/tcp");
client.RunCommand($"ufw allow {openFireWallPort}/udp");
client.RunCommand("yes | ufw reset");
}
//}
//else
//{
// client.RunCommand($"ufw allow {openFireWallPort}/tcp");
// client.RunCommand($"ufw allow {openFireWallPort}/udp");
// client.RunCommand("yes | ufw reset");
//}
}
if (serverConfig.Contains("trojan_server") == true)
{
currentStatus = "使用Trojan+TLS+Web模式正在安装acme.sh......";
//if (serverConfig.Contains("trojan_server") == true)
//{
currentStatus = "正在安装acme.sh......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
@ -2333,25 +2358,17 @@ namespace ProxySU
//client.RunCommand("mkdir -p /etc/v2ray/ssl");
client.RunCommand($"/root/.acme.sh/acme.sh --issue --standalone -d {ReceiveConfigurationParameters[4]}");
currentStatus = "安装证书到Trojan......";
currentStatus = "安装证书到Trojan-Go......";
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\"");
}
client.RunCommand($"/root/.acme.sh/acme.sh --installcert -d {ReceiveConfigurationParameters[4]} --certpath /etc/trojan-go/trojan-go.crt --keypath /etc/trojan-go/trojan-go.key --capath /etc/trojan-go/trojan-go.crt --reloadcmd \"systemctl restart trojan-go\"");
//}
currentStatus = "正在启动Trojan......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//启动V2ray服务
client.RunCommand("systemctl restart trojan");
currentStatus = "Trojan启动成功";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//安装Caddy
if (serverConfig.Contains("trojan_server") == true)
{
//if (serverConfig.Contains("trojan_server") == true)
//{
currentStatus = "正在安装Caddy";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
@ -2367,10 +2384,10 @@ namespace ProxySU
Thread.Sleep(1000);
string caddyConfig = "";
if (serverConfig.Contains("trojan_server") == true)
{
//if (serverConfig.Contains("trojan_server") == true)
//{
caddyConfig = "TemplateConfg\\trojan_caddy_config.caddyfile";
}
//}
upLoadPath = "/etc/caddy/Caddyfile";
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
@ -2396,11 +2413,28 @@ namespace ProxySU
sshCmd = $"caddy -service install -agree -conf /etc/caddy/Caddyfile -email {email}";
//MessageBox.Show(sshCmd);
client.RunCommand(sshCmd);
//启动Caddy服务
currentStatus = "正在启动Caddy......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//启动V2ray服务
client.RunCommand("caddy -service restart");
}
currentStatus = "Caddy启动成功";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//}
currentStatus = "正在启动Trojan-Go......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//启动V2ray服务
client.RunCommand("systemctl restart trojan-go");
currentStatus = "Trojan启动成功";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//测试BBR条件若满足提示是否启用
var result = client.RunCommand("uname -r");
@ -2412,8 +2446,8 @@ namespace ProxySU
//如果内核满足大于等于4.9且还未启用BBR则启用BBR
if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false)
{
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"sysctl -p");
}
@ -2421,20 +2455,22 @@ namespace ProxySU
currentStatus = "生成客户端配置......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
if (!Directory.Exists("trojan_config"))//如果不存在就创建file文件夹     
if (!Directory.Exists("trojan-go_config"))//如果不存在就创建file文件夹     
{
Directory.CreateDirectory("trojan_config");//创建该文件夹  
Directory.CreateDirectory("trojan-go_config");//创建该文件夹  
}
//string clientConfig = "TemplateConfg\\tcp_client_config.json";
clientConfig = "TemplateConfg\\trojan-go_all_config.json";
using (StreamReader reader = File.OpenText(clientConfig))
{
JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
clientJson["run_type"] = "client";
clientJson["local_addr"] = "127.0.0.1";
clientJson["local_port"] = 1080;
clientJson["remote_addr"] = ReceiveConfigurationParameters[4];
clientJson["remote_port"] = int.Parse(ReceiveConfigurationParameters[1]);
clientJson["remote_port"] = 443;
clientJson["password"][0] = ReceiveConfigurationParameters[2];
using (StreamWriter sw = new StreamWriter(@"trojan_config\config.json"))
using (StreamWriter sw = new StreamWriter(@"trojan-go_config\config.json"))
{
sw.Write(clientJson.ToString());
}
@ -2448,7 +2484,7 @@ namespace ProxySU
//显示服务端连接参数
//MessageBox.Show("用于Trojan官方客户端的配置文件已保存在config文件夹中");
TrojanResultClientInfoWindow resultClientInformation = new TrojanResultClientInfoWindow();
TrojanGoResultClientInfoWindow resultClientInformation = new TrojanGoResultClientInfoWindow();
resultClientInformation.ShowDialog();
return;
@ -2913,41 +2949,41 @@ namespace ProxySU
Thread.Sleep(1000);
//优化网络参数
sshCmd = @"bash - c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'";
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);
sshCmd = @"bash - c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"sysctl -p";
client.RunCommand(sshCmd);
@ -2966,8 +3002,8 @@ namespace ProxySU
//如果内核满足大于等于4.9且还未启用BBR则启用BBR
if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false)
{
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"sysctl -p");
}
@ -3625,6 +3661,202 @@ namespace ProxySU
}
#endregion
}
//检测升级Trojan-Go版本
private void ButtonUpdateTrojanGo_Click(object sender, RoutedEventArgs e)
{
ConnectionInfo connectionInfo = GenerateConnectionInfo();
if (connectionInfo == null)
{
MessageBox.Show("远程主机连接信息有误,请检查");
return;
}
Thread thread = new Thread(() => UpdateTojanGo(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
//升级Trojan主程序
private void UpdateTojanGo(ConnectionInfo connectionInfo, TextBlock textBlockName, ProgressBar progressBar)
{
string currentStatus = "正在登录远程主机......";
Action<TextBlock, ProgressBar, string> updateAction = new Action<TextBlock, ProgressBar, string>(UpdateTextBlock);
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
try
{
#region
//byte[] expectedFingerPrint = new byte[] {
// 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31,
// 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b
// };
#endregion
using (var client = new SshClient(connectionInfo))
{
#region ssh登录验证主机指纹代码块
// client.HostKeyReceived += (sender, e) =>
// {
// if (expectedFingerPrint.Length == e.FingerPrint.Length)
// {
// for (var i = 0; i < expectedFingerPrint.Length; i++)
// {
// if (expectedFingerPrint[i] != e.FingerPrint[i])
// {
// e.CanTrust = false;
// break;
// }
// }
// }
// else
// {
// e.CanTrust = false;
// }
// };
#endregion
client.Connect();
if (client.IsConnected == true)
{
currentStatus = "主机登录成功";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
}
//检测是否运行在root权限下
string testRootAuthority = client.RunCommand(@"id -u").Result;
if (testRootAuthority.Equals("0\n") == false)
{
MessageBox.Show("请使用具有root权限的账户登录主机");
client.Disconnect();
return;
}
//检测远程主机V2ray版本
currentStatus = "检测远程主机Trojan-Go版本......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
string cmdTestTrojanInstalled = @"find / -name trojan-go";
//MessageBox.Show(cmdTestV2rayInstalled);
string resultCmdTestTrojanInstalled = client.RunCommand(cmdTestTrojanInstalled).Result;
//client.Disconnect();
//MessageBox.Show(resultCmdTestV2rayInstalled);
if (resultCmdTestTrojanInstalled.Contains("/usr/bin/trojan-go/trojan-go") == false)
{
MessageBoxResult messageBoxResult = MessageBox.Show("远程主机未安装Trojan-Go");
currentStatus = "未安装Trojan-Go退出";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
client.Disconnect();
return;
}
string sshcmd;
sshcmd = @"echo ""$(/usr/bin/trojan-go/trojan-go -version)"" | head -n 1 | cut -d "" "" -f2";
//MessageBox.Show(sshcmd);
string trojanCurrentVersion = client.RunCommand(sshcmd).Result;//含字母v
//MessageBox.Show(v2rayCurrentVersion);
sshcmd = @"curl -s https://api.github.com/repos/p4gefau1t/trojan-go/tags | grep 'name' | cut -d\"" -f4 | head -1";
//MessageBox.Show(sshcmd);
string trojanNewVersion = client.RunCommand(sshcmd).Result;//含字母v
//MessageBox.Show(v2rayNewVersion);
if (trojanNewVersion.Equals(trojanCurrentVersion) == false)
{
MessageBoxResult messageBoxResult = MessageBox.Show($"远程主机当前版本为v{trojanCurrentVersion}\n最新版本为{trojanNewVersion}\n是否升级为最新版本", "", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (messageBoxResult == MessageBoxResult.No)
{
currentStatus = "升级取消,退出";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
client.Disconnect();
return;
}
else
{
currentStatus = "正在升级Trojan-Go到最新版本......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//备份配置文件
//sshcmd = @"mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.bak";
//client.RunCommand(sshcmd);
//升级Trojan-Go主程序
client.RunCommand("curl -o /tmp/trojan-go.sh https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh");
client.RunCommand("bash /tmp/trojan-go.sh -f");
sshcmd = @"curl -s https://api.github.com/repos/p4gefau1t/trojan-go/tags | grep 'name' | cut -d\"" -f4 | head -1";
//MessageBox.Show(sshcmd);
trojanCurrentVersion = client.RunCommand(sshcmd).Result;//含字母v
if (trojanNewVersion.Equals(trojanCurrentVersion) == true)
{
//恢复原来的配置文件备份
//sshcmd = @"rm -f /usr/local/etc/trojan/config.json";
//client.RunCommand(sshcmd);
//sshcmd = @"mv /usr/local/etc/trojan/config.json.bak /usr/local/etc/trojan/config.json";
//client.RunCommand(sshcmd);
MessageBox.Show($"升级成功!!\n当前版本为v{trojanCurrentVersion}\n最新版本为{trojanNewVersion}");
currentStatus = "升级成功!当前已是最新版本!";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
}
else
{
MessageBox.Show("升级失败,原因未知,请向开发者提问,以寻求支持!");
currentStatus = "升级失败!";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
}
}
}
else
{
MessageBox.Show($"远程主机当前已是最新版本:{trojanNewVersion}\n无需升级");
currentStatus = "已是最新版本,无需升级,退出";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
}
client.Disconnect();
return;
}
}
catch (Exception ex1)//例外处理
#region
{
//MessageBox.Show(ex1.Message);
if (ex1.Message.Contains("连接尝试失败") == true)
{
MessageBox.Show($"{ex1.Message}\n请检查主机地址及端口是否正确如果通过代理请检查代理是否正常工作");
}
else if (ex1.Message.Contains("denied (password)") == true)
{
MessageBox.Show($"{ex1.Message}\n密码错误或用户名错误");
}
else if (ex1.Message.Contains("Invalid private key file") == true)
{
MessageBox.Show($"{ex1.Message}\n所选密钥文件错误或者格式不对");
}
else if (ex1.Message.Contains("denied (publickey)") == true)
{
MessageBox.Show($"{ex1.Message}\n使用密钥登录密钥文件错误或用户名错误");
}
else if (ex1.Message.Contains("目标计算机积极拒绝") == true)
{
MessageBox.Show($"{ex1.Message}\n主机地址错误如果使用了代理也可能是连接代理的端口错误");
}
else
{
MessageBox.Show("发生错误");
MessageBox.Show(ex1.Message);
}
currentStatus = "主机登录失败";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
}
#endregion
}
//生成三合一的v2ray路径
@ -4225,8 +4457,8 @@ namespace ProxySU
//如果内核满足大于等于4.9且还未启用BBR则启用BBR
if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false)
{
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
client.RunCommand(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
client.RunCommand(@"sysctl -p");
}
resultCmdTestBBR = client.RunCommand(@"sysctl net.ipv4.tcp_congestion_control | grep bbr").Result;
@ -4247,41 +4479,41 @@ namespace ProxySU
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
//优化网络参数
sshCmd = @"bash - c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'";
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);
sshCmd = @"bash - c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'";
sshCmd = @"bash -c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'";
client.RunCommand(sshCmd);
sshCmd = @"sysctl -p";
client.RunCommand(sshCmd);

View File

@ -51,5 +51,5 @@ using System.Windows;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.4.0")]
[assembly: AssemblyFileVersion("1.6.4.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]

View File

@ -93,6 +93,12 @@
<Compile Include="TemplateConfiguration.xaml.cs">
<DependentUpon>TemplateConfiguration.xaml</DependentUpon>
</Compile>
<Compile Include="TrojanGoResultClientInfoWindow.xaml.cs">
<DependentUpon>TrojanGoResultClientInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="TrojanGoTemplateWindow.xaml.cs">
<DependentUpon>TrojanGoTemplateWindow.xaml</DependentUpon>
</Compile>
<Compile Include="TrojanResultClientInfoWindow.xaml.cs">
<DependentUpon>TrojanResultClientInfoWindow.xaml</DependentUpon>
</Compile>
@ -127,6 +133,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TrojanGoResultClientInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TrojanGoTemplateWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TrojanResultClientInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -78,7 +78,7 @@
<ColumnDefinition Width="85"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="二维码和vmess链接可用于&#x0a;&#x0a;v2rayN(windows)&#x0a;&#x0a;Shadowrocket(ios)&#x0a;&#x0a;v2rayNG(Android)&#x0a;&#x0a;导入v2ray节点" TextWrapping="Wrap" Grid.Column="0"></TextBlock>
<TextBlock Text="二维码和vmess链接可用于&#x0a;&#x0a;v2rayN(windows)&#x0a;&#x0a;Trojan-QT5(windows)&#x0a;&#x0a;Shadowrocket(ios)&#x0a;&#x0a;v2rayNG(Android)&#x0a;&#x0a;导入v2ray节点" TextWrapping="Wrap" Grid.Column="0"></TextBlock>
<Image x:Name="ImageShareQRcode" Grid.Column="1"></Image>
</Grid>
</Grid>

View File

@ -361,15 +361,16 @@ namespace ProxySU
sw.WriteLine("下载相应版本Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录运行v2ray.exe即可。");
sw.WriteLine("-----------------------------------------");
sw.WriteLine("QR.bmp");
sw.WriteLine("此文件为v2rayN、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点");
sw.WriteLine("此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点");
sw.WriteLine("v2rayN下载网址https://github.com/2dust/v2rayN/releases");
sw.WriteLine("Trojan-QT5https://github.com/Trojan-Qt5/Trojan-Qt5");
sw.WriteLine("v2rayNG(Android)下载网址https://github.com/2dust/v2rayNG/releases");
sw.WriteLine("v2rayNG(Android)在Google Play下载网址https://play.google.com/store/apps/details?id=com.v2ray.ang");
sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。");
sw.WriteLine("-----------------------------------------");
sw.WriteLine("url.txt");
sw.WriteLine("此文件为v2rayN、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址");
sw.WriteLine("此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址");
sw.WriteLine("-----------------------------------------\n");
sw.WriteLine("服务器通用连接配置参数");
sw.WriteLine($"地址(address){TextBoxHostAddress.Text}");

View File

@ -0,0 +1,72 @@
<Window x:Class="ProxySU.TrojanGoResultClientInfoWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU"
mc:Ignorable="d"
Title="TrojanGoResultClientInfoWindow" Height="550" Width="400">
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.7*"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="0.2*"></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Header="服务器连接参数" Grid.Row="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="服务器地址:" Grid.Column="0" Grid.Row="1"></TextBlock>
<TextBox x:Name="TextBoxTrojanServerHost" Grid.Column="1" Grid.Row="1" Margin="4"></TextBox>
<TextBlock Grid.Column="2" Grid.Row="1"></TextBlock>
<TextBlock Text="端口:" Grid.Column="0" Grid.Row="2"></TextBlock>
<TextBox x:Name="TextBoxTrojanServerPort" Grid.Column="1" Grid.Row="2" Margin="4"></TextBox>
<TextBlock Grid.Column="2" Grid.Row="2"></TextBlock>
<TextBlock Text="密钥:" Grid.Column="0" Grid.Row="3"></TextBlock>
<TextBox x:Name="TextBoxTrojanServerPassword" Grid.Column="1" Grid.Row="3" Margin="4"></TextBox>
<TextBlock Grid.Column="2" Grid.Row="3"></TextBlock>
<TextBlock x:Name="TextBlockTrojanGoWebSocketPath" Text="WebSocket路径" Grid.Column="0" Grid.Row="4"></TextBlock>
<TextBox x:Name="TextBoxTrojanGoWSPath" Grid.Column="1" Grid.Row="4" Margin="4"></TextBox>
<TextBlock x:Name="TextBlockTrojanGoCaption" Grid.Column="2" Grid.Row="4"></TextBlock>
</Grid>
</GroupBox>
<GroupBox Header="二维码/URL" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="0.4*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="可用于ShadowRocket (ios)、igniterAndroid、Trojan-QT5 (windows) 扫码和导入url" TextWrapping="Wrap" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"></TextBlock>
<Image x:Name="ImageTrojanShareQRurl" Grid.Column="0" Grid.Row="1"></Image>
<TextBox x:Name="TextBoxTrojanUrl" TextWrapping="Wrap" Grid.Column="1" Grid.Row="1"></TextBox>
</Grid>
</GroupBox>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button x:Name="ButtonTrojanResultOpen" Content="确定" Grid.Column="1" Margin="4" Click="ButtonTrojanResultOpen_Click"></Button>
</Grid>
</Grid>
</Grid>
</Window>

View File

@ -0,0 +1,161 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using Renci.SshNet;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System.Drawing;
using QRCoder;
namespace ProxySU
{
/// <summary>
/// TrojanGoResultClientInfoWindow.xaml 的交互逻辑
/// </summary>
public partial class TrojanGoResultClientInfoWindow : Window
{
private string saveFileFolder = "";
public TrojanGoResultClientInfoWindow()
{
InitializeComponent();
TextBoxTrojanGoWSPath.Visibility = Visibility.Hidden;
TextBlockTrojanGoWebSocketPath.Visibility = Visibility.Hidden;
TextBlockTrojanGoCaption.Visibility = Visibility.Hidden;
//主机地址
TextBoxTrojanServerHost.Text = MainWindow.ReceiveConfigurationParameters[4];
//主机端口
TextBoxTrojanServerPort.Text = "443";
//密钥uuid
TextBoxTrojanServerPassword.Text = MainWindow.ReceiveConfigurationParameters[2];
//WebSocket路径
if (MainWindow.ReceiveConfigurationParameters[0].Equals("TrojanGoWebSocketTLS2Web"))
{
TextBoxTrojanGoWSPath.Text = MainWindow.ReceiveConfigurationParameters[3];
TextBoxTrojanGoWSPath.Visibility = Visibility.Visible;
TextBlockTrojanGoWebSocketPath.Visibility = Visibility.Visible;
TextBlockTrojanGoCaption.Visibility = Visibility.Visible;
}
GenerateV2rayShareQRcodeAndBase64Url();
}
private void GenerateV2rayShareQRcodeAndBase64Url()
{
string saveFileFolderFirst = TextBoxTrojanServerHost.Text;
int num = 1;
saveFileFolder = saveFileFolderFirst;
CheckDir("trojan-go_config");
while (Directory.Exists(@"trojan-go_config\" + saveFileFolder))
{
saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString();
num++;
}
CheckDir(@"trojan-go_config\" + saveFileFolder);
string trojanUrl = $"trojan://{TextBoxTrojanServerPassword.Text}@{TextBoxTrojanServerHost.Text}:{TextBoxTrojanServerPort.Text}?allowinsecure=0&tfo=0&sni=&mux=0&ws=0&group=#{TextBoxTrojanServerHost.Text}";
//MessageBox.Show(v2rayNjsonObject.ToString());
//string trojanUrl = "trojan://" + ToBase64Encode(v2rayNjsonObject.ToString());
TextBoxTrojanUrl.Text = trojanUrl;
using (StreamWriter sw = new StreamWriter($"trojan-go_config\\{saveFileFolder}\\url.txt"))
{
sw.WriteLine(trojanUrl);
}
CreateQRCode(trojanUrl);
//移动Trojan官方程序配置文件到相应目录
if (File.Exists(@"trojan-go_config\config.json"))
{
File.Move(@"trojan-go_config\config.json", @"trojan-go_config\" + saveFileFolder + @"\config.json");
//File.Delete(@"config\config.json");//删除该文件
}
using (StreamWriter sw = new StreamWriter($"trojan-go_config\\{saveFileFolder}\\说明.txt"))
{
sw.WriteLine("config.json");
sw.WriteLine("此文件为Trojan-go官方程序所使用的客户端配置文件配置为全局模式http与socks5地址127.0.0.1:1080");
sw.WriteLine("Trojan-go官方网站https://github.com/p4gefau1t/trojan-go");
sw.WriteLine("Trojan-go官方程序下载地址https://github.com/p4gefau1t/trojan-go/releases");
sw.WriteLine("下载相应版本Windows选择Trojan-x.xx-win.zip,解压后提取trojan.exe。与config.json放在同一目录运行trojan.exe即可。");
sw.WriteLine("-----------------------------------------\n");
sw.WriteLine("QR.bmp");
sw.WriteLine("此文件为Trojan-QT5 (windows)、igniterAndroid、Shadowrocket(ios)扫码导入节点Trojan-Go的WebSocket模式暂不支持");
sw.WriteLine("Trojan-QT5 (windows)下载网址https://github.com/TheWanderingCoel/Trojan-Qt5/releases");
sw.WriteLine("igniterAndroid下载网址https://github.com/trojan-gfw/igniter/releases");
sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。");
sw.WriteLine("-----------------------------------------\n");
sw.WriteLine("url.txt");
sw.WriteLine("此文件为Trojan-QT5 (windows)、igniterAndroid、Shadowrocket(ios)复制粘贴导入节点的网址Trojan-Go的WebSocket模式暂不支持");
sw.WriteLine("-----------------------------------------\n");
sw.WriteLine("服务器通用连接配置参数");
sw.WriteLine($"地址(address){TextBoxTrojanServerHost.Text}");
sw.WriteLine($"端口(Port){TextBoxTrojanServerPort.Text}");
sw.WriteLine($"密钥:{TextBoxTrojanServerPassword.Text}");
sw.WriteLine($"WebSocket路径{TextBoxTrojanGoWSPath.Text}");
}
}
//生成base64
//private string ToBase64Encode(string text)
//{
// if (String.IsNullOrEmpty(text))
// {
// return text;
// }
// byte[] textBytes = Encoding.UTF8.GetBytes(text);
// return Convert.ToBase64String(textBytes);
//}
//生成QRcoder图片
private void CreateQRCode(string varBase64)
{
//string varBase64 = varBase64;
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(varBase64, QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);
IntPtr myImagePtr = qrCodeImage.GetHbitmap();
BitmapSource imgsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(myImagePtr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
ImageTrojanShareQRurl.Source = imgsource;
//DeleteObject(myImagePtr);
qrCodeImage.Save($"trojan-go_config\\{saveFileFolder}\\QR.bmp");
}
//判断目录是否存在,不存在则创建
private static bool CheckDir(string folder)
{
try
{
if (!Directory.Exists(folder))//如果不存在就创建file文件夹
Directory.CreateDirectory(folder);//创建该文件夹  
return true;
}
catch (Exception)
{
return false;
}
}
private void ButtonTrojanResultOpen_Click(object sender, RoutedEventArgs e)
{
string openFolderPath = @"trojan-go_config\" + saveFileFolder;
System.Diagnostics.Process.Start("explorer.exe", openFolderPath);
this.Close();
}
}
}

View File

@ -0,0 +1,115 @@
<Window x:Class="ProxySU.TrojanGoTemplateWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU"
mc:Ignorable="d"
Title="TrojanGoTemplateWindow" Height="450" Width="800">
<Window.Resources>
<Style BasedOn="{StaticResource {x:Type TextBox}}"
TargetType="TextBox"
x:Key="TitleText">
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Text" Value=""/>
<Condition Property="TextBox.IsFocused" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="1" BorderBrush="Gray" Margin="0">
<TextBlock x:Name="MainTextBlock" Text="{TemplateBinding TextBox.Tag}" Width="{TemplateBinding TextBox.ActualWidth}" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</MultiTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.7*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Header="模板库" Grid.Row="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.6*"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="0.5*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<RadioButton x:Name="RadioButtonTrojanGoTLS2Web" Content="Trojan-Go+TLS+Web" Grid.Column="0" Grid.Row="1" Checked="RadioButtonTrojanTLS2Web_Checked"></RadioButton>
<TextBlock Text="说明" Grid.Column="1" Grid.Row="1"></TextBlock>
<RadioButton x:Name="RadioButtonTrojanGoWebSocketTLS2Web" Content="Trojan-Go+WebSocket+TLS+Web" Grid.Column="0" Grid.Row="2" Checked="RadioButtonTrojanGoWebSocketTLS2Web_Checked"></RadioButton>
<TextBlock Text="支持CDN" Grid.Column="1" Grid.Row="2"></TextBlock>
</Grid>
</GroupBox>
<GroupBox Header="其他设置" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="0.4*"></ColumnDefinition>
<ColumnDefinition Width="0.4*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock x:Name="TextBlockDomain" Text="域名:" Grid.Column="0" Grid.Row="0" Margin="5"></TextBlock>
<TextBox x:Name="TextBoxDomain" Style="{StaticResource TitleText}" Tag="不可为空" Grid.Column="1" Grid.Row="0" Margin="5"></TextBox>
<TextBlock Text="端口443" Grid.Column="2" Grid.Row="0" Margin="5"></TextBlock>
<!--<Button x:Name="ButtonDomain" Content="检测" Visibility="Collapsed" Grid.Column="2" Grid.Row="0" Margin="2" Click="ButtonDomain_Click"></Button>-->
<!--<TextBlock x:Name="TextBlockServerListenPort" Text="服务端口:" Grid.Column="0" Grid.Row="1"></TextBlock>
<TextBox x:Name="TextBoxServerListenPort" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
<Button x:Name="ButtonServerListenPort" Content="随机选择" Grid.Column="2" Grid.Row="1" Margin="2" Click="ButtonServerListenPort_Click"></Button>-->
<TextBlock x:Name="TextBlockNewUUID" Text="密码:" Grid.Column="0" Grid.Row="1" ></TextBlock>
<TextBox x:Name="TextBoxNewUUID" Grid.Column="1" Grid.Row="1" Margin="5"></TextBox>
<Button x:Name="ButtonNewUUID" Content="更新" Grid.Column="2" Grid.Row="1" Margin="3" Click="ButtonNewUUID_Click"></Button>
<TextBlock Text="使用已有密码,直接粘贴到框中" TextWrapping="Wrap" Grid.Column="3" Grid.Row="1"></TextBlock>
<TextBlock x:Name="TextBlockPath" Text="WebSocket路径" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"></TextBlock>
<TextBox x:Name="TextBoxPath" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="1" Margin="5"></TextBox>
<Button x:Name="ButtonPath" Content="随机" Grid.Column="2" Grid.Row="2" Margin="2" Click="ButtonPath_Click"></Button>
<TextBlock x:Name="TextBlockMaskSites" Text="伪装网站:" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="设置此项可增加代理的隐蔽(可为空)" Grid.Column="1" Grid.Row="3" Margin="5"></TextBox>
<Grid Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="4">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button x:Name="ButtondDecide" Content="确定" Grid.Column="1" Grid.Row="6" Margin="3" Click="ButtondDecide_Click"></Button>
<Button x:Name="ButtondCancel" Content="取消" Grid.Column="3" Grid.Row="6" Margin="3" Click="ButtondCancel_Click"></Button>
</Grid>
</Grid>
</GroupBox>
</Grid>
</Grid>
</Window>

View File

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ProxySU
{
/// <summary>
/// TrojanGoTemplateWindow.xaml 的交互逻辑
/// </summary>
public partial class TrojanGoTemplateWindow : Window
{
public TrojanGoTemplateWindow()
{
InitializeComponent();
RadioButtonTrojanGoTLS2Web.IsChecked = true;
}
private void ButtondDecide_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(TextBoxDomain.Text.ToString()) == true)
{
MessageBox.Show("域名不能为空!");
return;
}
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
//处理伪装网站域名中的前缀
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
if (TextBoxMaskSites.Text.ToString().Length >= 7)
{
string testDomain = TextBoxMaskSites.Text.Substring(0, 7);
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
{
//MessageBox.Show(testDomain);
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/");
}
else
{
MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text;
}
}
//传递服务端口
MainWindow.ReceiveConfigurationParameters[1] = "443";
//传递密码(uuid)
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();
if (RadioButtonTrojanGoTLS2Web.IsChecked == true)
{
//传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "TrojanGoTLS2Web";
}
else if (RadioButtonTrojanGoWebSocketTLS2Web.IsChecked == true)
{
//传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "TrojanGoWebSocketTLS2Web";
MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text;
}
this.Close();
}
//更新密码
private void ButtonNewUUID_Click(object sender, RoutedEventArgs e)
{
Guid uuid = Guid.NewGuid();
TextBoxNewUUID.Text = uuid.ToString();
}
//更新路径
private void ButtonPath_Click(object sender, RoutedEventArgs e)
{
Random random = new Random();
int randomSerialNum = random.Next(0, 4);
Guid uuid = Guid.NewGuid();
string[] pathArray = uuid.ToString().Split('-');
string path = pathArray[randomSerialNum];
TextBoxPath.Text = $"/{path}";
//MessageBox.Show(path);
}
//private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e)
//{
// Random random = new Random();
// int randomServerPort = random.Next(10000, 50000);
// TextBoxServerListenPort.Text = randomServerPort.ToString();
//}
private void ButtondCancel_Click(object sender, RoutedEventArgs e) => Close();
private void RadioButtonTrojanTLS2Web_Checked(object sender, RoutedEventArgs e)
{
Guid uuid = Guid.NewGuid();
TextBoxNewUUID.Text = uuid.ToString();
TextBlockPath.Visibility = Visibility.Collapsed;
TextBoxPath.Visibility = Visibility.Collapsed;
ButtonPath.Visibility = Visibility.Collapsed;
//Random random = new Random();
//int randomServerPort = random.Next(10000, 50000);
//TextBoxServerListenPort.Text = "443";
}
private void RadioButtonTrojanGoWebSocketTLS2Web_Checked(object sender, RoutedEventArgs e)
{
Guid uuid = Guid.NewGuid();
TextBoxNewUUID.Text = uuid.ToString();
TextBlockPath.Visibility = Visibility.Visible;
TextBoxPath.Visibility = Visibility.Visible;
ButtonPath.Visibility = Visibility.Visible;
TextBoxPath.Text = "/trojan";
}
}
}

View File

@ -39,6 +39,9 @@
<TextBlock Text="密钥:" Grid.Column="0" Grid.Row="3"></TextBlock>
<TextBox x:Name="TextBoxTrojanServerPassword" Grid.Column="1" Grid.Row="3" Margin="4"></TextBox>
<TextBlock Grid.Column="2" Grid.Row="3"></TextBlock>
<!--<TextBlock x:Name="TextBlockTrojanGoWebSocketPath" Text="WebSocket路径" Grid.Column="0" Grid.Row="4"></TextBlock>
<TextBox x:Name="TextBoxTrojanGoWSPath" Grid.Column="1" Grid.Row="4" Margin="4"></TextBox>
<TextBlock x:Name="TextBlockTrojanGoCaption" Grid.Column="2" Grid.Row="4"></TextBlock>-->
</Grid>
</GroupBox>
<GroupBox Header="二维码/URL" Grid.Row="1">

View File

@ -29,13 +29,25 @@ namespace ProxySU
public TrojanResultClientInfoWindow()
{
InitializeComponent();
//TextBoxTrojanGoWSPath.Visibility = Visibility.Hidden;
//TextBlockTrojanGoWebSocketPath.Visibility = Visibility.Hidden;
//TextBlockTrojanGoCaption.Visibility = Visibility.Hidden;
//主机地址
TextBoxTrojanServerHost.Text = MainWindow.ReceiveConfigurationParameters[4];
//主机端口
TextBoxTrojanServerPort.Text = MainWindow.ReceiveConfigurationParameters[1];
TextBoxTrojanServerPort.Text = "443";
//密钥uuid
TextBoxTrojanServerPassword.Text = MainWindow.ReceiveConfigurationParameters[2];
//WebSocket路径
//if (MainWindow.ReceiveConfigurationParameters[0].Equals("TrojanGoWebSocketTLS2Web"))
//{
// TextBoxTrojanGoWSPath.Text = MainWindow.ReceiveConfigurationParameters[3];
// TextBoxTrojanGoWSPath.Visibility = Visibility.Visible;
// TextBlockTrojanGoWebSocketPath.Visibility = Visibility.Visible;
// TextBlockTrojanGoCaption.Visibility = Visibility.Visible;
//}
GenerateV2rayShareQRcodeAndBase64Url();
}

View File

@ -73,15 +73,16 @@
</Grid.RowDefinitions>
<TextBlock x:Name="TextBlockDomain" Text="域名:" Grid.Column="0" Grid.Row="0" ></TextBlock>
<TextBox x:Name="TextBoxDomain" Style="{StaticResource TitleText}" Tag="不可为空" Grid.Column="1" Grid.Row="0" Margin="3"></TextBox>
<TextBlock Text="端口443" Grid.Column="2" Grid.Row="0" Margin="5"></TextBlock>
<!--<Button x:Name="ButtonDomain" Content="检测" Visibility="Collapsed" Grid.Column="2" Grid.Row="0" Margin="2" Click="ButtonDomain_Click"></Button>-->
<TextBlock x:Name="TextBlockServerListenPort" Text="服务端口:" Grid.Column="0" Grid.Row="1"></TextBlock>
<!--<TextBlock x:Name="TextBlockServerListenPort" Text="服务端口:" Grid.Column="0" Grid.Row="1"></TextBlock>
<TextBox x:Name="TextBoxServerListenPort" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
<Button x:Name="ButtonServerListenPort" Content="随机选择" Grid.Column="2" Grid.Row="1" Margin="2" Click="ButtonServerListenPort_Click"></Button>
<Button x:Name="ButtonServerListenPort" Content="随机选择" Grid.Column="2" Grid.Row="1" Margin="2" Click="ButtonServerListenPort_Click"></Button>-->
<TextBlock x:Name="TextBlockNewUUID" Text="密码:" Grid.Column="0" Grid.Row="2" ></TextBlock>
<TextBox x:Name="TextBoxNewUUID" Grid.Column="1" Grid.Row="2" Margin="3"></TextBox>
<Button x:Name="ButtonNewUUID" Content="更新" Grid.Column="2" Grid.Row="2" Margin="3" Click="ButtonNewUUID_Click"></Button>
<TextBlock Text="使用已有密码,直接粘贴到框中" TextWrapping="Wrap" Grid.Column="3" Grid.Row="2"></TextBlock>
<TextBlock x:Name="TextBlockNewUUID" Text="密码:" Grid.Column="0" Grid.Row="1" ></TextBlock>
<TextBox x:Name="TextBoxNewUUID" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
<Button x:Name="ButtonNewUUID" Content="更新" Grid.Column="2" Grid.Row="1" Margin="3" Click="ButtonNewUUID_Click"></Button>
<TextBlock Text="使用已有密码,直接粘贴到框中" TextWrapping="Wrap" Grid.Column="3" Grid.Row="1"></TextBlock>
<TextBlock x:Name="TextBlockMaskSites" Text="伪装网站:" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="设置此项可增加代理的隐蔽(可为空)" Grid.Column="1" Grid.Row="3" Margin="3"></TextBox>
<Grid Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="4">

View File

@ -54,7 +54,7 @@ namespace ProxySU
}
}
//传递服务端口
MainWindow.ReceiveConfigurationParameters[1] = TextBoxServerListenPort.Text.ToString();
MainWindow.ReceiveConfigurationParameters[1] = "443";
//传递密码(uuid)
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();
}
@ -67,12 +67,12 @@ namespace ProxySU
Guid uuid = Guid.NewGuid();
TextBoxNewUUID.Text = uuid.ToString();
}
private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e)
{
Random random = new Random();
int randomServerPort = random.Next(10000, 50000);
TextBoxServerListenPort.Text = randomServerPort.ToString();
}
//private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e)
//{
// Random random = new Random();
// int randomServerPort = random.Next(10000, 50000);
// TextBoxServerListenPort.Text = randomServerPort.ToString();
//}
private void ButtondCancel_Click(object sender, RoutedEventArgs e) => Close();
private void RadioButtonTrojanTLS2Web_Checked(object sender, RoutedEventArgs e)
@ -81,7 +81,7 @@ namespace ProxySU
TextBoxNewUUID.Text = uuid.ToString();
//Random random = new Random();
//int randomServerPort = random.Next(10000, 50000);
TextBoxServerListenPort.Text = "443";
//TextBoxServerListenPort.Text = "443";
}
}
}

Binary file not shown.

View File

@ -0,0 +1,113 @@
{
"run_type": "",
"local_addr": "",
"local_port": "",
"remote_addr": "",
"remote_port": "",
"log_level": 1,
"log_file": "",
"password": [
""
],
"buffer_size": 32,
"dns": [],
"disable_http_check": false,
"ssl": {
"verify": true,
"verify_hostname": true,
"cert": "",
"key": "",
"key_password": "",
"cipher": "",
"cipher_tls13": "",
"curves": "",
"prefer_server_cipher": false,
"sni": "",
"alpn": [
"http/1.1"
],
"session_ticket": true,
"reuse_session": true,
"plain_http_response": "",
"fallback_port": 0,
"fingerprint": "firefox",
"serve_plain_text": false
},
"tcp": {
"no_delay": true,
"keep_alive": true,
"reuse_port": false,
"prefer_ipv4": false,
"fast_open": false,
"fast_open_qlen": 20
},
"mux": {
"enabled": false,
"concurrency": 8,
"idle_timeout": 60
},
"router": {
"enabled": false,
"bypass": [],
"proxy": [],
"block": [],
"default_policy": "proxy",
"domain_strategy": "as_is",
"geoip": "./geoip.dat",
"geosite": "./geosite.dat"
},
"websocket": {
"enabled": false,
"path": "",
"hostname": "",
"obfuscation_password": "",
"double_tls": true,
"ssl": {
"verify": true,
"verify_hostname": true,
"cert": "",
"key": "",
"key_password": "",
"prefer_server_cipher": false,
"sni": "",
"session_ticket": true,
"reuse_session": true,
"plain_http_response": "",
"key_log": ""
}
},
"forward_proxy": {
"enabled": false,
"proxy_addr": "",
"proxy_port": 0,
"username": "",
"password": ""
},
"mysql": {
"enabled": false,
"server_addr": "localhost",
"server_port": 3306,
"database": "",
"username": "",
"password": "",
"check_rate": 60
},
"redis": {
"enabled": false,
"server_addr": "localhost",
"server_port": 6379,
"password": ""
},
"api": {
"enabled": false,
"api_addr": "",
"api_port": 0,
"api_tls": false,
"ssl": {
"cert": "",
"key": "",
"key_password": "",
"client_cert": []
}
}
}