1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 13:16:09 +03:00

save install xray/trojan-go

This commit is contained in:
next-autumn 2021-05-21 18:03:40 +08:00
parent 5093082fc4
commit 4cd4509cb9
49 changed files with 698 additions and 25 deletions

View File

@ -619,8 +619,8 @@ namespace ProxySuper.Core.Services
/// <param name="keyPath"></param> /// <param name="keyPath"></param>
protected void InstallCert(string dirPath, string certName, string keyName) protected void InstallCert(string dirPath, string certName, string keyName)
{ {
string certPath = Path.Combine(dirPath, certName); string certPath = dirPath + "/" + certName;
string keyPath = Path.Combine(dirPath, keyName); string keyPath = dirPath + "/" + keyName;
// 安装依赖 // 安装依赖
RunCmd(GetInstallCmd("socat")); RunCmd(GetInstallCmd("socat"));

View File

@ -37,8 +37,8 @@ namespace ProxySuper.Core.Services
public static string BuildCaddyConfig(TrojanGoSettings parameters, bool useCustomWeb = false) public static string BuildCaddyConfig(TrojanGoSettings parameters, bool useCustomWeb = false)
{ {
var caddyStr = File.ReadAllText(CaddyFilePath); var caddyStr = File.ReadAllText(CaddyFilePath);
caddyStr.Replace("##domain##", parameters.Domain); caddyStr = caddyStr.Replace("##domain##", parameters.Domain);
caddyStr.Replace("##port##", WebPort.ToString()); caddyStr = caddyStr.Replace("##port##", WebPort.ToString());
if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain)) if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain))
{ {

View File

@ -17,15 +17,58 @@ namespace ProxySuper.Core.Services
{ {
} }
public void InstallCertToTrojanGo()
{
EnsureRootAuth();
EnsureSystemEnv();
InstallCert(
dirPath: "/usr/local/etc/trojan-go",
certName: "trojan-go.crt",
keyName: "trojan-go.key");
RunCmd("systemctl restart trojan-go");
WriteOutput("************ 安装证书完成 ************");
}
public void UploadWeb(Stream stream)
{
EnsureRootAuth();
EnsureSystemEnv();
if (!FileExists("/usr/share/caddy"))
{
RunCmd("mkdir /usr/share/caddy");
}
RunCmd("rm -rf /usr/share/caddy/*");
UploadFile(stream, "/usr/share/caddy/caddy.zip");
RunCmd("unzip /usr/share/caddy/caddy.zip -d /usr/share/caddy");
RunCmd("chmod -R 777 /usr/share/caddy");
UploadCaddyFile(useCustomWeb: true);
WriteOutput("************ 上传网站模板完成 ************");
}
public void Uninstall()
{
RunCmd("systemctl stop trojan-go");
RunCmd("systemctl stop caddy");
RunCmd("rm -rf /usr/local/bin/trojan-go");
RunCmd("rm -rf /usr/local/etc/trojan-go");
RunCmd("acme.sh --uninstall");
RunCmd("rm -r ~/.acme.sh");
WriteOutput("卸载Trojan-Go完成");
}
public override void Install() public override void Install()
{ {
try try
{ {
EnsureRootAuth(); EnsureRootAuth();
if (FileExists("/usr/local/bin/xray")) if (FileExists("/usr/local/bin/trojan-go"))
{ {
var btnResult = MessageBox.Show("已经安装Xray是否需要重装", "提示", MessageBoxButton.YesNo); var btnResult = MessageBox.Show("已经安装Trojan-Go,是否需要重装?", "提示", MessageBoxButton.YesNo);
if (btnResult == MessageBoxResult.No) if (btnResult == MessageBoxResult.No)
{ {
MessageBox.Show("安装终止", "提示"); MessageBox.Show("安装终止", "提示");
@ -89,7 +132,7 @@ namespace ProxySuper.Core.Services
{ {
WriteOutput("安装Trojan-Go"); WriteOutput("安装Trojan-Go");
RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh yes | bash"); RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh yes | bash");
var success = FileExists("/usr/local/etc/trojan-go"); var success = FileExists("/usr/local/bin/trojan-go");
if (success == false) if (success == false)
{ {
throw new Exception("trojan-go 安装失败,请联系开发者!"); throw new Exception("trojan-go 安装失败,请联系开发者!");
@ -114,6 +157,11 @@ namespace ProxySuper.Core.Services
RunCmd("mv /usr/local/etc/trojan-go/config.json config.json.old"); RunCmd("mv /usr/local/etc/trojan-go/config.json config.json.old");
} }
UploadTrojanGoSettings();
}
private void UploadTrojanGoSettings()
{
// 上传配置 // 上传配置
var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Parameters); var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Parameters);
var stream = new MemoryStream(Encoding.UTF8.GetBytes(settings)); var stream = new MemoryStream(Encoding.UTF8.GetBytes(settings));

View File

@ -38,7 +38,7 @@ namespace ProxySuper.Core.ViewModels
set set
{ {
_connected = value; _connected = value;
RaisePropertyChanged("HasConnected"); RaisePropertyChanged("Connected");
} }
} }

View File

@ -178,6 +178,120 @@
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
<None Include="Templates\trojan-go\base.caddyfile">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\trojan-go\trojan-go.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\base.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\caddy\base.caddyfile">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\00_log\00_log.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\01_api\01_api.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\02_dns\02_dns.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\03_routing\03_routing.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\04_policy\04_policy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\05_inbounds\05_inbounds.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\06_outbounds\06_outbounds.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\06_outbounds\VLESS_HTTP2_TLS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\06_outbounds\VLESS_TCP_TLS_WS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\07_transport\07_transport.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\08_stats\08_stats.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\09_reverse\09_reverse.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\00_log\00_log.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\01_api\01_api.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\02_dns\02_dns.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\03_routing\03_routing.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\04_policy\04_policy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\05_inbounds.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\Shadowsocks-AEAD.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\Trojan_TCP.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\Trojan_WS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VLESS_gRPC.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VLESS_HTTP2.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VLESS_KCP.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VLESS_TCP_XTLS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VLESS_WS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VMESS_HTTP2.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VMESS_KCP.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VMESS_TCP.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VMESS_WS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\06_outbounds\06_outbounds.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\07_transport\07_transport.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\08_stats\08_stats.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\09_reverse\09_reverse.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />

View File

@ -0,0 +1,9 @@
:##port## {
root * /usr/share/caddy
file_server
##reverse_proxy##
}
##domain##:80 {
redir https://##domain##{uri}
}

View File

@ -0,0 +1,16 @@
{
"run_type": "server",
"local_addr": "0.0.0.0",
"local_port": 443,
"remote_addr": "127.0.0.1",
"remote_port": 80,
"password": [
""
],
"ssl": {
"cert": "/usr/local/etc/trojan-go/trojan-go.crt",
"key": "/usr/local/etc/trojan-go/trojan-go.key",
"sni": ""
}
}

View File

@ -0,0 +1,12 @@
{
"log": {},
"api": {},
"dns": {},
"routing": {},
"policy": {},
"inbounds": [],
"outbounds": [],
"transport": {},
"stats": {},
"reverse": {}
}

View File

@ -0,0 +1,9 @@
:##port## {
root * /usr/share/caddy
file_server
##reverse_proxy##
}
##domain##:80 {
redir https://##domain##{uri}
}

View File

@ -0,0 +1,5 @@
{
"log": {
"loglevel": "warning"
}
}

View File

@ -0,0 +1,3 @@
{
"api": null
}

View File

@ -0,0 +1,3 @@
{
"dns": {}
}

View File

@ -0,0 +1,3 @@
{
"routing": {}
}

View File

@ -0,0 +1,3 @@
{
"policy": {}
}

View File

@ -0,0 +1,23 @@
{
"inbounds": [
{
"protocol": "http",
"port": 1081
},
{
"port": 1080,
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
},
"settings": {
"udp": true,
"auth": "noauth"
}
}
]
}

View File

@ -0,0 +1,3 @@
{
"outbounds": []
}

View File

@ -0,0 +1,31 @@
{
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "",
"port": 443,
"users": [
{
"id": "",
"encryption": "none"
}
]
}
]
},
"streamSettings": {
"network": "h2",
"security": "tls",
"httpSettings": {
"host": [
""
],
"path": null
}
}
}
]
}

