1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 13:16:09 +03:00
This commit is contained in:
autumn 2021-08-19 12:06:05 +08:00
parent 69b29fce21
commit e85a0b93bf
9 changed files with 78 additions and 20 deletions

View File

@ -60,9 +60,12 @@ namespace ProxySuper.Core.Services
Progress.Step = $"{index++}. 启动BBR"; Progress.Step = $"{index++}. 启动BBR";
EnableBBR(); EnableBBR();
Progress.Desc = "重启Caddy服务";
RunCmd("systemctl restart caddy");
Progress.Percentage = 100; Progress.Percentage = 100;
Progress.Step = "NaiveProxy安装成功"; Progress.Step = "NaiveProxy安装成功";
Progress.Desc = "NaiveProxy安装成功"; Progress.Desc = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -117,10 +120,12 @@ namespace ProxySuper.Core.Services
Progress.Percentage = 30; Progress.Percentage = 30;
UploadCaddySettings(); UploadCaddySettings();
Progress.Desc = "重启Caddy服务";
RunCmd("systemctl restart caddy");
Progress.Percentage = 100; Progress.Percentage = 100;
Progress.Step = "更新配置成功"; Progress.Step = "更新配置成功";
Progress.Desc = "更新配置成功"; Progress.Desc = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -233,9 +238,6 @@ namespace ProxySuper.Core.Services
Progress.Desc = "上传配置文件"; Progress.Desc = "上传配置文件";
WriteToFile(caddyStr, "/etc/caddy/Caddyfile"); WriteToFile(caddyStr, "/etc/caddy/Caddyfile");
Progress.Desc = "重启Caddy服务";
RunCmd("systemctl restart caddy");
} }
private string BuildConfig(bool useCustomWeb = false) private string BuildConfig(bool useCustomWeb = false)

View File

@ -72,13 +72,16 @@ namespace ProxySuper.Core.Services
UploadCaddySettings(); UploadCaddySettings();
Progress.Percentage = 90; Progress.Percentage = 90;
Progress.Step = $"{index++}. 启动BBR"; Progress.Step = $"{index++}. 启动BBR";
EnableBBR(); EnableBBR();
Progress.Desc = "启用Trojan-Go开机启动";
RunCmd("systemctl enable trojan-go");
RunCmd("systemctl restart trojan-go");
Progress.Percentage = 100; Progress.Percentage = 100;
Progress.Step = "安装成功"; Progress.Step = "安装成功";
Progress.Desc = "安装成功"; Progress.Desc = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -122,7 +125,7 @@ namespace ProxySuper.Core.Services
Progress.Percentage = 100; Progress.Percentage = 100;
Progress.Step = "卸载Trojan-Go成功"; Progress.Step = "卸载Trojan-Go成功";
Progress.Desc = "卸载Trojan-Go成功"; Progress.Desc = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -144,8 +147,10 @@ namespace ProxySuper.Core.Services
Progress.Desc = "更新配置文件"; Progress.Desc = "更新配置文件";
UploadTrojanGoSettings(); UploadTrojanGoSettings();
Progress.Desc = "重启Trojan-Go服务器";
RunCmd("systemctl restart trojan-go");
Progress.Percentage = 100; Progress.Percentage = 100;
Progress.Step = "更新配置成功";
Progress.Desc = "更新配置成功"; Progress.Desc = "更新配置成功";
} }
@ -331,10 +336,6 @@ namespace ProxySuper.Core.Services
RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/trojan-go.service"); RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/trojan-go.service");
RunCmd($"systemctl daemon-reload"); RunCmd($"systemctl daemon-reload");
Progress.Desc = "启用Trojan-Go开机启动";
RunCmd("systemctl enable trojan-go");
RunCmd("systemctl start trojan-go");
Progress.Desc = "Trojan-Go 安装完成"; Progress.Desc = "Trojan-Go 安装完成";
Progress.Desc = "安装TLS证书"; Progress.Desc = "安装TLS证书";
@ -358,8 +359,6 @@ namespace ProxySuper.Core.Services
Progress.Desc = "正在上传配置文件"; Progress.Desc = "正在上传配置文件";
UploadFile(stream, "/usr/local/etc/trojan-go/config.json"); UploadFile(stream, "/usr/local/etc/trojan-go/config.json");
Progress.Desc = "重启Trojan-Go服务器";
RunCmd("systemctl restart trojan-go");
} }
#endregion #endregion

