diff --git a/ProxySU/MainWindow.xaml b/ProxySU/MainWindow.xaml
index 9cdc911..08988a8 100644
--- a/ProxySU/MainWindow.xaml
+++ b/ProxySU/MainWindow.xaml
@@ -134,7 +134,7 @@
-
+
@@ -152,7 +152,7 @@
-
+
@@ -277,6 +277,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -387,7 +411,7 @@
-
+
diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs
index 9752945..51275ac 100644
--- a/ProxySU/MainWindow.xaml.cs
+++ b/ProxySU/MainWindow.xaml.cs
@@ -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 updateAction = new Action(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);
diff --git a/ProxySU/Properties/AssemblyInfo.cs b/ProxySU/Properties/AssemblyInfo.cs
index 34e53bb..a5ff342 100644
--- a/ProxySU/Properties/AssemblyInfo.cs
+++ b/ProxySU/Properties/AssemblyInfo.cs
@@ -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")]
diff --git a/ProxySU/ProxySU.csproj b/ProxySU/ProxySU.csproj
index 43271eb..8febe77 100644
--- a/ProxySU/ProxySU.csproj
+++ b/ProxySU/ProxySU.csproj
@@ -93,6 +93,12 @@
TemplateConfiguration.xaml
+
+ TrojanGoResultClientInfoWindow.xaml
+
+
+ TrojanGoTemplateWindow.xaml
+
TrojanResultClientInfoWindow.xaml
@@ -127,6 +133,14 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/ProxySU/ResultClientInformation.xaml b/ProxySU/ResultClientInformation.xaml
index 20d53b7..ebb4d60 100644
--- a/ProxySU/ResultClientInformation.xaml
+++ b/ProxySU/ResultClientInformation.xaml
@@ -78,7 +78,7 @@
-
+
diff --git a/ProxySU/ResultClientInformation.xaml.cs b/ProxySU/ResultClientInformation.xaml.cs
index e8bd9b1..5c87506 100644
--- a/ProxySU/ResultClientInformation.xaml.cs
+++ b/ProxySU/ResultClientInformation.xaml.cs
@@ -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-QT5:https://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}");
diff --git a/ProxySU/TrojanGoResultClientInfoWindow.xaml b/ProxySU/TrojanGoResultClientInfoWindow.xaml
new file mode 100644
index 0000000..7e185ea
--- /dev/null
+++ b/ProxySU/TrojanGoResultClientInfoWindow.xaml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProxySU/TrojanGoResultClientInfoWindow.xaml.cs b/ProxySU/TrojanGoResultClientInfoWindow.xaml.cs
new file mode 100644
index 0000000..619585e
--- /dev/null
+++ b/ProxySU/TrojanGoResultClientInfoWindow.xaml.cs
@@ -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
+{
+ ///
+ /// TrojanGoResultClientInfoWindow.xaml 的交互逻辑
+ ///
+ 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)、igniter(Android)、Shadowrocket(ios)扫码导入节点(Trojan-Go的WebSocket模式暂不支持)");
+ sw.WriteLine("Trojan-QT5 (windows)下载网址:https://github.com/TheWanderingCoel/Trojan-Qt5/releases");
+ sw.WriteLine("igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases");
+ sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。");
+
+ sw.WriteLine("-----------------------------------------\n");
+ sw.WriteLine("url.txt");
+ sw.WriteLine("此文件为Trojan-QT5 (windows)、igniter(Android)、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();
+ }
+ }
+}
diff --git a/ProxySU/TrojanGoTemplateWindow.xaml b/ProxySU/TrojanGoTemplateWindow.xaml
new file mode 100644
index 0000000..c7f5667
--- /dev/null
+++ b/ProxySU/TrojanGoTemplateWindow.xaml
@@ -0,0 +1,115 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProxySU/TrojanGoTemplateWindow.xaml.cs b/ProxySU/TrojanGoTemplateWindow.xaml.cs
new file mode 100644
index 0000000..12c9cc3
--- /dev/null
+++ b/ProxySU/TrojanGoTemplateWindow.xaml.cs
@@ -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
+{
+ ///
+ /// TrojanGoTemplateWindow.xaml 的交互逻辑
+ ///
+ 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";
+ }
+
+
+
+ }
+}
diff --git a/ProxySU/TrojanResultClientInfoWindow.xaml b/ProxySU/TrojanResultClientInfoWindow.xaml
index 87ec6fc..915b6ae 100644
--- a/ProxySU/TrojanResultClientInfoWindow.xaml
+++ b/ProxySU/TrojanResultClientInfoWindow.xaml
@@ -39,6 +39,9 @@
+
diff --git a/ProxySU/TrojanResultClientInfoWindow.xaml.cs b/ProxySU/TrojanResultClientInfoWindow.xaml.cs
index 52e318e..a1080f6 100644
--- a/ProxySU/TrojanResultClientInfoWindow.xaml.cs
+++ b/ProxySU/TrojanResultClientInfoWindow.xaml.cs
@@ -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();
}
diff --git a/ProxySU/TrojanTemplateWindow.xaml b/ProxySU/TrojanTemplateWindow.xaml
index 63bd780..0d05b5d 100644
--- a/ProxySU/TrojanTemplateWindow.xaml
+++ b/ProxySU/TrojanTemplateWindow.xaml
@@ -73,15 +73,16 @@
+
-
+
-
-
-
-
+
+
+
+
diff --git a/ProxySU/TrojanTemplateWindow.xaml.cs b/ProxySU/TrojanTemplateWindow.xaml.cs
index e0f9e99..8fc7b91 100644
--- a/ProxySU/TrojanTemplateWindow.xaml.cs
+++ b/ProxySU/TrojanTemplateWindow.xaml.cs
@@ -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";
}
}
}
diff --git a/ProxySU/bin/Beta/Beta.zip b/ProxySU/bin/Beta/Beta.zip
index 91faeca..7402aad 100644
Binary files a/ProxySU/bin/Beta/Beta.zip and b/ProxySU/bin/Beta/Beta.zip differ
diff --git a/TemplateConfg/trojan-go_all_config.json b/TemplateConfg/trojan-go_all_config.json
new file mode 100644
index 0000000..5a31b5e
--- /dev/null
+++ b/TemplateConfg/trojan-go_all_config.json
@@ -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": []
+ }
+ }
+}
\ No newline at end of file