View File

@ -0,0 +1,32 @@
{
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "",
"port": 443,
"users": [
{
"id": "",
"encryption": "none",
"level": 0
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"serverName": ""
},
"wsSettings": {
"path": ""
}
}
}
]
}

View File

@ -0,0 +1,3 @@
{
"transport": {}
}

View File

@ -0,0 +1,3 @@
{
"stats": null
}

View File

@ -0,0 +1,3 @@
{
"reverse": {}
}

View File

@ -0,0 +1,6 @@
{
"log": {
"access": "none",
"loglevel": "none"
}
}

View File

@ -0,0 +1,3 @@
{
"api": {}
}

View File

@ -0,0 +1,3 @@
{
"dns": {}
}

View File

@ -0,0 +1,14 @@
{
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "block"
}
]
}
}

View File

@ -0,0 +1,3 @@
{
"policy": {}
}

View File

@ -0,0 +1,3 @@
{
"inbounds": []
}

View File

@ -0,0 +1,13 @@
{
"port": 12345,
"protocol": "shadowsocks",
"settings": {
"clients": [
{
"password": "",
"method": "aes-128-gcm"
}
],
"network": "tcp,udp"
}
}

View File

@ -0,0 +1,24 @@
{
"port": 1310,
"listen": "127.0.0.1",
"protocol": "trojan",
"settings": {
"clients": [
{
"password": ""
}
],
"fallbacks": [
{
"dest": 8080
}
]
},
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": true
}
}
}