View File

@ -78,9 +78,13 @@ namespace ProxySuper.Core.Services
Progress.Step = $"{index++}. 启动BBR"; Progress.Step = $"{index++}. 启动BBR";
EnableBBR(); EnableBBR();
Progress.Desc = "重启Xray服务";
RunCmd("systemctl restart caddy");
RunCmd("systemctl restart xray");
Progress.Percentage = 100; Progress.Percentage = 100;
Progress.Step = "安装成功"; Progress.Step = "安装成功";
Progress.Desc = "安装成功"; Progress.Desc = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -388,7 +392,6 @@ namespace ProxySuper.Core.Services
Progress.Desc = ("生成Xray服务器配置文件"); Progress.Desc = ("生成Xray服务器配置文件");
var configJson = XrayConfigBuilder.BuildXrayConfig(Settings); var configJson = XrayConfigBuilder.BuildXrayConfig(Settings);
WriteToFile(configJson, "/usr/local/etc/xray/config.json"); WriteToFile(configJson, "/usr/local/etc/xray/config.json");
RunCmd("systemctl restart xray");
} }
private void UploadCaddyFile(bool useCustomWeb = false) private void UploadCaddyFile(bool useCustomWeb = false)
@ -400,7 +403,6 @@ namespace ProxySuper.Core.Services
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back"); RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
} }
WriteToFile(configJson, "/etc/caddy/Caddyfile"); WriteToFile(configJson, "/etc/caddy/Caddyfile");
RunCmd("systemctl restart caddy");
} }

View File

@ -6,6 +6,7 @@ using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services; using ProxySuper.Core.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -31,12 +32,14 @@ namespace ProxySuper.Core.ViewModels
_service = new BrookService(_host, _settings); _service = new BrookService(_host, _settings);
_service.Progress.StepUpdate = () => RaisePropertyChanged("Progress"); _service.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
_service.Progress.LogsUpdate = () => RaisePropertyChanged("Logs"); _service.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
_service.Connect();
return base.Initialize(); return base.Initialize();
} }
public override void ViewDestroy(bool viewFinishing = true) public override void ViewDestroy(bool viewFinishing = true)
{ {
_service.Disconnect(); _service.Disconnect();
this.SaveInstallLog();
base.ViewDestroy(viewFinishing); base.ViewDestroy(viewFinishing);
} }
@ -47,5 +50,16 @@ namespace ProxySuper.Core.ViewModels
public IMvxCommand InstallCommand => new MvxCommand(_service.Install); public IMvxCommand InstallCommand => new MvxCommand(_service.Install);
public IMvxCommand UninstallCommand => new MvxCommand(_service.Uninstall); public IMvxCommand UninstallCommand => new MvxCommand(_service.Uninstall);
private void SaveInstallLog()
{
if (!Directory.Exists("Logs"))
{
Directory.CreateDirectory("Logs");
}
var fileName = System.IO.Path.Combine("Logs", DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".brook.txt");
File.WriteAllText(fileName, Logs);
}
} }
} }

View File

