mirror of
https://github.com/proxysu/ProxySU.git
synced 2025-02-17 23:13:18 +03:00
添加Trojan一键安装2
This commit is contained in:
parent
57291b5397
commit
194ecc78c1
@ -174,7 +174,7 @@
|
|||||||
<Button x:Name="ButtonClearOccupiedPorts" Content="释放80/443端口" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonClearOccupiedPorts_Click"></Button>
|
<Button x:Name="ButtonClearOccupiedPorts" Content="释放80/443端口" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonClearOccupiedPorts_Click"></Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<!--<TabItem Header="测试面板" Visibility="Visible" Width="150" Height="30">
|
<TabItem Header="测试面板" Visibility="Visible" Width="150" Height="30">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition></ColumnDefinition>
|
<ColumnDefinition></ColumnDefinition>
|
||||||
@ -182,23 +182,15 @@
|
|||||||
<ColumnDefinition></ColumnDefinition>
|
<ColumnDefinition></ColumnDefinition>
|
||||||
<ColumnDefinition></ColumnDefinition>
|
<ColumnDefinition></ColumnDefinition>
|
||||||
<ColumnDefinition></ColumnDefinition>
|
<ColumnDefinition></ColumnDefinition>
|
||||||
<ColumnDefinition></ColumnDefinition>
|
|
||||||
<ColumnDefinition></ColumnDefinition>
|
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
--><!--<Button Content="更改SELinux模式" Grid.Column="0" Grid.Row="0" Margin="10" Click="Button_Click"></Button>-->
|
<Button x:Name="ButtonTestTrojanClientInfoWin" Content="测试Trojan结果窗口" Click="ButtonTestTrojanClientInfoWin_Click"></Button>
|
||||||
<!--<Button x:Name="testresultClientInform" Content="测试结果窗口" Grid.Column="0" Grid.Row="1" Margin="5" Click="TestresultClientInform_Click"></Button>
|
|
||||||
<Button x:Name="testPortOccupy" Content="测试端口占用" Grid.Column="0" Grid.Row="2" Margin="5" Click="TestPortOccupy_Click"></Button>
|
|
||||||
<Button x:Name="testInstalledV2ray" Content="测试是否安装V2ray" Grid.Column="1" Grid.Row="0" Margin="5" Click="TestInstalledV2ray_Click"></Button>
|
|
||||||
<Button x:Name="testsshCmd" Content="测试ssh命令" Grid.Column="1" Grid.Row="1" Margin="5" Click="TestsshCmd_Click"></Button>-->
|
|
||||||
<!--<Button Content="测试数组赋值" Grid.Column="2" Grid.Row="0" Margin="5" Click="Button_Click"></Button>--><!--
|
|
||||||
<Button Content="test" Click="Button_Click_1"></Button>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>-->
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1323,7 +1323,7 @@ namespace ProxySU
|
|||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
//检测是否安装有Trojan
|
//检测是否安装有Trojan
|
||||||
currentStatus = "检测系统是否已经安装V2ray......";
|
currentStatus = "检测系统是否已经安装Trojan......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
@ -1422,10 +1422,12 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
|
|
||||||
string nativeIp = client.RunCommand("curl -4 ip.sb").Result.ToString();
|
string nativeIp = client.RunCommand("curl -4 ip.sb").Result.ToString();
|
||||||
|
//MessageBox.Show(nativeIp);
|
||||||
string testDomainCmd = "ping " + ReceiveConfigurationParameters[4] + " -c 1 | grep -oE -m1 \"([0-9]{1,3}\\.){3}[0-9]{1,3}\"";
|
string testDomainCmd = "ping " + ReceiveConfigurationParameters[4] + " -c 1 | grep -oE -m1 \"([0-9]{1,3}\\.){3}[0-9]{1,3}\"";
|
||||||
|
//MessageBox.Show(testDomainCmd);
|
||||||
string resultTestDomainCmd = client.RunCommand(testDomainCmd).Result.ToString();
|
string resultTestDomainCmd = client.RunCommand(testDomainCmd).Result.ToString();
|
||||||
|
//MessageBox.Show(resultTestDomainCmd);
|
||||||
if (String.Equals(nativeIp, resultCmd) == true)
|
if (String.Equals(nativeIp, resultTestDomainCmd) == true)
|
||||||
{
|
{
|
||||||
currentStatus = "解析正确!";
|
currentStatus = "解析正确!";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
@ -1505,7 +1507,8 @@ namespace ProxySU
|
|||||||
|
|
||||||
//下载官方安装脚本安装
|
//下载官方安装脚本安装
|
||||||
|
|
||||||
client.RunCommand("bash -c \"$(curl - fsSL https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh)\"");
|
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("bash /tmp/go.sh -f");
|
//client.RunCommand("bash /tmp/go.sh -f");
|
||||||
string installResult = client.RunCommand("find / -name trojan").Result.ToString();
|
string installResult = client.RunCommand("find / -name trojan").Result.ToString();
|
||||||
|
|
||||||
@ -1575,62 +1578,7 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//安装nginx
|
|
||||||
if (serverConfig.Contains("trojan_server") == true)
|
|
||||||
{
|
|
||||||
currentStatus = "正在安装Caddy";
|
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
|
|
||||||
client.RunCommand("curl https://getcaddy.com -o getcaddy");
|
|
||||||
client.RunCommand("bash getcaddy personal hook.service");
|
|
||||||
client.RunCommand("mkdir -p /etc/caddy");
|
|
||||||
client.RunCommand("mkdir -p /var/www");
|
|
||||||
|
|
||||||
|
|
||||||
currentStatus = "上传Caddy配置文件......";
|
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
if (serverConfig.Contains("trojan_server") == true)
|
|
||||||
{
|
|
||||||
serverConfig = "TemplateConfg\\trojan_caddy_config.caddyfile";
|
|
||||||
}
|
|
||||||
|
|
||||||
upLoadPath = "/etc/caddy/Caddyfile";
|
|
||||||
UploadConfig(connectionInfo, serverConfig, upLoadPath);
|
|
||||||
|
|
||||||
//设置Caddyfile文件中的tls 邮箱
|
|
||||||
//string sshCmdEmail = $"email={ReceiveConfigurationParameters[4]};email=${{email/./@}};echo $email";//结尾有回车符
|
|
||||||
//string email = client.RunCommand(sshCmdEmail).Result.Replace("\n", "");//删除结尾的回车符
|
|
||||||
string email = $"user@{ReceiveConfigurationParameters[4]}";
|
|
||||||
string sshCmd;// = $"sed -i 's/off/{email}/' {upLoadPath}";//设置Caddyfile中的邮箱
|
|
||||||
//client.RunCommand(sshCmd);
|
|
||||||
//设置Path
|
|
||||||
//sshCmd = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[3]}/' {upLoadPath}";
|
|
||||||
//MessageBox.Show(sshCmd);
|
|
||||||
//client.RunCommand(sshCmd);
|
|
||||||
//设置域名
|
|
||||||
sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}";
|
|
||||||
//MessageBox.Show(sshCmd);
|
|
||||||
client.RunCommand(sshCmd);
|
|
||||||
//设置伪装网站
|
|
||||||
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
|
|
||||||
{
|
|
||||||
sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
|
|
||||||
//MessageBox.Show(sshCmd);
|
|
||||||
client.RunCommand(sshCmd);
|
|
||||||
}
|
|
||||||
Thread.Sleep(2000);
|
|
||||||
|
|
||||||
//安装Caddy服务
|
|
||||||
sshCmd = $"caddy -service install -agree -conf /etc/caddy/Caddyfile -email {email}";
|
|
||||||
//MessageBox.Show(sshCmd);
|
|
||||||
client.RunCommand(sshCmd);
|
|
||||||
|
|
||||||
|
|
||||||
//启动Caddy服务
|
|
||||||
client.RunCommand("caddy -service restart");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverConfig.Contains("trojan_server") == true)
|
if (serverConfig.Contains("trojan_server") == true)
|
||||||
{
|
{
|
||||||
@ -1664,7 +1612,7 @@ namespace ProxySU
|
|||||||
//client.RunCommand("mkdir -p /etc/v2ray/ssl");
|
//client.RunCommand("mkdir -p /etc/v2ray/ssl");
|
||||||
client.RunCommand($"/root/.acme.sh/acme.sh --issue --standalone -d {ReceiveConfigurationParameters[4]}");
|
client.RunCommand($"/root/.acme.sh/acme.sh --issue --standalone -d {ReceiveConfigurationParameters[4]}");
|
||||||
|
|
||||||
currentStatus = "安装证书到V2ray......";
|
currentStatus = "安装证书到Trojan......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
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 /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\"");
|
||||||
@ -1680,6 +1628,58 @@ namespace ProxySU
|
|||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
//安装Caddy
|
||||||
|
if (serverConfig.Contains("trojan_server") == true)
|
||||||
|
{
|
||||||
|
currentStatus = "正在安装Caddy";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
client.RunCommand("curl https://getcaddy.com -o getcaddy");
|
||||||
|
client.RunCommand("bash getcaddy personal hook.service");
|
||||||
|
client.RunCommand("mkdir -p /etc/caddy");
|
||||||
|
client.RunCommand("mkdir -p /var/www");
|
||||||
|
|
||||||
|
|
||||||
|
currentStatus = "上传Caddy配置文件......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
string caddyConfig = "";
|
||||||
|
if (serverConfig.Contains("trojan_server") == true)
|
||||||
|
{
|
||||||
|
caddyConfig = "TemplateConfg\\trojan_caddy_config.caddyfile";
|
||||||
|
}
|
||||||
|
|
||||||
|
upLoadPath = "/etc/caddy/Caddyfile";
|
||||||
|
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
|
||||||
|
|
||||||
|
//设置Caddyfile文件中的tls 邮箱
|
||||||
|
|
||||||
|
string email = $"user@{ReceiveConfigurationParameters[4]}";
|
||||||
|
string sshCmd;
|
||||||
|
//设置域名
|
||||||
|
sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}:80/' {upLoadPath}";
|
||||||
|
//MessageBox.Show(sshCmd);
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
//设置伪装网站
|
||||||
|
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
|
||||||
|
{
|
||||||
|
sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
|
||||||
|
//MessageBox.Show(sshCmd);
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
}
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
|
||||||
|
//安装Caddy服务
|
||||||
|
sshCmd = $"caddy -service install -agree -conf /etc/caddy/Caddyfile -email {email}";
|
||||||
|
//MessageBox.Show(sshCmd);
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
|
||||||
|
|
||||||
|
//启动Caddy服务
|
||||||
|
client.RunCommand("caddy -service restart");
|
||||||
|
}
|
||||||
|
|
||||||
//生成客户端配置
|
//生成客户端配置
|
||||||
currentStatus = "生成客户端配置......";
|
currentStatus = "生成客户端配置......";
|
||||||
@ -1711,7 +1711,7 @@ namespace ProxySU
|
|||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
//显示服务端连接参数
|
//显示服务端连接参数
|
||||||
//MessageBox.Show("用于V2ray官方客户端的配置文件已保存在config文件夹中");
|
//MessageBox.Show("用于Trojan官方客户端的配置文件已保存在config文件夹中");
|
||||||
TrojanResultClientInfoWindow resultClientInformation = new TrojanResultClientInfoWindow();
|
TrojanResultClientInfoWindow resultClientInformation = new TrojanResultClientInfoWindow();
|
||||||
resultClientInformation.ShowDialog();
|
resultClientInformation.ShowDialog();
|
||||||
|
|
||||||
@ -1755,6 +1755,13 @@ namespace ProxySU
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ButtonTestTrojanClientInfoWin_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
//TrojanResultClientInfoWindow resultClientInformation = new TrojanResultClientInfoWindow();
|
||||||
|
//resultClientInformation.ShowDialog();
|
||||||
|
MessageBox.Show(ReceiveConfigurationParameters[4]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -329,6 +329,7 @@ namespace ProxySU
|
|||||||
string saveFileFolderFirst = v2rayNjsonObject["ps"].ToString();
|
string saveFileFolderFirst = v2rayNjsonObject["ps"].ToString();
|
||||||
int num = 1;
|
int num = 1;
|
||||||
saveFileFolder = saveFileFolderFirst;
|
saveFileFolder = saveFileFolderFirst;
|
||||||
|
CheckDir(@"v2ray_config");
|
||||||
while (Directory.Exists(@"v2ray_config\" + saveFileFolder))
|
while (Directory.Exists(@"v2ray_config\" + saveFileFolder))
|
||||||
{
|
{
|
||||||
saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString();
|
saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString();
|
||||||
|
@ -14,13 +14,43 @@
|
|||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition Height="0.2*"></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<GroupBox Header="服务器连接参数" Grid.Row="0">
|
<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>
|
||||||
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox Header="二维码/URL" Grid.Row="1">
|
<GroupBox Header="二维码/URL" Grid.Row="1">
|
||||||
|
|
||||||
</GroupBox>
|
</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>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -10,6 +10,13 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
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
|
namespace ProxySU
|
||||||
{
|
{
|
||||||
@ -18,9 +25,133 @@ namespace ProxySU
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class TrojanResultClientInfoWindow : Window
|
public partial class TrojanResultClientInfoWindow : Window
|
||||||
{
|
{
|
||||||
|
private string saveFileFolder = "";
|
||||||
public TrojanResultClientInfoWindow()
|
public TrojanResultClientInfoWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
//主机地址
|
||||||
|
TextBoxTrojanServerHost.Text = MainWindow.ReceiveConfigurationParameters[4];
|
||||||
|
//主机端口
|
||||||
|
TextBoxTrojanServerPort.Text = MainWindow.ReceiveConfigurationParameters[1];
|
||||||
|
//密钥(uuid)
|
||||||
|
TextBoxTrojanServerPassword.Text = MainWindow.ReceiveConfigurationParameters[2];
|
||||||
|
|
||||||
|
GenerateV2rayShareQRcodeAndBase64Url();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成v2rayN客户端导入文件
|
||||||
|
private void GenerateV2rayShareQRcodeAndBase64Url()
|
||||||
|
{
|
||||||
|
|
||||||
|
string saveFileFolderFirst = TextBoxTrojanServerHost.Text;
|
||||||
|
int num = 1;
|
||||||
|
saveFileFolder = saveFileFolderFirst;
|
||||||
|
CheckDir("trojan_config");
|
||||||
|
while (Directory.Exists(@"trojan_config\" + saveFileFolder))
|
||||||
|
{
|
||||||
|
saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString();
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
CheckDir(@"trojan_config\" + saveFileFolder);
|
||||||
|
//MessageBox.Show(v2rayNjsonObject.ToString());
|
||||||
|
// string vmessUrl = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString());
|
||||||
|
//TextBoxvVmessUrl.Text = vmessUrl;
|
||||||
|
//using (StreamWriter sw = new StreamWriter($"trojan_config\\{saveFileFolder}\\url.txt"))
|
||||||
|
//{
|
||||||
|
// sw.WriteLine(vmessUrl);
|
||||||
|
|
||||||
|
//}
|
||||||
|
//CreateQRCode(vmessUrl);
|
||||||
|
|
||||||
|
//移动Trojan官方程序配置文件到相应目录
|
||||||
|
if (File.Exists(@"trojan_config\config.json"))
|
||||||
|
{
|
||||||
|
File.Move(@"trojan_config\config.json", @"trojan_config\" + saveFileFolder + @"\config.json");
|
||||||
|
//File.Delete(@"config\config.json");//删除该文件
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamWriter sw = new StreamWriter($"trojan_config\\{saveFileFolder}\\说明.txt"))
|
||||||
|
{
|
||||||
|
sw.WriteLine("config.json");
|
||||||
|
sw.WriteLine("此文件为Trojan官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080");
|
||||||
|
sw.WriteLine("Trojan官方网站:https://trojan-gfw.github.io/trojan/");
|
||||||
|
sw.WriteLine("Trojan官方程序下载地址:https://github.com/trojan-gfw/trojan/releases");
|
||||||
|
sw.WriteLine("下载相应版本,Windows选择Trojan-x.xx-win.zip,解压后提取trojan.exe。与config.json放在同一目录,运行trojan.exe即可。");
|
||||||
|
//sw.WriteLine("-----------------------------------------");
|
||||||
|
//sw.WriteLine("QR.bmp");
|
||||||
|
//sw.WriteLine("此文件为v2rayN、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点");
|
||||||
|
//sw.WriteLine("v2rayN下载网址:https://github.com/2dust/v2rayN/releases");
|
||||||
|
//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("-----------------------------------------\n");
|
||||||
|
sw.WriteLine("服务器通用连接配置参数");
|
||||||
|
sw.WriteLine($"地址(address):{TextBoxTrojanServerHost.Text}");
|
||||||
|
sw.WriteLine($"端口(Port):{TextBoxTrojanServerPort.Text}");
|
||||||
|
sw.WriteLine($"密钥:{TextBoxTrojanServerPassword.Text}");
|
||||||
|
//sw.WriteLine($"额外ID:{TextBoxUUIDextra.Text}");
|
||||||
|
//sw.WriteLine($"加密方式:{TextBoxEncryption.Text}");
|
||||||
|
//sw.WriteLine($"传输协议:{TextBoxTransmission.Text}");
|
||||||
|
//sw.WriteLine($"伪装类型:{TextBoxCamouflageType.Text}");
|
||||||
|
//sw.WriteLine($"是否使用TLS:{TextBoxTLS.Text}");
|
||||||
|
//sw.WriteLine($"host:{TextBoxHostAddress.Text}");
|
||||||
|
//sw.WriteLine($"路径(Path):{TextBoxPath.Text}");
|
||||||
|
//sw.WriteLine($"QUIC密钥:{TextBoxQuicKey.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());
|
||||||
|
//ImageShareQRcode.Source = imgsource;
|
||||||
|
//DeleteObject(myImagePtr);
|
||||||
|
qrCodeImage.Save($"trojan_config\\{saveFileFolder}\\QR.bmp");
|
||||||
|
//ImageShareQRcode.Source = @"config\v2rayN.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_config\" + saveFileFolder;
|
||||||
|
System.Diagnostics.Process.Start("explorer.exe", openFolderPath);
|
||||||
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,12 @@ namespace ProxySU
|
|||||||
MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text;
|
MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//传递服务端口
|
||||||
|
MainWindow.ReceiveConfigurationParameters[1] = TextBoxServerListenPort.Text.ToString();
|
||||||
|
//传递密码(uuid)
|
||||||
|
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();
|
||||||
}
|
}
|
||||||
//传递服务端口
|
|
||||||
MainWindow.ReceiveConfigurationParameters[1] = TextBoxServerListenPort.Text.ToString();
|
|
||||||
//传递密码(uuid)
|
|
||||||
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();
|
|
||||||
|
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user