View File

@ -0,0 +1,26 @@
{
"port": 1320,
"listen": "127.0.0.1",
"protocol": "trojan",
"settings": {
"clients": [
{
"password": ""
}
],
"fallbacks": [
{
"dest": 80
}
]
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"acceptProxyProtocol": true,
"path": "/trojanws"
}
}
}

View File

@ -0,0 +1,19 @@
{
"port": 1234,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"decryption": "none",
"clients": [
{
"id": ""
}
]
},
"streamSettings": {
"network": "h2",
"httpSettings": {
"path": ""
}
}
}

View File

@ -0,0 +1,24 @@
{
"port": 3456,
"protocol": "vless",
"settings": {
"clients": [
{
"id": ""
}
],
"decryption": "none"
},
"streamSettings": {
"network": "mkcp",
"kcpSettings": {
"uplinkCapacity": 100,
"downlinkCapacity": 100,
"congestion": true,
"header": {
"type": "none"
},
"seed": null
}
}
}

View File

@ -0,0 +1,31 @@
{
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "",
"flow": "xtls-rprx-direct"
}
],
"decryption": "none",
"fallbacks": []
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"allowInsecure": false,
"minVersion": "1.2",
"alpn": [
"http/1.1"
],
"certificates": [
{
"certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt",
"keyFile": "/usr/local/etc/xray/ssl/xray_ssl.key"
}
]
}
}
}

View File

@ -0,0 +1,21 @@
{
"port": 1234,
"listen": "127.0.0.1",
"protocol": "vless",
"settings": {
"clients": [
{
"id": ""
}
],
"decryption": "none"
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"acceptProxyProtocol": true,
"path": "/websocket"
}
}
}

View File