@ -6,6 +6,7 @@ using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services; using ProxySuper.Core.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -31,12 +32,14 @@ namespace ProxySuper.Core.ViewModels
_service = new NaiveProxyService(_host, _settings); _service = new NaiveProxyService(_host, _settings);
_service.Progress.StepUpdate = () => RaisePropertyChanged("Progress"); _service.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
_service.Progress.LogsUpdate = () => RaisePropertyChanged("Logs"); _service.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
_service.Connect();
return base.Initialize(); return base.Initialize();
} }
public override void ViewDestroy(bool viewFinishing = true) public override void ViewDestroy(bool viewFinishing = true)
{ {
_service.Disconnect(); _service.Disconnect();
this.SaveInstallLog();
base.ViewDestroy(viewFinishing); base.ViewDestroy(viewFinishing);
} }
@ -57,5 +60,16 @@ namespace ProxySuper.Core.ViewModels
public IMvxCommand UploadWebCommand => new MvxCommand(_service.UploadWeb); public IMvxCommand UploadWebCommand => new MvxCommand(_service.UploadWeb);
#endregion #endregion
private void SaveInstallLog()
{
if (!Directory.Exists("Logs"))
{
Directory.CreateDirectory("Logs");
}
var fileName = System.IO.Path.Combine("Logs", DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".naiveproxy.txt");
File.WriteAllText(fileName, Logs);
}
} }
} }

View File

@ -6,6 +6,7 @@ using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services; using ProxySuper.Core.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -38,6 +39,7 @@ namespace ProxySuper.Core.ViewModels
public override void ViewDestroy(bool viewFinishing = true) public override void ViewDestroy(bool viewFinishing = true)
{ {
_trojanGoService.Disconnect(); _trojanGoService.Disconnect();
this.SaveInstallLog();
base.ViewDestroy(viewFinishing); base.ViewDestroy(viewFinishing);
} }
@ -67,5 +69,17 @@ namespace ProxySuper.Core.ViewModels
public IMvxCommand ApplyForCertCommand => new MvxCommand(_trojanGoService.ApplyForCert); public IMvxCommand ApplyForCertCommand => new MvxCommand(_trojanGoService.ApplyForCert);
#endregion #endregion
private void SaveInstallLog()
{
if (!Directory.Exists("Logs"))
{
Directory.CreateDirectory("Logs");
}
var fileName = System.IO.Path.Combine("Logs", DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".trojan-go.txt");
File.WriteAllText(fileName, Logs);
}
} }
} }

View File

@ -6,6 +6,7 @@ using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services; using ProxySuper.Core.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -23,6 +24,7 @@ namespace ProxySuper.Core.ViewModels
public override void ViewDestroy(bool viewFinishing = true) public override void ViewDestroy(bool viewFinishing = true)
{ {
_xrayService.Disconnect(); _xrayService.Disconnect();
this.SaveInstallLog();
base.ViewDestroy(viewFinishing); base.ViewDestroy(viewFinishing);
} }
@ -71,5 +73,16 @@ namespace ProxySuper.Core.ViewModels
public IMvxCommand ApplyForCertCommand => new MvxCommand(_xrayService.ApplyForCert); public IMvxCommand ApplyForCertCommand => new MvxCommand(_xrayService.ApplyForCert);
#endregion #endregion
private void SaveInstallLog()
{
if (!Directory.Exists("Logs"))
{
Directory.CreateDirectory("Logs");
}
var fileName = Path.Combine("Logs", DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".xary.txt");
File.WriteAllText(fileName, Logs);
}
} }
} }

View File

@ -19,7 +19,7 @@
VerticalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
Text="{Binding Path=Logs,Mode=OneWay}" Text="{Binding Path=Logs,Mode=OneWay}"
VerticalContentAlignment="Top" VerticalContentAlignment="Top"
Padding="10" Padding="10,0"
FontSize="13" FontSize="13"
IsReadOnly="True" IsReadOnly="True"
FontFamily="微软雅黑" FontFamily="微软雅黑"

View File

@ -30,7 +30,7 @@
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Settings.Port}" IsReadOnly="True" /> <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Settings.Port}" IsReadOnly="True" />
<Label Grid.Row="2" Grid.Column="0" Content="用户名(UserName)" /> <Label Grid.Row="2" Grid.Column="0" Content="用户名(UserName)" />
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Settings.Domain}" IsReadOnly="True" /> <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Settings.UserName}" IsReadOnly="True" />
<Label Grid.Row="3" Grid.Column="0" Content="密码(Password)" /> <Label Grid.Row="3" Grid.Column="0" Content="密码(Password)" />
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Settings.Password}" IsReadOnly="True" /> <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Settings.Password}" IsReadOnly="True" />