@ -0,0 +1,25 @@
{
"port": 2002,
"listen": "127.0.0.1",
"protocol": "vless",
"settings": {
"clients": [
{
"id": ""
}
],
"decryption": "none"
},
"streamSettings": {
"network": "grpc",
"grpcSettings": {
"serviceName": "",
"certificates": [
{
"certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt",
"keyFile": "/usr/local/etc/xray/ssl/xray_ssl.key"
}
]
}
}
}

View File

@ -0,0 +1,18 @@
{
"port": 1234,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": ""
}
]
},
"streamSettings": {
"network": "h2",
"httpSettings": {
"path": ""
}
}
}

View File

@ -0,0 +1,23 @@
{
"port": 3456,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": ""
}
]
},
"streamSettings": {
"network": "mkcp",
"kcpSettings": {
"uplinkCapacity": 100,
"downlinkCapacity": 100,
"congestion": true,
"header": {
"type": "none"
},
"seed": null
}
}
}

View File

@ -0,0 +1,27 @@
{
"port": 443,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": ""
}
]
},
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": true,
"header": {
"type": "http",
"request": {
"path": [
"/vmesstcp"
]
}
}
}
}
}

View File

@ -0,0 +1,20 @@
{
"port": 3456,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": ""
}
]
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"acceptProxyProtocol": true,
"path": "/vmessws"
}
}
}

View File

@ -0,0 +1,12 @@
{
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
]
}

View File

@ -0,0 +1,3 @@
{
"transport": {}
}

View File

@ -0,0 +1,3 @@
{
"stats": {}
}

View File

@ -0,0 +1,3 @@
{
"reverse": {}
}

View File

@ -19,7 +19,7 @@ namespace ProxySuper.WPF.Views
/// <summary> /// <summary>
/// TrojanEditorView.xaml 的交互逻辑 /// TrojanEditorView.xaml 的交互逻辑
/// </summary> /// </summary>
[MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = true)] [MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = false)]
public partial class TrojanGoEditorView : MvxWindow public partial class TrojanGoEditorView : MvxWindow
{ {
public TrojanGoEditorView() public TrojanGoEditorView()

View File

@ -8,7 +8,7 @@
mc:Ignorable="d" mc:Ignorable="d"
Icon="/Resources/ProxySU.ico" Icon="/Resources/ProxySU.ico"
Title="TrojanGoInstallerView" Height="450" Width="800"> Title="TrojanGoInstallerView" Height="450" Width="800">
<Grid> <StackPanel>
<TextBox IsReadOnly="True" <TextBox IsReadOnly="True"
Block.LineHeight="18" Block.LineHeight="18"
Background="#000" Background="#000"
@ -27,15 +27,13 @@
<StackPanel Margin="10" Orientation="Horizontal"> <StackPanel Margin="10" Orientation="Horizontal">
<Label Content="安装" /> <Label Content="安装" />
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="Install">一键安装</Button> <Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="Install">一键安装</Button>
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UpdateSettings">更新配置</Button>
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="Uninstall">卸载代理</Button> <Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="Uninstall">卸载代理</Button>
</StackPanel> </StackPanel>
<StackPanel Margin="10" Orientation="Horizontal"> <StackPanel Margin="10" Orientation="Horizontal">
<Label Content="配置" /> <Label Content="配置" />
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="InstallCert">重新申请证书</Button> <Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="InstallCert">手动续签证书</Button>
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadWeb">上传伪装网站</Button> <Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadWeb">上传伪装网站</Button>
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadCert">上传自有证书</Button>
</StackPanel> </StackPanel>
</Grid> </StackPanel>
</views:MvxWindow> </views:MvxWindow>

View File

@ -1,4 +1,5 @@
using MvvmCross.Platforms.Wpf.Presenters.Attributes; using Microsoft.Win32;
using MvvmCross.Platforms.Wpf.Presenters.Attributes;
using MvvmCross.Platforms.Wpf.Views; using MvvmCross.Platforms.Wpf.Views;
using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Services; using ProxySuper.Core.Services;
@ -6,6 +7,7 @@ using ProxySuper.Core.ViewModels;
using Renci.SshNet; using Renci.SshNet;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -23,7 +25,7 @@ namespace ProxySuper.WPF.Views
/// <summary> /// <summary>
/// TrojanGoInstallerView.xaml 的交互逻辑 /// TrojanGoInstallerView.xaml 的交互逻辑
/// </summary> /// </summary>
[MvxWindowPresentation(Identifier = nameof(TrojanGoInstallerView), Modal = true)] [MvxWindowPresentation(Identifier = nameof(TrojanGoInstallerView), Modal = false)]
public partial class TrojanGoInstallerView : MvxWindow public partial class TrojanGoInstallerView : MvxWindow
{ {
public TrojanGoInstallerView() public TrojanGoInstallerView()
@ -120,17 +122,42 @@ namespace ProxySuper.WPF.Views
}; };
} }
private void Install(object sender, RoutedEventArgs e) { } private void Install(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(Project.Install);
}
private void UpdateSettings(object sender, RoutedEventArgs e) { }
private void Uninstall(object sender, RoutedEventArgs e) { } private void Uninstall(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(Project.Uninstall);
}
private void UploadWeb(object sender, RoutedEventArgs e) { } private void InstallCert(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(Project.InstallCertToTrojanGo);
}
private void UploadCert(object sender, RoutedEventArgs e) { }
private void InstallCert(object sender, RoutedEventArgs e) { } private void UploadWeb(object sender, RoutedEventArgs e)
{
var fileDialog = new OpenFileDialog();
fileDialog.Filter = "压缩文件|*.zip";
fileDialog.FileOk += DoUploadWeb;
fileDialog.ShowDialog();
}
private void DoUploadWeb(object sender, CancelEventArgs e)
{
Task.Factory.StartNew(() =>
{
var file = sender as OpenFileDialog;
using (var stream = file.OpenFile())
{
Project.UploadWeb(stream);
}
});
}
} }
} }

View File

@ -19,7 +19,7 @@ namespace ProxySuper.WPF.Views
/// <summary> /// <summary>
/// XrayEditorView.xaml 的交互逻辑 /// XrayEditorView.xaml 的交互逻辑
/// </summary> /// </summary>
[MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = true)] [MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = false)]
public partial class XrayEditorView : MvxWindow public partial class XrayEditorView : MvxWindow
{ {
public XrayEditorView() public XrayEditorView()

View File

@ -6,6 +6,7 @@
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf" xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
xmlns:local="clr-namespace:ProxySuper.WPF.Views" xmlns:local="clr-namespace:ProxySuper.WPF.Views"
mc:Ignorable="d" mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Icon="/Resources/ProxySU.ico" Icon="/Resources/ProxySU.ico"
Title="XrayInstallerView" Height="450" Width="800"> Title="XrayInstallerView" Height="450" Width="800">
<StackPanel> <StackPanel>
@ -34,7 +35,7 @@
<StackPanel Margin="10" Orientation="Horizontal"> <StackPanel Margin="10" Orientation="Horizontal">
<Label Content="配置" /> <Label Content="配置" />
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="InstallCert">重新申请证书</Button> <Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="InstallCert">手动续签证书</Button>
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadWeb">上传伪装网站</Button> <Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadWeb">上传伪装网站</Button>
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadCert">上传自有证书</Button> <Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadCert">上传自有证书</Button>
</StackPanel> </StackPanel>

View File

@ -17,7 +17,7 @@ namespace ProxySuper.WPF.Views
/// <summary> /// <summary>
/// XrayInstallerView.xaml 的交互逻辑 /// XrayInstallerView.xaml 的交互逻辑
/// </summary> /// </summary>
[MvxWindowPresentation(Identifier = nameof(XrayInstallerView), Modal = true)] [MvxWindowPresentation(Identifier = nameof(XrayInstallerView), Modal = false)]
public partial class XrayInstallerView : MvxWindow public partial class XrayInstallerView : MvxWindow
{ {
public XrayInstallerView() public XrayInstallerView()