mirror of
https://github.com/proxysu/ProxySU.git
synced 2025-04-10 12:40:55 +00:00
Compare commits
143 commits
Author | SHA1 | Date | |
---|---|---|---|
|
201d3da3a5 | ||
|
03f015f8d4 | ||
|
2047f3d480 | ||
|
ba5629bd49 | ||
|
97a1f45abc | ||
|
5cfe086d50 | ||
|
2d5a589bcb | ||
|
332f54224f | ||
|
be74f42f19 | ||
|
d9d9393c5f | ||
|
6e4b3f7c01 | ||
|
703183274b | ||
|
1907061064 | ||
|
6177ea99d1 | ||
|
ef3542f338 | ||
|
5cc6229437 | ||
|
705b0df116 | ||
|
8d1863729a | ||
|
8ea6af4018 | ||
|
280dacabac | ||
|
62403f68ca | ||
|
eabd976de8 | ||
|
6a67a3e685 | ||
|
1e1cad2ad7 | ||
|
f371277362 | ||
|
b9ebd8700c | ||
|
07c8d9bb2b | ||
|
1a5a7219e3 | ||
|
5db61a02b5 | ||
|
ac003d476b | ||
|
91827f47ee | ||
|
433883c3bf | ||
|
e86db631c5 | ||
|
4c0d3a0cf4 | ||
|
db6a399ca9 | ||
|
1110f8291e | ||
|
89649d136f | ||
|
89af852433 | ||
|
13e5edf50d | ||
|
5a79ceccba | ||
|
10c8c0f74e | ||
|
2567635002 | ||
|
1e96735db6 | ||
|
4d9890c797 | ||
|
d815152d2d | ||
|
ef5bb6d977 | ||
|
9f7a4b8626 | ||
|
dade426ff7 | ||
|
eaca464f9c | ||
|
bd32650fa9 | ||
|
9f4edca5d4 | ||
|
3fc01e8f2f | ||
|
c2b764a7c9 | ||
|
84674d15ac | ||
|
460b9a9abc | ||
|
6b10682060 | ||
|
1b8240b460 | ||
|
4f23cd735c | ||
|
b185e4f64e | ||
|
0937e8083d | ||
|
aaf899ea73 | ||
|
14c622b272 | ||
|
d87e4ddb96 | ||
|
62c2ad7be8 | ||
|
9cec097baa | ||
|
fcaa50b248 | ||
|
d628147bdb | ||
|
983e15f98f | ||
|
361bdb4e2d | ||
|
e7da4962e8 | ||
|
ba48b34c9a | ||
|
38784d1e4e | ||
|
682ceadd5e | ||
|
751b0d19ca | ||
|
10a62f55eb | ||
|
535998f233 | ||
|
d30ead12af | ||
|
9a552edbeb | ||
|
f0905945f6 | ||
|
bc903cbf4a | ||
|
8bc507ef43 | ||
|
dbadab1499 | ||
|
96ed54702b | ||
|
a637e6fc54 | ||
|
d3619fadd7 | ||
|
725d202b38 | ||
|
fb8a0de49d | ||
|
e1b92a499e | ||
|
9ae318c01f | ||
|
ca01190672 | ||
|
57b222bc5b | ||
|
87f01d180d | ||
|
34fb030b95 | ||
|
1792c6912a | ||
|
3e71d14424 | ||
|
e4bd5a9167 | ||
|
fc131ededd | ||
|
2cffa483aa | ||
|
524c341e9a | ||
|
d5e1125c36 | ||
|
819b8dd440 | ||
|
81ae945e4f | ||
|
553cb7b431 | ||
|
2b1e65adb4 | ||
|
7869e77126 | ||
|
6e61ef1ff6 | ||
|
be9ae4a8de | ||
|
7b7251279f | ||
|
eab70cc48c | ||
|
6c79b07d3c | ||
|
995d9ff435 | ||
|
b0d0e761de | ||
|
e85a0b93bf | ||
|
69b29fce21 | ||
|
389f80f655 | ||
|
bbf6cf64fe | ||
|
4fe8b03daa | ||
|
bbc508557b | ||
|
f39c1e70ae | ||
|
2ca98258b8 | ||
|
0296c2be89 | ||
|
db3d4491bb | ||
|
860dfb6520 | ||
|
b9b41b6554 | ||
|
2378f0c416 | ||
|
6be1fdb84a | ||
|
c33de96563 | ||
|
0859efb2dd | ||
|
399c852857 | ||
|
d5878079f1 | ||
|
5bd7529bec | ||
|
a2b27076b1 | ||
|
fe94157c7b | ||
|
b82e857edd | ||
|
9923437691 | ||
|
2f0f9fb09d | ||
|
395d01aea8 | ||
|
63c7f8b7a7 | ||
|
95dccb1c6c | ||
|
11021fac1a | ||
|
e05e9cff3d | ||
|
316453c89b | ||
|
424e0945db |
223 changed files with 10754 additions and 3754 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -199,3 +199,4 @@ FakesAssemblies/
|
|||
# vs code
|
||||
.vscode/*
|
||||
/ProxySU_Core/Data/Record.json
|
||||
/ProxySuper.WPF/bin
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31005.135
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31606.5
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libs", "Libs", "{CE908112-DB46-4B91-8236-9139A19D66E9}"
|
||||
EndProject
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core
|
||||
{
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using MvvmCross.Converters;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ProxySuper.Core.Converters
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ProxySuper.Core.Converters
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Helpers
|
||||
{
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
|
@ -33,5 +28,13 @@ namespace ProxySuper.Core.Services
|
|||
{
|
||||
return DateTime.Now.Ticks.ToString();
|
||||
}
|
||||
|
||||
private static Random random = new Random();
|
||||
public static string RandomString(int length)
|
||||
{
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
return new string(Enumerable.Repeat(chars, length)
|
||||
.Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
42
ProxySuper.Core/Models/Caddy.cs
Normal file
42
ProxySuper.Core/Models/Caddy.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models
|
||||
{
|
||||
public static class Caddy
|
||||
{
|
||||
public static string Service = @"
|
||||
[Unit]
|
||||
Description=Caddy
|
||||
Documentation=https://caddyserver.com/docs/
|
||||
After=network.target network-online.target
|
||||
Requires=network-online.target
|
||||
|
||||
[Service]
|
||||
#User=caddy
|
||||
#Group=caddy
|
||||
User=root
|
||||
Group=root
|
||||
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
|
||||
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
|
||||
TimeoutStopSec=5s
|
||||
#LimitNOFILE=1048576
|
||||
#LimitNPROC=512
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
#AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
";
|
||||
|
||||
public static string DefaultCaddyFile = @"
|
||||
:80 {
|
||||
respond ""Hello world!"";
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
using Microsoft.Win32;
|
||||
using MvvmCross.Commands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
|
@ -31,6 +28,8 @@ namespace ProxySuper.Core.Models.Hosts
|
|||
|
||||
public string PrivateKeyPath { get; set; }
|
||||
|
||||
public string PrivateKeyPassPhrase { get; set; }
|
||||
|
||||
public LocalProxy Proxy { get; set; }
|
||||
|
||||
public LoginSecretType SecretType { get; set; }
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Renci.SshNet;
|
||||
|
||||
namespace ProxySuper.Core.Models.Hosts
|
||||
{
|
||||
|
@ -12,7 +8,7 @@ namespace ProxySuper.Core.Models.Hosts
|
|||
|
||||
public int Port { get; set; } = 1080;
|
||||
|
||||
public LocalProxyType Type { get; set; }
|
||||
public ProxyTypes Type { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
|
@ -20,5 +16,5 @@ namespace ProxySuper.Core.Models.Hosts
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Hosts
|
||||
{
|
||||
public enum LocalProxyType
|
||||
{
|
||||
None = 0,
|
||||
//
|
||||
// 摘要:
|
||||
// A SOCKS4 proxy server.
|
||||
Socks4 = 1,
|
||||
//
|
||||
// 摘要:
|
||||
// A SOCKS5 proxy server.
|
||||
Socks5 = 2,
|
||||
//
|
||||
// 摘要:
|
||||
// A HTTP proxy server.
|
||||
Http = 3
|
||||
}
|
||||
}
|
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Hosts
|
||||
namespace ProxySuper.Core.Models.Hosts
|
||||
{
|
||||
public enum LoginSecretType
|
||||
{
|
||||
|
|
83
ProxySuper.Core/Models/ProjectProgress.cs
Normal file
83
ProxySuper.Core/Models/ProjectProgress.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models
|
||||
{
|
||||
public class ProjectProgress
|
||||
{
|
||||
private string _step;
|
||||
|
||||
private string _desc;
|
||||
|
||||
private int _percentage;
|
||||
|
||||
private string _logs;
|
||||
|
||||
public ProjectProgress()
|
||||
{
|
||||
_step = "步骤";
|
||||
|
||||
_desc = "步骤描述";
|
||||
|
||||
_percentage = 0;
|
||||
|
||||
_logs = string.Empty;
|
||||
|
||||
StepUpdate = () => { };
|
||||
}
|
||||
|
||||
|
||||
public Action StepUpdate { get; set; }
|
||||
|
||||
public Action LogsUpdate { get; set; }
|
||||
|
||||
public string Desc
|
||||
{
|
||||
get { return _desc; }
|
||||
set
|
||||
{
|
||||
_desc = value;
|
||||
StepUpdate();
|
||||
|
||||
_logs += _desc + "\n";
|
||||
LogsUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public string Step
|
||||
{
|
||||
get { return _step; }
|
||||
set
|
||||
{
|
||||
_step = value;
|
||||
StepUpdate();
|
||||
|
||||
_logs += Step + "\n";
|
||||
LogsUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public int Percentage
|
||||
{
|
||||
get { return _percentage; }
|
||||
set
|
||||
{
|
||||
_percentage = value;
|
||||
StepUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public string Logs
|
||||
{
|
||||
get { return _logs; }
|
||||
set
|
||||
{
|
||||
_logs = value;
|
||||
LogsUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
ProxySuper.Core/Models/Projects/BrookSettings.cs
Normal file
34
ProxySuper.Core/Models/Projects/BrookSettings.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public class BrookSettings : IProjectSettings
|
||||
{
|
||||
public string Domain { get; set; }
|
||||
|
||||
public string IP { get; set; }
|
||||
|
||||
public string Password { get; set; }
|
||||
|
||||
public BrookType BrookType { get; set; }
|
||||
|
||||
public int Port { get; set; } = 443;
|
||||
|
||||
public List<int> FreePorts
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Port == 443)
|
||||
{
|
||||
return new List<int> { 80, 443 };
|
||||
}
|
||||
return new List<int> { Port };
|
||||
}
|
||||
}
|
||||
|
||||
public string Email => "server@brook.com";
|
||||
|
||||
public ProjectType Type { get; set; } = ProjectType.Brook;
|
||||
|
||||
}
|
||||
}
|
10
ProxySuper.Core/Models/Projects/BrookType.cs
Normal file
10
ProxySuper.Core/Models/Projects/BrookType.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public enum BrookType
|
||||
{
|
||||
server,
|
||||
wsserver,
|
||||
wssserver,
|
||||
socks5
|
||||
}
|
||||
}
|
33
ProxySuper.Core/Models/Projects/HysteriaSettings.cs
Normal file
33
ProxySuper.Core/Models/Projects/HysteriaSettings.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public class HysteriaSettings : IProjectSettings
|
||||
{
|
||||
public string Domain { get; set; } = "";
|
||||
|
||||
public string Obfs { get; set; } = "";
|
||||
|
||||
public string Email { get; set; } = "";
|
||||
|
||||
public string Protocol { get; set; } = "udp";
|
||||
|
||||
public int Port { get; set; } = 36712;
|
||||
|
||||
public int UpMbps { get; set; } = 300;
|
||||
|
||||
public int DownMbps { get; set; } = 300;
|
||||
|
||||
public List<int> FreePorts
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<int> { Port, 80 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
|
@ -26,6 +22,11 @@ namespace ProxySuper.Core.Models.Projects
|
|||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
ProjectType Type { get; set; }
|
||||
//ProjectType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱
|
||||
/// </summary>
|
||||
string Email { get; }
|
||||
}
|
||||
}
|
||||
|
|
34
ProxySuper.Core/Models/Projects/MTProtoGoSettings.cs
Normal file
34
ProxySuper.Core/Models/Projects/MTProtoGoSettings.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public class MTProtoGoSettings : IProjectSettings
|
||||
{
|
||||
public MTProtoGoSettings()
|
||||
{
|
||||
Port = 443;
|
||||
|
||||
Domain = string.Empty;
|
||||
|
||||
Cleartext = "bing.com";
|
||||
|
||||
SecretText = string.Empty;
|
||||
}
|
||||
|
||||
public int Port { get; set; }
|
||||
|
||||
public string Domain { get; set; }
|
||||
|
||||
public List<int> FreePorts => new List<int> { Port };
|
||||
|
||||
public string Email => "";
|
||||
|
||||
public string Cleartext { get; set; }
|
||||
|
||||
public string SecretText { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
|
@ -13,7 +11,13 @@ namespace ProxySuper.Core.Models.Projects
|
|||
Port = 443;
|
||||
}
|
||||
|
||||
public List<int> FreePorts => new List<int>();
|
||||
public List<int> FreePorts
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<int> { 80, 443, Port }.Distinct().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectType Type { get; set; } = ProjectType.NaiveProxy;
|
||||
|
||||
|
@ -26,5 +30,24 @@ namespace ProxySuper.Core.Models.Projects
|
|||
public string Password { get; set; }
|
||||
|
||||
public string MaskDomain { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string Email
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Domain))
|
||||
{
|
||||
var arr = Domain.Split('.');
|
||||
if (arr.Length == 3)
|
||||
{
|
||||
return $"{arr[0]}@{arr[1]}.{arr[2]}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $"{UserName + Port.ToString()}@gmail.com";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public enum ProjectType
|
||||
{
|
||||
Xray = 0,
|
||||
TrojanGo = 1,
|
||||
NaiveProxy = 2
|
||||
NaiveProxy = 2,
|
||||
Brook = 3,
|
||||
V2ray = 4,
|
||||
MTProtoGo = 5,
|
||||
Hysteria = 6,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public enum XrayType
|
||||
public enum RayType
|
||||
{
|
||||
// 入口
|
||||
VLESS_TCP_XTLS = 100,
|
||||
|
@ -16,6 +10,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||
VLESS_WS = 102,
|
||||
VLESS_H2 = 103,
|
||||
VLESS_KCP = 104,
|
||||
VLESS_QUIC = 105,
|
||||
VLESS_gRPC = 110,
|
||||
|
||||
// VMESS 201开头
|
||||
|
@ -23,6 +18,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||
VMESS_WS = 202,
|
||||
VMESS_H2 = 203,
|
||||
VMESS_KCP = 204,
|
||||
VMESS_QUIC = 205,
|
||||
|
||||
// Trojan 301开头
|
||||
Trojan_TCP = 301,
|
||||
|
@ -31,4 +27,6 @@ namespace ProxySuper.Core.Models.Projects
|
|||
// SS
|
||||
ShadowsocksAEAD = 401
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
|
@ -12,20 +9,27 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
public TrojanGoSettings()
|
||||
{
|
||||
WithTLS = true;
|
||||
Port = 443;
|
||||
WebSocketPath = "/ws";
|
||||
Password = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
public List<int> FreePorts
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<int>();
|
||||
return new List<int> { 80, 443, Port }.Distinct().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectType Type { get; set; } = ProjectType.TrojanGo;
|
||||
|
||||
/// <summary>
|
||||
/// 是否安装TLS证书
|
||||
/// </summary>
|
||||
public bool WithTLS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 域名
|
||||
/// </summary>
|
||||
|
@ -63,5 +67,25 @@ namespace ProxySuper.Core.Models.Projects
|
|||
/// </summary>
|
||||
public string WebSocketPath { get; set; }
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public string Email
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Domain))
|
||||
{
|
||||
var arr = Domain.Split('.');
|
||||
if (arr.Length == 3)
|
||||
{
|
||||
return $"{arr[0]}@{arr[1]}.{arr[2]}";
|
||||
}
|
||||
}
|
||||
|
||||
var prefix = Password.Length > 7 ? Password.Substring(0, 7) : Password;
|
||||
return $"{prefix}@gmail.com";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
187
ProxySuper.Core/Models/Projects/V2raySettings.cs
Normal file
187
ProxySuper.Core/Models/Projects/V2raySettings.cs
Normal file
|
@ -0,0 +1,187 @@
|
|||
using Newtonsoft.Json;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public partial class V2raySettings : IProjectSettings
|
||||
{
|
||||
public static List<string> DisguiseTypes = new List<string> {
|
||||
"none",
|
||||
"srtp",
|
||||
"utp",
|
||||
"wechat-video",
|
||||
"dtls",
|
||||
"wireguard",
|
||||
};
|
||||
|
||||
public V2raySettings()
|
||||
{
|
||||
WithTLS = true;
|
||||
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
Port = 443;
|
||||
VLESS_KCP_Port = 2001;
|
||||
VLESS_QUIC_Port = 2002;
|
||||
VLESS_gRPC_Port = 2003;
|
||||
|
||||
VMESS_KCP_Port = 3001;
|
||||
VMESS_QUIC_Port = 3002;
|
||||
ShadowSocksPort = 4001;
|
||||
|
||||
UUID = guid;
|
||||
Types = new List<RayType>();
|
||||
|
||||
VLESS_WS_Path = "/" + Utils.RandomString(6);
|
||||
VLESS_KCP_Type = "none";
|
||||
VLESS_KCP_Seed = guid;
|
||||
VLESS_QUIC_Key = "";
|
||||
VLESS_QUIC_Type = "none";
|
||||
VLESS_QUIC_Security = "none";
|
||||
VLESS_QUIC_Type = "none";
|
||||
VLESS_gRPC_ServiceName = Utils.RandomString(7);
|
||||
|
||||
VMESS_WS_Path = "/" + Utils.RandomString(8);
|
||||
VMESS_TCP_Path = "/" + Utils.RandomString(9);
|
||||
VMESS_KCP_Seed = guid;
|
||||
VMESS_QUIC_Key = "";
|
||||
VMESS_KCP_Type = "none";
|
||||
VMESS_QUIC_Security = "none";
|
||||
VMESS_QUIC_Type = "none";
|
||||
|
||||
TrojanPassword = guid;
|
||||
|
||||
ShadowSocksPassword = guid;
|
||||
ShadowSocksMethod = "aes-128-gcm";
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsIPAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return IPAddress.TryParse(Domain, out _);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public List<int> FreePorts
|
||||
{
|
||||
get
|
||||
{
|
||||
var list = new List<int>();
|
||||
list.Add(80);
|
||||
list.Add(Port);
|
||||
|
||||
if (Types.Contains(RayType.VLESS_KCP))
|
||||
{
|
||||
list.Add(VLESS_KCP_Port);
|
||||
}
|
||||
|
||||
if (Types.Contains(RayType.VLESS_QUIC))
|
||||
{
|
||||
list.Add(VLESS_QUIC_Port);
|
||||
}
|
||||
|
||||
if (Types.Contains(RayType.VMESS_KCP))
|
||||
{
|
||||
list.Add(VMESS_KCP_Port);
|
||||
}
|
||||
|
||||
if (Types.Contains(RayType.VMESS_QUIC))
|
||||
{
|
||||
list.Add(VMESS_QUIC_Port);
|
||||
}
|
||||
|
||||
if (Types.Contains(RayType.ShadowsocksAEAD))
|
||||
{
|
||||
list.Add(ShadowSocksPort);
|
||||
}
|
||||
|
||||
if (Types.Contains(RayType.VLESS_gRPC))
|
||||
{
|
||||
list.Add(VLESS_gRPC_Port);
|
||||
}
|
||||
|
||||
return list.Distinct().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否安装证书,
|
||||
/// 上传自有证书时选False,则不会自动安装证书。
|
||||
/// </summary>
|
||||
public bool WithTLS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 端口
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 域名
|
||||
/// </summary>
|
||||
public string Domain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// UUID
|
||||
/// </summary>
|
||||
public string UUID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 多用户
|
||||
/// </summary>
|
||||
public List<string> MulitUUID { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 伪装域名
|
||||
/// </summary>
|
||||
public string MaskDomain { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string Email
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Domain))
|
||||
{
|
||||
var arr = Domain.Split('.');
|
||||
if (arr.Length == 3)
|
||||
{
|
||||
return $"{arr[0]}@{arr[1]}.{arr[2]}";
|
||||
}
|
||||
}
|
||||
|
||||
return $"{UUID.Substring(2, 6)}@gmail.com";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安装类型
|
||||
/// </summary>
|
||||
public List<RayType> Types { get; set; } = new List<RayType>();
|
||||
|
||||
/// <summary>
|
||||
/// 根据xray类型获取路径
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public string GetPath(RayType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RayType.VLESS_WS:
|
||||
return VLESS_WS_Path;
|
||||
case RayType.VMESS_TCP:
|
||||
return VMESS_TCP_Path;
|
||||
case RayType.VMESS_WS:
|
||||
return VMESS_WS_Path;
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,8 @@
|
|||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public partial class XraySettings
|
||||
public partial class V2raySettings
|
||||
{
|
||||
/// <summary>
|
||||
/// ss password
|
||||
|
@ -24,11 +19,14 @@ namespace ProxySuper.Core.Models.Projects
|
|||
/// </summary>
|
||||
public int ShadowSocksPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// share link
|
||||
/// </summary>
|
||||
public string ShadowSocksShareLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.ShadowsocksAEAD, this);
|
||||
return ShareLink.Build(RayType.ShadowsocksAEAD, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,8 @@
|
|||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public partial class XraySettings
|
||||
public partial class V2raySettings
|
||||
{
|
||||
public string TrojanPassword { get; set; }
|
||||
|
||||
|
@ -15,7 +10,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.Trojan_TCP, this);
|
||||
return ShareLink.Build(RayType.Trojan_TCP, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +1,12 @@
|
|||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public partial class XraySettings
|
||||
public partial class V2raySettings
|
||||
{
|
||||
/// <summary>
|
||||
/// vless xtls shareLink
|
||||
/// </summary>
|
||||
public string VLESS_TCP_XTLS_ShareLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.VLESS_TCP_XTLS, this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// vless tcp shareLink
|
||||
/// </summary>
|
||||
|
@ -27,7 +14,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.VLESS_TCP, this);
|
||||
return ShareLink.Build(RayType.VLESS_TCP, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +30,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.VLESS_WS, this);
|
||||
return ShareLink.Build(RayType.VLESS_WS, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +56,38 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.VLESS_KCP, this);
|
||||
return ShareLink.Build(RayType.VLESS_KCP, this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// vless quic security
|
||||
/// </summary>
|
||||
public string VLESS_QUIC_Security { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// vless quic type
|
||||
/// </summary>
|
||||
public string VLESS_QUIC_Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// vless quic port
|
||||
/// </summary>
|
||||
public int VLESS_QUIC_Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// vless quic key
|
||||
/// </summary>
|
||||
public string VLESS_QUIC_Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// vless quic ShareLink
|
||||
/// </summary>
|
||||
public string VLESS_QUIC_ShareLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(RayType.VLESS_QUIC, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +108,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.VLESS_gRPC, this);
|
||||
return ShareLink.Build(RayType.VLESS_gRPC, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,8 @@
|
|||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public partial class XraySettings
|
||||
public partial class V2raySettings
|
||||
{
|
||||
/// <summary>
|
||||
/// vmess websocket path
|
||||
|
@ -21,7 +16,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.VMESS_WS, this);
|
||||
return ShareLink.Build(RayType.VMESS_WS, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +32,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.VMESS_TCP, this);
|
||||
return ShareLink.Build(RayType.VMESS_TCP, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +58,38 @@ namespace ProxySuper.Core.Models.Projects
|
|||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(XrayType.VMESS_KCP, this);
|
||||
return ShareLink.Build(RayType.VMESS_KCP, this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// vmess quic security
|
||||
/// </summary>
|
||||
public string VMESS_QUIC_Security { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// vmess quic type
|
||||
/// </summary>
|
||||
public string VMESS_QUIC_Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// vmess quic port
|
||||
/// </summary>
|
||||
public int VMESS_QUIC_Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// vmess quic key
|
||||
/// </summary>
|
||||
public string VMESS_QUIC_Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// vmess quic ShareLink
|
||||
/// </summary>
|
||||
public string VMESS_QUIC_ShareLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.Build(RayType.VMESS_QUIC, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -6,93 +7,25 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public partial class XraySettings : IProjectSettings
|
||||
public class XraySettings : V2raySettings
|
||||
{
|
||||
public XraySettings()
|
||||
{
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
Port = 443;
|
||||
VLESS_KCP_Port = 2001;
|
||||
VLESS_gRPC_Port = 2002;
|
||||
VMESS_KCP_Port = 3001;
|
||||
ShadowSocksPort = 4001;
|
||||
public static List<string> UTLSList = new List<string> { "", "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random", "randomized" };
|
||||
|
||||
UUID = guid;
|
||||
Types = new List<XrayType>();
|
||||
//流控参数在服务端只有两种 "none", "xtls-rprx-vision",客户端可以选择三种:"none", "xtls-rprx-vision", "xtls-rprx-vision-udp443",但是选择了XTLS模式就是默认flow不为空或者"none",所以这里不再填加"none"这一项。
|
||||
public static List<string> FlowList = new List<string> { "xtls-rprx-vision", "xtls-rprx-vision-udp443" }; //{ "xtls-rprx-origin", "xtls-rprx-origin-udp443", "xtls-rprx-direct", "xtls-rprx-direct-udp443", "xtls-rprx-splice", "xtls-rprx-splice-udp443" };
|
||||
|
||||
VLESS_WS_Path = "/vlessws";
|
||||
VLESS_KCP_Type = "none";
|
||||
VLESS_KCP_Seed = guid;
|
||||
VLESS_gRPC_ServiceName = "xray_gRPC";
|
||||
public string UTLS { get; set; } = UTLSList[1];
|
||||
|
||||
VMESS_WS_Path = "/vmessws";
|
||||
VMESS_TCP_Path = "/vmesstcp";
|
||||
VMESS_KCP_Seed = guid;
|
||||
VMESS_KCP_Type = "none";
|
||||
public string Flow { get; set; } = FlowList[0];
|
||||
|
||||
TrojanPassword = guid;
|
||||
|
||||
ShadowSocksPassword = guid;
|
||||
ShadowSocksMethod = "aes-128-gcm";
|
||||
}
|
||||
|
||||
public List<int> FreePorts
|
||||
/// <summary>
|
||||
/// vless xtls shareLink
|
||||
/// </summary>
|
||||
public string VLESS_TCP_XTLS_ShareLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<int>
|
||||
{
|
||||
VLESS_KCP_Port,
|
||||
VMESS_KCP_Port,
|
||||
ShadowSocksPort,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectType Type { get; set; } = ProjectType.Xray;
|
||||
|
||||
/// <summary>
|
||||
/// 端口
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 域名
|
||||
/// </summary>
|
||||
public string Domain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// UUID
|
||||
/// </summary>
|
||||
public string UUID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 伪装域名
|
||||
/// </summary>
|
||||
public string MaskDomain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 安装类型
|
||||
/// </summary>
|
||||
public List<XrayType> Types { get; set; } = new List<XrayType>();
|
||||
|
||||
/// <summary>
|
||||
/// 根据xray类型获取路径
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public string GetPath(XrayType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case XrayType.VLESS_WS:
|
||||
return VLESS_WS_Path;
|
||||
case XrayType.VMESS_TCP:
|
||||
return VMESS_TCP_Path;
|
||||
case XrayType.VMESS_WS:
|
||||
return VMESS_WS_Path;
|
||||
default:
|
||||
return string.Empty;
|
||||
return ShareLink.Build(RayType.VLESS_TCP_XTLS, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
using Microsoft.Win32;
|
||||
using MvvmCross;
|
||||
using MvvmCross.Commands;
|
||||
using MvvmCross.Navigation;
|
||||
using MvvmCross.ViewModels;
|
||||
using MvvmCross.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Models
|
||||
{
|
||||
|
@ -44,6 +33,9 @@ namespace ProxySuper.Core.Models
|
|||
}
|
||||
}
|
||||
|
||||
[JsonProperty("v2raySettings")]
|
||||
public V2raySettings V2raySettings { get; set; }
|
||||
|
||||
[JsonProperty("settings")]
|
||||
public XraySettings XraySettings { get; set; }
|
||||
|
||||
|
@ -53,6 +45,15 @@ namespace ProxySuper.Core.Models
|
|||
[JsonProperty("naiveProxySettings")]
|
||||
public NaiveProxySettings NaiveProxySettings { get; set; }
|
||||
|
||||
[JsonProperty("brook")]
|
||||
public BrookSettings BrookSettings { get; set; }
|
||||
|
||||
[JsonProperty("mtProtoGoSettings")]
|
||||
public MTProtoGoSettings MTProtoGoSettings { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public HysteriaSettings HysteriaSettings { get; set; }
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public ProjectType Type
|
||||
|
@ -61,9 +62,17 @@ namespace ProxySuper.Core.Models
|
|||
{
|
||||
if (XraySettings != null) return ProjectType.Xray;
|
||||
|
||||
if (V2raySettings != null) return ProjectType.V2ray;
|
||||
|
||||
if (TrojanGoSettings != null) return ProjectType.TrojanGo;
|
||||
|
||||
return ProjectType.NaiveProxy;
|
||||
if (NaiveProxySettings != null) return ProjectType.NaiveProxy;
|
||||
|
||||
if (MTProtoGoSettings != null) return ProjectType.MTProtoGo;
|
||||
|
||||
if (HysteriaSettings != null) return ProjectType.Hysteria;
|
||||
|
||||
return ProjectType.Brook;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,8 +90,22 @@ namespace ProxySuper.Core.Models
|
|||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Action OnSave { get; set; } = () => { };
|
||||
|
||||
public string GetShareLink()
|
||||
{
|
||||
if (Type == ProjectType.V2ray)
|
||||
{
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
V2raySettings.Types.ForEach(type =>
|
||||
{
|
||||
var link = ShareLink.Build(type, V2raySettings);
|
||||
strBuilder.AppendLine(link);
|
||||
});
|
||||
return strBuilder.ToString();
|
||||
}
|
||||
|
||||
if (Type == ProjectType.Xray)
|
||||
{
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
|
|
|
@ -32,8 +32,11 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MvvmCross, Version=7.1.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MvvmCross.7.1.2\lib\net461\MvvmCross.dll</HintPath>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MvvmCross, Version=8.0.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MvvmCross.8.0.2\lib\net461\MvvmCross.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
@ -41,17 +44,31 @@
|
|||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="QRCoder, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\QRCoder.1.4.1\lib\net40\QRCoder.dll</HintPath>
|
||||
<Reference Include="QRCoder, Version=1.4.3.0, Culture=neutral, PublicKeyToken=c4ed5b9ae8358a28, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\QRCoder.1.4.3\lib\net40\QRCoder.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Renci.SshNet, Version=2020.0.1.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SSH.NET.2020.0.1\lib\net40\Renci.SshNet.dll</HintPath>
|
||||
<Reference Include="Renci.SshNet, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SSH.NET.2023.0.0\lib\net462\Renci.SshNet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Console, Version=4.0.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Console.4.3.1\lib\net46\System.Console.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime" />
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
@ -67,43 +84,68 @@
|
|||
<Compile Include="Converters\ProxyTypeConverter.cs" />
|
||||
<Compile Include="Converters\VisibleConverter.cs" />
|
||||
<Compile Include="Helpers\DateTimeUtils.cs" />
|
||||
<Compile Include="Models\Caddy.cs" />
|
||||
<Compile Include="Models\Hosts\Host.cs" />
|
||||
<Compile Include="Models\Hosts\LocalProxyType.cs" />
|
||||
<Compile Include="Models\Hosts\LoginSecretType.cs" />
|
||||
<Compile Include="Models\ProjectProgress.cs" />
|
||||
<Compile Include="Models\Projects\BrookSettings.cs" />
|
||||
<Compile Include="Models\Projects\BrookType.cs" />
|
||||
<Compile Include="Models\Projects\HysteriaSettings.cs" />
|
||||
<Compile Include="Models\Projects\IProjectSettings.cs" />
|
||||
<Compile Include="Models\Hosts\LocalProxy.cs" />
|
||||
<Compile Include="Models\Projects\MTProtoGoSettings.cs" />
|
||||
<Compile Include="Models\Projects\NaiveProxySettings.cs" />
|
||||
<Compile Include="Models\Projects\ProjectType.cs" />
|
||||
<Compile Include="Models\Projects\TrojanGoSettings.cs" />
|
||||
<Compile Include="Models\Projects\XraySettings_SS.cs" />
|
||||
<Compile Include="Models\Projects\XraySettings_Trojan.cs" />
|
||||
<Compile Include="Models\Projects\XraySettings_VLESS.cs" />
|
||||
<Compile Include="Models\Projects\V2raySettings_SS.cs" />
|
||||
<Compile Include="Models\Projects\V2raySettings_Trojan.cs" />
|
||||
<Compile Include="Models\Projects\V2raySettings_VLESS.cs" />
|
||||
<Compile Include="Models\Projects\V2raySettings.cs" />
|
||||
<Compile Include="Models\Projects\V2raySettings_VMESS.cs" />
|
||||
<Compile Include="Models\Projects\XraySettings.cs" />
|
||||
<Compile Include="Models\Projects\XraySettings_VMESS.cs" />
|
||||
<Compile Include="Models\Projects\XrayType.cs" />
|
||||
<Compile Include="Models\Projects\RayType.cs" />
|
||||
<Compile Include="Models\Record.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helpers\Utils.cs" />
|
||||
<Compile Include="Services\NaiveProxyProject.cs" />
|
||||
<Compile Include="Services\ProjectBase.cs" />
|
||||
<Compile Include="Services\BrookService.cs" />
|
||||
<Compile Include="Services\HysteriaService.cs" />
|
||||
<Compile Include="Services\MTProtoGoService.cs" />
|
||||
<Compile Include="Services\NaiveProxyService.cs" />
|
||||
<Compile Include="Services\ServiceBase.cs" />
|
||||
<Compile Include="Services\ShareLink.cs" />
|
||||
<Compile Include="Services\TrojanGoConfigBuilder.cs" />
|
||||
<Compile Include="Services\TrojanGoProject.cs" />
|
||||
<Compile Include="Services\TrojanGoService.cs" />
|
||||
<Compile Include="Services\V2rayConfigBuilder.cs" />
|
||||
<Compile Include="Services\V2rayService.cs" />
|
||||
<Compile Include="Services\XrayConfigBuilder.cs" />
|
||||
<Compile Include="Services\XrayProject.cs" />
|
||||
<Compile Include="Services\XrayService.cs" />
|
||||
<Compile Include="ViewModels\BrookConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\BrookEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\BrookInstallViewModel.cs" />
|
||||
<Compile Include="ViewModels\EnableRootViewModel.cs" />
|
||||
<Compile Include="ViewModels\HomeViewModel.cs" />
|
||||
<Compile Include="ViewModels\HysteriaConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\HysteriaEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\HysteriaInstallViewModel.cs" />
|
||||
<Compile Include="ViewModels\MTProtoGoConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\MTProtoGoEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\MTProtoGoInstallViewModel.cs" />
|
||||
<Compile Include="ViewModels\NaiveProxyConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\NaiveProxyEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\NaiveProxyInstallerViewModel.cs" />
|
||||
<Compile Include="ViewModels\NaiveProxyInstallViewModel.cs" />
|
||||
<Compile Include="ViewModels\ShareLinkViewModel.cs" />
|
||||
<Compile Include="ViewModels\TrojanGoConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\TrojanGoEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\TrojanGoInstallerViewModel.cs" />
|
||||
<Compile Include="ViewModels\TrojanGoInstallViewModel.cs" />
|
||||
<Compile Include="ViewModels\V2rayConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\V2rayEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\V2rayInstallViewModel.cs" />
|
||||
<Compile Include="ViewModels\XrayConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\XrayEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\XrayInstallerViewModel.cs" />
|
||||
<Compile Include="ViewModels\XrayInstallViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
|
|
171
ProxySuper.Core/Services/BrookService.cs
Normal file
171
ProxySuper.Core/Services/BrookService.cs
Normal file
|
@ -0,0 +1,171 @@
|
|||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class BrookService : ServiceBase<BrookSettings>
|
||||
{
|
||||
private string brookServiceTemp = @"
|
||||
[Unit]
|
||||
Description=brook service
|
||||
After=network.target syslog.target
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=##run_cmd##
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target";
|
||||
|
||||
|
||||
public BrookService(Host host, BrookSettings settings) : base(host, settings)
|
||||
{
|
||||
}
|
||||
|
||||
public void Install()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "安装Brook";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "安装必要的系统工具";
|
||||
InstallSystemTools();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Desc = "配置防火墙";
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 50;
|
||||
|
||||
|
||||
Progress.Step = "检测网络环境";
|
||||
EnsureNetwork();
|
||||
Progress.Percentage = 60;
|
||||
if (Settings.BrookType == BrookType.wssserver)
|
||||
{
|
||||
Progress.Desc = "检测域名是否绑定本机IP";
|
||||
ValidateDomain();
|
||||
Progress.Percentage = 80;
|
||||
}
|
||||
|
||||
Progress.Step = "安装Brook服务";
|
||||
InstallBrook();
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "安装Brook成功";
|
||||
Progress.Desc = "安装Brook成功";
|
||||
|
||||
AppendCommand("分享连接:");
|
||||
AppendCommand(ShareLink.BuildBrook(Settings));
|
||||
|
||||
NavigationService.Navigate<BrookConfigViewModel, BrookSettings>(Settings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void InstallBrook()
|
||||
{
|
||||
Progress.Desc = "执行Brook安装文件";
|
||||
string url = "https://github.com/txthinking/brook/releases/latest/download/brook_linux_amd64";
|
||||
if (ArchType == ArchType.arm)
|
||||
{
|
||||
url = url.Replace("brook_linux_amd64", "brook_linux_arm7");
|
||||
}
|
||||
|
||||
RunCmd($"curl -L {url} -o /usr/bin/brook");
|
||||
RunCmd("chmod +x /usr/bin/brook");
|
||||
|
||||
Progress.Desc = "设置Brook服务";
|
||||
var brookService = brookServiceTemp.Replace("##run_cmd##", GetRunBrookCommand());
|
||||
|
||||
RunCmd("rm -rf /etc/systemd/system/brook.service");
|
||||
RunCmd("touch /etc/systemd/system/brook.service");
|
||||
RunCmd($"echo \"{brookService}\" > /etc/systemd/system/brook.service");
|
||||
RunCmd("sudo chmod 777 /etc/systemd/system/brook.service");
|
||||
|
||||
Progress.Desc = "启动Brook服务";
|
||||
RunCmd("systemctl enable brook");
|
||||
RunCmd("systemctl restart brook");
|
||||
}
|
||||
|
||||
private string GetRunBrookCommand()
|
||||
{
|
||||
var runBrookCmd = string.Empty;
|
||||
|
||||
if (Settings.BrookType == BrookType.server)
|
||||
{
|
||||
return $"/usr/bin/brook server --listen :{Settings.Port} --password {Settings.Password}";
|
||||
}
|
||||
|
||||
if (Settings.BrookType == BrookType.wsserver)
|
||||
{
|
||||
return $"/usr/bin/brook wsserver --listen :{Settings.Port} --password {Settings.Password}";
|
||||
}
|
||||
|
||||
if (Settings.BrookType == BrookType.wssserver)
|
||||
{
|
||||
return $"/usr/bin/brook wssserver --domain {Settings.Domain} --password {Settings.Password}";
|
||||
}
|
||||
|
||||
if (Settings.BrookType == BrookType.socks5)
|
||||
{
|
||||
var ip = IsOnlyIPv6 ? IPv6 : IPv4;
|
||||
return $"/usr/bin/brook socks5 --socks5 {ip}:{Settings.Port}";
|
||||
}
|
||||
|
||||
return runBrookCmd;
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "卸载Brook";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "停止Brook服务";
|
||||
RunCmd("systemctl stop brook");
|
||||
RunCmd("systemctl disable brook");
|
||||
Progress.Percentage = 30;
|
||||
|
||||
Progress.Desc = "删除Brook相关文件";
|
||||
RunCmd("rm -rf /etc/systemd/system/brook.service");
|
||||
RunCmd("rm -rf /usr/bin/brook");
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Desc = "重置防火墙设置";
|
||||
ResetFirewalld();
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "卸载完成";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
172
ProxySuper.Core/Services/HysteriaService.cs
Normal file
172
ProxySuper.Core/Services/HysteriaService.cs
Normal file
|
@ -0,0 +1,172 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using Renci.SshNet.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class HysteriaService : ServiceBase<HysteriaSettings>
|
||||
{
|
||||
public HysteriaService(Host host, HysteriaSettings settings) : base(host, settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void Install()
|
||||
{
|
||||
try
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
Progress.Step = "安装Hysteria";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "安装必要的系统工具";
|
||||
InstallSystemTools();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Desc = "配置防火墙";
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 50;
|
||||
|
||||
Progress.Step = "检测网络环境";
|
||||
EnsureNetwork();
|
||||
Progress.Percentage = 60;
|
||||
|
||||
|
||||
Progress.Desc = "检测域名是否绑定本机IP";
|
||||
ValidateDomain();
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Step = "上传Hysteria配置文件";
|
||||
UploadConfigFile();
|
||||
Progress.Step = "安装Hysteria服务";
|
||||
InstallHysteria();
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "安装Hysteria成功";
|
||||
Progress.Desc = "安装Hysteria成功";
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "卸载Hysteria";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "停止Hysteria服务";
|
||||
RunCmd("systemctl stop Hysteria");
|
||||
RunCmd("systemctl disable Hysteria");
|
||||
Progress.Percentage = 30;
|
||||
|
||||
Progress.Desc = "删除Hysteria相关文件";
|
||||
RunCmd("rm -rf /etc/systemd/system/Hysteria.service");
|
||||
RunCmd("rm -rf /usr/bin/Hysteria");
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Desc = "重置防火墙设置";
|
||||
ResetFirewalld();
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "卸载完成";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private string HysteriaServiceTemp = @"
|
||||
[Unit]
|
||||
Description=hysteria service
|
||||
After=network.target syslog.target
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=##run_cmd##
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target";
|
||||
|
||||
private void InstallHysteria()
|
||||
{
|
||||
Progress.Desc = "执行Hysteria安装文件";
|
||||
string url = "https://github.com/apernet/hysteria/releases/download/v1.3.4/hysteria-linux-386";
|
||||
string targetPath = "/usr/bin/hysteria/hysteria-linux-386";
|
||||
|
||||
if (ArchType == ArchType.arm)
|
||||
{
|
||||
url = url.Replace("hysteria-linux-386", "hysteria-linux-arm");
|
||||
targetPath = targetPath.Replace("hysteria-linux-386", "hysteria-linux-arm");
|
||||
}
|
||||
|
||||
RunCmd($"curl -L {url} -o {targetPath}");
|
||||
RunCmd($"chmod +x {targetPath}");
|
||||
|
||||
Progress.Desc = "设置Hysteria服务";
|
||||
var cmd = targetPath + " -c /usr/bin/hysteria/config.json server";
|
||||
var hysteriaService = HysteriaServiceTemp.Replace("##run_cmd##", cmd);
|
||||
|
||||
RunCmd("rm -rf /etc/systemd/system/hysteria.service");
|
||||
RunCmd("touch /etc/systemd/system/hysteria.service");
|
||||
|
||||
RunCmd($"echo \"{hysteriaService}\" > /etc/systemd/system/hysteria.service");
|
||||
RunCmd("sudo chmod 777 /etc/systemd/system/hysteria.service");
|
||||
|
||||
|
||||
Progress.Desc = "启动Hysteria服务";
|
||||
RunCmd("systemctl enable hysteria");
|
||||
RunCmd("systemctl restart hysteria");
|
||||
}
|
||||
|
||||
private const string ConfigFilePath = @"Templates\Hysteria\config.json";
|
||||
private void UploadConfigFile()
|
||||
{
|
||||
var text = File.ReadAllText(ConfigFilePath, Encoding.UTF8);
|
||||
var json = JsonConvert.DeserializeObject(text);
|
||||
var obj = JToken.FromObject(json) as dynamic;
|
||||
|
||||
|
||||
obj["listen"] = $":{Settings.Port}";
|
||||
obj["acme"]["domains"][0] = Settings.Domain;
|
||||
obj["email"] = Settings.Email;
|
||||
obj["obfs"] = Settings.Obfs;
|
||||
|
||||
var configJson = JsonConvert.SerializeObject(
|
||||
obj,
|
||||
Formatting.Indented,
|
||||
new JsonSerializerSettings()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
|
||||
RunCmd("mkdir /usr/bin/hysteria");
|
||||
WriteToFile(configJson, "/usr/bin/hysteria/config.json");
|
||||
}
|
||||
}
|
||||
}
|
160
ProxySuper.Core/Services/MTProtoGoService.cs
Normal file
160
ProxySuper.Core/Services/MTProtoGoService.cs
Normal file
|
@ -0,0 +1,160 @@
|
|||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class MTProtoGoService : ServiceBase<MTProtoGoSettings>
|
||||
{
|
||||
public MTProtoGoService(Host host, MTProtoGoSettings settings) : base(host, settings)
|
||||
{
|
||||
}
|
||||
|
||||
public void Install()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "1. 检测系统环境";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 15;
|
||||
|
||||
Progress.Step = "2. 安装必要的系统工具";
|
||||
InstallSystemTools();
|
||||
Progress.Percentage = 25;
|
||||
|
||||
Progress.Step = "3. 配置防火墙";
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 35;
|
||||
|
||||
Progress.Step = "4. 安装docker";
|
||||
InstallDocker();
|
||||
Progress.Percentage = 50;
|
||||
|
||||
Progress.Step = "5. 生成密钥";
|
||||
//RunCmd("docker pull nineseconds/mtg:2"); //拉取v2版本命令,但是似乎不用也可以。
|
||||
//下面的命令是v1版本的命令格式。可以保留。将来如启用v1,可用。
|
||||
//Settings.SecretText = RunCmd($"docker run nineseconds/mtg:1 generate-secret -c {Settings.Cleartext} tls").TrimEnd('\n');
|
||||
Settings.SecretText = RunCmd($"docker run nineseconds/mtg:2 generate-secret {Settings.Cleartext}").TrimEnd('\n');
|
||||
Progress.Percentage = 65;
|
||||
|
||||
Progress.Step = "6. 生成配置文件";
|
||||
Progress.Desc = "创建配置";
|
||||
RunCmd("touch /etc/mtg.toml");
|
||||
|
||||
Progress.Desc = "写入配置内容";
|
||||
RunCmd($"echo \"secret=\\\"{Settings.SecretText}\\\"\" > /etc/mtg.toml");
|
||||
RunCmd($"echo \"bind-to=\\\"0.0.0.0:{Settings.Port}\\\"\" >> /etc/mtg.toml");
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Step = "7. 启动MTProto服务";
|
||||
RunCmd($"docker run -d -v /etc/mtg.toml:/config.toml --name=mtg --restart=always -p {Settings.Port + ":" + Settings.Port} nineseconds/mtg:2");
|
||||
Progress.Desc = "设置自启动MTProto服务";
|
||||
|
||||
Progress.Step = "安装完成";
|
||||
Progress.Percentage = 100;
|
||||
|
||||
AppendCommand("Host: " + Settings.Domain);
|
||||
AppendCommand("Port: " + Settings.Port);
|
||||
AppendCommand("Secret: " + Settings.SecretText);
|
||||
|
||||
NavigationService.Navigate<MTProtoGoConfigViewModel, MTProtoGoSettings>(Settings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Percentage = 0;
|
||||
Progress.Step = "卸载MTProto";
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureRootUser();
|
||||
Progress.Percentage = 30;
|
||||
|
||||
Progress.Desc = "删除docker容器";
|
||||
var cid = RunCmd("docker ps -q --filter name=mtg");
|
||||
RunCmd($"docker stop {cid}");
|
||||
RunCmd($"docker rm {cid}");
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "卸载完成";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateSettings()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Percentage = 0;
|
||||
Progress.Step = "更新MTProto配置";
|
||||
|
||||
Progress.Desc = "暂停MTProto服务";
|
||||
var cid = RunCmd("docker ps -q --filter name=mtg");
|
||||
RunCmd($"docker stop {cid}");
|
||||
Progress.Percentage = 50;
|
||||
|
||||
Progress.Desc = "生成密钥";
|
||||
//Settings.SecretText = RunCmd($"docker run nineseconds/mtg:1 generate-secret -c {Settings.Cleartext} tls").TrimEnd('\n'); //v1版本
|
||||
Settings.SecretText = RunCmd($"docker run nineseconds/mtg:2 generate-secret {Settings.Cleartext}").TrimEnd('\n');
|
||||
Progress.Percentage = 65;
|
||||
|
||||
Progress.Desc = "修改配置文件";
|
||||
RunCmd($"echo \"secret=\\\"{Settings.SecretText}\\\"\" > /etc/mtg.toml");
|
||||
RunCmd($"echo \"bind-to=\\\"0.0.0.0:{Settings.Port}\\\"\" >> /etc/mtg.toml");
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Desc = "重启MTProto服务";
|
||||
RunCmd($"docker restart {cid}");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "更新配置成功";
|
||||
|
||||
AppendCommand("Host: " + Settings.Domain);
|
||||
AppendCommand("Port: " + Settings.Port);
|
||||
AppendCommand("Secret: " + Settings.SecretText);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void InstallDocker()
|
||||
{
|
||||
Progress.Desc = "执行docker安装脚本";
|
||||
RunCmd("yes | curl https://get.docker.com | sh");
|
||||
|
||||
if (!FileExists("/usr/bin/docker"))
|
||||
{
|
||||
Progress.Desc = "docker安装失败";
|
||||
throw new Exception("docker安装失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,172 +0,0 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using Renci.SshNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class NaiveProxyProject : ProjectBase<NaiveProxySettings>
|
||||
{
|
||||
public NaiveProxyProject(SshClient sshClient, NaiveProxySettings parameters, Action<string> writeOutput) : base(sshClient, parameters, writeOutput)
|
||||
{
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
UninstallCaddy();
|
||||
WriteOutput("ProxyNaive卸载完成");
|
||||
}
|
||||
|
||||
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 override void Install()
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootAuth();
|
||||
|
||||
WriteOutput("检测安装系统环境...");
|
||||
EnsureSystemEnv();
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("配置服务器端口...");
|
||||
ConfigurePort();
|
||||
WriteOutput("端口配置完成");
|
||||
|
||||
WriteOutput("安装必要的系统工具...");
|
||||
ConfigureSoftware();
|
||||
WriteOutput("系统工具安装完成");
|
||||
|
||||
WriteOutput("检测IP6...");
|
||||
ConfigureIPv6();
|
||||
WriteOutput("检测IP6完成");
|
||||
|
||||
WriteOutput("配置防火墙...");
|
||||
ConfigureFirewall();
|
||||
WriteOutput("防火墙配置完成");
|
||||
|
||||
WriteOutput("同步系统和本地时间...");
|
||||
SyncTimeDiff();
|
||||
WriteOutput("时间同步完成");
|
||||
|
||||
WriteOutput("检测域名是否绑定本机IP...");
|
||||
ValidateDomain();
|
||||
WriteOutput("域名检测完成");
|
||||
|
||||
WriteOutput("安装NaiveProxy...");
|
||||
InstallNaiveProxy();
|
||||
WriteOutput("NaiveProxy安装完成");
|
||||
|
||||
WriteOutput("启动BBR");
|
||||
EnableBBR();
|
||||
|
||||
WriteOutput("************");
|
||||
WriteOutput("安装完成,尽情享用吧......");
|
||||
WriteOutput("************");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorLog = "安装终止," + ex.Message;
|
||||
WriteOutput(errorLog);
|
||||
MessageBox.Show(errorLog);
|
||||
}
|
||||
}
|
||||
|
||||
private void InstallNaiveProxy()
|
||||
{
|
||||
WriteOutput("安装 NaiveProxy");
|
||||
RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh yes | bash");
|
||||
UploadCaddyFile(false);
|
||||
ConfigNetwork();
|
||||
WriteOutput("NaiveProxy 安装完成");
|
||||
}
|
||||
|
||||
private void ConfigNetwork()
|
||||
{
|
||||
WriteOutput("优化网络参数");
|
||||
RunCmd(@"bash -c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.rmem_max = 67108864"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"sysctl -p");
|
||||
WriteOutput("网络参数优化完成");
|
||||
}
|
||||
|
||||
private void UploadCaddyFile(bool useCustomWeb = false)
|
||||
{
|
||||
var caddyStr = BuildConfig(useCustomWeb);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(caddyStr));
|
||||
|
||||
if (FileExists("/etc/caddy/Caddyfile"))
|
||||
{
|
||||
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
||||
}
|
||||
UploadFile(stream, "/etc/caddy/Caddyfile");
|
||||
RunCmd("systemctl restart caddy");
|
||||
}
|
||||
|
||||
private string BuildConfig(bool useCustomWeb = false)
|
||||
{
|
||||
var jsonStr = File.ReadAllText("Templates/NaiveProxy/naive_server.caddyfile");
|
||||
jsonStr = jsonStr.Replace("##port##", Parameters.Port.ToString());
|
||||
jsonStr = jsonStr.Replace("##domain##", Parameters.Domain);
|
||||
jsonStr = jsonStr.Replace("##basicauth##", $"basic_auth {Parameters.UserName} {Parameters.Password}");
|
||||
|
||||
if (!useCustomWeb && !string.IsNullOrEmpty(Parameters.MaskDomain))
|
||||
{
|
||||
var prefix = "http://";
|
||||
if (Parameters.MaskDomain.StartsWith("https://"))
|
||||
{
|
||||
prefix = "https://";
|
||||
}
|
||||
var domain = Parameters.MaskDomain
|
||||
.TrimStart("http://".ToCharArray())
|
||||
.TrimStart("https://".ToCharArray());
|
||||
|
||||
jsonStr = jsonStr.Replace("##reverse_proxy##", $"reverse_proxy {prefix}{domain} {{ \n header_up Host {domain} \n }}");
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonStr = jsonStr.Replace("##reverse_proxy##", "");
|
||||
jsonStr = jsonStr.Replace("#file_server", "file_server");
|
||||
}
|
||||
return jsonStr;
|
||||
}
|
||||
}
|
||||
}
|
282
ProxySuper.Core/Services/NaiveProxyService.cs
Normal file
282
ProxySuper.Core/Services/NaiveProxyService.cs
Normal file
|
@ -0,0 +1,282 @@
|
|||
using Microsoft.Win32;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class NaiveProxyService : ServiceBase<NaiveProxySettings>
|
||||
{
|
||||
public NaiveProxyService(Host host, NaiveProxySettings settings) : base(host, settings)
|
||||
{
|
||||
}
|
||||
|
||||
public void Install()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var index = 1;
|
||||
|
||||
Progress.Step = $"{index++}. 检测系统环境";
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Step = $"{index++}. 安装系统必要工具";
|
||||
InstallSystemTools();
|
||||
Progress.Percentage = 30;
|
||||
|
||||
Progress.Step = $"{index++}. 配置防火墙";
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Step = $"{index++}. 检测网络环境";
|
||||
EnsureNetwork();
|
||||
Progress.Percentage = 50;
|
||||
|
||||
Progress.Step = $"{index++}. 检测域名是否绑定到本机";
|
||||
ValidateDomain();
|
||||
Progress.Percentage = 60;
|
||||
|
||||
Progress.Step = $"{index++}. 安装NaiveProxy";
|
||||
InstallNaiveProxy();
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Step = $"{index++}. 优化网络参数";
|
||||
ConfigNetwork();
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Step = $"{index++}. 启动BBR";
|
||||
EnableBBR();
|
||||
|
||||
Progress.Desc = "重启Caddy服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "NaiveProxy安装成功";
|
||||
Progress.Desc = string.Empty;
|
||||
|
||||
AppendCommand("分享连接:");
|
||||
AppendCommand(ShareLink.BuildNaiveProxy(Settings));
|
||||
|
||||
NavigationService.Navigate<NaiveProxyConfigViewModel, NaiveProxySettings>(Settings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "卸载NaiveProxy";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "正在卸载...";
|
||||
RunCmd("rm -rf caddy_install.sh");
|
||||
Progress.Percentage = 10;
|
||||
|
||||
RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh");
|
||||
Progress.Percentage = 20;
|
||||
|
||||
RunCmd("yes | bash caddy_install.sh uninstall");
|
||||
Progress.Percentage = 80;
|
||||
|
||||
RunCmd("rm -rf caddy_install.sh");
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "卸载NaiveProxy成功";
|
||||
Progress.Desc = "卸载NaiveProxy成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateSettings()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "更新配置";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 30;
|
||||
|
||||
UploadCaddySettings();
|
||||
Progress.Desc = "重启Caddy服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Step = "更新配置成功";
|
||||
Progress.Desc = string.Empty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UploadWeb()
|
||||
{
|
||||
var fileDialog = new OpenFileDialog();
|
||||
fileDialog.Filter = "压缩文件|*.zip";
|
||||
fileDialog.FileOk += DoUploadWeb;
|
||||
fileDialog.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
#region 私有方法
|
||||
|
||||
private void DoUploadWeb(object sender, CancelEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
Progress.Step = "上传静态网站";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "创建网站目录";
|
||||
if (!FileExists("/usr/share/caddy"))
|
||||
{
|
||||
RunCmd("mkdir /usr/share/caddy");
|
||||
}
|
||||
RunCmd("rm -rf /usr/share/caddy/*");
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Desc = "正在上传文件";
|
||||
var file = sender as OpenFileDialog;
|
||||
using (var stream = file.OpenFile())
|
||||
{
|
||||
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");
|
||||
Progress.Percentage = 700;
|
||||
}
|
||||
|
||||
Progress.Desc = "上传Caddy配置文件";
|
||||
UploadCaddySettings(useCustomWeb: true);
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Desc = "重启caddy服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "上传静态网站成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void InstallNaiveProxy()
|
||||
{
|
||||
Progress.Desc = "下载NaiveProxy安装文件";
|
||||
RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh yes | bash");
|
||||
|
||||
Progress.Desc = "设置NaiveProxy开机启动";
|
||||
RunCmd("systemctl enable caddy");
|
||||
|
||||
Progress.Desc = "上传配置文件";
|
||||
UploadCaddySettings(false);
|
||||
}
|
||||
|
||||
private void ConfigNetwork()
|
||||
{
|
||||
RunCmd(@"bash -c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.rmem_max = 67108864"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"sysctl -p");
|
||||
}
|
||||
|
||||
private void UploadCaddySettings(bool useCustomWeb = false)
|
||||
{
|
||||
Progress.Desc = "生成配置文件";
|
||||
var caddyStr = BuildConfig(useCustomWeb);
|
||||
|
||||
if (FileExists("/etc/caddy/Caddyfile"))
|
||||
{
|
||||
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
||||
}
|
||||
|
||||
Progress.Desc = "上传配置文件";
|
||||
WriteToFile(caddyStr, "/etc/caddy/Caddyfile");
|
||||
}
|
||||
|
||||
private string BuildConfig(bool useCustomWeb = false)
|
||||
{
|
||||
var jsonStr = File.ReadAllText("Templates/NaiveProxy/naive_server.caddyfile");
|
||||
jsonStr = jsonStr.Replace("##port##", Settings.Port.ToString());
|
||||
jsonStr = jsonStr.Replace("##domain##", Settings.Domain);
|
||||
jsonStr = jsonStr.Replace("##basicauth##", $"basic_auth {Settings.UserName} {Settings.Password}");
|
||||
|
||||
if (!useCustomWeb && !string.IsNullOrEmpty(Settings.MaskDomain))
|
||||
{
|
||||
var prefix = "http://";
|
||||
if (Settings.MaskDomain.StartsWith("https://"))
|
||||
{
|
||||
prefix = "https://";
|
||||
}
|
||||
var domain = Settings.MaskDomain
|
||||
.TrimStart("http://".ToCharArray())
|
||||
.TrimStart("https://".ToCharArray());
|
||||
|
||||
jsonStr = jsonStr.Replace("##reverse_proxy##", $"reverse_proxy {prefix}{domain} {{ \n header_up Host {domain} \n }}");
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonStr = jsonStr.Replace("##reverse_proxy##", "");
|
||||
jsonStr = jsonStr.Replace("#file_server", "file_server");
|
||||
}
|
||||
return jsonStr;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,747 +0,0 @@
|
|||
using ProxySuper.Core.Helpers;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using Renci.SshNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public enum CmdType
|
||||
{
|
||||
None,
|
||||
Apt,
|
||||
Dnf,
|
||||
Yum
|
||||
}
|
||||
|
||||
public abstract class ProjectBase<TSettings> where TSettings : IProjectSettings
|
||||
{
|
||||
private SshClient _sshClient;
|
||||
|
||||
protected Action<string> WriteOutput;
|
||||
|
||||
protected CmdType CmdType { get; set; }
|
||||
|
||||
protected bool IsSELinux { get; set; }
|
||||
|
||||
protected bool OnlyIpv6 { get; set; }
|
||||
|
||||
protected string IPv4 { get; set; }
|
||||
|
||||
protected string IPv6 { get; set; }
|
||||
|
||||
protected TSettings Parameters { get; set; }
|
||||
|
||||
public ProjectBase(SshClient sshClient, TSettings parameters, Action<string> writeOutput)
|
||||
{
|
||||
_sshClient = sshClient;
|
||||
WriteOutput = writeOutput;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
protected string RunCmd(string cmdStr)
|
||||
{
|
||||
var cmd = _sshClient.CreateCommand(cmdStr);
|
||||
WriteOutput(cmdStr);
|
||||
|
||||
var result = cmd.Execute();
|
||||
WriteOutput(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行安装命令
|
||||
/// </summary>
|
||||
public abstract void Install();
|
||||
|
||||
/// <summary>
|
||||
/// 配置系统基础环境
|
||||
/// </summary>
|
||||
protected void EnsureSystemEnv()
|
||||
{
|
||||
string cmd;
|
||||
|
||||
// 确认安装命令
|
||||
if (CmdType == CmdType.None)
|
||||
{
|
||||
cmd = RunCmd("command -v apt-get");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
CmdType = CmdType.Apt;
|
||||
}
|
||||
}
|
||||
|
||||
if (CmdType == CmdType.None)
|
||||
{
|
||||
cmd = RunCmd("command -v dnf");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
CmdType = CmdType.Dnf;
|
||||
}
|
||||
}
|
||||
|
||||
if (CmdType == CmdType.None)
|
||||
{
|
||||
cmd = RunCmd("command -v yum");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
CmdType = CmdType.Yum;
|
||||
}
|
||||
}
|
||||
|
||||
// systemctl
|
||||
cmd = RunCmd("command -v systemctl");
|
||||
var hasSystemCtl = !string.IsNullOrEmpty(cmd);
|
||||
|
||||
// SELinux
|
||||
cmd = RunCmd("command -v getenforce");
|
||||
IsSELinux = !string.IsNullOrEmpty(cmd);
|
||||
|
||||
if (CmdType == CmdType.None || !hasSystemCtl)
|
||||
{
|
||||
throw new Exception("系统缺乏必要的安装组件如:apt-get||dnf||yum||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本");
|
||||
}
|
||||
|
||||
|
||||
// 判断是否启用了SELinux,如果启用了,并且工作在Enforcing模式下,则改为Permissive模式
|
||||
if (IsSELinux)
|
||||
{
|
||||
cmd = RunCmd("getenforce");
|
||||
|
||||
// 检测到系统启用SELinux,且工作在严格模式下,需改为宽松模式
|
||||
if (cmd.Contains("Enforcing"))
|
||||
{
|
||||
RunCmd("setenforce 0");
|
||||
RunCmd(@"sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确保Root账户登陆
|
||||
/// </summary>
|
||||
protected void EnsureRootAuth()
|
||||
{
|
||||
// 禁止一些可能产生的干扰信息
|
||||
RunCmd(@"sed -i 's/echo/#echo/g' ~/.bashrc");
|
||||
RunCmd(@"sed -i 's/echo/#echo/g' ~/.profile");
|
||||
|
||||
|
||||
// 检测是否运行在Root权限下
|
||||
var cmd = RunCmd("id -u");
|
||||
if (!cmd.Equals("0\n"))
|
||||
{
|
||||
throw new Exception("请使用Root账户登陆主机");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置IPV6环境
|
||||
/// </summary>
|
||||
protected void ConfigureIPv6()
|
||||
{
|
||||
if (IsOnlyIpv6())
|
||||
{
|
||||
SetNat64();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置必要的软件
|
||||
/// </summary>
|
||||
protected void ConfigureSoftware()
|
||||
{
|
||||
string cmd = RunCmd("command -v sudo");
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
RunCmd(GetInstallCmd("sudo"));
|
||||
}
|
||||
|
||||
// 安装curl,wget,unzip
|
||||
cmd = RunCmd("command -v curl");
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
RunCmd(GetInstallCmd("curl"));
|
||||
}
|
||||
|
||||
cmd = RunCmd("command -v wget");
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
RunCmd(GetInstallCmd("wget"));
|
||||
}
|
||||
|
||||
cmd = RunCmd("command -v unzip");
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
RunCmd(GetInstallCmd("unzip"));
|
||||
}
|
||||
|
||||
// 安装dig
|
||||
cmd = RunCmd("command -v dig");
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
if (CmdType == CmdType.Apt)
|
||||
{
|
||||
RunCmd(GetUpdateCmd());
|
||||
RunCmd(GetInstallCmd("dnsutils"));
|
||||
}
|
||||
else if (CmdType == CmdType.Dnf)
|
||||
{
|
||||
RunCmd(GetUpdateCmd());
|
||||
RunCmd(GetInstallCmd("bind-utils"));
|
||||
}
|
||||
else if (CmdType == CmdType.Yum)
|
||||
{
|
||||
RunCmd(GetUpdateCmd());
|
||||
RunCmd(GetInstallCmd("bind-utils"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 处理极其少见的xz-utils未安装的情况
|
||||
if (CmdType == CmdType.Apt)
|
||||
{
|
||||
RunCmd(GetInstallCmd("xz-utils"));
|
||||
}
|
||||
else
|
||||
{
|
||||
RunCmd(GetInstallCmd("xz-devel"));
|
||||
}
|
||||
|
||||
// 检测是否安装lsof
|
||||
cmd = RunCmd("command -v lsof");
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
RunCmd(GetInstallCmd("lsof"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭端口
|
||||
/// </summary>
|
||||
/// <param name="portList"></param>
|
||||
protected void ClosePort(params int[] portList)
|
||||
{
|
||||
string cmd;
|
||||
|
||||
cmd = RunCmd("command -v firewall-cmd");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
//有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld
|
||||
//用于保证acme.sh申请证书成功
|
||||
cmd = RunCmd("firewall-cmd --state");
|
||||
if (cmd.Trim() != "running")
|
||||
{
|
||||
RunCmd("systemctl restart firewalld");
|
||||
}
|
||||
|
||||
foreach (var port in portList)
|
||||
{
|
||||
RunCmd($"firewall-cmd --zone=public --remove-port={port}/tcp --permanent");
|
||||
RunCmd($"firewall-cmd --zone=public --remove-port={port}/udp --permanent");
|
||||
}
|
||||
RunCmd("yes | firewall-cmd --reload");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = RunCmd("command -v ufw");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
foreach (var port in portList)
|
||||
{
|
||||
RunCmd($"ufw delete allow {port}/tcp");
|
||||
RunCmd($"ufw delete allow {port}/udp");
|
||||
}
|
||||
RunCmd("yes | ufw reload");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开放端口
|
||||
/// </summary>
|
||||
/// <param name="portList"></param>
|
||||
protected void OpenPort(params int[] portList)
|
||||
{
|
||||
|
||||
string cmd;
|
||||
|
||||
cmd = RunCmd("command -v firewall-cmd");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
//有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld
|
||||
//用于保证acme.sh申请证书成功
|
||||
cmd = RunCmd("firewall-cmd --state");
|
||||
if (cmd.Trim() != "running")
|
||||
{
|
||||
RunCmd("systemctl restart firewalld");
|
||||
}
|
||||
|
||||
foreach (var port in portList)
|
||||
{
|
||||
RunCmd($"firewall-cmd --zone=public --add-port={port}/tcp --permanent");
|
||||
RunCmd($"firewall-cmd --zone=public --add-port={port}/udp --permanent");
|
||||
}
|
||||
RunCmd("yes | firewall-cmd --reload");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = RunCmd("command -v ufw");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
foreach (var port in portList)
|
||||
{
|
||||
RunCmd($"ufw allow {port}/tcp");
|
||||
RunCmd($"ufw allow {port}/udp");
|
||||
}
|
||||
RunCmd("yes | ufw reload");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置防火墙
|
||||
/// </summary>
|
||||
protected void ConfigureFirewall()
|
||||
{
|
||||
var portList = new List<int>();
|
||||
portList.Add(80);
|
||||
portList.Add(Parameters.Port);
|
||||
portList.AddRange(Parameters.FreePorts);
|
||||
|
||||
OpenPort(portList.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置同步时间差
|
||||
/// </summary>
|
||||
protected void SyncTimeDiff()
|
||||
{
|
||||
RunCmd("rm -f /etc/localtime");
|
||||
RunCmd("ln -s /usr/share/zoneinfo/UTC /etc/localtime");
|
||||
|
||||
var result = RunCmd("date +%s");
|
||||
var vpsSeconds = Convert.ToInt64(result);
|
||||
var localSeconds = (int)(DateTime.Now.ToUniversalTime() - DateTime.Parse("1970-01-01")).TotalSeconds;
|
||||
|
||||
if (Math.Abs(vpsSeconds - localSeconds) >= 90)
|
||||
{
|
||||
// 同步本地时间
|
||||
var netUtcTime = DateTimeUtils.GetUTCTime();
|
||||
DateTimeUtils.SetDate(netUtcTime.ToLocalTime());
|
||||
|
||||
// 同步VPS时间
|
||||
var utcTS = DateTimeUtils.GetUTCTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
long timeStampVPS = Convert.ToInt64(utcTS.TotalSeconds);
|
||||
RunCmd($"date --set=\"$(date \"+%Y-%m-%d %H:%M:%S\" -d @{timeStampVPS.ToString()})\"");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证域名是否绑定了主机
|
||||
/// </summary>
|
||||
protected void ValidateDomain()
|
||||
{
|
||||
if (OnlyIpv6)
|
||||
{
|
||||
string cmdFilter = @"| grep -oE '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' | head -n 1";
|
||||
var cmd = $"dig @resolver1.opendns.com AAAA {Parameters.Domain} +short -6 {cmdFilter}";
|
||||
var result = RunCmd(cmd).TrimEnd('\r', '\n');
|
||||
|
||||
if (result == IPv6) return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
string cmdFilter = @"| grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1";
|
||||
var cmd = $"dig @resolver1.opendns.com A {Parameters.Domain} +short -4 {cmdFilter}";
|
||||
var result = RunCmd(cmd).TrimEnd('\r', '\n');
|
||||
|
||||
if (result == IPv4) return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
var btnResult = MessageBox.Show(
|
||||
$"{Parameters.Domain}未能正常解析到服务器的IP,如果您使用了CDN请忽略,是否继续安装?", "提示", MessageBoxButton.YesNo);
|
||||
|
||||
if (btnResult == MessageBoxResult.No)
|
||||
{
|
||||
throw new Exception($"域名解析失败,安装停止!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否安装某个软件
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
protected bool FileExists(string path)
|
||||
{
|
||||
var cmdStr = $"if [[ -f {path} ]];then echo '1';else echo '0'; fi";
|
||||
var cmd = RunCmd(cmdStr);
|
||||
return cmd.Trim() == "1";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安装 Caddy
|
||||
/// </summary>
|
||||
protected void InstallCaddy()
|
||||
{
|
||||
RunCmd("rm -rf caddy_install.sh");
|
||||
RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh");
|
||||
RunCmd("yes | bash caddy_install.sh");
|
||||
RunCmd("rm -rf caddy_install.sh");
|
||||
RunCmd("systemctl enable caddy.service");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卸载 Caddy
|
||||
/// </summary>
|
||||
protected void UninstallCaddy()
|
||||
{
|
||||
RunCmd("rm -rf caddy_install.sh");
|
||||
RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh");
|
||||
RunCmd("yes | bash caddy_install.sh uninstall");
|
||||
RunCmd("rm -rf caddy_install.sh");
|
||||
RunCmd("rm -rf /usr/share/caddy");
|
||||
}
|
||||
|
||||
|
||||
#region 检测系统环境
|
||||
|
||||
private bool IsOnlyIpv6()
|
||||
{
|
||||
string cmd;
|
||||
|
||||
cmd = RunCmd(@"curl -s https://api.ip.sb/ip --ipv4 --max-time 8");
|
||||
IPv4 = cmd.TrimEnd('\r', '\n');
|
||||
|
||||
if (!string.IsNullOrEmpty(IPv4))
|
||||
{
|
||||
OnlyIpv6 = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd = RunCmd(@"curl -s https://api.ip.sb/ip --ipv6 --max-time 8");
|
||||
IPv6 = cmd.TrimEnd('\r', '\n');
|
||||
|
||||
if (string.IsNullOrEmpty(IPv6))
|
||||
{
|
||||
throw new Exception("未检测可用的的IP地址");
|
||||
}
|
||||
|
||||
OnlyIpv6 = true;
|
||||
return OnlyIpv6;
|
||||
}
|
||||
|
||||
private bool SetPortFree(int port, bool force = true)
|
||||
{
|
||||
string result = RunCmd($"lsof -n -P -i :{port} | grep LISTEN");
|
||||
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
if (force)
|
||||
{
|
||||
var btnResult = MessageBox.Show($"{port}端口被占用,将强制停止占用{port}端口的程序?", "提示", MessageBoxButton.YesNo);
|
||||
if (btnResult == MessageBoxResult.No)
|
||||
{
|
||||
throw new Exception($"{port}端口被占用,安装停止!");
|
||||
}
|
||||
|
||||
string[] process = result.Split(' ');
|
||||
RunCmd($"systemctl stop {process[0]}");
|
||||
RunCmd($"systemctl disable {process[0]}");
|
||||
RunCmd($"pkill {process[0]}");
|
||||
return SetPortFree(port, force: false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ConfigurePort()
|
||||
{
|
||||
if (Parameters.Port == 80 || Parameters.Port == 443)
|
||||
{
|
||||
SetPortFree(80);
|
||||
SetPortFree(443);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPortFree(80);
|
||||
SetPortFree(443);
|
||||
SetPortFree(Parameters.Port);
|
||||
|
||||
Parameters.FreePorts.ForEach(port =>
|
||||
{
|
||||
SetPortFree(port);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetNat64()
|
||||
{
|
||||
var dns64List = FilterFastestIP();
|
||||
if (dns64List.Count == 0)
|
||||
{
|
||||
throw new Exception("未找到有效的Nat64网关");
|
||||
}
|
||||
|
||||
var exists = FileExists("/etc/resolv.conf.proxysu");
|
||||
if (!exists)
|
||||
{
|
||||
var cmdStr = @"mv /etc/resolv.conf /etc/resolv.conf.proxysu";
|
||||
RunCmd(cmdStr);
|
||||
}
|
||||
|
||||
foreach (var gateip in dns64List)
|
||||
{
|
||||
RunCmd($"echo \"nameserver {gateip}\" > /etc/resolv.conf");
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemoveNat64()
|
||||
{
|
||||
RunCmd("rm /etc/resolv.conf");
|
||||
RunCmd("mv /etc/resolv.conf.proxysu /etc/resolv.conf");
|
||||
}
|
||||
|
||||
private List<string> FilterFastestIP()
|
||||
{
|
||||
string[] gateNat64 = {
|
||||
"2a01:4f9:c010:3f02::1",
|
||||
"2001:67c:2b0::4",
|
||||
"2001:67c:2b0::6",
|
||||
"2a09:11c0:f1:bbf0::70",
|
||||
"2a01:4f8:c2c:123f::1",
|
||||
"2001:67c:27e4:15::6411",
|
||||
"2001:67c:27e4::64",
|
||||
"2001:67c:27e4:15::64",
|
||||
"2001:67c:27e4::60",
|
||||
"2a00:1098:2b::1",
|
||||
"2a03:7900:2:0:31:3:104:161",
|
||||
"2a00:1098:2c::1",
|
||||
"2a09:11c0:100::53",
|
||||
};
|
||||
|
||||
Dictionary<string, float> dns64List = new Dictionary<string, float>();
|
||||
foreach (var gateip in gateNat64)
|
||||
{
|
||||
var cmdStr = $"ping6 -c4 {gateip} | grep avg | awk '{{print $4}}'|cut -d/ -f2";
|
||||
var cmd = RunCmd(cmdStr);
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
if (float.TryParse(cmd, out float delay))
|
||||
{
|
||||
dns64List.Add(gateip, delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dns64List.Keys.ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region BBR
|
||||
private bool CheckKernelVersionBBR(string kernelVer)
|
||||
{
|
||||
string[] linuxKernelCompared = kernelVer.Split('.');
|
||||
if (int.Parse(linuxKernelCompared[0]) > 4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (int.Parse(linuxKernelCompared[0]) < 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (int.Parse(linuxKernelCompared[0]) == 4)
|
||||
{
|
||||
if (int.Parse(linuxKernelCompared[1]) >= 9)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (int.Parse(linuxKernelCompared[1]) < 9)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
protected void EnableBBR()
|
||||
{
|
||||
var osVersion = RunCmd("uname -r");
|
||||
var canInstallBBR = CheckKernelVersionBBR(osVersion.Split('-')[0]);
|
||||
|
||||
var bbrInfo = RunCmd("sysctl net.ipv4.tcp_congestion_control | grep bbr");
|
||||
var installed = bbrInfo.Contains("bbr");
|
||||
if (canInstallBBR && !installed)
|
||||
{
|
||||
RunCmd(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"sysctl -p");
|
||||
|
||||
if (OnlyIpv6)
|
||||
{
|
||||
RemoveNat64();
|
||||
}
|
||||
WriteOutput("BBR启动成功");
|
||||
}
|
||||
|
||||
if (!canInstallBBR)
|
||||
{
|
||||
WriteOutput("****** 系统不满足启用BBR条件,启动失败。 ******");
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 安装证书
|
||||
/// </summary>
|
||||
/// <param name="certPath"></param>
|
||||
/// <param name="keyPath"></param>
|
||||
protected void InstallCert(string dirPath, string certName, string keyName)
|
||||
{
|
||||
string certPath = dirPath + "/" + certName;
|
||||
string keyPath = dirPath + "/" + keyName;
|
||||
|
||||
// 安装依赖
|
||||
RunCmd(GetInstallCmd("socat"));
|
||||
|
||||
// 解决搬瓦工CentOS缺少问题
|
||||
RunCmd(GetInstallCmd("automake autoconf libtool"));
|
||||
|
||||
// 安装Acme
|
||||
var result = RunCmd($"curl https://get.acme.sh yes | sh");
|
||||
if (result.Contains("Install success"))
|
||||
{
|
||||
WriteOutput("安装 acme.sh 成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteOutput("安装 acme.sh 失败,请联系开发者!");
|
||||
throw new Exception("安装 acme.sh 失败,请联系开发者!");
|
||||
}
|
||||
|
||||
RunCmd("cd ~/.acme.sh/");
|
||||
RunCmd("alias acme.sh=~/.acme.sh/acme.sh");
|
||||
|
||||
// 申请证书
|
||||
if (OnlyIpv6)
|
||||
{
|
||||
var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --listen-v6 --pre-hook \"service caddy stop\" --post-hook \"service caddy start\"";
|
||||
result = RunCmd(cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --pre-hook \"service caddy stop\" --post-hook \"service caddy start\"";
|
||||
result = RunCmd(cmd);
|
||||
}
|
||||
|
||||
if (result.Contains("success"))
|
||||
{
|
||||
WriteOutput("申请证书成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteOutput("申请证书失败,如果申请次数过多请更换二级域名,或联系开发者!");
|
||||
throw new Exception("申请证书失败,如果申请次数过多请更换二级域名,或联系开发者!");
|
||||
}
|
||||
|
||||
// 安装证书
|
||||
RunCmd($"mkdir -p {dirPath}");
|
||||
RunCmd($"/root/.acme.sh/acme.sh --installcert -d {Parameters.Domain} --certpath {certPath} --keypath {keyPath} --capath {certPath}");
|
||||
|
||||
result = RunCmd($@"if [ ! -f ""{keyPath}"" ]; then echo ""0""; else echo ""1""; fi | head -n 1");
|
||||
|
||||
if (result.Contains("1"))
|
||||
{
|
||||
WriteOutput("安装证书成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteOutput("安装证书失败,请联系开发者!");
|
||||
throw new Exception("安装证书失败,请联系开发者!");
|
||||
}
|
||||
|
||||
RunCmd($"chmod 755 {dirPath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="path"></param>
|
||||
protected void UploadFile(Stream stream, string path)
|
||||
{
|
||||
using (var sftp = new SftpClient(_sshClient.ConnectionInfo))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.UploadFile(stream, path, true);
|
||||
sftp.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据系统环境匹配更新命令
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected string GetUpdateCmd()
|
||||
{
|
||||
if (CmdType == CmdType.Apt)
|
||||
{
|
||||
return "apt-get update";
|
||||
}
|
||||
else if (CmdType == CmdType.Dnf)
|
||||
{
|
||||
return "dnf clean all;dnf makecache";
|
||||
}
|
||||
else if (CmdType == CmdType.Yum)
|
||||
{
|
||||
return "yum clean all;yum makecache";
|
||||
}
|
||||
|
||||
throw new Exception("未识别的系统");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据系统匹配安装命令
|
||||
/// </summary>
|
||||
/// <param name="soft"></param>
|
||||
/// <returns></returns>
|
||||
protected string GetInstallCmd(string soft)
|
||||
{
|
||||
if (CmdType == CmdType.Apt)
|
||||
{
|
||||
return "echo y | apt-get install " + soft;
|
||||
}
|
||||
else if (CmdType == CmdType.Dnf)
|
||||
{
|
||||
return "echo y | dnf -y install " + soft;
|
||||
}
|
||||
else if (CmdType == CmdType.Yum)
|
||||
{
|
||||
return "echo y | yum -y install " + soft;
|
||||
}
|
||||
|
||||
throw new Exception("未识别的系统");
|
||||
}
|
||||
}
|
||||
}
|
843
ProxySuper.Core/Services/ServiceBase.cs
Normal file
843
ProxySuper.Core/Services/ServiceBase.cs
Normal file
|
@ -0,0 +1,843 @@
|
|||
using MvvmCross;
|
||||
using MvvmCross.Navigation;
|
||||
using ProxySuper.Core.Helpers;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using Renci.SshNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public enum ArchType
|
||||
{
|
||||
x86,
|
||||
arm
|
||||
}
|
||||
|
||||
public enum CmdType
|
||||
{
|
||||
None,
|
||||
Yum,
|
||||
Apt,
|
||||
Dnf
|
||||
}
|
||||
|
||||
public abstract class ServiceBase<TSettings> where TSettings : IProjectSettings
|
||||
{
|
||||
private Host _host;
|
||||
|
||||
private SshClient _sshClient;
|
||||
|
||||
private ProjectProgress _progress;
|
||||
|
||||
public ServiceBase(Host host, TSettings settings)
|
||||
{
|
||||
_host = host;
|
||||
|
||||
Settings = settings;
|
||||
|
||||
var connection = CreateConnectionInfo();
|
||||
if (connection != null)
|
||||
{
|
||||
_sshClient = new SshClient(connection);
|
||||
}
|
||||
|
||||
_progress = new ProjectProgress();
|
||||
|
||||
ArchType = ArchType.x86;
|
||||
|
||||
CmdType = CmdType.None;
|
||||
|
||||
IPv4 = string.Empty;
|
||||
|
||||
IPv6 = string.Empty;
|
||||
|
||||
IsOnlyIPv6 = false;
|
||||
|
||||
NavigationService = Mvx.IoCProvider.Resolve<IMvxNavigationService>();
|
||||
}
|
||||
|
||||
public string RunCmd(string command)
|
||||
{
|
||||
AppendCommand(command);
|
||||
|
||||
string result;
|
||||
if (_sshClient.IsConnected)
|
||||
{
|
||||
result = _sshClient.CreateCommand(command).Execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "连接已断开";
|
||||
}
|
||||
|
||||
AppendCommand(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ProjectProgress Progress => _progress;
|
||||
|
||||
public TSettings Settings { get; set; }
|
||||
|
||||
public ArchType ArchType { get; set; }
|
||||
|
||||
public CmdType CmdType { get; set; }
|
||||
|
||||
public string IPv4 { get; set; }
|
||||
|
||||
public string IPv6 { get; set; }
|
||||
|
||||
public bool IsOnlyIPv6 { get; set; }
|
||||
|
||||
public IMvxNavigationService NavigationService { get; set; }
|
||||
|
||||
|
||||
#region 公用方法
|
||||
public void Connect()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
if (_sshClient == null)
|
||||
{
|
||||
MessageBox.Show("无法建立连接,连接参数有误!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_sshClient.IsConnected == false)
|
||||
{
|
||||
Progress.Desc = ("正在与服务器建立连接");
|
||||
try
|
||||
{
|
||||
_sshClient.Connect();
|
||||
Progress.Desc = ("建立连接成功");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Progress.Desc = ("连接失败," + e.Message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
_sshClient?.Disconnect();
|
||||
});
|
||||
}
|
||||
|
||||
protected void WriteToFile(string text, string path)
|
||||
{
|
||||
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text)))
|
||||
{
|
||||
using (var sftp = new SftpClient(_sshClient.ConnectionInfo))
|
||||
{
|
||||
try
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.UploadFile(stream, path, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
sftp.Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected bool FileExists(string path)
|
||||
{
|
||||
var cmdStr = $"if [[ -f {path} ]];then echo '1';else echo '0'; fi";
|
||||
var cmd = RunCmd(cmdStr);
|
||||
return cmd.Trim() == "1";
|
||||
}
|
||||
|
||||
protected void SyncTimeDiff()
|
||||
{
|
||||
RunCmd("rm -f /etc/localtime");
|
||||
RunCmd("ln -s /usr/share/zoneinfo/UTC /etc/localtime");
|
||||
|
||||
var result = RunCmd("date +%s");
|
||||
var vpsSeconds = Convert.ToInt64(result);
|
||||
var localSeconds = (int)(DateTime.Now.ToUniversalTime() - DateTime.Parse("1970-01-01")).TotalSeconds;
|
||||
|
||||
if (Math.Abs(vpsSeconds - localSeconds) >= 90)
|
||||
{
|
||||
// 同步本地时间
|
||||
var netUtcTime = DateTimeUtils.GetUTCTime();
|
||||
DateTimeUtils.SetDate(netUtcTime.ToLocalTime());
|
||||
|
||||
// 同步VPS时间
|
||||
var utcTS = DateTimeUtils.GetUTCTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
long timeStampVPS = Convert.ToInt64(utcTS.TotalSeconds);
|
||||
RunCmd($"date --set=\"$(date \"+%Y-%m-%d %H:%M:%S\" -d @{timeStampVPS.ToString()})\"");
|
||||
}
|
||||
}
|
||||
|
||||
protected void ValidateDomain()
|
||||
{
|
||||
var domainIP = RunCmd($"ping \"{Settings.Domain}\" -c 1" + @" | sed '1{s/[^(]*(//;s/).*//;q}'")
|
||||
.Trim('\r', '\n');
|
||||
|
||||
if (IsOnlyIPv6)
|
||||
{
|
||||
Progress.Desc = ($"本机IP({IPv6})");
|
||||
if (IPv6 != domainIP)
|
||||
{
|
||||
//throw new Exception("域名解析地址与服务器IP不匹配!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Progress.Desc = ($"本机IP({IPv4})");
|
||||
Progress.Desc = ($"域名IP({domainIP})");
|
||||
if (IPv4 != domainIP)
|
||||
{
|
||||
//throw new Exception("域名解析地址与服务器IP不匹配!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void EnableBBR()
|
||||
{
|
||||
Progress.Desc = ("检查系统是否满足启动BBR条件");
|
||||
var osVersion = RunCmd("uname -r");
|
||||
var canInstallBBR = CheckKernelVersionBBR(osVersion.Split('-')[0]);
|
||||
|
||||
var bbrInfo = RunCmd("sysctl net.ipv4.tcp_congestion_control | grep bbr");
|
||||
var installed = bbrInfo.Contains("bbr");
|
||||
if (canInstallBBR && !installed)
|
||||
{
|
||||
RunCmd(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
|
||||
RunCmd(@"sysctl -p");
|
||||
|
||||
if (IsOnlyIPv6)
|
||||
{
|
||||
RemoveNat64();
|
||||
}
|
||||
Progress.Desc = ("启动BBR成功");
|
||||
}
|
||||
|
||||
if (!canInstallBBR)
|
||||
{
|
||||
Progress.Desc = ("系统不满足启用BBR条件,启动失败。");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安装证书
|
||||
/// </summary>
|
||||
/// <param name="certPath"></param>
|
||||
/// <param name="keyPath"></param>
|
||||
protected void InstallCert(string dirPath, string certName, string keyName)
|
||||
{
|
||||
string certPath = dirPath + "/" + certName;
|
||||
string keyPath = dirPath + "/" + keyName;
|
||||
|
||||
Progress.Desc = ("安装Acme软件");
|
||||
#region 安装Acme
|
||||
// 安装依赖
|
||||
RunCmd(GetInstallCmd("socat"));
|
||||
|
||||
// 解决搬瓦工CentOS缺少问题
|
||||
RunCmd(GetInstallCmd("automake autoconf libtool"));
|
||||
|
||||
// 安装Acme
|
||||
var result = RunCmd($"curl https://get.acme.sh yes | sh");
|
||||
if (!result.Contains("nstall success"))
|
||||
{
|
||||
throw new Exception("安装 Acme 失败,请联系开发者!");
|
||||
}
|
||||
|
||||
RunCmd("alias acme.sh=~/.acme.sh/acme.sh");
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 申请证书
|
||||
Progress.Desc = ("正在申请证书");
|
||||
// 申请证书
|
||||
var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Settings.Domain} {(IsOnlyIPv6 ? "--listen-v6" : "")} --pre-hook \"systemctl stop caddy\" --post-hook \"systemctl start caddy\" --server letsencrypt";
|
||||
result = RunCmd(cmd);
|
||||
|
||||
|
||||
if (result.Contains("success"))
|
||||
{
|
||||
Progress.Desc = ("申请证书成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
Progress.Desc = ("申请证书失败,如果申请次数过多请更换二级域名,或联系开发者!");
|
||||
throw new Exception("申请证书失败,如果申请次数过多请更换二级域名,或联系开发者!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
// 安装证书
|
||||
Progress.Desc = ("安装TLS证书");
|
||||
RunCmd($"mkdir -p {dirPath}");
|
||||
RunCmd($"/root/.acme.sh/acme.sh --installcert -d {Settings.Domain} --certpath {certPath} --keypath {keyPath} --capath {certPath}");
|
||||
|
||||
result = RunCmd($@"if [ ! -f ""{keyPath}"" ]; then echo ""0""; else echo ""1""; fi | head -n 1");
|
||||
|
||||
if (result.Contains("1"))
|
||||
{
|
||||
Progress.Desc = ("安装证书成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
Progress.Desc = ("安装证书失败,请联系开发者!");
|
||||
throw new Exception("安装证书失败,请联系开发者!");
|
||||
}
|
||||
|
||||
RunCmd($"chmod 755 {dirPath}");
|
||||
}
|
||||
|
||||
protected void UploadFile(Stream stream, string path)
|
||||
{
|
||||
using (var sftp = new SftpClient(_sshClient.ConnectionInfo))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.UploadFile(stream, path, true);
|
||||
sftp.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureRootUser()
|
||||
{
|
||||
// 禁止一些可能产生的干扰信息
|
||||
RunCmd(@"sed -i 's/echo/#echo/g' ~/.bashrc");
|
||||
RunCmd(@"sed -i 's/echo/#echo/g' ~/.profile");
|
||||
|
||||
var result = RunCmd("id -u");
|
||||
if (!result.Equals("0\n"))
|
||||
{
|
||||
throw new Exception("请使用Root权限账户登录!");
|
||||
}
|
||||
}
|
||||
|
||||
public void UninstallCaddy()
|
||||
{
|
||||
Progress.Desc = "关闭Caddy服务";
|
||||
RunCmd("systemctl stop caddy");
|
||||
RunCmd("systemctl disable caddy");
|
||||
|
||||
Progress.Desc = "彻底删除Caddy文件";
|
||||
RunCmd("rm -rf /etc/systemd/system/caddy.service");
|
||||
RunCmd("rm -rf /usr/bin/caddy");
|
||||
RunCmd("rm -rf /usr/share/caddy");
|
||||
RunCmd("rm -rf /etc/caddy");
|
||||
}
|
||||
|
||||
public void EnsureSystemEnv()
|
||||
{
|
||||
// cpu架构
|
||||
Progress.Desc = ("检测CPU架构");
|
||||
EnsureCPU();
|
||||
|
||||
// 安装命令类型
|
||||
Progress.Desc = ("检测系统安装命令");
|
||||
EnsureCmdType();
|
||||
|
||||
// systemctl
|
||||
Progress.Desc = ("检测Systemctl");
|
||||
EnsureSystemctl();
|
||||
|
||||
// SELinux
|
||||
Progress.Desc = ("检测SELinux");
|
||||
ConfigSELinux();
|
||||
}
|
||||
|
||||
public void InstallSystemTools()
|
||||
{
|
||||
Progress.Desc = ("更新安装包");
|
||||
RunUpdateCmd();
|
||||
|
||||
Progress.Desc = ("安装sudo工具");
|
||||
InstallSoftware("sudo");
|
||||
|
||||
Progress.Desc = ("安装curl工具");
|
||||
InstallSoftware("curl");
|
||||
|
||||
Progress.Desc = ("安装wget工具");
|
||||
InstallSoftware("wget");
|
||||
|
||||
Progress.Desc = ("安装ping工具");
|
||||
InstallSoftware("ping");
|
||||
|
||||
Progress.Desc = ("安装unzip工具");
|
||||
InstallSoftware("unzip");
|
||||
|
||||
Progress.Desc = ("安装cron工具");
|
||||
InstallSoftware("cron");
|
||||
|
||||
Progress.Desc = ("安装lsof工具");
|
||||
InstallSoftware("lsof");
|
||||
|
||||
Progress.Desc = ("安装systemd工具");
|
||||
InstallSoftware("systemd");
|
||||
}
|
||||
|
||||
public void ConfigFirewalld()
|
||||
{
|
||||
Progress.Desc = ("释放被占用的端口");
|
||||
Settings.FreePorts.ForEach(port => SetPortFree(port));
|
||||
|
||||
Progress.Desc = ("开放需要的端口");
|
||||
OpenPort(Settings.FreePorts.ToArray());
|
||||
}
|
||||
|
||||
public void ResetFirewalld()
|
||||
{
|
||||
ClosePort(Settings.FreePorts.ToArray());
|
||||
}
|
||||
|
||||
public void EnsureNetwork()
|
||||
{
|
||||
string cmd;
|
||||
|
||||
Progress.Desc = ("检测IPv4");
|
||||
cmd = RunCmd(@"curl -4 ip.sb");
|
||||
IPv4 = cmd.TrimEnd('\r', '\n');
|
||||
|
||||
Progress.Desc = ($"IPv4地址为{IPv4}");
|
||||
if (!string.IsNullOrEmpty(IPv4))
|
||||
{
|
||||
IsOnlyIPv6 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Progress.Desc = ("检测IPv6");
|
||||
cmd = RunCmd(@"curl -6 ip.sb");
|
||||
IPv6 = cmd.TrimEnd('\r', '\n');
|
||||
Progress.Desc = ($"IPv6地址为{IPv6}");
|
||||
|
||||
IsOnlyIPv6 = true;
|
||||
SetNat64();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(IPv4) && string.IsNullOrEmpty(IPv6))
|
||||
{
|
||||
throw new Exception("未检测到服务器公网IP,请检查网络或重试。");
|
||||
}
|
||||
}
|
||||
|
||||
public void InstallCaddy()
|
||||
{
|
||||
RunCmd("rm -rf caddy.tar.gz");
|
||||
RunCmd("rm -rf /etc/caddy");
|
||||
RunCmd("rm -rf /usr/share/caddy");
|
||||
|
||||
var url = "https://github.com/caddyserver/caddy/releases/download/v2.4.3/caddy_2.4.3_linux_amd64.tar.gz";
|
||||
if (ArchType == ArchType.arm)
|
||||
{
|
||||
url = "https://github.com/caddyserver/caddy/releases/download/v2.4.3/caddy_2.4.3_linux_armv7.tar.gz";
|
||||
}
|
||||
|
||||
RunCmd($"wget -O caddy.tar.gz {url}");
|
||||
RunCmd("mkdir /etc/caddy");
|
||||
RunCmd("tar -zxvf caddy.tar.gz -C /etc/caddy");
|
||||
RunCmd("cp -rf /etc/caddy/caddy /usr/bin");
|
||||
WriteToFile(Caddy.DefaultCaddyFile, "/etc/caddy/Caddyfile");
|
||||
WriteToFile(Caddy.Service, "/etc/systemd/system/caddy.service");
|
||||
RunCmd("systemctl daemon-reload");
|
||||
RunCmd("systemctl enable caddy");
|
||||
|
||||
RunCmd("mkdir /usr/share/caddy");
|
||||
RunCmd("chmod 775 /usr/share/caddy");
|
||||
|
||||
if (!FileExists("/usr/bin/caddy"))
|
||||
{
|
||||
throw new Exception("Caddy服务器安装失败,请联系开发者!");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 检测System环境
|
||||
private void EnsureCPU()
|
||||
{
|
||||
var result = RunCmd("uname -m");
|
||||
if (result.Contains("x86"))
|
||||
{
|
||||
ArchType = ArchType.x86;
|
||||
}
|
||||
else if (result.Contains("arm") || result.Contains("arch"))
|
||||
{
|
||||
ArchType = ArchType.arm;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureCmdType()
|
||||
{
|
||||
var result = string.Empty;
|
||||
|
||||
if (CmdType == CmdType.None)
|
||||
{
|
||||
result = RunCmd("command -v apt");
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
CmdType = CmdType.Apt;
|
||||
}
|
||||
}
|
||||
|
||||
if (CmdType == CmdType.None)
|
||||
{
|
||||
result = RunCmd("command -v dnf");
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
CmdType = CmdType.Dnf;
|
||||
}
|
||||
}
|
||||
|
||||
if (CmdType == CmdType.None)
|
||||
{
|
||||
result = RunCmd("command -v yum");
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
CmdType = CmdType.Yum;
|
||||
}
|
||||
}
|
||||
|
||||
if (CmdType == CmdType.None)
|
||||
{
|
||||
throw new Exception("未检测到正确的系统安装命令,请尝试使用ProxySU推荐的系统版本安装!");
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureSystemctl()
|
||||
{
|
||||
var result = RunCmd("command -v systemctl");
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
throw new Exception("系统缺少 systemctl 组件,请尝试使用ProxySU推荐的系统版本安装!");
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigSELinux()
|
||||
{
|
||||
// SELinux
|
||||
var result = RunCmd("command -v getenforce");
|
||||
var isSELinux = !string.IsNullOrEmpty(result);
|
||||
|
||||
// 判断是否启用了SELinux,如果启用了,并且工作在Enforcing模式下,则改为Permissive模式
|
||||
if (isSELinux)
|
||||
{
|
||||
result = RunCmd("getenforce");
|
||||
|
||||
// 检测到系统启用SELinux,且工作在严格模式下,需改为宽松模式
|
||||
if (result.Contains("Enforcing"))
|
||||
{
|
||||
RunCmd("setenforce 0");
|
||||
RunCmd(@"sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 私有方法
|
||||
|
||||
protected void SetNat64()
|
||||
{
|
||||
var dns64List = FilterFastestIP();
|
||||
if (dns64List.Count == 0)
|
||||
{
|
||||
throw new Exception("未找到有效的Nat64网关");
|
||||
}
|
||||
|
||||
var exists = FileExists("/etc/resolv.conf.proxysu");
|
||||
if (!exists)
|
||||
{
|
||||
var cmdStr = @"mv /etc/resolv.conf /etc/resolv.conf.proxysu";
|
||||
RunCmd(cmdStr);
|
||||
}
|
||||
|
||||
foreach (var gateip in dns64List)
|
||||
{
|
||||
RunCmd($"echo \"nameserver {gateip}\" > /etc/resolv.conf");
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemoveNat64()
|
||||
{
|
||||
RunCmd("rm /etc/resolv.conf");
|
||||
RunCmd("mv /etc/resolv.conf.proxysu /etc/resolv.conf");
|
||||
}
|
||||
|
||||
protected void AppendCommand(string command)
|
||||
{
|
||||
if (!command.EndsWith("\n"))
|
||||
{
|
||||
command += "\n";
|
||||
}
|
||||
Progress.Logs += command;
|
||||
}
|
||||
|
||||
private List<string> FilterFastestIP()
|
||||
{
|
||||
string[] gateNat64 = {
|
||||
"2a01:4f9:c010:3f02::1",
|
||||
"2001:67c:2b0::4",
|
||||
"2001:67c:2b0::6",
|
||||
"2a09:11c0:f1:bbf0::70",
|
||||
"2a01:4f8:c2c:123f::1",
|
||||
"2001:67c:27e4:15::6411",
|
||||
"2001:67c:27e4::64",
|
||||
"2001:67c:27e4:15::64",
|
||||
"2001:67c:27e4::60",
|
||||
"2a00:1098:2b::1",
|
||||
"2a03:7900:2:0:31:3:104:161",
|
||||
"2a00:1098:2c::1",
|
||||
"2a09:11c0:100::53",
|
||||
};
|
||||
|
||||
Dictionary<string, float> dns64List = new Dictionary<string, float>();
|
||||
foreach (var gateip in gateNat64)
|
||||
{
|
||||
var cmdStr = $"ping6 -c4 {gateip} | grep avg | awk '{{print $4}}'|cut -d/ -f2";
|
||||
var cmd = RunCmd(cmdStr);
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
if (float.TryParse(cmd, out float delay))
|
||||
{
|
||||
dns64List.Add(gateip, delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dns64List.Keys.ToList();
|
||||
}
|
||||
|
||||
private bool CheckKernelVersionBBR(string kernelVer)
|
||||
{
|
||||
string[] linuxKernelCompared = kernelVer.Split('.');
|
||||
if (int.Parse(linuxKernelCompared[0]) > 4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (int.Parse(linuxKernelCompared[0]) < 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (int.Parse(linuxKernelCompared[0]) == 4)
|
||||
{
|
||||
if (int.Parse(linuxKernelCompared[1]) >= 9)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (int.Parse(linuxKernelCompared[1]) < 9)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private void SetPortFree(int port)
|
||||
{
|
||||
string result = RunCmd($"lsof -n -P -i :{port} | grep LISTEN");
|
||||
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
string[] process = result.Split(' ');
|
||||
RunCmd($"systemctl stop {process[0]}");
|
||||
RunCmd($"systemctl disable {process[0]}");
|
||||
RunCmd($"pkill {process[0]}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenPort(params int[] portList)
|
||||
{
|
||||
string cmd;
|
||||
|
||||
cmd = RunCmd("command -v firewall-cmd");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
//有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld
|
||||
//用于保证acme.sh申请证书成功
|
||||
cmd = RunCmd("firewall-cmd --state");
|
||||
if (cmd.Trim() != "running")
|
||||
{
|
||||
RunCmd("systemctl restart firewalld");
|
||||
}
|
||||
|
||||
// 保持 ssh 端口开放
|
||||
RunCmd($"firewall-cmd --add-port={_host.Port}/tcp --permanent");
|
||||
foreach (var port in portList)
|
||||
{
|
||||
RunCmd($"firewall-cmd --add-port={port}/tcp --permanent");
|
||||
RunCmd($"firewall-cmd --add-port={port}/udp --permanent");
|
||||
}
|
||||
|
||||
RunCmd("yes | firewall-cmd --reload");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = RunCmd("command -v ufw");
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
RunCmd(GetInstallCmd("ufw"));
|
||||
RunCmd("echo y | ufw enable");
|
||||
}
|
||||
|
||||
// 保持 ssh 端口开放
|
||||
RunCmd($"ufw allow {_host.Port}/tcp");
|
||||
foreach (var port in portList)
|
||||
{
|
||||
RunCmd($"ufw allow {port}/tcp");
|
||||
RunCmd($"ufw allow {port}/udp");
|
||||
}
|
||||
RunCmd("yes | ufw reload");
|
||||
}
|
||||
}
|
||||
|
||||
private void ClosePort(params int[] portList)
|
||||
{
|
||||
string cmd;
|
||||
|
||||
cmd = RunCmd("command -v firewall-cmd");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
//有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld
|
||||
//用于保证acme.sh申请证书成功
|
||||
cmd = RunCmd("firewall-cmd --state");
|
||||
if (cmd.Trim() != "running")
|
||||
{
|
||||
RunCmd("systemctl restart firewalld");
|
||||
}
|
||||
|
||||
foreach (var port in portList)
|
||||
{
|
||||
RunCmd($"firewall-cmd --remove-port={port}/tcp --permanent");
|
||||
RunCmd($"firewall-cmd --remove-port={port}/udp --permanent");
|
||||
}
|
||||
RunCmd("yes | firewall-cmd --reload");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = RunCmd("command -v ufw");
|
||||
if (!string.IsNullOrEmpty(cmd))
|
||||
{
|
||||
foreach (var port in portList)
|
||||
{
|
||||
RunCmd($"ufw delete allow {port}/tcp");
|
||||
RunCmd($"ufw delete allow {port}/udp");
|
||||
}
|
||||
RunCmd("yes | ufw reload");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InstallSoftware(string software)
|
||||
{
|
||||
var result = RunCmd($"command -v {software}");
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
RunCmd(GetInstallCmd(software));
|
||||
}
|
||||
}
|
||||
|
||||
private string GetInstallCmd(string soft)
|
||||
{
|
||||
if (CmdType == CmdType.Apt)
|
||||
{
|
||||
return $"apt install -y {soft}";
|
||||
}
|
||||
else if (CmdType == CmdType.Yum)
|
||||
{
|
||||
return $"yum install -y {soft}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"dnf install -y {soft}";
|
||||
}
|
||||
}
|
||||
|
||||
private void RunUpdateCmd()
|
||||
{
|
||||
if (CmdType == CmdType.Apt)
|
||||
{
|
||||
RunCmd($"apt update -y");
|
||||
}
|
||||
else if (CmdType == CmdType.Yum)
|
||||
{
|
||||
RunCmd($"yum update -y");
|
||||
}
|
||||
else
|
||||
{
|
||||
RunCmd($"dnf update -y");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ConnectionInfo CreateConnectionInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var authMethods = new List<AuthenticationMethod>();
|
||||
|
||||
if (_host.SecretType == LoginSecretType.Password)
|
||||
{
|
||||
authMethods.Add(new PasswordAuthenticationMethod(_host.UserName, _host.Password));
|
||||
}
|
||||
|
||||
if (_host.SecretType == LoginSecretType.PrivateKey)
|
||||
{
|
||||
PrivateKeyFile keyFile;
|
||||
if (string.IsNullOrEmpty(_host.PrivateKeyPassPhrase))
|
||||
{
|
||||
keyFile = new PrivateKeyFile(_host.PrivateKeyPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyFile = new PrivateKeyFile(_host.PrivateKeyPath, _host.PrivateKeyPassPhrase);
|
||||
}
|
||||
authMethods.Add(new PrivateKeyAuthenticationMethod(_host.UserName, keyFile));
|
||||
}
|
||||
|
||||
if (_host.Proxy.Type == ProxyTypes.None)
|
||||
{
|
||||
return new ConnectionInfo(
|
||||
host: _host.Address,
|
||||
username: _host.UserName,
|
||||
port: _host.Port,
|
||||
authenticationMethods: authMethods.ToArray());
|
||||
}
|
||||
|
||||
return new ConnectionInfo(
|
||||
host: _host.Address,
|
||||
port: _host.Port,
|
||||
username: _host.UserName,
|
||||
proxyType: _host.Proxy.Type,
|
||||
proxyHost: _host.Proxy.Address,
|
||||
proxyPort: _host.Proxy.Port,
|
||||
proxyUsername: _host.Proxy.UserName, proxyPassword: _host.Proxy.Password,
|
||||
authenticationMethods: authMethods.ToArray());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,16 +1,44 @@
|
|||
using Newtonsoft.Json;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class ShareLink
|
||||
{
|
||||
public static string BuildBrook(BrookSettings settings)
|
||||
{
|
||||
var password = HttpUtility.UrlEncode(settings.Password);
|
||||
|
||||
if (settings.BrookType == BrookType.server)
|
||||
{
|
||||
var address = HttpUtility.UrlEncode($"{settings.IP}:{settings.Port}");
|
||||
return $"brook://server?password={password}&server={address}";
|
||||
}
|
||||
|
||||
if (settings.BrookType == BrookType.wsserver)
|
||||
{
|
||||
var address = HttpUtility.UrlEncode($"ws://{settings.IP}:{settings.Port}");
|
||||
return $"brook://wsserver?password={password}&wsserver={address}";
|
||||
}
|
||||
|
||||
if (settings.BrookType == BrookType.wssserver)
|
||||
{
|
||||
var address = HttpUtility.UrlEncode($"wss://{settings.Domain}:{settings.Port}");
|
||||
return $"brook://wssserver?password={password}&wssserver={address}";
|
||||
}
|
||||
|
||||
if (settings.BrookType == BrookType.socks5)
|
||||
{
|
||||
var address = HttpUtility.UrlEncode($"socks5://{settings.IP}:{settings.Port}");
|
||||
return $"brook://socks5?password={password}&socks5={address}";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string BuildNaiveProxy(NaiveProxySettings settings)
|
||||
{
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
|
@ -41,30 +69,32 @@ namespace ProxySuper.Core.Services
|
|||
return strBuilder.ToString();
|
||||
}
|
||||
|
||||
public static string Build(XrayType xrayType, XraySettings settings)
|
||||
public static string Build(RayType xrayType, V2raySettings settings)
|
||||
{
|
||||
|
||||
switch (xrayType)
|
||||
{
|
||||
case XrayType.VLESS_TCP:
|
||||
case XrayType.VLESS_TCP_XTLS:
|
||||
case XrayType.VLESS_WS:
|
||||
case XrayType.VLESS_KCP:
|
||||
case XrayType.VLESS_gRPC:
|
||||
case XrayType.Trojan_TCP:
|
||||
case RayType.VLESS_TCP:
|
||||
case RayType.VLESS_TCP_XTLS:
|
||||
case RayType.VLESS_WS:
|
||||
case RayType.VLESS_KCP:
|
||||
case RayType.VLESS_QUIC:
|
||||
case RayType.VLESS_gRPC:
|
||||
case RayType.Trojan_TCP:
|
||||
return BuildVlessShareLink(xrayType, settings);
|
||||
case XrayType.VMESS_TCP:
|
||||
case XrayType.VMESS_WS:
|
||||
case XrayType.VMESS_KCP:
|
||||
case RayType.VMESS_TCP:
|
||||
case RayType.VMESS_WS:
|
||||
case RayType.VMESS_KCP:
|
||||
case RayType.VMESS_QUIC:
|
||||
return BuildVmessShareLink(xrayType, settings);
|
||||
case XrayType.ShadowsocksAEAD:
|
||||
case RayType.ShadowsocksAEAD:
|
||||
return BuildShadowSocksShareLink(settings);
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private static string BuildShadowSocksShareLink(XraySettings settings)
|
||||
private static string BuildShadowSocksShareLink(V2raySettings settings)
|
||||
{
|
||||
var _method = settings.ShadowSocksMethod;
|
||||
var _password = settings.ShadowSocksPassword;
|
||||
|
@ -75,7 +105,7 @@ namespace ProxySuper.Core.Services
|
|||
return "ss://" + base64URL + "#ShadowSocks";
|
||||
}
|
||||
|
||||
private static string BuildVmessShareLink(XrayType xrayType, XraySettings settings)
|
||||
private static string BuildVmessShareLink(RayType xrayType, V2raySettings settings)
|
||||
{
|
||||
var vmess = new Vmess
|
||||
{
|
||||
|
@ -94,19 +124,19 @@ namespace ProxySuper.Core.Services
|
|||
|
||||
switch (xrayType)
|
||||
{
|
||||
case XrayType.VMESS_TCP:
|
||||
case RayType.VMESS_TCP:
|
||||
vmess.ps = "vmess-tcp-tls";
|
||||
vmess.net = "tcp";
|
||||
vmess.type = "http";
|
||||
vmess.path = settings.VMESS_TCP_Path;
|
||||
break;
|
||||
case XrayType.VMESS_WS:
|
||||
case RayType.VMESS_WS:
|
||||
vmess.ps = "vmess-ws-tls";
|
||||
vmess.net = "ws";
|
||||
vmess.type = "none";
|
||||
vmess.path = settings.VMESS_WS_Path;
|
||||
break;
|
||||
case XrayType.VMESS_KCP:
|
||||
case RayType.VMESS_KCP:
|
||||
vmess.ps = "vmess-mKCP";
|
||||
vmess.port = settings.VMESS_KCP_Port.ToString();
|
||||
vmess.net = "kcp";
|
||||
|
@ -114,6 +144,15 @@ namespace ProxySuper.Core.Services
|
|||
vmess.path = settings.VMESS_KCP_Seed;
|
||||
vmess.tls = "";
|
||||
break;
|
||||
case RayType.VMESS_QUIC:
|
||||
vmess.ps = "vmess-quic";
|
||||
vmess.port = settings.VMESS_QUIC_Port.ToString();
|
||||
vmess.net = "quic";
|
||||
vmess.type = settings.VMESS_QUIC_Type;
|
||||
vmess.path = settings.VMESS_QUIC_Key;
|
||||
vmess.host = settings.VMESS_QUIC_Security;
|
||||
vmess.tls = "tls";
|
||||
break;
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
|
@ -122,7 +161,7 @@ namespace ProxySuper.Core.Services
|
|||
return $"vmess://" + base64Url;
|
||||
}
|
||||
|
||||
private static string BuildVlessShareLink(XrayType xrayType, XraySettings settings)
|
||||
private static string BuildVlessShareLink(RayType xrayType, V2raySettings settings)
|
||||
{
|
||||
var _protocol = string.Empty;
|
||||
var _uuid = settings.UUID;
|
||||
|
@ -134,44 +173,47 @@ namespace ProxySuper.Core.Services
|
|||
var _path = "/";
|
||||
var _host = settings.Domain;
|
||||
var _descriptiveText = string.Empty;
|
||||
var _headerType = "none";
|
||||
var _seed = string.Empty;
|
||||
|
||||
switch (xrayType)
|
||||
{
|
||||
case XrayType.VLESS_TCP:
|
||||
case RayType.VLESS_TCP:
|
||||
_protocol = "vless";
|
||||
_type = "tcp";
|
||||
_descriptiveText = "vless-tcp-tls";
|
||||
break;
|
||||
case XrayType.VLESS_TCP_XTLS:
|
||||
case RayType.VLESS_TCP_XTLS:
|
||||
_protocol = "vless";
|
||||
_type = "tcp";
|
||||
_security = "xtls";
|
||||
_security = "tls";
|
||||
_descriptiveText = "vless-tcp-xtls";
|
||||
break;
|
||||
case XrayType.VLESS_WS:
|
||||
case RayType.VLESS_WS:
|
||||
_protocol = "vless";
|
||||
_type = "ws";
|
||||
_path = settings.VLESS_WS_Path;
|
||||
_descriptiveText = "vless-ws-tls";
|
||||
break;
|
||||
case XrayType.VLESS_KCP:
|
||||
case RayType.VLESS_KCP:
|
||||
_protocol = "vless";
|
||||
_type = "kcp";
|
||||
_headerType = settings.VLESS_KCP_Type;
|
||||
_seed = settings.VLESS_KCP_Seed;
|
||||
_port = settings.VLESS_KCP_Port;
|
||||
_security = "none";
|
||||
_descriptiveText = "vless-mKCP";
|
||||
break;
|
||||
case XrayType.VLESS_gRPC:
|
||||
case RayType.VLESS_QUIC:
|
||||
_protocol = "vless";
|
||||
_port = settings.VLESS_QUIC_Port;
|
||||
_type = "quic";
|
||||
_security = "tls";
|
||||
_descriptiveText = "vless-quic";
|
||||
break;
|
||||
case RayType.VLESS_gRPC:
|
||||
_protocol = "vless";
|
||||
_type = "grpc";
|
||||
_path = settings.VLESS_gRPC_ServiceName;
|
||||
_port = settings.VLESS_gRPC_Port;
|
||||
_descriptiveText = "vless-gRPC";
|
||||
break;
|
||||
case XrayType.Trojan_TCP:
|
||||
case RayType.Trojan_TCP:
|
||||
_protocol = "trojan";
|
||||
_uuid = settings.TrojanPassword;
|
||||
_descriptiveText = "trojan-tcp";
|
||||
|
@ -182,21 +224,41 @@ namespace ProxySuper.Core.Services
|
|||
|
||||
|
||||
string parametersURL = string.Empty;
|
||||
if (xrayType != XrayType.Trojan_TCP)
|
||||
if (xrayType != RayType.Trojan_TCP)
|
||||
{
|
||||
// 4.3 传输层相关段
|
||||
parametersURL = $"?type={_type}&encryption={_encryption}&security={_security}&path={HttpUtility.UrlEncode(_path)}&headerType={_headerType}";
|
||||
parametersURL = $"?type={_type}&encryption={_encryption}&security={_security}&path={HttpUtility.UrlEncode(_path)}";
|
||||
|
||||
// kcp
|
||||
if (xrayType == XrayType.VLESS_KCP)
|
||||
if (xrayType == RayType.VLESS_KCP)
|
||||
{
|
||||
parametersURL += $"&seed={_seed}";
|
||||
parametersURL += $"&seed={settings.VLESS_KCP_Seed}&headerType={settings.VLESS_KCP_Type}";
|
||||
}
|
||||
|
||||
if (xrayType == RayType.VLESS_QUIC)
|
||||
{
|
||||
parametersURL += $"&quicSecurity={settings.VLESS_QUIC_Security}";
|
||||
if (settings.VLESS_QUIC_Security != "none")
|
||||
{
|
||||
parametersURL += $"&key={HttpUtility.UrlEncode(settings.VLESS_QUIC_Key)}";
|
||||
}
|
||||
parametersURL += $"&headerType={settings.VLESS_QUIC_Type}";
|
||||
}
|
||||
|
||||
// 4.4 TLS 相关段
|
||||
if (xrayType == XrayType.VLESS_TCP_XTLS)
|
||||
if (settings is XraySettings)
|
||||
{
|
||||
parametersURL += "&flow=xtls-rprx-direct";
|
||||
if (xrayType == RayType.VLESS_TCP_XTLS)
|
||||
{
|
||||
var xraySettings = settings as XraySettings;
|
||||
parametersURL += $"&flow={xraySettings.Flow}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (xrayType == RayType.VLESS_gRPC)
|
||||
{
|
||||
parametersURL += $"&serviceName={settings.VLESS_gRPC_ServiceName}&mode=gun";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
|
|
|
@ -1,188 +0,0 @@
|
|||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using Renci.SshNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class TrojanGoProject : ProjectBase<TrojanGoSettings>
|
||||
{
|
||||
public TrojanGoProject(SshClient sshClient, TrojanGoSettings parameters, Action<string> writeOutput) : base(sshClient, parameters, writeOutput)
|
||||
{
|
||||
}
|
||||
|
||||
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");
|
||||
base.UninstallCaddy();
|
||||
|
||||
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()
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootAuth();
|
||||
|
||||
if (FileExists("/usr/local/bin/trojan-go"))
|
||||
{
|
||||
var btnResult = MessageBox.Show("已经安装Trojan-Go,是否需要重装?", "提示", MessageBoxButton.YesNo);
|
||||
if (btnResult == MessageBoxResult.No)
|
||||
{
|
||||
MessageBox.Show("安装终止", "提示");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
WriteOutput("检测安装系统环境...");
|
||||
EnsureSystemEnv();
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("配置服务器端口...");
|
||||
ConfigurePort();
|
||||
WriteOutput("端口配置完成");
|
||||
|
||||
WriteOutput("安装必要的系统工具...");
|
||||
ConfigureSoftware();
|
||||
WriteOutput("系统工具安装完成");
|
||||
|
||||
WriteOutput("检测IP6...");
|
||||
ConfigureIPv6();
|
||||
WriteOutput("检测IP6完成");
|
||||
|
||||
WriteOutput("配置防火墙...");
|
||||
ConfigureFirewall();
|
||||
WriteOutput("防火墙配置完成");
|
||||
|
||||
WriteOutput("同步系统和本地时间...");
|
||||
SyncTimeDiff();
|
||||
WriteOutput("时间同步完成");
|
||||
|
||||
WriteOutput("检测域名是否绑定本机IP...");
|
||||
ValidateDomain();
|
||||
WriteOutput("域名检测完成");
|
||||
|
||||
WriteOutput("安装Caddy...");
|
||||
InstallCaddy();
|
||||
UploadCaddyFile();
|
||||
WriteOutput("Caddy安装完成");
|
||||
|
||||
WriteOutput("安装Trojan-Go...");
|
||||
InstallTrojanGo();
|
||||
WriteOutput("Trojan-Go安装完成");
|
||||
|
||||
|
||||
WriteOutput("启动BBR");
|
||||
EnableBBR();
|
||||
|
||||
RunCmd("systemctl restart trojan-go");
|
||||
WriteOutput("************");
|
||||
WriteOutput("安装完成,尽情享用吧......");
|
||||
WriteOutput("************");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorLog = "安装终止," + ex.Message;
|
||||
WriteOutput(errorLog);
|
||||
MessageBox.Show(errorLog);
|
||||
}
|
||||
}
|
||||
|
||||
private void InstallTrojanGo()
|
||||
{
|
||||
WriteOutput("安装Trojan-Go");
|
||||
RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh yes | bash");
|
||||
var success = FileExists("/usr/local/bin/trojan-go");
|
||||
if (success == false)
|
||||
{
|
||||
throw new Exception("trojan-go 安装失败,请联系开发者!");
|
||||
}
|
||||
|
||||
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/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 enable trojan-go");
|
||||
RunCmd("systemctl start trojan-go");
|
||||
WriteOutput("Trojan-Go 安装完成");
|
||||
|
||||
InstallCert(
|
||||
dirPath: "/usr/local/etc/trojan-go",
|
||||
certName: "trojan-go.crt",
|
||||
keyName: "trojan-go.key");
|
||||
|
||||
if (FileExists("/usr/local/etc/trojan-go/config.json"))
|
||||
{
|
||||
RunCmd("mv /usr/local/etc/trojan-go/config.json config.json.old");
|
||||
}
|
||||
|
||||
UploadTrojanGoSettings();
|
||||
}
|
||||
|
||||
private void UploadTrojanGoSettings()
|
||||
{
|
||||
// 上传配置
|
||||
var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Parameters);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(settings));
|
||||
UploadFile(stream, "/usr/local/etc/trojan-go/config.json");
|
||||
RunCmd("systemctl restart trojan-go");
|
||||
}
|
||||
|
||||
private void UploadCaddyFile(bool useCustomWeb = false)
|
||||
{
|
||||
var config = TrojanGoConfigBuilder.BuildCaddyConfig(Parameters, useCustomWeb);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(config));
|
||||
if (FileExists("/etc/caddy/Caddyfile"))
|
||||
{
|
||||
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
||||
}
|
||||
UploadFile(stream, "/etc/caddy/Caddyfile");
|
||||
RunCmd("systemctl restart caddy");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
401
ProxySuper.Core/Services/TrojanGoService.cs
Normal file
401
ProxySuper.Core/Services/TrojanGoService.cs
Normal file
|
@ -0,0 +1,401 @@
|
|||
using Microsoft.Win32;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class TrojanGoService : ServiceBase<TrojanGoSettings>
|
||||
{
|
||||
public TrojanGoService(Host host, TrojanGoSettings settings) : base(host, settings)
|
||||
{
|
||||
}
|
||||
|
||||
public void Install()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Percentage = 0;
|
||||
Progress.Step = "安装TrojanGo";
|
||||
Progress.Desc = "安装TrojanGo";
|
||||
EnsureRootUser();
|
||||
|
||||
if (FileExists("/usr/local/bin/trojan-go"))
|
||||
{
|
||||
var btnResult = MessageBox.Show("已经安装Trojan-Go,是否需要重装?", "提示", MessageBoxButton.YesNo);
|
||||
if (btnResult == MessageBoxResult.No)
|
||||
{
|
||||
MessageBox.Show("安装终止", "提示");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var index = 1;
|
||||
Progress.Step = $"{index++}. 检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 10;
|
||||
|
||||
Progress.Step = $"{index++}. 安装必要的系统工具";
|
||||
InstallSystemTools();
|
||||
Progress.Percentage = 30;
|
||||
|
||||
Progress.Step = $"{index++}. 配置防火墙";
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Step = $"{index++}. 检测网络环境";
|
||||
EnsureNetwork();
|
||||
Progress.Percentage = 50;
|
||||
|
||||
Progress.Step = $"{index++}. 检测域名是否解析到本机";
|
||||
ValidateDomain();
|
||||
Progress.Percentage = 60;
|
||||
|
||||
Progress.Step = $"{index++}. 安装Caddy服务";
|
||||
InstallCaddy();
|
||||
Progress.Percentage = 70;
|
||||
|
||||
Progress.Step = $"{index++}. 安装TrojanGo";
|
||||
InstallTrojanGo();
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Step = $"{index++}. 上传Caddy配置文件";
|
||||
UploadCaddySettings();
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Step = $"{index++}. 启动BBR";
|
||||
EnableBBR();
|
||||
|
||||
Progress.Step = $"{index++}. 重启caddy服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
|
||||
Progress.Desc = "启用Trojan-Go开机启动";
|
||||
RunCmd("systemctl enable trojan-go");
|
||||
RunCmd("systemctl restart trojan-go");
|
||||
|
||||
AppendCommand("分享连接:");
|
||||
AppendCommand(ShareLink.BuildTrojanGo(Settings));
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "安装成功";
|
||||
Progress.Desc = string.Empty;
|
||||
|
||||
if (!Settings.WithTLS)
|
||||
{
|
||||
Progress.Step = "安装成功,请上传您的 TLS 证书。";
|
||||
}
|
||||
else
|
||||
{
|
||||
NavigationService.Navigate<TrojanGoConfigViewModel, TrojanGoSettings>(Settings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
Progress.Step = "卸载Trojgan-Go";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "停止Trojan—Go服务";
|
||||
RunCmd("systemctl stop trojan-go");
|
||||
Progress.Percentage = 40;
|
||||
|
||||
|
||||
Progress.Desc = "卸载Caddy";
|
||||
UninstallCaddy();
|
||||
Progress.Percentage = 60;
|
||||
|
||||
Progress.Desc = "卸载Trojan-Go";
|
||||
RunCmd("rm -rf /usr/local/bin/trojan-go");
|
||||
RunCmd("rm -rf /usr/local/etc/trojan-go");
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Desc = "删除 acme.sh";
|
||||
RunCmd("acme.sh --uninstall");
|
||||
RunCmd("rm -r ~/.acme.sh");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "卸载Trojan-Go成功";
|
||||
Progress.Desc = string.Empty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateSettings()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "更新配置文件";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 30;
|
||||
|
||||
Progress.Desc = "更新配置文件";
|
||||
UploadTrojanGoSettings();
|
||||
Progress.Percentage = 70;
|
||||
|
||||
Progress.Desc = "重启caddy服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Desc = "重启Trojan-Go服务器";
|
||||
RunCmd("systemctl restart trojan-go");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "更新配置成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UploadWeb()
|
||||
{
|
||||
var fileDialog = new OpenFileDialog();
|
||||
fileDialog.Filter = "压缩文件|*.zip";
|
||||
fileDialog.FileOk += DoUploadWeb;
|
||||
fileDialog.ShowDialog();
|
||||
}
|
||||
|
||||
public void UploadCert()
|
||||
{
|
||||
var fileDialog = new OpenFileDialog();
|
||||
fileDialog.Filter = "压缩文件|*.zip";
|
||||
fileDialog.FileOk += DoUploadCert;
|
||||
fileDialog.ShowDialog();
|
||||
}
|
||||
|
||||
public void ApplyForCert()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Progress.Step = "续签证书";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "安装TLS证书";
|
||||
InstallCert(
|
||||
dirPath: "/usr/local/etc/trojan-go",
|
||||
certName: "trojan-go.crt",
|
||||
keyName: "trojan-go.key");
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Desc = "重启Trojan-go服务";
|
||||
RunCmd("systemctl restart trojan-go");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "续签证书成功";
|
||||
Progress.Desc = "续签证书成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#region 私有方法
|
||||
|
||||
|
||||
private void DoUploadCert(object sender, CancelEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
Progress.Percentage = 0;
|
||||
Progress.Step = "上传自有证书";
|
||||
Progress.Desc = "检测系统环境";
|
||||
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "正在上传文件";
|
||||
var file = sender as OpenFileDialog;
|
||||
using (var stream = file.OpenFile())
|
||||
{
|
||||
var oldFileName = $"ssl_{DateTime.Now.Ticks}";
|
||||
RunCmd($"mv /usr/local/etc/trojan-go/ssl /usr/local/etc/trojan-go/{oldFileName}");
|
||||
|
||||
RunCmd("mkdir /usr/local/etc/trojan-go/ssl");
|
||||
UploadFile(stream, "/usr/local/etc/trojan-go/ssl/ssl.zip");
|
||||
RunCmd("unzip /usr/local/etc/trojan-go/ssl/ssl.zip -d /usr/local/etc/trojan-go/ssl");
|
||||
}
|
||||
|
||||
var crtFiles = RunCmd("find /usr/local/etc/trojan-go/ssl/*.crt").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
var keyFiles = RunCmd("find /usr/local/etc/trojan-go/ssl/*.key").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (crtFiles.Length > 0 && keyFiles.Length > 0)
|
||||
{
|
||||
RunCmd($"mv {crtFiles[0]} /usr/local/etc/trojan-go/ssl/trojan-go.crt");
|
||||
RunCmd($"mv {keyFiles[0]} /usr/local/etc/trojan-go/ssl/trojan-go.key");
|
||||
}
|
||||
else
|
||||
{
|
||||
Progress.Step = "上传失败";
|
||||
Progress.Desc = "上传证书失败,缺少 .crt 和 .key 文件";
|
||||
return;
|
||||
}
|
||||
|
||||
Progress.Desc = "重启trojan-go服务";
|
||||
RunCmd("systemctl restart trojan-go");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "上传证书完成";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void DoUploadWeb(object sender, CancelEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
Progress.Step = "上传静态网站";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "创建网站目录";
|
||||
if (!FileExists("/usr/share/caddy"))
|
||||
{
|
||||
RunCmd("mkdir /usr/share/caddy");
|
||||
}
|
||||
RunCmd("rm -rf /usr/share/caddy/*");
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Desc = "正在上传文件";
|
||||
var file = sender as OpenFileDialog;
|
||||
using (var stream = file.OpenFile())
|
||||
{
|
||||
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");
|
||||
Progress.Percentage = 700;
|
||||
}
|
||||
|
||||
Progress.Desc = "上传Caddy配置文件";
|
||||
UploadCaddySettings(useCustomWeb: true);
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Desc = "重启caddy服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "上传静态网站成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void UploadCaddySettings(bool useCustomWeb = false)
|
||||
{
|
||||
var config = TrojanGoConfigBuilder.BuildCaddyConfig(Settings, useCustomWeb);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(config));
|
||||
if (FileExists("/etc/caddy/Caddyfile"))
|
||||
{
|
||||
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
||||
}
|
||||
UploadFile(stream, "/etc/caddy/Caddyfile");
|
||||
}
|
||||
|
||||
private void InstallTrojanGo()
|
||||
{
|
||||
RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh yes | bash");
|
||||
var success = FileExists("/usr/local/bin/trojan-go");
|
||||
if (success == false)
|
||||
{
|
||||
throw new Exception("trojan-go 安装失败,请联系开发者!");
|
||||
}
|
||||
|
||||
Progress.Desc = "设置Trojan-Go权限";
|
||||
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"systemctl daemon-reload");
|
||||
|
||||
if (Settings.WithTLS)
|
||||
{
|
||||
Progress.Desc = "安装TLS证书";
|
||||
InstallCert(
|
||||
dirPath: "/usr/local/etc/trojan-go/ssl",
|
||||
certName: "trojan-go.crt",
|
||||
keyName: "trojan-go.key");
|
||||
}
|
||||
|
||||
Progress.Desc = "上传Trojan-Go配置文件";
|
||||
UploadTrojanGoSettings();
|
||||
}
|
||||
|
||||
private void UploadTrojanGoSettings()
|
||||
{
|
||||
// 上传配置
|
||||
Progress.Desc = "生成配置文件";
|
||||
var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Settings);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(settings));
|
||||
|
||||
Progress.Desc = "正在上传配置文件";
|
||||
UploadFile(stream, "/usr/local/etc/trojan-go/config.json");
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
287
ProxySuper.Core/Services/V2rayConfigBuilder.cs
Normal file
287
ProxySuper.Core/Services/V2rayConfigBuilder.cs
Normal file
|
@ -0,0 +1,287 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class V2rayConfigBuilder
|
||||
{
|
||||
private const string ServerLogDir = @"Templates\v2ray\server\00_log";
|
||||
private const string ServerApiDir = @"Templates\v2ray\server\01_api";
|
||||
private const string ServerDnsDir = @"Templates\v2ray\server\02_dns";
|
||||
private const string ServerRoutingDir = @"Templates\v2ray\server\03_routing";
|
||||
private const string ServerPolicyDir = @"Templates\v2ray\server\04_policy";
|
||||
private const string ServerInboundsDir = @"Templates\v2ray\server\05_inbounds";
|
||||
private const string ServerOutboundsDir = @"Templates\v2ray\server\06_outbounds";
|
||||
private const string ServerTransportDir = @"Templates\v2ray\server\07_transport";
|
||||
private const string ServerStatsDir = @"Templates\v2ray\server\08_stats";
|
||||
private const string ServerReverseDir = @"Templates\v2ray\server\09_reverse";
|
||||
private const string CaddyFileDir = @"Templates\v2ray\caddy";
|
||||
|
||||
public static int VLESS_TCP_Port = 1110;
|
||||
public static int VLESS_WS_Port = 1111;
|
||||
public static int VLESS_H2_Port = 1112;
|
||||
|
||||
public static int VMESS_TCP_Port = 1210;
|
||||
public static int VMESS_WS_Port = 1211;
|
||||
public static int VMESS_H2_Port = 1212;
|
||||
|
||||
public static int Trojan_TCP_Port = 1310;
|
||||
public static int Trojan_WS_Port = 1311;
|
||||
|
||||
public static int FullbackPort = 8080;
|
||||
|
||||
|
||||
|
||||
public static dynamic LoadV2rayConfig()
|
||||
{
|
||||
dynamic logObj = LoadJsonObj(Path.Combine(ServerLogDir, "00_log.json"));
|
||||
dynamic apiObj = LoadJsonObj(Path.Combine(ServerApiDir, "01_api.json"));
|
||||
dynamic dnsObj = LoadJsonObj(Path.Combine(ServerDnsDir, "02_dns.json"));
|
||||
dynamic routingObj = LoadJsonObj(Path.Combine(ServerRoutingDir, "03_routing.json"));
|
||||
dynamic policyObj = LoadJsonObj(Path.Combine(ServerPolicyDir, "04_policy.json"));
|
||||
dynamic inboundsObj = LoadJsonObj(Path.Combine(ServerInboundsDir, "05_inbounds.json"));
|
||||
dynamic outboundsObj = LoadJsonObj(Path.Combine(ServerOutboundsDir, "06_outbounds.json"));
|
||||
dynamic transportObj = LoadJsonObj(Path.Combine(ServerTransportDir, "07_transport.json"));
|
||||
dynamic statsObj = LoadJsonObj(Path.Combine(ServerStatsDir, "08_stats.json"));
|
||||
dynamic reverseObj = LoadJsonObj(Path.Combine(ServerReverseDir, "09_reverse.json"));
|
||||
|
||||
return new
|
||||
{
|
||||
log = logObj["log"],
|
||||
//api = apiObj["api"], api不能为空
|
||||
dns = dnsObj["dns"],
|
||||
routing = routingObj["routing"],
|
||||
policy = policyObj["policy"],
|
||||
inbounds = inboundsObj["inbounds"],
|
||||
outbounds = outboundsObj["outbounds"],
|
||||
transport = transportObj["transport"],
|
||||
stats = statsObj["stats"],
|
||||
reverse = reverseObj["reverse"]
|
||||
};
|
||||
}
|
||||
|
||||
public static string BuildCaddyConfig(V2raySettings parameters, bool useCustomWeb = false)
|
||||
{
|
||||
var caddyStr = File.ReadAllText(Path.Combine(CaddyFileDir, "base.caddyfile"));
|
||||
caddyStr = caddyStr.Replace("##domain##", parameters.IsIPAddress ? "" : parameters.Domain);
|
||||
caddyStr = caddyStr.Replace("##port##", FullbackPort.ToString());
|
||||
|
||||
if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain))
|
||||
{
|
||||
var prefix = "http://";
|
||||
if (parameters.MaskDomain.StartsWith("https://"))
|
||||
{
|
||||
prefix = "https://";
|
||||
}
|
||||
var domain = parameters.MaskDomain
|
||||
.TrimStart("http://".ToCharArray())
|
||||
.TrimStart("https://".ToCharArray());
|
||||
|
||||
caddyStr = caddyStr.Replace("##reverse_proxy##", $"reverse_proxy {prefix}{domain} {{ \n header_up Host {domain} \n }}");
|
||||
}
|
||||
else
|
||||
{
|
||||
caddyStr = caddyStr.Replace("##reverse_proxy##", "");
|
||||
}
|
||||
|
||||
return caddyStr;
|
||||
}
|
||||
|
||||
private static void SetClients(dynamic bound, List<string> uuidList)
|
||||
{
|
||||
bound.settings.clients.Clear();
|
||||
uuidList.ForEach(id =>
|
||||
{
|
||||
object obj;
|
||||
|
||||
obj = new { id = id };
|
||||
|
||||
bound.settings.clients.Add(JToken.FromObject(obj));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static string BuildV2rayConfig(V2raySettings parameters)
|
||||
{
|
||||
var uuidList = new List<string>();
|
||||
uuidList.Add(parameters.UUID);
|
||||
uuidList.AddRange(parameters.MulitUUID);
|
||||
|
||||
var xrayConfig = LoadV2rayConfig();
|
||||
|
||||
var baseBound = GetBound("VLESS_TCP_TLS.json");
|
||||
baseBound.port = parameters.Port;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = FullbackPort
|
||||
}));
|
||||
xrayConfig.inbounds.Add(baseBound);
|
||||
SetClients(baseBound, uuidList);
|
||||
|
||||
#region Fullbacks
|
||||
|
||||
if (parameters.Types.Contains(RayType.VLESS_WS))
|
||||
{
|
||||
var wsInbound = GetBound("VLESS_WS.json");
|
||||
wsInbound.port = VLESS_WS_Port;
|
||||
SetClients(wsInbound, uuidList);
|
||||
wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VLESS_WS_Port,
|
||||
path = parameters.VLESS_WS_Path,
|
||||
xver = 1,
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(wsInbound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(RayType.VMESS_TCP))
|
||||
{
|
||||
var mtcpBound = GetBound("VMESS_TCP.json");
|
||||
mtcpBound.port = VMESS_TCP_Port;
|
||||
SetClients(mtcpBound, uuidList);
|
||||
mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VMESS_TCP_Port,
|
||||
path = parameters.VMESS_TCP_Path,
|
||||
xver = 1,
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(mtcpBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(RayType.VMESS_WS))
|
||||
{
|
||||
var mwsBound = GetBound("VMESS_WS.json");
|
||||
mwsBound.port = VMESS_WS_Port;
|
||||
SetClients(mwsBound, uuidList);
|
||||
mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VMESS_WS_Port,
|
||||
path = parameters.VMESS_WS_Path,
|
||||
xver = 1,
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(mwsBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(RayType.Trojan_TCP))
|
||||
{
|
||||
var trojanTcpBound = GetBound("Trojan_TCP.json");
|
||||
trojanTcpBound.port = Trojan_TCP_Port;
|
||||
trojanTcpBound.settings.clients[0].password = parameters.TrojanPassword;
|
||||
trojanTcpBound.settings.fallbacks[0].dest = FullbackPort;
|
||||
baseBound.settings.fallbacks[0] = JToken.FromObject(new
|
||||
{
|
||||
dest = Trojan_TCP_Port,
|
||||
xver = 1,
|
||||
});
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS GRPC
|
||||
if (parameters.Types.Contains(RayType.VLESS_gRPC))
|
||||
{
|
||||
var gRPCInBound = GetBound("VLESS_gRPC.json");
|
||||
gRPCInBound.port = parameters.VLESS_gRPC_Port;
|
||||
SetClients(gRPCInBound, uuidList);
|
||||
gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName;
|
||||
gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS KCP
|
||||
if (parameters.Types.Contains(RayType.VLESS_KCP))
|
||||
{
|
||||
var kcpBound = GetBound("VLESS_KCP.json");
|
||||
kcpBound.port = parameters.VLESS_KCP_Port;
|
||||
SetClients(kcpBound, uuidList);
|
||||
kcpBound.streamSettings.kcpSettings.header.type = parameters.VLESS_KCP_Type;
|
||||
kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS QUIC
|
||||
if (parameters.Types.Contains(RayType.VLESS_QUIC))
|
||||
{
|
||||
var quicBound = GetBound("VLESS_QUIC.json");
|
||||
quicBound.port = parameters.VLESS_QUIC_Port;
|
||||
SetClients(quicBound, uuidList);
|
||||
quicBound.streamSettings.quicSettings.security = parameters.VLESS_QUIC_Security;
|
||||
quicBound.streamSettings.quicSettings.key = parameters.VLESS_QUIC_Key;
|
||||
quicBound.streamSettings.quicSettings.header.type = parameters.VLESS_QUIC_Type;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(quicBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VMESS KCP
|
||||
if (parameters.Types.Contains(RayType.VMESS_KCP))
|
||||
{
|
||||
var kcpBound = GetBound("VMESS_KCP.json");
|
||||
kcpBound.port = parameters.VMESS_KCP_Port;
|
||||
SetClients(kcpBound, uuidList);
|
||||
kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type;
|
||||
kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VMESS QUIC
|
||||
if (parameters.Types.Contains(RayType.VMESS_QUIC))
|
||||
{
|
||||
var quicBound = GetBound("VMESS_QUIC.json");
|
||||
quicBound.port = parameters.VMESS_QUIC_Port;
|
||||
SetClients(quicBound, uuidList);
|
||||
quicBound.streamSettings.quicSettings.security = parameters.VMESS_QUIC_Security;
|
||||
quicBound.streamSettings.quicSettings.key = parameters.VMESS_QUIC_Key;
|
||||
quicBound.streamSettings.quicSettings.header.type = parameters.VMESS_QUIC_Type;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(quicBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Shadowsocks
|
||||
if (parameters.Types.Contains(RayType.ShadowsocksAEAD))
|
||||
{
|
||||
var ssBound = GetBound("Shadowsocks-AEAD.json");
|
||||
ssBound.port = parameters.ShadowSocksPort;
|
||||
ssBound.settings.password = parameters.ShadowSocksPassword;
|
||||
ssBound.settings.method = parameters.ShadowSocksMethod;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(ssBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
return JsonConvert.SerializeObject(
|
||||
xrayConfig,
|
||||
Formatting.Indented,
|
||||
new JsonSerializerSettings()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
}
|
||||
|
||||
private static dynamic GetBound(string name)
|
||||
{
|
||||
return LoadJsonObj(Path.Combine(ServerInboundsDir, name));
|
||||
}
|
||||
|
||||
private static dynamic LoadJsonObj(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var jsonStr = File.ReadAllText(path, Encoding.UTF8);
|
||||
return JToken.FromObject(JsonConvert.DeserializeObject(jsonStr));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
449
ProxySuper.Core/Services/V2rayService.cs
Normal file
449
ProxySuper.Core/Services/V2rayService.cs
Normal file
|
@ -0,0 +1,449 @@
|
|||
using Microsoft.Win32;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class V2rayService : ServiceBase<V2raySettings>
|
||||
{
|
||||
public V2rayService(Host host, V2raySettings settings) : base(host, settings)
|
||||
{
|
||||
}
|
||||
|
||||
public void Install()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
int index = 1;
|
||||
EnsureRootUser();
|
||||
|
||||
if (FileExists("/usr/local/bin/v2ray"))
|
||||
{
|
||||
var btnResult = MessageBox.Show("已经安装v2ray,是否需要重装?", "提示", MessageBoxButton.YesNo);
|
||||
if (btnResult == MessageBoxResult.No)
|
||||
{
|
||||
MessageBox.Show("安装终止", "提示");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Progress.Step = $"{index++}. 检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 5;
|
||||
|
||||
Progress.Step = $"{index++}. 安装必要的系统工具";
|
||||
InstallSystemTools();
|
||||
Progress.Percentage = 15;
|
||||
|
||||
Progress.Step = $"{index++}. 配置防火墙";
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Step = $"{index++}. 检测网络环境";
|
||||
EnsureNetwork();
|
||||
if (Settings.IsIPAddress)
|
||||
{
|
||||
Progress.Desc = ("检查域名是否解析正确");
|
||||
ValidateDomain();
|
||||
}
|
||||
Progress.Percentage = 25;
|
||||
|
||||
Progress.Step = $"{index}. 同步系统和本地时间";
|
||||
SyncTimeDiff();
|
||||
Progress.Percentage = 30;
|
||||
|
||||
Progress.Step = $"{index++}. 安装Caddy服务器";
|
||||
InstallCaddy();
|
||||
Progress.Percentage = 50;
|
||||
|
||||
Progress.Step = $"{index++}. 安装V2ray-Core";
|
||||
InstallV2ray();
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Step = $"{index++}. 上传Web服务器配置";
|
||||
UploadCaddyFile();
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Step = $"{index++}. 启动BBR";
|
||||
EnableBBR();
|
||||
|
||||
Progress.Desc = "重启V2ray服务";
|
||||
|
||||
RunCmd("systemctl restart caddy");
|
||||
RunCmd("systemctl restart v2ray");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "安装成功";
|
||||
Progress.Desc = string.Empty;
|
||||
|
||||
if (!Settings.WithTLS)
|
||||
{
|
||||
Progress.Step = "安装成功,请上传您的 TLS 证书。";
|
||||
}
|
||||
else
|
||||
{
|
||||
NavigationService.Navigate<V2rayConfigViewModel, V2raySettings>(Settings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateSettings()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "更新V2ray配置";
|
||||
Progress.Percentage = 0;
|
||||
EnsureRootUser();
|
||||
var index = 0;
|
||||
|
||||
Progress.Desc = $"{index++}. 检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = $"{index++}. 配置防火墙";
|
||||
RunCmd("systemctl stop v2ray");
|
||||
RunCmd("systemctl stop caddy");
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Desc = $"{index++}. 上传V2ray配置文件";
|
||||
var configJson = V2rayConfigBuilder.BuildV2rayConfig(Settings);
|
||||
WriteToFile(configJson, "/usr/local/etc/v2ray/config.json");
|
||||
Progress.Percentage = 70;
|
||||
|
||||
Progress.Desc = $"{index++}. 上传Caddy配置文件";
|
||||
UploadCaddyFile();
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Desc = $"{index++}. 重启v2ray服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
RunCmd("systemctl restart v2ray");
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Desc = ("更新配置成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateV2rayCore()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "更新V2ray-Core";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
EnsureRootUser();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "下载最新版本V2ray-Core";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
RunCmd("bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)");
|
||||
RunCmd("systemctl restart v2ray");
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Desc = "更新V2ray-Core成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
var index = 1;
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Step = $"{index++}. 检测系统环境";
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Step = $"{index++}. 卸载Caddy服务";
|
||||
UninstallCaddy();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Step = $"{index++}. 卸载V2ray服务";
|
||||
UninstallV2ray();
|
||||
Progress.Percentage = 60;
|
||||
|
||||
Progress.Step = $"{index++}. 卸载Acme证书申请服务";
|
||||
UninstallAcme();
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Step = $"{index++}. 重置防火墙端口";
|
||||
ResetFirewalld();
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Step = "卸载完成";
|
||||
Progress.Desc = "卸载完成";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UploadCert()
|
||||
{
|
||||
var fileDialog = new OpenFileDialog();
|
||||
fileDialog.Filter = "压缩文件|*.zip";
|
||||
fileDialog.FileOk += DoUploadCert;
|
||||
fileDialog.ShowDialog();
|
||||
}
|
||||
|
||||
public void UploadWeb()
|
||||
{
|
||||
var fileDialog = new OpenFileDialog();
|
||||
fileDialog.Filter = "压缩文件|*.zip";
|
||||
fileDialog.FileOk += DoUploadWeb;
|
||||
fileDialog.ShowDialog();
|
||||
}
|
||||
|
||||
public void ApplyForCert()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Percentage = 0;
|
||||
Progress.Step = "续签证书";
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
|
||||
Progress.Desc = "安装证书";
|
||||
InstallCert(
|
||||
dirPath: "/usr/local/etc/v2ray/ssl",
|
||||
certName: "v2ray_ssl.crt",
|
||||
keyName: "v2ray_ssl.key");
|
||||
|
||||
Progress.Percentage = 90;
|
||||
Progress.Desc = "重启服务";
|
||||
RunCmd("systemctl restart v2ray");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "续签证书成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
#region 似有方法
|
||||
|
||||
private void DoUploadCert(object sender, CancelEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
Progress.Percentage = 0;
|
||||
Progress.Step = "上传自有证书";
|
||||
Progress.Desc = "检测系统环境";
|
||||
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "正在上传文件";
|
||||
var file = sender as OpenFileDialog;
|
||||
using (var stream = file.OpenFile())
|
||||
{
|
||||
var oldFileName = $"ssl_{DateTime.Now.Ticks}";
|
||||
RunCmd($"mv /usr/local/etc/v2ray/ssl /usr/local/etc/v2ray/{oldFileName}");
|
||||
|
||||
RunCmd("mkdir /usr/local/etc/v2ray/ssl");
|
||||
UploadFile(stream, "/usr/local/etc/v2ray/ssl/ssl.zip");
|
||||
RunCmd("unzip /usr/local/etc/v2ray/ssl/ssl.zip -d /usr/local/etc/v2ray/ssl");
|
||||
}
|
||||
|
||||
var crtFiles = RunCmd("find /usr/local/etc/v2ray/ssl/*.crt").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
var keyFiles = RunCmd("find /usr/local/etc/v2ray/ssl/*.key").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (crtFiles.Length > 0 && keyFiles.Length > 0)
|
||||
{
|
||||
RunCmd($"mv {crtFiles[0]} /usr/local/etc/v2ray/ssl/v2ray_ssl.crt");
|
||||
RunCmd($"mv {keyFiles[0]} /usr/local/etc/v2ray/ssl/v2ray_ssl.key");
|
||||
}
|
||||
else
|
||||
{
|
||||
Progress.Step = "上传失败";
|
||||
Progress.Desc = "上传证书失败,缺少 .crt 和 .key 文件";
|
||||
return;
|
||||
}
|
||||
|
||||
Progress.Desc = "重启V2ray服务";
|
||||
RunCmd("systemctl restart v2ray");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "上传证书完成";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void DoUploadWeb(object sender, CancelEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
Progress.Step = "上传静态网站";
|
||||
Progress.Desc = "上传静态网站";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "创建网站目录";
|
||||
if (!FileExists("/usr/share/caddy"))
|
||||
{
|
||||
RunCmd("mkdir /usr/share/caddy");
|
||||
}
|
||||
RunCmd("rm -rf /usr/share/caddy/*");
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Desc = "正在上传文件";
|
||||
var file = sender as OpenFileDialog;
|
||||
using (var stream = file.OpenFile())
|
||||
{
|
||||
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");
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Desc = "上传Web配置文件";
|
||||
UploadCaddyFile(useCustomWeb: true);
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Desc = "重启caddy服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Desc = "上传静态网站成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void InstallV2ray()
|
||||
{
|
||||
Progress.Desc = ("开始安装V2ray-Core");
|
||||
RunCmd("bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)");
|
||||
|
||||
if (!FileExists("/usr/local/bin/v2ray"))
|
||||
{
|
||||
Progress.Desc = ("V2ray-Core安装失败,请联系开发者");
|
||||
throw new Exception("V2ray-Core安装失败,请联系开发者");
|
||||
}
|
||||
|
||||
Progress.Desc = ("设置V2ray-Core权限");
|
||||
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/v2ray.service");
|
||||
RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/v2ray.service");
|
||||
RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/v2ray.service");
|
||||
RunCmd($"systemctl daemon-reload");
|
||||
RunCmd("systemctl enable v2ray");
|
||||
|
||||
if (FileExists("/usr/local/etc/v2ray/config.json"))
|
||||
{
|
||||
RunCmd(@"mv /usr/local/etc/v2ray/config.json /usr/local/etc/v2ray/config.json.1");
|
||||
}
|
||||
Progress.Percentage = 60;
|
||||
|
||||
if (Settings.WithTLS && !Settings.IsIPAddress)
|
||||
{
|
||||
Progress.Desc = ("安装TLS证书");
|
||||
InstallCert(
|
||||
dirPath: "/usr/local/etc/v2ray/ssl",
|
||||
certName: "v2ray_ssl.crt",
|
||||
keyName: "v2ray_ssl.key");
|
||||
Progress.Percentage = 75;
|
||||
}
|
||||
|
||||
Progress.Desc = ("生成v2ray服务器配置文件");
|
||||
var configJson = V2rayConfigBuilder.BuildV2rayConfig(Settings);
|
||||
WriteToFile(configJson, "/usr/local/etc/v2ray/config.json");
|
||||
}
|
||||
|
||||
private void UploadCaddyFile(bool useCustomWeb = false)
|
||||
{
|
||||
var configJson = V2rayConfigBuilder.BuildCaddyConfig(Settings, useCustomWeb);
|
||||
|
||||
if (FileExists("/etc/caddy/Caddyfile"))
|
||||
{
|
||||
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
||||
}
|
||||
WriteToFile(configJson, "/etc/caddy/Caddyfile");
|
||||
}
|
||||
|
||||
|
||||
private void UninstallV2ray()
|
||||
{
|
||||
Progress.Desc = "关闭V2ray服务";
|
||||
RunCmd("systemctl stop v2ray");
|
||||
RunCmd("systemctl disable v2ray");
|
||||
|
||||
Progress.Desc = "卸载V2ray";
|
||||
RunCmd("bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove");
|
||||
}
|
||||
|
||||
private void UninstallAcme()
|
||||
{
|
||||
Progress.Desc = "卸载 acme.sh";
|
||||
RunCmd("acme.sh --uninstall");
|
||||
|
||||
Progress.Desc = "删除 acme.sh 相关文件";
|
||||
RunCmd("rm -rf ~/.acme.sh");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,13 +1,9 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
|
@ -28,7 +24,6 @@ namespace ProxySuper.Core.Services
|
|||
public static int VLESS_TCP_Port = 1110;
|
||||
public static int VLESS_WS_Port = 1111;
|
||||
public static int VLESS_H2_Port = 1112;
|
||||
public static int VLESS_mKCP_Port = 1113;
|
||||
|
||||
public static int VMESS_TCP_Port = 1210;
|
||||
public static int VMESS_WS_Port = 1211;
|
||||
|
@ -72,7 +67,7 @@ namespace ProxySuper.Core.Services
|
|||
public static string BuildCaddyConfig(XraySettings parameters, bool useCustomWeb = false)
|
||||
{
|
||||
var caddyStr = File.ReadAllText(Path.Combine(CaddyFileDir, "base.caddyfile"));
|
||||
caddyStr = caddyStr.Replace("##domain##", parameters.Domain);
|
||||
caddyStr = caddyStr.Replace("##domain##", parameters.IsIPAddress ? "" : parameters.Domain);
|
||||
caddyStr = caddyStr.Replace("##port##", FullbackPort.ToString());
|
||||
|
||||
if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain))
|
||||
|
@ -84,7 +79,8 @@ namespace ProxySuper.Core.Services
|
|||
}
|
||||
var domain = parameters.MaskDomain
|
||||
.TrimStart("http://".ToCharArray())
|
||||
.TrimStart("https://".ToCharArray());
|
||||
.TrimStart("https://".ToCharArray())
|
||||
.TrimEnd('/');
|
||||
|
||||
caddyStr = caddyStr.Replace("##reverse_proxy##", $"reverse_proxy {prefix}{domain} {{ \n header_up Host {domain} \n }}");
|
||||
}
|
||||
|
@ -96,9 +92,34 @@ namespace ProxySuper.Core.Services
|
|||
return caddyStr;
|
||||
}
|
||||
|
||||
private static void SetClients(dynamic bound, List<string> uuidList, bool withXtls = false, string flow = "")
|
||||
{
|
||||
bound.settings.clients.Clear();
|
||||
uuidList.ForEach(id =>
|
||||
{
|
||||
object obj;
|
||||
if (!withXtls)
|
||||
{
|
||||
obj = new { id = id };
|
||||
}
|
||||
else
|
||||
{
|
||||
flow = "xtls-rprx-vision";//兼容普通tls与xtls
|
||||
obj = new { id = id, flow = flow };
|
||||
}
|
||||
|
||||
bound.settings.clients.Add(JToken.FromObject(obj));
|
||||
});
|
||||
}
|
||||
|
||||
public static string BuildXrayConfig(XraySettings parameters)
|
||||
{
|
||||
var uuidList = new List<string>();
|
||||
uuidList.Add(parameters.UUID);
|
||||
uuidList.AddRange(parameters.MulitUUID);
|
||||
|
||||
var xrayConfig = LoadXrayConfig();
|
||||
|
||||
var baseBound = GetBound("VLESS_TCP_XTLS.json");
|
||||
baseBound.port = parameters.Port;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
|
@ -106,13 +127,15 @@ namespace ProxySuper.Core.Services
|
|||
dest = FullbackPort
|
||||
}));
|
||||
xrayConfig.inbounds.Add(baseBound);
|
||||
baseBound.settings.clients[0].id = parameters.UUID;
|
||||
SetClients(baseBound, uuidList, withXtls: true, flow: parameters.Flow);
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VLESS_WS))
|
||||
#region Fullbacks
|
||||
|
||||
if (parameters.Types.Contains(RayType.VLESS_WS))
|
||||
{
|
||||
var wsInbound = GetBound("VLESS_WS.json");
|
||||
wsInbound.port = VLESS_WS_Port;
|
||||
wsInbound.settings.clients[0].id = parameters.UUID;
|
||||
SetClients(wsInbound, uuidList);
|
||||
wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
|
@ -123,30 +146,11 @@ namespace ProxySuper.Core.Services
|
|||
xrayConfig.inbounds.Add(JToken.FromObject(wsInbound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VLESS_gRPC))
|
||||
{
|
||||
var gRPCInBound = GetBound("VLESS_gRPC.json");
|
||||
gRPCInBound.port = parameters.VLESS_gRPC_Port;
|
||||
gRPCInBound.settings.clients[0].id = parameters.UUID;
|
||||
gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VLESS_KCP))
|
||||
{
|
||||
var kcpBound = GetBound("VLESS_KCP.json");
|
||||
kcpBound.port = parameters.VLESS_KCP_Port;
|
||||
kcpBound.settings.clients[0].id = parameters.UUID;
|
||||
kcpBound.streamSettings.kcpSettings.header.type = parameters.VLESS_KCP_Type;
|
||||
kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VMESS_TCP))
|
||||
if (parameters.Types.Contains(RayType.VMESS_TCP))
|
||||
{
|
||||
var mtcpBound = GetBound("VMESS_TCP.json");
|
||||
mtcpBound.port = VMESS_TCP_Port;
|
||||
mtcpBound.settings.clients[0].id = parameters.UUID;
|
||||
SetClients(mtcpBound, uuidList);
|
||||
mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
|
@ -157,11 +161,11 @@ namespace ProxySuper.Core.Services
|
|||
xrayConfig.inbounds.Add(JToken.FromObject(mtcpBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VMESS_WS))
|
||||
if (parameters.Types.Contains(RayType.VMESS_WS))
|
||||
{
|
||||
var mwsBound = GetBound("VMESS_WS.json");
|
||||
mwsBound.port = VMESS_WS_Port;
|
||||
mwsBound.settings.clients[0].id = parameters.UUID;
|
||||
SetClients(mwsBound, uuidList);
|
||||
mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
|
@ -172,17 +176,7 @@ namespace ProxySuper.Core.Services
|
|||
xrayConfig.inbounds.Add(JToken.FromObject(mwsBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VMESS_KCP))
|
||||
{
|
||||
var kcpBound = GetBound("VMESS_KCP.json");
|
||||
kcpBound.port = parameters.VMESS_KCP_Port;
|
||||
kcpBound.settings.clients[0].id = parameters.UUID;
|
||||
kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type;
|
||||
kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.Trojan_TCP))
|
||||
if (parameters.Types.Contains(RayType.Trojan_TCP))
|
||||
{
|
||||
var trojanTcpBound = GetBound("Trojan_TCP.json");
|
||||
trojanTcpBound.port = Trojan_TCP_Port;
|
||||
|
@ -195,16 +189,80 @@ namespace ProxySuper.Core.Services
|
|||
});
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS GRPC
|
||||
if (parameters.Types.Contains(RayType.VLESS_gRPC))
|
||||
{
|
||||
var gRPCInBound = GetBound("VLESS_gRPC.json");
|
||||
gRPCInBound.port = parameters.VLESS_gRPC_Port;
|
||||
SetClients(gRPCInBound, uuidList);
|
||||
gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName;
|
||||
gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (parameters.Types.Contains(XrayType.ShadowsocksAEAD))
|
||||
#region VLESS KCP
|
||||
if (parameters.Types.Contains(RayType.VLESS_KCP))
|
||||
{
|
||||
var kcpBound = GetBound("VLESS_KCP.json");
|
||||
kcpBound.port = parameters.VLESS_KCP_Port;
|
||||
SetClients(kcpBound, uuidList);
|
||||
kcpBound.streamSettings.kcpSettings.header.type = parameters.VLESS_KCP_Type;
|
||||
kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS QUIC
|
||||
if (parameters.Types.Contains(RayType.VLESS_QUIC))
|
||||
{
|
||||
var quicBound = GetBound("VLESS_QUIC.json");
|
||||
quicBound.port = parameters.VLESS_QUIC_Port;
|
||||
SetClients(quicBound, uuidList);
|
||||
quicBound.streamSettings.quicSettings.security = parameters.VLESS_QUIC_Security;
|
||||
quicBound.streamSettings.quicSettings.key = parameters.VLESS_QUIC_Key;
|
||||
quicBound.streamSettings.quicSettings.header.type = parameters.VLESS_QUIC_Type;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(quicBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VMESS KCP
|
||||
if (parameters.Types.Contains(RayType.VMESS_KCP))
|
||||
{
|
||||
var kcpBound = GetBound("VMESS_KCP.json");
|
||||
kcpBound.port = parameters.VMESS_KCP_Port;
|
||||
SetClients(kcpBound, uuidList);
|
||||
kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type;
|
||||
kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VMESS QUIC
|
||||
if (parameters.Types.Contains(RayType.VMESS_QUIC))
|
||||
{
|
||||
var quicBound = GetBound("VMESS_QUIC.json");
|
||||
quicBound.port = parameters.VMESS_QUIC_Port;
|
||||
SetClients(quicBound, uuidList);
|
||||
quicBound.streamSettings.quicSettings.security = parameters.VMESS_QUIC_Security;
|
||||
quicBound.streamSettings.quicSettings.key = parameters.VMESS_QUIC_Key;
|
||||
quicBound.streamSettings.quicSettings.header.type = parameters.VMESS_QUIC_Type;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(quicBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Shadowsocks
|
||||
if (parameters.Types.Contains(RayType.ShadowsocksAEAD))
|
||||
{
|
||||
var ssBound = GetBound("Shadowsocks-AEAD.json");
|
||||
ssBound.port = parameters.ShadowSocksPort;
|
||||
ssBound.settings.clients[0].password = parameters.ShadowSocksPassword;
|
||||
ssBound.settings.clients[0].method = parameters.ShadowSocksMethod;
|
||||
ssBound.settings.password = parameters.ShadowSocksPassword;
|
||||
ssBound.settings.method = parameters.ShadowSocksMethod;
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(ssBound));
|
||||
}
|
||||
#endregion
|
||||
|
||||
return JsonConvert.SerializeObject(
|
||||
xrayConfig,
|
||||
|
|
|
@ -1,325 +0,0 @@
|
|||
using Newtonsoft.Json;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using Renci.SshNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class XrayProject : ProjectBase<XraySettings>
|
||||
{
|
||||
|
||||
private const string ServerLogDir = @"Templates\xray\server\00_log";
|
||||
private const string ServerApiDir = @"Templates\xray\server\01_api";
|
||||
private const string ServerDnsDir = @"Templates\xray\server\02_dns";
|
||||
private const string ServerRoutingDir = @"Templates\xray\server\03_routing";
|
||||
private const string ServerPolicyDir = @"Templates\xray\server\04_policy";
|
||||
private const string ServerInboundsDir = @"Templates\xray\server\05_inbounds";
|
||||
private const string ServerOutboundsDir = @"Templates\xray\server\06_outbounds";
|
||||
private const string ServerTransportDir = @"Templates\xray\server\07_transport";
|
||||
private const string ServerStatsDir = @"Templates\xray\server\08_stats";
|
||||
private const string ServerReverseDir = @"Templates\xray\server\09_reverse";
|
||||
private const string CaddyFileDir = @"Templates\xray\caddy";
|
||||
|
||||
public XrayProject(SshClient sshClient, XraySettings parameters, Action<string> writeOutput) : base(sshClient, parameters, writeOutput)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安装Xray
|
||||
/// </summary>
|
||||
public override void Install()
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootAuth();
|
||||
|
||||
if (FileExists("/usr/local/bin/xray"))
|
||||
{
|
||||
var btnResult = MessageBox.Show("已经安装Xray,是否需要重装?", "提示", MessageBoxButton.YesNo);
|
||||
if (btnResult == MessageBoxResult.No)
|
||||
{
|
||||
MessageBox.Show("安装终止", "提示");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
WriteOutput("检测安装系统环境...");
|
||||
EnsureSystemEnv();
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("配置服务器端口...");
|
||||
ConfigurePort();
|
||||
WriteOutput("端口配置完成");
|
||||
|
||||
WriteOutput("安装必要的系统工具...");
|
||||
ConfigureSoftware();
|
||||
WriteOutput("系统工具安装完成");
|
||||
|
||||
WriteOutput("检测IP6...");
|
||||
ConfigureIPv6();
|
||||
WriteOutput("检测IP6完成");
|
||||
|
||||
WriteOutput("配置防火墙...");
|
||||
ConfigureFirewall();
|
||||
WriteOutput("防火墙配置完成");
|
||||
|
||||
WriteOutput("同步系统和本地时间...");
|
||||
SyncTimeDiff();
|
||||
WriteOutput("时间同步完成");
|
||||
|
||||
WriteOutput("检测域名是否绑定本机IP...");
|
||||
ValidateDomain();
|
||||
WriteOutput("域名检测完成");
|
||||
|
||||
WriteOutput("安装Caddy...");
|
||||
InstallCaddy();
|
||||
WriteOutput("Caddy安装完成");
|
||||
|
||||
WriteOutput("安装Xray-Core...");
|
||||
InstallXrayWithCert();
|
||||
WriteOutput("Xray-Core安装完成");
|
||||
|
||||
WriteOutput("启动BBR");
|
||||
EnableBBR();
|
||||
|
||||
UploadCaddyFile();
|
||||
WriteOutput("************");
|
||||
WriteOutput("安装完成,尽情享用吧......");
|
||||
WriteOutput("************");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorLog = "安装终止," + ex.Message;
|
||||
WriteOutput(errorLog);
|
||||
MessageBox.Show(errorLog);
|
||||
}
|
||||
}
|
||||
|
||||
public void UninstallProxy()
|
||||
{
|
||||
EnsureRootAuth();
|
||||
WriteOutput("卸载Caddy");
|
||||
UninstallCaddy();
|
||||
WriteOutput("卸载Xray");
|
||||
UninstallXray();
|
||||
WriteOutput("卸载证书");
|
||||
UninstallAcme();
|
||||
WriteOutput("关闭端口");
|
||||
ClosePort(Parameters.ShadowSocksPort, Parameters.VMESS_KCP_Port);
|
||||
|
||||
WriteOutput("************ 卸载完成 ************");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新xray内核
|
||||
/// </summary>
|
||||
public void UpdateXrayCore()
|
||||
{
|
||||
EnsureRootAuth();
|
||||
EnsureSystemEnv();
|
||||
RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install");
|
||||
RunCmd("systemctl restart xray");
|
||||
WriteOutput("************ 更新xray内核完成 ************");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新xray配置
|
||||
/// </summary>
|
||||
public void UpdateXraySettings()
|
||||
{
|
||||
EnsureRootAuth();
|
||||
EnsureSystemEnv();
|
||||
ConfigureFirewall();
|
||||
var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
|
||||
RunCmd("rm -rf /usr/local/etc/xray/config.json");
|
||||
UploadFile(stream, "/usr/local/etc/xray/config.json");
|
||||
ConfigurePort();
|
||||
UploadCaddyFile(string.IsNullOrEmpty(Parameters.MaskDomain));
|
||||
RunCmd("systemctl restart xray");
|
||||
WriteOutput("************ 更新Xray配置成功,更新配置不包含域名,如果域名更换请重新安装。 ************");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重装Caddy
|
||||
/// </summary>
|
||||
public void DoUninstallCaddy()
|
||||
{
|
||||
EnsureRootAuth();
|
||||
UninstallCaddy();
|
||||
WriteOutput("************ 卸载Caddy完成 ************");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安装证书
|
||||
/// </summary>
|
||||
public void InstallCertToXray()
|
||||
{
|
||||
EnsureRootAuth();
|
||||
EnsureSystemEnv();
|
||||
InstallCert(
|
||||
dirPath: "/usr/local/etc/xray/ssl",
|
||||
certName: "xray_ssl.crt",
|
||||
keyName: "xray_ssl.key");
|
||||
|
||||
RunCmd("systemctl restart xray");
|
||||
WriteOutput("************ 安装证书完成 ************");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传证书
|
||||
/// </summary>
|
||||
/// <param name="keyStrem"></param>
|
||||
/// <param name="crtStream"></param>
|
||||
public void UploadCert(Stream stream)
|
||||
{
|
||||
EnsureRootAuth();
|
||||
EnsureSystemEnv();
|
||||
|
||||
// 转移旧文件
|
||||
var oldFileName = $"ssl_{DateTime.Now.Ticks}";
|
||||
RunCmd($"mv /usr/local/etc/xray/ssl /usr/local/etc/xray/{oldFileName}");
|
||||
|
||||
// 上传新文件
|
||||
RunCmd("mkdir /usr/local/etc/xray/ssl");
|
||||
UploadFile(stream, "/usr/local/etc/xray/ssl/ssl.zip");
|
||||
RunCmd("unzip /usr/local/etc/xray/ssl/ssl.zip -d /usr/local/etc/xray/ssl");
|
||||
|
||||
// 改名
|
||||
var crtFiles = RunCmd("find /usr/local/etc/xray/ssl/*.crt").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (crtFiles.Length > 0)
|
||||
{
|
||||
RunCmd($"mv {crtFiles[0]} /usr/local/etc/xray/ssl/xray_ssl.crt");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteOutput("************ 上传证书失败,请联系开发者 ************");
|
||||
RunCmd("rm -rf /usr/local/etc/xray/ssl");
|
||||
RunCmd($"mv /usr/local/etc/xray/ssl{oldFileName} /usr/local/etc/xray/ssl");
|
||||
WriteOutput("操作已回滚");
|
||||
return;
|
||||
}
|
||||
|
||||
var keyFiles = RunCmd("find /usr/local/etc/xray/ssl/*.key").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (keyFiles.Length > 0)
|
||||
{
|
||||
RunCmd($"mv {keyFiles[0]} /usr/local/etc/xray/ssl/xray_ssl.key");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteOutput("************ 上传证书失败,请联系开发者 ************");
|
||||
RunCmd("rm -rf /usr/local/etc/xray/ssl");
|
||||
RunCmd($"mv /usr/local/etc/xray/ssl{oldFileName} /usr/local/etc/xray/ssl");
|
||||
WriteOutput("操作已回滚");
|
||||
return;
|
||||
}
|
||||
|
||||
RunCmd("systemctl restart xray");
|
||||
WriteOutput("************ 上传证书完成 ************");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传静态网站
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
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("************ 上传网站模板完成 ************");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传Caddy文件
|
||||
/// </summary>
|
||||
/// <param name="useCustomWeb"></param>
|
||||
private void UploadCaddyFile(bool useCustomWeb = false)
|
||||
{
|
||||
var configJson = XrayConfigBuilder.BuildCaddyConfig(Parameters, useCustomWeb);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
|
||||
if (FileExists("/etc/caddy/Caddyfile"))
|
||||
{
|
||||
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
||||
}
|
||||
UploadFile(stream, "/etc/caddy/Caddyfile");
|
||||
RunCmd("systemctl restart caddy");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void UninstallXray()
|
||||
{
|
||||
RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ remove");
|
||||
}
|
||||
|
||||
private void UninstallAcme()
|
||||
{
|
||||
RunCmd("acme.sh --uninstall");
|
||||
RunCmd("rm -r ~/.acme.sh");
|
||||
}
|
||||
|
||||
private void InstallXrayWithCert()
|
||||
{
|
||||
RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install");
|
||||
|
||||
if (!FileExists("/usr/local/bin/xray"))
|
||||
{
|
||||
WriteOutput("Xray-Core安装失败,请联系开发者");
|
||||
throw new Exception("Xray-Core安装失败,请联系开发者");
|
||||
}
|
||||
|
||||
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"systemctl daemon-reload");
|
||||
|
||||
if (FileExists("/usr/local/etc/xray/config.json"))
|
||||
{
|
||||
RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1");
|
||||
}
|
||||
|
||||
WriteOutput("安装TLS证书");
|
||||
InstallCertToXray();
|
||||
WriteOutput("TLS证书安装完成");
|
||||
|
||||
|
||||
var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
|
||||
UploadFile(stream, "/usr/local/etc/xray/config.json");
|
||||
RunCmd("systemctl restart xray");
|
||||
}
|
||||
|
||||
private int GetRandomPort()
|
||||
{
|
||||
var random = new Random();
|
||||
return random.Next(10001, 60000);
|
||||
}
|
||||
|
||||
private dynamic LoadJsonObj(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var jsonStr = File.ReadAllText(path, Encoding.UTF8);
|
||||
return JsonConvert.DeserializeObject(jsonStr);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
448
ProxySuper.Core/Services/XrayService.cs
Normal file
448
ProxySuper.Core/Services/XrayService.cs
Normal file
|
@ -0,0 +1,448 @@
|
|||
using Microsoft.Win32;
|
||||
using ProxySuper.Core.Helpers;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class XrayService : ServiceBase<XraySettings>
|
||||
{
|
||||
|
||||
public XrayService(Host host, XraySettings settings) : base(host, settings)
|
||||
{
|
||||
}
|
||||
|
||||
public void Install()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
int index = 1;
|
||||
EnsureRootUser();
|
||||
|
||||
if (FileExists("/usr/local/bin/xray"))
|
||||
{
|
||||
var btnResult = MessageBox.Show("已经安装Xray,是否需要重装?", "提示", MessageBoxButton.YesNo);
|
||||
if (btnResult == MessageBoxResult.No)
|
||||
{
|
||||
MessageBox.Show("安装终止", "提示");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Progress.Step = $"{index++}. 检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 5;
|
||||
|
||||
Progress.Step = $"{index++}. 安装必要的系统工具";
|
||||
InstallSystemTools();
|
||||
Progress.Percentage = 15;
|
||||
|
||||
Progress.Step = $"{index++}. 配置防火墙";
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Step = $"{index++}. 检测网络环境";
|
||||
EnsureNetwork();
|
||||
if (Settings.IsIPAddress)
|
||||
{
|
||||
Progress.Desc = ("检查域名是否解析正确");
|
||||
ValidateDomain();
|
||||
}
|
||||
Progress.Percentage = 25;
|
||||
|
||||
Progress.Step = $"{index}. 同步系统和本地时间";
|
||||
SyncTimeDiff();
|
||||
Progress.Percentage = 30;
|
||||
|
||||
Progress.Step = $"{index++}. 安装Caddy服务器";
|
||||
InstallCaddy();
|
||||
Progress.Percentage = 50;
|
||||
|
||||
Progress.Step = $"{index++}. 安装Xray-Core";
|
||||
InstallXray();
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Step = $"{index++}. 上传Web服务器配置";
|
||||
UploadCaddyFile();
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Step = $"{index++}. 启动BBR";
|
||||
EnableBBR();
|
||||
|
||||
Progress.Desc = "重启Xray服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
RunCmd("systemctl restart xray");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Step = "安装成功";
|
||||
Progress.Desc = string.Empty;
|
||||
|
||||
if (!Settings.WithTLS)
|
||||
{
|
||||
Progress.Step = "安装成功,请上传您的 TLS 证书。";
|
||||
}
|
||||
else
|
||||
{
|
||||
NavigationService.Navigate<XrayConfigViewModel, XraySettings>(Settings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateSettings()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "更新Xray配置";
|
||||
Progress.Percentage = 0;
|
||||
EnsureRootUser();
|
||||
var index = 0;
|
||||
|
||||
Progress.Desc = $"{index++}. 检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = $"{index++}. 配置防火墙";
|
||||
RunCmd("systemctl stop xray");
|
||||
RunCmd("systemctl stop caddy");
|
||||
ConfigFirewalld();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Desc = $"{index++}. 上传Xray配置文件";
|
||||
var configJson = XrayConfigBuilder.BuildXrayConfig(Settings);
|
||||
WriteToFile(configJson, "/usr/local/etc/xray/config.json");
|
||||
Progress.Percentage = 70;
|
||||
|
||||
Progress.Desc = $"{index++}. 上传Caddy配置文件";
|
||||
UploadCaddyFile();
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Desc = $"{index++}. 重启xray服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
RunCmd("systemctl restart xray");
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Desc = ("更新配置成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateXrayCore()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Step = "更新Xray-Core";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
EnsureRootUser();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "下载最新版本Xray-Core";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install");
|
||||
RunCmd("systemctl restart xray");
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Desc = "更新Xray-Core成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
var index = 1;
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Step = $"{index++}. 检测系统环境";
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Step = $"{index++}. 卸载Caddy服务";
|
||||
UninstallCaddy();
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Step = $"{index++}. 卸载Xray服务";
|
||||
UninstallXray();
|
||||
Progress.Percentage = 60;
|
||||
|
||||
Progress.Step = $"{index++}. 卸载Acme证书申请服务";
|
||||
UninstallAcme();
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Step = $"{index++}. 重置防火墙端口";
|
||||
ResetFirewalld();
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Step = "卸载完成";
|
||||
Progress.Desc = "卸载完成";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UploadCert()
|
||||
{
|
||||
var fileDialog = new OpenFileDialog();
|
||||
fileDialog.Filter = "压缩文件|*.zip";
|
||||
fileDialog.FileOk += DoUploadCert;
|
||||
fileDialog.ShowDialog();
|
||||
}
|
||||
|
||||
public void UploadWeb()
|
||||
{
|
||||
var fileDialog = new OpenFileDialog();
|
||||
fileDialog.Filter = "压缩文件|*.zip";
|
||||
fileDialog.FileOk += DoUploadWeb;
|
||||
fileDialog.ShowDialog();
|
||||
}
|
||||
|
||||
public void ApplyForCert()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Progress.Percentage = 0;
|
||||
Progress.Step = "续签证书";
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureRootUser();
|
||||
EnsureSystemEnv();
|
||||
|
||||
Progress.Desc = "安装证书";
|
||||
InstallCert(
|
||||
dirPath: "/usr/local/etc/xray/ssl",
|
||||
certName: "xray_ssl.crt",
|
||||
keyName: "xray_ssl.key");
|
||||
|
||||
Progress.Percentage = 90;
|
||||
Progress.Desc = "重启服务";
|
||||
RunCmd("systemctl restart xray");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "续签证书成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
#region 私有方法
|
||||
|
||||
private void DoUploadCert(object sender, CancelEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
Progress.Percentage = 0;
|
||||
Progress.Step = "上传自有证书";
|
||||
Progress.Desc = "检测系统环境";
|
||||
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "正在上传文件";
|
||||
var file = sender as OpenFileDialog;
|
||||
using (var stream = file.OpenFile())
|
||||
{
|
||||
var oldFileName = $"ssl_{DateTime.Now.Ticks}";
|
||||
RunCmd($"mv /usr/local/etc/xray/ssl /usr/local/etc/xray/{oldFileName}");
|
||||
|
||||
RunCmd("mkdir /usr/local/etc/xray/ssl");
|
||||
UploadFile(stream, "/usr/local/etc/xray/ssl/ssl.zip");
|
||||
RunCmd("unzip /usr/local/etc/xray/ssl/ssl.zip -d /usr/local/etc/xray/ssl");
|
||||
}
|
||||
|
||||
var crtFiles = RunCmd("find /usr/local/etc/xray/ssl/*.crt").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
var keyFiles = RunCmd("find /usr/local/etc/xray/ssl/*.key").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (crtFiles.Length > 0 && keyFiles.Length > 0)
|
||||
{
|
||||
RunCmd($"mv {crtFiles[0]} /usr/local/etc/xray/ssl/xray_ssl.crt");
|
||||
RunCmd($"mv {keyFiles[0]} /usr/local/etc/xray/ssl/xray_ssl.key");
|
||||
}
|
||||
else
|
||||
{
|
||||
Progress.Step = "上传失败";
|
||||
Progress.Desc = "上传证书失败,缺少 .crt 和 .key 文件";
|
||||
return;
|
||||
}
|
||||
|
||||
Progress.Desc = "重启Xray服务";
|
||||
RunCmd("systemctl restart xray");
|
||||
|
||||
Progress.Percentage = 100;
|
||||
Progress.Desc = "上传证书完成";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void DoUploadWeb(object sender, CancelEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootUser();
|
||||
|
||||
Progress.Step = "上传静态网站";
|
||||
Progress.Desc = "上传静态网站";
|
||||
Progress.Percentage = 0;
|
||||
|
||||
Progress.Desc = "检测系统环境";
|
||||
EnsureSystemEnv();
|
||||
Progress.Percentage = 20;
|
||||
|
||||
Progress.Desc = "创建网站目录";
|
||||
if (!FileExists("/usr/share/caddy"))
|
||||
{
|
||||
RunCmd("mkdir /usr/share/caddy");
|
||||
}
|
||||
RunCmd("rm -rf /usr/share/caddy/*");
|
||||
Progress.Percentage = 40;
|
||||
|
||||
Progress.Desc = "正在上传文件";
|
||||
var file = sender as OpenFileDialog;
|
||||
using (var stream = file.OpenFile())
|
||||
{
|
||||
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");
|
||||
Progress.Percentage = 80;
|
||||
|
||||
Progress.Desc = "上传Web配置文件";
|
||||
UploadCaddyFile(useCustomWeb: true);
|
||||
Progress.Percentage = 90;
|
||||
|
||||
Progress.Desc = "重启caddy服务";
|
||||
RunCmd("systemctl restart caddy");
|
||||
Progress.Percentage = 100;
|
||||
|
||||
Progress.Desc = "上传静态网站成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void InstallXray()
|
||||
{
|
||||
Progress.Desc = ("开始安装Xray-Core");
|
||||
RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install");
|
||||
|
||||
if (!FileExists("/usr/local/bin/xray"))
|
||||
{
|
||||
Progress.Desc = ("Xray-Core安装失败,请联系开发者");
|
||||
throw new Exception("Xray-Core安装失败,请联系开发者");
|
||||
}
|
||||
|
||||
Progress.Desc = ("设置Xray-core权限");
|
||||
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"systemctl daemon-reload");
|
||||
|
||||
if (FileExists("/usr/local/etc/xray/config.json"))
|
||||
{
|
||||
RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1");
|
||||
}
|
||||
Progress.Percentage = 60;
|
||||
|
||||
if (Settings.WithTLS && !Settings.IsIPAddress)
|
||||
{
|
||||
Progress.Desc = ("安装TLS证书");
|
||||
InstallCert(
|
||||
dirPath: "/usr/local/etc/xray/ssl",
|
||||
certName: "xray_ssl.crt",
|
||||
keyName: "xray_ssl.key");
|
||||
Progress.Percentage = 75;
|
||||
}
|
||||
|
||||
Progress.Desc = ("生成Xray服务器配置文件");
|
||||
var configJson = XrayConfigBuilder.BuildXrayConfig(Settings);
|
||||
WriteToFile(configJson, "/usr/local/etc/xray/config.json");
|
||||
}
|
||||
|
||||
private void UploadCaddyFile(bool useCustomWeb = false)
|
||||
{
|
||||
var configJson = XrayConfigBuilder.BuildCaddyConfig(Settings, useCustomWeb);
|
||||
|
||||
if (FileExists("/etc/caddy/Caddyfile"))
|
||||
{
|
||||
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
||||
}
|
||||
WriteToFile(configJson, "/etc/caddy/Caddyfile");
|
||||
}
|
||||
|
||||
private void UninstallXray()
|
||||
{
|
||||
Progress.Desc = "关闭Xray服务";
|
||||
RunCmd("systemctl stop xray");
|
||||
RunCmd("systemctl disable xray");
|
||||
|
||||
Progress.Desc = "卸载Xray";
|
||||
RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ remove");
|
||||
}
|
||||
|
||||
private void UninstallAcme()
|
||||
{
|
||||
Progress.Desc = "卸载 acme.sh";
|
||||
RunCmd("acme.sh --uninstall");
|
||||
|
||||
Progress.Desc = "删除 acme.sh 相关文件";
|
||||
RunCmd("rm -rf ~/.acme.sh");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
24
ProxySuper.Core/ViewModels/BrookConfigViewModel.cs
Normal file
24
ProxySuper.Core/ViewModels/BrookConfigViewModel.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class BrookConfigViewModel : MvxViewModel<BrookSettings>
|
||||
{
|
||||
public BrookSettings Settings { get; set; }
|
||||
|
||||
public override void Prepare(BrookSettings parameter)
|
||||
{
|
||||
Settings = parameter;
|
||||
}
|
||||
|
||||
public string Link
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.BuildBrook(Settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
102
ProxySuper.Core/ViewModels/BrookEditorViewModel.cs
Normal file
102
ProxySuper.Core/ViewModels/BrookEditorViewModel.cs
Normal file
|
@ -0,0 +1,102 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.Navigation;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class BrookEditorViewModel : MvxViewModel<Record, Record>
|
||||
{
|
||||
public BrookEditorViewModel(IMvxNavigationService navigationService)
|
||||
{
|
||||
NavigationService = navigationService;
|
||||
}
|
||||
|
||||
public IMvxNavigationService NavigationService { get; }
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public Host Host { get; set; }
|
||||
|
||||
public BrookSettings Settings { get; set; }
|
||||
|
||||
public List<string> BrookTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<string> {
|
||||
BrookType.server.ToString(),
|
||||
BrookType.wsserver.ToString(),
|
||||
BrookType.wssserver.ToString(),
|
||||
BrookType.socks5.ToString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public string CheckedBrookType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.BrookType.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings.BrookType = (BrookType)Enum.Parse(typeof(BrookType), value);
|
||||
|
||||
if (Settings.BrookType == BrookType.wssserver)
|
||||
{
|
||||
Settings.Port = 443;
|
||||
RaisePropertyChanged("Settings");
|
||||
}
|
||||
RaisePropertyChanged("EnablePort");
|
||||
RaisePropertyChanged("EnableDomain");
|
||||
RaisePropertyChanged("EnableIP");
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnablePort => Settings.BrookType != BrookType.wssserver;
|
||||
|
||||
public bool EnableDomain => Settings.BrookType == BrookType.wssserver;
|
||||
|
||||
public bool EnableIP => Settings.BrookType != BrookType.wssserver;
|
||||
|
||||
public IMvxCommand SaveCommand => new MvxCommand(() => Save());
|
||||
|
||||
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
var record = Utils.DeepClone(parameter);
|
||||
Id = record.Id;
|
||||
Host = record.Host;
|
||||
Settings = record.BrookSettings;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
NavigationService.Close(this, new Record()
|
||||
{
|
||||
Id = Id,
|
||||
Host = Host,
|
||||
BrookSettings = Settings,
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveAndInstall()
|
||||
{
|
||||
var record = new Record
|
||||
{
|
||||
Id = this.Id,
|
||||
Host = this.Host,
|
||||
BrookSettings = Settings,
|
||||
};
|
||||
NavigationService.Close(this, record);
|
||||
NavigationService.Navigate<BrookInstallViewModel, Record>(record);
|
||||
}
|
||||
}
|
||||
}
|
65
ProxySuper.Core/ViewModels/BrookInstallViewModel.cs
Normal file
65
ProxySuper.Core/ViewModels/BrookInstallViewModel.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class BrookInstallViewModel : MvxViewModel<Record>
|
||||
{
|
||||
Host _host;
|
||||
|
||||
BrookSettings _settings;
|
||||
|
||||
BrookService _service;
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
_host = parameter.Host;
|
||||
_settings = parameter.BrookSettings;
|
||||
}
|
||||
|
||||
public override Task Initialize()
|
||||
{
|
||||
_service = new BrookService(_host, _settings);
|
||||
_service.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
|
||||
_service.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
|
||||
_service.Connect();
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
public override void ViewDestroy(bool viewFinishing = true)
|
||||
{
|
||||
_service.Disconnect();
|
||||
this.SaveInstallLog();
|
||||
base.ViewDestroy(viewFinishing);
|
||||
}
|
||||
|
||||
public ProjectProgress Progress => _service.Progress;
|
||||
|
||||
public string Logs => _service.Progress.Logs;
|
||||
|
||||
public IMvxCommand InstallCommand => new MvxCommand(_service.Install);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
168
ProxySuper.Core/ViewModels/EnableRootViewModel.cs
Normal file
168
ProxySuper.Core/ViewModels/EnableRootViewModel.cs
Normal file
|
@ -0,0 +1,168 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using Renci.SshNet;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class EnableRootViewModel : MvxViewModel
|
||||
{
|
||||
private SshClient _sshClient;
|
||||
|
||||
public EnableRootViewModel()
|
||||
{
|
||||
Host = new Host();
|
||||
}
|
||||
|
||||
public Host Host { get; set; }
|
||||
|
||||
public string RootUserName { get; set; }
|
||||
|
||||
public string RootPassword { get; set; }
|
||||
|
||||
public string OutputText { get; set; }
|
||||
|
||||
public IMvxCommand ExecuteCommand => new MvxCommand(Execute);
|
||||
|
||||
public override void ViewDisappearing()
|
||||
{
|
||||
base.ViewDisappearing();
|
||||
if (_sshClient != null)
|
||||
{
|
||||
_sshClient.Disconnect();
|
||||
_sshClient.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
OpenConnect();
|
||||
if (!_sshClient.IsConnected)
|
||||
{
|
||||
MessageBox.Show("连接失败,请重试!");
|
||||
return;
|
||||
}
|
||||
|
||||
string result = string.Empty;
|
||||
result = RunCmd("id -u");
|
||||
|
||||
if (result.TrimEnd('\r', '\n') == "0")
|
||||
{
|
||||
MessageBox.Show("当前账户已经具有root权限,无需再设置!");
|
||||
return;
|
||||
}
|
||||
|
||||
result = RunCmd($"echo {Host.Password} | sudo -S id -u");
|
||||
if (result.TrimEnd('\r', '\n') != "0")
|
||||
{
|
||||
MessageBox.Show("当前账户无法获取sudo权限,设置失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
string cmdPre = $"echo {Host.Password} | sudo -S id -u" + ';';
|
||||
RunCmd(cmdPre + "sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config");
|
||||
RunCmd(cmdPre + "sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config");
|
||||
RunCmd(cmdPre + "sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config");
|
||||
RunCmd(cmdPre + "echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config");
|
||||
RunCmd(cmdPre + "echo 'PasswordAuthentication yes' | sudo tee -a /etc/ssh/sshd_config");
|
||||
RunCmd(cmdPre + "echo 'PermitEmptyPasswords no' | sudo tee -a /etc/ssh/sshd_config");
|
||||
RunCmd(cmdPre + "sudo systemctl restart sshd");
|
||||
|
||||
result = RunCmd(@"cat /dev/urandom | tr -dc '_A-Z#\-+=a-z(0-9%^>)]{<|' | head -c 20 ; echo ''");
|
||||
string setPassword = result.TrimEnd('\r', '\n') + '\n';
|
||||
RunCmd(cmdPre + $"echo \"{setPassword}{setPassword}\" | sudo passwd root");
|
||||
RunCmd("sudo systemctl restart sshd");
|
||||
|
||||
RootUserName = "root";
|
||||
RootPassword = setPassword.Trim('\n');
|
||||
RaisePropertyChanged("RootUserName");
|
||||
RaisePropertyChanged("RootPassword");
|
||||
|
||||
|
||||
var filePath = Host.Address.Replace(':', '_');
|
||||
using (StreamWriter sw = new StreamWriter("Logs\\host_password_info.txt"))
|
||||
{
|
||||
sw.WriteLine(Host.Address);
|
||||
sw.WriteLine("root");
|
||||
sw.WriteLine(setPassword);
|
||||
}
|
||||
WriteOutput("设置成功,账号信息保存在Logs/host_password_info.txt");
|
||||
WriteOutput("账号:\nroot");
|
||||
WriteOutput($"密码:\n{setPassword}");
|
||||
});
|
||||
}
|
||||
|
||||
protected string RunCmd(string cmdStr)
|
||||
{
|
||||
var cmd = _sshClient.CreateCommand(cmdStr);
|
||||
WriteOutput(cmdStr);
|
||||
|
||||
var result = cmd.Execute();
|
||||
WriteOutput(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void WriteOutput(string text)
|
||||
{
|
||||
OutputText += text + '\n';
|
||||
RaisePropertyChanged("OutputText");
|
||||
}
|
||||
|
||||
|
||||
private void OpenConnect()
|
||||
{
|
||||
WriteOutput("正在建立连接...");
|
||||
var conneInfo = CreateConnectionInfo(Host);
|
||||
_sshClient = new SshClient(conneInfo);
|
||||
try
|
||||
{
|
||||
_sshClient.Connect();
|
||||
WriteOutput("Connected...");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteOutput(ex.Message);
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private ConnectionInfo CreateConnectionInfo(Host host)
|
||||
{
|
||||
AuthenticationMethod auth = null;
|
||||
|
||||
if (host.SecretType == LoginSecretType.Password)
|
||||
{
|
||||
auth = new PasswordAuthenticationMethod(host.UserName, host.Password);
|
||||
}
|
||||
else if (host.SecretType == LoginSecretType.PrivateKey)
|
||||
{
|
||||
auth = new PrivateKeyAuthenticationMethod(host.UserName, new PrivateKeyFile(host.PrivateKeyPath));
|
||||
}
|
||||
|
||||
if (host.Proxy.Type == ProxyTypes.None)
|
||||
{
|
||||
return new ConnectionInfo(host.Address, host.Port, host.UserName, auth);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ConnectionInfo(
|
||||
host: host.Address,
|
||||
port: host.Port,
|
||||
username: host.UserName,
|
||||
proxyType: host.Proxy.Type,
|
||||
proxyHost: host.Proxy.Address,
|
||||
proxyPort: host.Proxy.Port,
|
||||
proxyUsername: host.Proxy.UserName,
|
||||
proxyPassword: host.Proxy.Password,
|
||||
authenticationMethods: auth);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
|
@ -55,17 +53,63 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
});
|
||||
if (!Directory.Exists("Data"))
|
||||
{
|
||||
Directory.CreateDirectory("Data");
|
||||
}
|
||||
File.WriteAllText("Data/Record.json", json);
|
||||
}
|
||||
|
||||
public void SortDone(string id)
|
||||
{
|
||||
var item = Records.Where(x => x.Id == id).FirstOrDefault();
|
||||
if (item == null) return;
|
||||
|
||||
var index = Records.IndexOf(item);
|
||||
if (index >= Records.Count - 1) return;
|
||||
|
||||
Records.Remove(item);
|
||||
Records.Insert(index + 1, item);
|
||||
|
||||
RaisePropertyChanged("Records");
|
||||
SaveToJson();
|
||||
}
|
||||
|
||||
public void SortUp(string id)
|
||||
{
|
||||
var item = Records.Where(x => x.Id == id).FirstOrDefault();
|
||||
if (item == null) return;
|
||||
|
||||
var index = Records.IndexOf(item);
|
||||
if (index <= 0) return;
|
||||
|
||||
Records.Remove(item);
|
||||
Records.Insert(index - 1, item);
|
||||
|
||||
RaisePropertyChanged("Records");
|
||||
SaveToJson();
|
||||
}
|
||||
|
||||
public MvxObservableCollection<Record> Records { get; set; }
|
||||
|
||||
public IMvxCommand SortUpCommand => new MvxCommand<string>(SortUp);
|
||||
|
||||
public IMvxCommand SortDoneCommand => new MvxCommand<string>(SortDone);
|
||||
|
||||
public IMvxCommand AddV2rayCommand => new MvxAsyncCommand(AddV2rayRecord);
|
||||
|
||||
public IMvxCommand AddXrayCommand => new MvxAsyncCommand(AddXrayRecord);
|
||||
|
||||
public IMvxCommand AddTrojanGoCommand => new MvxAsyncCommand(AddTrojanGoRecord);
|
||||
|
||||
public IMvxCommand AddNaiveProxyCommand => new MvxAsyncCommand(AddNaiveProxyRecord);
|
||||
|
||||
public IMvxCommand AddMTProtoGoCommand => new MvxAsyncCommand(AddMTProtoGoRecord);
|
||||
|
||||
public IMvxCommand AddBrookCommand => new MvxAsyncCommand(AddBrookRecord);
|
||||
|
||||
public IMvxCommand AddHysteriaCommand => new MvxAsyncCommand(AddHysteriaRecord);
|
||||
|
||||
public IMvxCommand RemoveCommand => new MvxAsyncCommand<string>(DeleteRecord);
|
||||
|
||||
public IMvxCommand EditCommand => new MvxAsyncCommand<string>(EditRecord);
|
||||
|
@ -74,6 +118,20 @@ namespace ProxySuper.Core.ViewModels
|
|||
|
||||
public IMvxCommand InstallCommand => new MvxAsyncCommand<string>(GoToInstall);
|
||||
|
||||
public async Task AddV2rayRecord()
|
||||
{
|
||||
Record record = new Record();
|
||||
record.Id = Utils.GetTickID();
|
||||
record.Host = new Host();
|
||||
record.V2raySettings = new V2raySettings();
|
||||
|
||||
var result = await _navigationService.Navigate<V2rayEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
Records.Add(result);
|
||||
SaveToJson();
|
||||
}
|
||||
|
||||
public async Task AddXrayRecord()
|
||||
{
|
||||
Record record = new Record();
|
||||
|
@ -103,6 +161,21 @@ namespace ProxySuper.Core.ViewModels
|
|||
SaveToJson();
|
||||
}
|
||||
|
||||
public async Task AddMTProtoGoRecord()
|
||||
{
|
||||
Record record = new Record();
|
||||
record.Id = Utils.GetTickID();
|
||||
record.Host = new Host();
|
||||
record.MTProtoGoSettings = new MTProtoGoSettings();
|
||||
|
||||
var result = await _navigationService.Navigate<MTProtoGoEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
Records.Add(result);
|
||||
|
||||
SaveToJson();
|
||||
}
|
||||
|
||||
public async Task AddNaiveProxyRecord()
|
||||
{
|
||||
Record record = new Record();
|
||||
|
@ -118,6 +191,36 @@ namespace ProxySuper.Core.ViewModels
|
|||
SaveToJson();
|
||||
}
|
||||
|
||||
public async Task AddBrookRecord()
|
||||
{
|
||||
Record record = new Record();
|
||||
record.Id = Utils.GetTickID();
|
||||
record.Host = new Host();
|
||||
record.BrookSettings = new BrookSettings();
|
||||
|
||||
var result = await _navigationService.Navigate<BrookEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
Records.Add(result);
|
||||
|
||||
SaveToJson();
|
||||
}
|
||||
|
||||
public async Task AddHysteriaRecord()
|
||||
{
|
||||
Record record = new Record();
|
||||
record.Id = Utils.GetTickID();
|
||||
record.Host = new Host();
|
||||
record.HysteriaSettings = new HysteriaSettings();
|
||||
|
||||
var result = await _navigationService.Navigate<HysteriaEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
Records.Add(result);
|
||||
|
||||
SaveToJson();
|
||||
}
|
||||
|
||||
|
||||
public async Task EditRecord(string id)
|
||||
{
|
||||
|
@ -125,6 +228,14 @@ namespace ProxySuper.Core.ViewModels
|
|||
if (record == null) return;
|
||||
|
||||
Record result = null;
|
||||
if (record.Type == ProjectType.V2ray)
|
||||
{
|
||||
result = await _navigationService.Navigate<V2rayEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
record.Host = result.Host;
|
||||
record.V2raySettings = result.V2raySettings;
|
||||
}
|
||||
if (record.Type == ProjectType.Xray)
|
||||
{
|
||||
result = await _navigationService.Navigate<XrayEditorViewModel, Record, Record>(record);
|
||||
|
@ -149,6 +260,30 @@ namespace ProxySuper.Core.ViewModels
|
|||
record.Host = result.Host;
|
||||
record.NaiveProxySettings = result.NaiveProxySettings;
|
||||
}
|
||||
if (record.Type == ProjectType.Brook)
|
||||
{
|
||||
result = await _navigationService.Navigate<BrookEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
record.Host = result.Host;
|
||||
record.BrookSettings = result.BrookSettings;
|
||||
}
|
||||
if (record.Type == ProjectType.MTProtoGo)
|
||||
{
|
||||
result = await _navigationService.Navigate<MTProtoGoEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
record.Host = result.Host;
|
||||
record.MTProtoGoSettings = result.MTProtoGoSettings;
|
||||
}
|
||||
if (record.Type == ProjectType.Hysteria)
|
||||
{
|
||||
result = await _navigationService.Navigate<HysteriaEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
record.Host = result.Host;
|
||||
record.HysteriaSettings = result.HysteriaSettings;
|
||||
}
|
||||
|
||||
SaveToJson();
|
||||
}
|
||||
|
@ -173,6 +308,10 @@ namespace ProxySuper.Core.ViewModels
|
|||
var record = Records.FirstOrDefault(x => x.Id == id);
|
||||
if (record == null) return;
|
||||
|
||||
if (record.Type == ProjectType.V2ray)
|
||||
{
|
||||
await _navigationService.Navigate<V2rayConfigViewModel, V2raySettings>(record.V2raySettings);
|
||||
}
|
||||
if (record.Type == ProjectType.Xray)
|
||||
{
|
||||
await _navigationService.Navigate<XrayConfigViewModel, XraySettings>(record.XraySettings);
|
||||
|
@ -185,25 +324,57 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
await _navigationService.Navigate<NaiveProxyConfigViewModel, NaiveProxySettings>(record.NaiveProxySettings);
|
||||
}
|
||||
if (record.Type == ProjectType.Brook)
|
||||
{
|
||||
await _navigationService.Navigate<BrookConfigViewModel, BrookSettings>(record.BrookSettings);
|
||||
}
|
||||
if (record.Type == ProjectType.MTProtoGo)
|
||||
{
|
||||
await _navigationService.Navigate<MTProtoGoConfigViewModel, MTProtoGoSettings>(record.MTProtoGoSettings);
|
||||
}
|
||||
if (record.Type == ProjectType.Hysteria)
|
||||
{
|
||||
await _navigationService.Navigate<HysteriaConfigViewModel, HysteriaSettings>(record.HysteriaSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GoToInstall(string id)
|
||||
{
|
||||
var record = Records.FirstOrDefault(x => x.Id == id);
|
||||
if (record == null) return;
|
||||
record.OnSave = SaveToJson;
|
||||
|
||||
if (record.Type == ProjectType.V2ray)
|
||||
{
|
||||
await _navigationService.Navigate<V2rayInstallViewModel, Record>(record);
|
||||
}
|
||||
if (record.Type == ProjectType.Xray)
|
||||
{
|
||||
await _navigationService.Navigate<XrayInstallerViewModel, Record>(record);
|
||||
await _navigationService.Navigate<XrayInstallViewModel, Record>(record);
|
||||
}
|
||||
if (record.Type == ProjectType.TrojanGo)
|
||||
{
|
||||
await _navigationService.Navigate<TrojanGoInstallerViewModel, Record>(record);
|
||||
await _navigationService.Navigate<TrojanGoInstallViewModel, Record>(record);
|
||||
}
|
||||
if (record.Type == ProjectType.NaiveProxy)
|
||||
{
|
||||
await _navigationService.Navigate<NaiveProxyInstallerViewModel, Record>(record);
|
||||
await _navigationService.Navigate<NaiveProxyInstallViewModel, Record>(record);
|
||||
}
|
||||
if (record.Type == ProjectType.Brook)
|
||||
{
|
||||
await _navigationService.Navigate<BrookInstallViewModel, Record>(record);
|
||||
}
|
||||
if (record.Type == ProjectType.MTProtoGo)
|
||||
{
|
||||
await _navigationService.Navigate<MTProtoGoInstallViewModel, Record>(record);
|
||||
}
|
||||
if (record.Type == ProjectType.Hysteria)
|
||||
{
|
||||
await _navigationService.Navigate<HysteriaInstallViewModel, Record>(record);
|
||||
}
|
||||
|
||||
SaveToJson();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
45
ProxySuper.Core/ViewModels/HysteriaConfigViewModel.cs
Normal file
45
ProxySuper.Core/ViewModels/HysteriaConfigViewModel.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class HysteriaConfigViewModel : MvxViewModel<HysteriaSettings>
|
||||
{
|
||||
public HysteriaSettings Settings { get; set; }
|
||||
|
||||
public override void Prepare(HysteriaSettings parameter)
|
||||
{
|
||||
Settings = parameter;
|
||||
}
|
||||
|
||||
public string ClientJson {
|
||||
|
||||
get
|
||||
{
|
||||
var jsonData = new
|
||||
{
|
||||
server = $"{Settings.Domain}:{Settings.Port}",
|
||||
obfs = Settings.Obfs,
|
||||
up_mbps = 10,
|
||||
down_mbps = 50,
|
||||
socks5 = new
|
||||
{
|
||||
listen = "127.0.0.1:1080"
|
||||
},
|
||||
http = new
|
||||
{
|
||||
listen = "127.0.0.1:1081"
|
||||
}
|
||||
};
|
||||
|
||||
return JsonConvert.SerializeObject(jsonData, Formatting.Indented);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
68
ProxySuper.Core/ViewModels/HysteriaEditorViewModel.cs
Normal file
68
ProxySuper.Core/ViewModels/HysteriaEditorViewModel.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.Navigation;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class HysteriaEditorViewModel : MvxViewModel<Record, Record>
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
public Host Host { get; set; }
|
||||
|
||||
public HysteriaSettings Settings { get; set; }
|
||||
|
||||
public IMvxNavigationService NavigationService { get; }
|
||||
|
||||
public IMvxCommand SaveCommand => new MvxCommand(() => Save());
|
||||
|
||||
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
|
||||
|
||||
public HysteriaEditorViewModel(IMvxNavigationService mvxNavigationService)
|
||||
{
|
||||
NavigationService = mvxNavigationService;
|
||||
}
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
var record = Utils.DeepClone(parameter);
|
||||
|
||||
Id = record.Id;
|
||||
Host = record.Host;
|
||||
Settings = record.HysteriaSettings;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
NavigationService.Close(this, new Record
|
||||
{
|
||||
Id = Id,
|
||||
Host = Host,
|
||||
HysteriaSettings = Settings,
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveAndInstall()
|
||||
{
|
||||
var record = new Record
|
||||
{
|
||||
Id = Id,
|
||||
Host = Host,
|
||||
HysteriaSettings = Settings,
|
||||
};
|
||||
|
||||
NavigationService.Close(this, record);
|
||||
NavigationService.Navigate<HysteriaInstallViewModel, Record>(record);
|
||||
}
|
||||
}
|
||||
}
|
66
ProxySuper.Core/ViewModels/HysteriaInstallViewModel.cs
Normal file
66
ProxySuper.Core/ViewModels/HysteriaInstallViewModel.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class HysteriaInstallViewModel : MvxViewModel<Record>
|
||||
{
|
||||
public Host _host { get; set; }
|
||||
|
||||
public HysteriaSettings _settings { get; set; }
|
||||
|
||||
public HysteriaService _service { get; set; }
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
_host = parameter.Host;
|
||||
_settings = parameter.HysteriaSettings;
|
||||
}
|
||||
|
||||
public override Task Initialize()
|
||||
{
|
||||
_service = new HysteriaService(_host, _settings);
|
||||
_service.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
|
||||
_service.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
|
||||
_service.Connect();
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
public override void ViewDestroy(bool viewFinishing = true)
|
||||
{
|
||||
_service.Disconnect();
|
||||
this.SaveInstallLog();
|
||||
base.ViewDestroy(viewFinishing);
|
||||
}
|
||||
|
||||
public ProjectProgress Progress => _service.Progress;
|
||||
|
||||
public string Logs => _service.Progress.Logs;
|
||||
|
||||
public IMvxCommand InstallCommand => new MvxCommand(_service.Install);
|
||||
|
||||
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") + ".hysteria.txt");
|
||||
File.WriteAllText(fileName, Logs);
|
||||
}
|
||||
}
|
||||
}
|
21
ProxySuper.Core/ViewModels/MTProtoGoConfigViewModel.cs
Normal file
21
ProxySuper.Core/ViewModels/MTProtoGoConfigViewModel.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class MTProtoGoConfigViewModel : MvxViewModel<MTProtoGoSettings>
|
||||
{
|
||||
public MTProtoGoSettings Settings { get; set; }
|
||||
|
||||
public override void Prepare(MTProtoGoSettings parameter)
|
||||
{
|
||||
Settings = parameter;
|
||||
}
|
||||
}
|
||||
}
|
66
ProxySuper.Core/ViewModels/MTProtoGoEditorViewModel.cs
Normal file
66
ProxySuper.Core/ViewModels/MTProtoGoEditorViewModel.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.Navigation;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class MTProtoGoEditorViewModel : MvxViewModel<Record, Record>
|
||||
{
|
||||
public MTProtoGoEditorViewModel(IMvxNavigationService navigationService)
|
||||
{
|
||||
NavigationService = navigationService;
|
||||
}
|
||||
|
||||
public IMvxNavigationService NavigationService { get; }
|
||||
|
||||
public IMvxCommand SaveCommand => new MvxCommand(Save);
|
||||
|
||||
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public Host Host { get; set; }
|
||||
|
||||
public MTProtoGoSettings Settings { get; set; }
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
var record = Utils.DeepClone(parameter);
|
||||
|
||||
Id = record.Id;
|
||||
Host = record.Host;
|
||||
Settings = record.MTProtoGoSettings;
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
NavigationService.Close(this, new Record
|
||||
{
|
||||
Id = this.Id,
|
||||
Host = this.Host,
|
||||
MTProtoGoSettings = Settings,
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveAndInstall()
|
||||
{
|
||||
var record = new Record
|
||||
{
|
||||
Id = this.Id,
|
||||
Host = this.Host,
|
||||
MTProtoGoSettings = Settings,
|
||||
};
|
||||
NavigationService.Close(this, record);
|
||||
NavigationService.Navigate<MTProtoGoInstallViewModel, Record>(record);
|
||||
}
|
||||
}
|
||||
}
|
94
ProxySuper.Core/ViewModels/MTProtoGoInstallViewModel.cs
Normal file
94
ProxySuper.Core/ViewModels/MTProtoGoInstallViewModel.cs
Normal file
|
@ -0,0 +1,94 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class MTProtoGoInstallViewModel : MvxViewModel<Record>
|
||||
{
|
||||
Host _host;
|
||||
|
||||
MTProtoGoSettings _settings;
|
||||
|
||||
MTProtoGoService _mtproxyService;
|
||||
|
||||
Action _onSave;
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
_host = parameter.Host;
|
||||
_settings = parameter.MTProtoGoSettings;
|
||||
_onSave = parameter.OnSave;
|
||||
}
|
||||
|
||||
public override Task Initialize()
|
||||
{
|
||||
_mtproxyService = new MTProtoGoService(_host, _settings);
|
||||
_mtproxyService.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
|
||||
_mtproxyService.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
|
||||
_mtproxyService.Connect();
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
public override void ViewDestroy(bool viewFinishing = true)
|
||||
{
|
||||
_mtproxyService.Disconnect();
|
||||
this.SaveInstallLog();
|
||||
base.ViewDestroy(viewFinishing);
|
||||
}
|
||||
|
||||
public ProjectProgress Progress
|
||||
{
|
||||
get => _mtproxyService.Progress;
|
||||
}
|
||||
|
||||
public string Logs
|
||||
{
|
||||
get => _mtproxyService.Progress.Logs;
|
||||
}
|
||||
|
||||
|
||||
#region Command
|
||||
|
||||
public IMvxCommand InstallCommand => new MvxCommand(() =>
|
||||
{
|
||||
_mtproxyService.Install();
|
||||
|
||||
// 安装时生成的Secret需要保存
|
||||
_onSave();
|
||||
});
|
||||
|
||||
public IMvxCommand UpdateSettingsCommand => new MvxCommand(() =>
|
||||
{
|
||||
_mtproxyService.UpdateSettings();
|
||||
|
||||
// 安装时生成的Secret需要保存
|
||||
_onSave();
|
||||
});
|
||||
|
||||
public IMvxCommand UninstallCommand => new MvxCommand(_mtproxyService.Uninstall);
|
||||
|
||||
#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") + ".mtproxy-go.txt");
|
||||
File.WriteAllText(fileName, Logs);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
using Microsoft.Win32;
|
||||
using MvvmCross.Commands;
|
||||
using MvvmCross.Commands;
|
||||
using MvvmCross.Navigation;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
|
@ -42,6 +35,8 @@ namespace ProxySuper.Core.ViewModels
|
|||
|
||||
public IMvxCommand SaveCommand => new MvxCommand(Save);
|
||||
|
||||
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
|
||||
|
||||
private void Save()
|
||||
{
|
||||
NavigationService.Close(this, new Record
|
||||
|
@ -51,5 +46,18 @@ namespace ProxySuper.Core.ViewModels
|
|||
NaiveProxySettings = Settings
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void SaveAndInstall()
|
||||
{
|
||||
var record = new Record
|
||||
{
|
||||
Id = this.Id,
|
||||
Host = this.Host,
|
||||
NaiveProxySettings = Settings,
|
||||
};
|
||||
NavigationService.Close(this, record);
|
||||
NavigationService.Navigate<NaiveProxyInstallViewModel, Record>(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
75
ProxySuper.Core/ViewModels/NaiveProxyInstallViewModel.cs
Normal file
75
ProxySuper.Core/ViewModels/NaiveProxyInstallViewModel.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class NaiveProxyInstallViewModel : MvxViewModel<Record>
|
||||
{
|
||||
Host _host;
|
||||
|
||||
NaiveProxySettings _settings;
|
||||
|
||||
NaiveProxyService _service;
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
_host = parameter.Host;
|
||||
_settings = parameter.NaiveProxySettings;
|
||||
}
|
||||
|
||||
public override Task Initialize()
|
||||
{
|
||||
_service = new NaiveProxyService(_host, _settings);
|
||||
_service.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
|
||||
_service.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
|
||||
_service.Connect();
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
public override void ViewDestroy(bool viewFinishing = true)
|
||||
{
|
||||
_service.Disconnect();
|
||||
this.SaveInstallLog();
|
||||
base.ViewDestroy(viewFinishing);
|
||||
}
|
||||
|
||||
|
||||
public ProjectProgress Progress => _service.Progress;
|
||||
|
||||
public string Logs => _service.Progress.Logs;
|
||||
|
||||
|
||||
#region Commands
|
||||
|
||||
public IMvxCommand InstallCommand => new MvxCommand(_service.Install);
|
||||
|
||||
public IMvxCommand UpdateSettingsCommand => new MvxCommand(_service.UpdateSettings);
|
||||
|
||||
public IMvxCommand UninstallCommand => new MvxCommand(_service.Uninstall);
|
||||
|
||||
public IMvxCommand UploadWebCommand => new MvxCommand(_service.UploadWeb);
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class NaiveProxyInstallerViewModel : MvxViewModel<Record>
|
||||
{
|
||||
public Host Host { get; set; }
|
||||
|
||||
public NaiveProxySettings Settings { get; set; }
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
var record = Utils.DeepClone(parameter);
|
||||
Host = record.Host;
|
||||
Settings = record.NaiveProxySettings;
|
||||
}
|
||||
|
||||
private bool _connected;
|
||||
public bool Connected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _connected;
|
||||
}
|
||||
set
|
||||
{
|
||||
_connected = value;
|
||||
RaisePropertyChanged("Connected");
|
||||
}
|
||||
}
|
||||
|
||||
public string CommandText { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
|
|
|
@ -5,11 +5,6 @@ using ProxySuper.Core.Models;
|
|||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
|
@ -24,6 +19,8 @@ namespace ProxySuper.Core.ViewModels
|
|||
|
||||
public IMvxCommand SaveCommand => new MvxCommand(Save);
|
||||
|
||||
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public Host Host { get; set; }
|
||||
|
@ -48,6 +45,18 @@ namespace ProxySuper.Core.ViewModels
|
|||
TrojanGoSettings = Settings,
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveAndInstall()
|
||||
{
|
||||
var record = new Record
|
||||
{
|
||||
Id = this.Id,
|
||||
Host = this.Host,
|
||||
TrojanGoSettings = Settings,
|
||||
};
|
||||
NavigationService.Close(this, record);
|
||||
NavigationService.Navigate<TrojanGoInstallViewModel, Record>(record);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
85
ProxySuper.Core/ViewModels/TrojanGoInstallViewModel.cs
Normal file
85
ProxySuper.Core/ViewModels/TrojanGoInstallViewModel.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class TrojanGoInstallViewModel : MvxViewModel<Record>
|
||||
{
|
||||
Host _host;
|
||||
|
||||
TrojanGoSettings _settings;
|
||||
|
||||
TrojanGoService _trojanGoService;
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
_host = parameter.Host;
|
||||
_settings = parameter.TrojanGoSettings;
|
||||
}
|
||||
|
||||
public override Task Initialize()
|
||||
{
|
||||
_trojanGoService = new TrojanGoService(_host, _settings);
|
||||
_trojanGoService.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
|
||||
_trojanGoService.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
|
||||
_trojanGoService.Connect();
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
public override void ViewDestroy(bool viewFinishing = true)
|
||||
{
|
||||
_trojanGoService.Disconnect();
|
||||
this.SaveInstallLog();
|
||||
base.ViewDestroy(viewFinishing);
|
||||
}
|
||||
|
||||
public ProjectProgress Progress
|
||||
{
|
||||
get => _trojanGoService.Progress;
|
||||
}
|
||||
|
||||
public string Logs
|
||||
{
|
||||
get => _trojanGoService.Progress.Logs;
|
||||
}
|
||||
|
||||
|
||||
#region Command
|
||||
|
||||
public IMvxCommand InstallCommand => new MvxCommand(_trojanGoService.Install);
|
||||
|
||||
public IMvxCommand UpdateSettingsCommand => new MvxCommand(_trojanGoService.UpdateSettings);
|
||||
|
||||
public IMvxCommand UninstallCommand => new MvxCommand(_trojanGoService.Uninstall);
|
||||
|
||||
public IMvxCommand UploadCertCommand => new MvxCommand(_trojanGoService.UploadCert);
|
||||
|
||||
public IMvxCommand UploadWebCommand => new MvxCommand(_trojanGoService.UploadWeb);
|
||||
|
||||
public IMvxCommand ApplyForCertCommand => new MvxCommand(_trojanGoService.ApplyForCert);
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class TrojanGoInstallerViewModel : MvxViewModel<Record>
|
||||
{
|
||||
public Host Host { get; set; }
|
||||
|
||||
public TrojanGoSettings Settings { get; set; }
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
var record = Utils.DeepClone(parameter);
|
||||
Host = record.Host;
|
||||
Settings = record.TrojanGoSettings;
|
||||
}
|
||||
|
||||
private bool _connected;
|
||||
public bool Connected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _connected;
|
||||
}
|
||||
set
|
||||
{
|
||||
_connected = value;
|
||||
RaisePropertyChanged("Connected");
|
||||
}
|
||||
}
|
||||
|
||||
public string CommandText { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
109
ProxySuper.Core/ViewModels/V2rayConfigViewModel.cs
Normal file
109
ProxySuper.Core/ViewModels/V2rayConfigViewModel.cs
Normal file
|
@ -0,0 +1,109 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class V2rayConfigViewModel : MvxViewModel<V2raySettings>
|
||||
{
|
||||
public V2raySettings Settings { get; set; }
|
||||
|
||||
public override void Prepare(V2raySettings parameter)
|
||||
{
|
||||
Settings = parameter;
|
||||
}
|
||||
|
||||
|
||||
public bool Checked_VLESS_TCP
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VLESS_TCP);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VLESS_WS
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VLESS_WS);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VLESS_KCP
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VLESS_KCP);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VLESS_QUIC
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VLESS_QUIC);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VLESS_gRPC
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VLESS_gRPC);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VMESS_TCP
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VMESS_TCP);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VMESS_WS
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VMESS_WS);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VMESS_KCP
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VMESS_KCP);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VMESS_QUIC
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VMESS_QUIC);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_Trojan_TCP
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.Trojan_TCP);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckedShadowSocks
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.ShadowsocksAEAD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
572
ProxySuper.Core/ViewModels/V2rayEditorViewModel.cs
Normal file
572
ProxySuper.Core/ViewModels/V2rayEditorViewModel.cs
Normal file
|
@ -0,0 +1,572 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.Navigation;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public partial class V2rayEditorViewModel : MvxViewModel<Record, Record>
|
||||
{
|
||||
public V2rayEditorViewModel(IMvxNavigationService navigationService)
|
||||
{
|
||||
NavigationService = navigationService;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public Host Host { get; set; }
|
||||
|
||||
public V2raySettings Settings { get; set; }
|
||||
|
||||
public IMvxCommand SaveCommand => new MvxCommand(Save);
|
||||
|
||||
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
|
||||
|
||||
public IMvxNavigationService NavigationService { get; }
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
var record = Utils.DeepClone(parameter);
|
||||
Id = record.Id;
|
||||
Host = record.Host;
|
||||
Settings = record.V2raySettings;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
NavigationService.Close(this, new Record()
|
||||
{
|
||||
Id = Id,
|
||||
Host = Host,
|
||||
V2raySettings = Settings,
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveAndInstall()
|
||||
{
|
||||
var record = new Record()
|
||||
{
|
||||
Id = Id,
|
||||
Host = Host,
|
||||
V2raySettings = Settings,
|
||||
};
|
||||
NavigationService.Close(this, record);
|
||||
NavigationService.Navigate<V2rayInstallViewModel, Record>(record);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class V2rayEditorViewModel
|
||||
{
|
||||
public List<string> KcpTypes => V2raySettings.DisguiseTypes;
|
||||
|
||||
public List<string> QuicTypes => V2raySettings.DisguiseTypes;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.v2ray.com/chapter_02/transport/quic.html
|
||||
/// </summary>
|
||||
public List<string> QuicSecurities => new List<string> {
|
||||
"none",
|
||||
"aes-128-gcm",
|
||||
"chacha20-poly1305"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// https://www.v2ray.com/chapter_02/protocols/shadowsocks.html
|
||||
/// </summary>
|
||||
public List<string> ShadowSocksMethods => new List<string> {
|
||||
"aes-256-cfb",
|
||||
"aes-128-cfb",
|
||||
"chacha20",
|
||||
"chacha20-ietf",
|
||||
"aes-256-gcm",
|
||||
"aes-128-gcm",
|
||||
"chacha20-poly1305"
|
||||
};
|
||||
|
||||
public IMvxCommand RandomUuid => new MvxCommand(() => GetUuid());
|
||||
|
||||
public bool WithTLS
|
||||
{
|
||||
get => Settings.WithTLS;
|
||||
set
|
||||
{
|
||||
Settings.WithTLS = value;
|
||||
RaisePropertyChanged("Port");
|
||||
}
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
get => Settings.Port;
|
||||
set
|
||||
{
|
||||
Settings.Port = value;
|
||||
RaisePropertyChanged("Port");
|
||||
}
|
||||
}
|
||||
|
||||
public int VLESS_KCP_Port
|
||||
{
|
||||
get => Settings.VLESS_KCP_Port;
|
||||
set
|
||||
{
|
||||
Settings.VLESS_KCP_Port = value;
|
||||
RaisePropertyChanged("VLESS_KCP_Port");
|
||||
}
|
||||
}
|
||||
|
||||
public int VMESS_KCP_Port
|
||||
{
|
||||
get => Settings.VMESS_KCP_Port;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_KCP_Port = value;
|
||||
RaisePropertyChanged("VMESS_KCP_Port");
|
||||
}
|
||||
}
|
||||
|
||||
public string UUID
|
||||
{
|
||||
get => Settings.UUID;
|
||||
set
|
||||
{
|
||||
Settings.UUID = value;
|
||||
RaisePropertyChanged("UUID");
|
||||
}
|
||||
}
|
||||
|
||||
public string MultiUUID
|
||||
{
|
||||
get => string.Join(",", Settings.MulitUUID);
|
||||
set
|
||||
{
|
||||
var input = value.Replace(',', ',');
|
||||
var arr = input.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
arr.RemoveAll(x => x == this.UUID);
|
||||
Settings.MulitUUID = arr;
|
||||
RaisePropertyChanged("MultiUUID");
|
||||
}
|
||||
}
|
||||
|
||||
public string Domain
|
||||
{
|
||||
get => Settings.Domain;
|
||||
set
|
||||
{
|
||||
Settings.Domain = value;
|
||||
RaisePropertyChanged("Domain");
|
||||
}
|
||||
}
|
||||
|
||||
public string MaskDomain
|
||||
{
|
||||
get => Settings.MaskDomain;
|
||||
set
|
||||
{
|
||||
Settings.MaskDomain = value;
|
||||
RaisePropertyChanged("MaskDomain");
|
||||
}
|
||||
}
|
||||
|
||||
#region Torjan
|
||||
public string TrojanPassword
|
||||
{
|
||||
get => Settings.TrojanPassword;
|
||||
set => Settings.TrojanPassword = value;
|
||||
}
|
||||
public bool Checked_Trojan_TCP
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.Trojan_TCP);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
if (!Settings.Types.Contains(RayType.Trojan_TCP))
|
||||
Settings.Types.Add(RayType.Trojan_TCP);
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Types.Remove(RayType.Trojan_TCP);
|
||||
}
|
||||
RaisePropertyChanged("Checked_Trojan_TCP");
|
||||
}
|
||||
}
|
||||
public string Trojan_TCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.Trojan_TCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ShadowSocks
|
||||
public int ShadowSocksPort
|
||||
{
|
||||
get => Settings.ShadowSocksPort;
|
||||
set
|
||||
{
|
||||
Settings.ShadowSocksPort = value;
|
||||
RaisePropertyChanged("ShadowSocksPort");
|
||||
}
|
||||
}
|
||||
public bool CheckedShadowSocks
|
||||
{
|
||||
|
||||
get => Settings.Types.Contains(RayType.ShadowsocksAEAD);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.ShadowsocksAEAD);
|
||||
RaisePropertyChanged("CheckedShadowSocks");
|
||||
}
|
||||
}
|
||||
|
||||
public string ShadowSocksPassword
|
||||
{
|
||||
get => Settings.ShadowSocksPassword;
|
||||
set => Settings.ShadowSocksPassword = value;
|
||||
}
|
||||
public string ShadowSocksMethod
|
||||
{
|
||||
get => Settings.ShadowSocksMethod;
|
||||
set
|
||||
{
|
||||
var namespaceStr = typeof(ComboBoxItem).FullName + ":";
|
||||
var trimValue = value.Replace(namespaceStr, "");
|
||||
trimValue = trimValue.Trim();
|
||||
Settings.ShadowSocksMethod = trimValue;
|
||||
RaisePropertyChanged("ShadowSocksMethod");
|
||||
}
|
||||
}
|
||||
public string ShadowSocksShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.ShadowsocksAEAD, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
private void CheckBoxChanged(bool value, RayType type)
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
if (!Settings.Types.Contains(type))
|
||||
{
|
||||
Settings.Types.Add(type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Types.RemoveAll(x => x == type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void GetUuid()
|
||||
{
|
||||
UUID = Guid.NewGuid().ToString();
|
||||
RaisePropertyChanged("UUID");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// VMESS SETTINGS
|
||||
/// </summary>
|
||||
public partial class V2rayEditorViewModel
|
||||
{
|
||||
#region VMESS TCP
|
||||
public bool Checked_VMESS_TCP
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VMESS_TCP);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VMESS_TCP);
|
||||
RaisePropertyChanged("Checked_VMESS_TCP");
|
||||
}
|
||||
}
|
||||
public string VMESS_TCP_Path
|
||||
{
|
||||
get => Settings.VMESS_TCP_Path;
|
||||
set => Settings.VMESS_TCP_Path = value;
|
||||
}
|
||||
public string VMESS_TCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VMESS_TCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VMESS WS
|
||||
public bool Checked_VMESS_WS
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VMESS_WS);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VMESS_WS);
|
||||
RaisePropertyChanged("Checked_VMESS_WS");
|
||||
}
|
||||
}
|
||||
public string VMESS_WS_Path
|
||||
{
|
||||
get => Settings.VMESS_WS_Path;
|
||||
set => Settings.VMESS_WS_Path = value;
|
||||
}
|
||||
public string VMESS_WS_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VMESS_WS, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VMESS KCP
|
||||
public string VMESS_KCP_Seed
|
||||
{
|
||||
get => Settings.VMESS_KCP_Seed;
|
||||
set => Settings.VMESS_KCP_Seed = value;
|
||||
}
|
||||
public string VMESS_KCP_Type
|
||||
{
|
||||
get => Settings.VMESS_KCP_Type;
|
||||
set
|
||||
{
|
||||
var namespaceStr = typeof(ComboBoxItem).FullName + ":";
|
||||
var trimValue = value.Replace(namespaceStr, "");
|
||||
trimValue = trimValue.Trim();
|
||||
Settings.VMESS_KCP_Type = trimValue;
|
||||
RaisePropertyChanged("VMESS_KCP_Type");
|
||||
}
|
||||
}
|
||||
public bool Checked_VMESS_KCP
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VMESS_KCP);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VMESS_KCP);
|
||||
RaisePropertyChanged("Checked_VMESS_KCP");
|
||||
}
|
||||
}
|
||||
public string VMESS_KCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VMESS_KCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VMESS QUIC
|
||||
public bool Checked_VMESS_QUIC
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VMESS_QUIC);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VMESS_QUIC);
|
||||
RaisePropertyChanged(nameof(Checked_VMESS_QUIC));
|
||||
}
|
||||
}
|
||||
public string VMESS_QUIC_Key
|
||||
{
|
||||
get => Settings.VMESS_QUIC_Key;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_QUIC_Key = value;
|
||||
RaisePropertyChanged(nameof(VMESS_QUIC_Key));
|
||||
}
|
||||
}
|
||||
public string VMESS_QUIC_Security
|
||||
{
|
||||
get => Settings.VMESS_QUIC_Security;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_QUIC_Security = value;
|
||||
RaisePropertyChanged(nameof(VMESS_QUIC_Security));
|
||||
}
|
||||
}
|
||||
public string VMESS_QUIC_Type
|
||||
{
|
||||
get => Settings.VMESS_QUIC_Type;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_QUIC_Type = value;
|
||||
RaisePropertyChanged(nameof(VMESS_QUIC_Type));
|
||||
}
|
||||
}
|
||||
public int VMESS_QUIC_Port
|
||||
{
|
||||
get => Settings.VMESS_QUIC_Port;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_QUIC_Port = value;
|
||||
RaisePropertyChanged(nameof(VMESS_QUIC_Port));
|
||||
}
|
||||
}
|
||||
public string VMESS_QUIC_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VMESS_QUIC, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// VLESS SETTINGS
|
||||
/// </summary>
|
||||
public partial class V2rayEditorViewModel
|
||||
{
|
||||
#region VLESS TCP
|
||||
public bool Checked_VLESS_TCP
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VLESS_TCP);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VLESS_TCP);
|
||||
RaisePropertyChanged("Checked_VLESS_TCP");
|
||||
}
|
||||
}
|
||||
public string VLESS_TCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VLESS_TCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS WS
|
||||
public string VLESS_WS_Path
|
||||
{
|
||||
get => Settings.VLESS_WS_Path;
|
||||
set => Settings.VLESS_WS_Path = value;
|
||||
}
|
||||
public bool Checked_VLESS_WS
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VLESS_WS);
|
||||
}
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VLESS_WS);
|
||||
RaisePropertyChanged("Checked_VLESS_WS");
|
||||
}
|
||||
}
|
||||
public string VLESS_WS_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VLESS_WS, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS KCP
|
||||
public string VLESS_KCP_Seed
|
||||
{
|
||||
get => Settings.VLESS_KCP_Seed;
|
||||
set => Settings.VLESS_KCP_Seed = value;
|
||||
}
|
||||
public string VLESS_KCP_Type
|
||||
{
|
||||
get => Settings.VLESS_KCP_Type;
|
||||
set
|
||||
{
|
||||
var namespaceStr = typeof(ComboBoxItem).FullName + ":";
|
||||
var trimValue = value.Replace(namespaceStr, "");
|
||||
trimValue = trimValue.Trim();
|
||||
Settings.VLESS_KCP_Type = trimValue;
|
||||
RaisePropertyChanged("VLESS_KCP_Type");
|
||||
}
|
||||
}
|
||||
public bool Checked_VLESS_KCP
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VLESS_KCP);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VLESS_KCP);
|
||||
RaisePropertyChanged("Checked_VLESS_KCP");
|
||||
}
|
||||
}
|
||||
public string VLESS_KCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VLESS_KCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS QUIC
|
||||
public bool Checked_VLESS_QUIC
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VLESS_QUIC);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VLESS_QUIC);
|
||||
RaisePropertyChanged(nameof(Checked_VLESS_QUIC));
|
||||
}
|
||||
}
|
||||
public string VLESS_QUIC_Key
|
||||
{
|
||||
get => Settings.VLESS_QUIC_Key; set
|
||||
{
|
||||
Settings.VLESS_QUIC_Key = value;
|
||||
RaisePropertyChanged(nameof(VLESS_QUIC_Key));
|
||||
}
|
||||
}
|
||||
public string VLESS_QUIC_Security
|
||||
{
|
||||
get => Settings.VLESS_QUIC_Security;
|
||||
set
|
||||
{
|
||||
Settings.VLESS_QUIC_Security = value;
|
||||
RaisePropertyChanged(nameof(VLESS_QUIC_Security));
|
||||
}
|
||||
}
|
||||
public string VLESS_QUIC_Type
|
||||
{
|
||||
get => Settings.VLESS_QUIC_Type;
|
||||
set
|
||||
{
|
||||
Settings.VLESS_QUIC_Type = value;
|
||||
RaisePropertyChanged(nameof(VLESS_QUIC_Type));
|
||||
}
|
||||
}
|
||||
public int VLESS_QUIC_Port
|
||||
{
|
||||
get => Settings.VLESS_QUIC_Port;
|
||||
set
|
||||
{
|
||||
Settings.VLESS_QUIC_Port = value;
|
||||
RaisePropertyChanged(nameof(VLESS_QUIC_Port));
|
||||
}
|
||||
}
|
||||
public string VLESS_QUIC_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VLESS_QUIC, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS gRPC
|
||||
public string VLESS_gRPC_ServiceName
|
||||
{
|
||||
get => Settings.VLESS_gRPC_ServiceName;
|
||||
set => Settings.VLESS_gRPC_ServiceName = value;
|
||||
}
|
||||
public int VLESS_gRPC_Port
|
||||
{
|
||||
get => Settings.VLESS_gRPC_Port;
|
||||
set => Settings.VLESS_gRPC_Port = value;
|
||||
}
|
||||
public bool Checked_VLESS_gRPC
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VLESS_gRPC);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VLESS_gRPC);
|
||||
RaisePropertyChanged("Checked_VLESS_gRPC");
|
||||
}
|
||||
}
|
||||
public string VLESS_gRPC_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VLESS_gRPC, Settings);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
88
ProxySuper.Core/ViewModels/V2rayInstallViewModel.cs
Normal file
88
ProxySuper.Core/ViewModels/V2rayInstallViewModel.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class V2rayInstallViewModel : MvxViewModel<Record>
|
||||
{
|
||||
Host _host;
|
||||
|
||||
V2raySettings _settings;
|
||||
|
||||
V2rayService _service;
|
||||
|
||||
public override void ViewDestroy(bool viewFinishing = true)
|
||||
{
|
||||
_service.Disconnect();
|
||||
this.SaveInstallLog();
|
||||
base.ViewDestroy(viewFinishing);
|
||||
}
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
this._host = parameter.Host;
|
||||
this._settings = parameter.V2raySettings;
|
||||
}
|
||||
|
||||
public override Task Initialize()
|
||||
{
|
||||
_service = new V2rayService(_host, _settings);
|
||||
_service.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
|
||||
_service.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
|
||||
_service.Connect();
|
||||
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
public ProjectProgress Progress
|
||||
{
|
||||
get => _service.Progress;
|
||||
}
|
||||
|
||||
public string Logs
|
||||
{
|
||||
get => _service.Progress.Logs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Command
|
||||
|
||||
public IMvxCommand InstallCommand => new MvxCommand(_service.Install);
|
||||
|
||||
public IMvxCommand UpdateSettingsCommand => new MvxCommand(_service.UpdateSettings);
|
||||
|
||||
public IMvxCommand UpdateV2rayCoreCommand => new MvxCommand(_service.UpdateV2rayCore);
|
||||
|
||||
public IMvxCommand UninstallCommand => new MvxCommand(_service.Uninstall);
|
||||
|
||||
public IMvxCommand UploadCertCommand => new MvxCommand(_service.UploadCert);
|
||||
|
||||
public IMvxCommand UploadWebCommand => new MvxCommand(_service.UploadWeb);
|
||||
|
||||
public IMvxCommand ApplyForCertCommand => new MvxCommand(_service.ApplyForCert);
|
||||
|
||||
#endregion
|
||||
|
||||
private void SaveInstallLog()
|
||||
{
|
||||
if (!Directory.Exists("Logs"))
|
||||
{
|
||||
Directory.CreateDirectory("Logs");
|
||||
}
|
||||
|
||||
var fileName = Path.Combine("Logs", DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".v2ray.txt");
|
||||
File.WriteAllText(fileName, Logs);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,5 @@
|
|||
using Microsoft.Win32;
|
||||
using MvvmCross.ViewModels;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
using QRCoder;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
|
@ -24,11 +13,21 @@ namespace ProxySuper.Core.ViewModels
|
|||
Settings = parameter;
|
||||
}
|
||||
|
||||
public string Flow
|
||||
{
|
||||
get { return Settings.Flow; }
|
||||
}
|
||||
|
||||
public string UTLS
|
||||
{
|
||||
get { return Settings.UTLS; }
|
||||
}
|
||||
|
||||
public bool Checked_VLESS_TCP_XTLS
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.VLESS_TCP_XTLS);
|
||||
return Settings.Types.Contains(RayType.VLESS_TCP_XTLS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +35,7 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.VLESS_TCP);
|
||||
return Settings.Types.Contains(RayType.VLESS_TCP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +43,7 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.VLESS_WS);
|
||||
return Settings.Types.Contains(RayType.VLESS_WS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +51,23 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.VLESS_KCP);
|
||||
return Settings.Types.Contains(RayType.VLESS_KCP);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VLESS_QUIC
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VLESS_QUIC);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VLESS_gRPC
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VLESS_gRPC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +75,7 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.VMESS_TCP);
|
||||
return Settings.Types.Contains(RayType.VMESS_TCP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +83,7 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.VMESS_WS);
|
||||
return Settings.Types.Contains(RayType.VMESS_WS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +91,15 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.VMESS_KCP);
|
||||
return Settings.Types.Contains(RayType.VMESS_KCP);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Checked_VMESS_QUIC
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(RayType.VMESS_QUIC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +107,7 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.Trojan_TCP);
|
||||
return Settings.Types.Contains(RayType.Trojan_TCP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +115,7 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.ShadowsocksAEAD);
|
||||
return Settings.Types.Contains(RayType.ShadowsocksAEAD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
using MvvmCross;
|
||||
using MvvmCross.Commands;
|
||||
using MvvmCross.Commands;
|
||||
using MvvmCross.Navigation;
|
||||
using MvvmCross.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
|
@ -10,10 +8,7 @@ using ProxySuper.Core.Services;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
|
@ -31,7 +26,9 @@ namespace ProxySuper.Core.ViewModels
|
|||
|
||||
public XraySettings Settings { get; set; }
|
||||
|
||||
public IMvxCommand SaveCommand => new MvxCommand(() => Save());
|
||||
public IMvxCommand SaveCommand => new MvxCommand(Save);
|
||||
|
||||
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
|
||||
|
||||
public IMvxNavigationService NavigationService { get; }
|
||||
|
||||
|
@ -52,12 +49,57 @@ namespace ProxySuper.Core.ViewModels
|
|||
XraySettings = Settings,
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveAndInstall()
|
||||
{
|
||||
var record = new Record()
|
||||
{
|
||||
Id = Id,
|
||||
Host = Host,
|
||||
XraySettings = Settings,
|
||||
};
|
||||
NavigationService.Close(this, record);
|
||||
NavigationService.Navigate<XrayInstallViewModel, Record>(record);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class XrayEditorViewModel
|
||||
{
|
||||
public List<string> UTLSList { get => XraySettings.UTLSList; }
|
||||
|
||||
public List<string> KcpTypes => V2raySettings.DisguiseTypes;
|
||||
|
||||
public List<string> QuicTypes => V2raySettings.DisguiseTypes;
|
||||
|
||||
public List<string> QuicSecurities => new List<string>
|
||||
{
|
||||
"none",
|
||||
"aes-128-gcm",
|
||||
"chacha20-poly1305"
|
||||
};
|
||||
|
||||
public List<string> ShadowSocksMethods => new List<string>
|
||||
{
|
||||
"2022-blake3-aes-128-gcm",
|
||||
"2022-blake3-aes-256-gcm",
|
||||
"2022-blake3-chacha20-poly1305",
|
||||
"aes-256-gcm",
|
||||
"aes-128-gcm",
|
||||
"chacha20-poly1305",
|
||||
"none"
|
||||
};
|
||||
|
||||
public IMvxCommand RandomUuid => new MvxCommand(() => GetUuid());
|
||||
|
||||
public bool WithTLS
|
||||
{
|
||||
get => Settings.WithTLS;
|
||||
set
|
||||
{
|
||||
Settings.WithTLS = value;
|
||||
RaisePropertyChanged("Port");
|
||||
}
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
|
@ -69,6 +111,17 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public string UTLS
|
||||
{
|
||||
get => Settings.UTLS;
|
||||
set
|
||||
{
|
||||
Settings.UTLS = value;
|
||||
RaisePropertyChanged(nameof(UTLS));
|
||||
}
|
||||
}
|
||||
|
||||
public int VLESS_KCP_Port
|
||||
{
|
||||
get => Settings.VLESS_KCP_Port;
|
||||
|
@ -89,17 +142,6 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public int ShadowSocksPort
|
||||
{
|
||||
get => Settings.ShadowSocksPort;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_KCP_Port = value;
|
||||
RaisePropertyChanged("ShadowSocksPort");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string UUID
|
||||
{
|
||||
get => Settings.UUID;
|
||||
|
@ -110,6 +152,19 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public string MultiUUID
|
||||
{
|
||||
get => string.Join(",", Settings.MulitUUID);
|
||||
set
|
||||
{
|
||||
var input = value.Replace(',', ',');
|
||||
var arr = input.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
arr.RemoveAll(x => x == this.UUID);
|
||||
Settings.MulitUUID = arr;
|
||||
RaisePropertyChanged("MultiUUID");
|
||||
}
|
||||
}
|
||||
|
||||
public string Domain
|
||||
{
|
||||
get => Settings.Domain;
|
||||
|
@ -130,45 +185,56 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
#region Trojan
|
||||
public string TrojanPassword
|
||||
{
|
||||
get => Settings.TrojanPassword;
|
||||
set => Settings.TrojanPassword = value;
|
||||
}
|
||||
|
||||
public bool Checked_Trojan_TCP
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.Trojan_TCP);
|
||||
return Settings.Types.Contains(RayType.Trojan_TCP);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
if (!Settings.Types.Contains(XrayType.Trojan_TCP))
|
||||
Settings.Types.Add(XrayType.Trojan_TCP);
|
||||
if (!Settings.Types.Contains(RayType.Trojan_TCP))
|
||||
Settings.Types.Add(RayType.Trojan_TCP);
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Types.Remove(XrayType.Trojan_TCP);
|
||||
Settings.Types.Remove(RayType.Trojan_TCP);
|
||||
}
|
||||
RaisePropertyChanged("Checked_Trojan_TCP");
|
||||
}
|
||||
}
|
||||
public string Trojan_TCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.Trojan_TCP, Settings);
|
||||
get => ShareLink.Build(RayType.Trojan_TCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private List<string> _ssMethods = new List<string> { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305" };
|
||||
public List<string> ShadowSocksMethods => _ssMethods;
|
||||
#region ShadowSocks
|
||||
public int ShadowSocksPort
|
||||
{
|
||||
get => Settings.ShadowSocksPort;
|
||||
set
|
||||
{
|
||||
Settings.ShadowSocksPort = value;
|
||||
RaisePropertyChanged("ShadowSocksPort");
|
||||
}
|
||||
}
|
||||
public bool CheckedShadowSocks
|
||||
{
|
||||
|
||||
get => Settings.Types.Contains(XrayType.ShadowsocksAEAD);
|
||||
get => Settings.Types.Contains(RayType.ShadowsocksAEAD);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.ShadowsocksAEAD);
|
||||
CheckBoxChanged(value, RayType.ShadowsocksAEAD);
|
||||
RaisePropertyChanged("CheckedShadowSocks");
|
||||
}
|
||||
}
|
||||
|
@ -191,11 +257,11 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
public string ShadowSocksShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.ShadowsocksAEAD, Settings);
|
||||
get => ShareLink.Build(RayType.ShadowsocksAEAD, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
private void CheckBoxChanged(bool value, XrayType type)
|
||||
private void CheckBoxChanged(bool value, RayType type)
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
|
@ -210,8 +276,6 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void GetUuid()
|
||||
{
|
||||
UUID = Guid.NewGuid().ToString();
|
||||
|
@ -225,13 +289,13 @@ namespace ProxySuper.Core.ViewModels
|
|||
/// </summary>
|
||||
public partial class XrayEditorViewModel
|
||||
{
|
||||
// vmess tcp
|
||||
#region VMESS TCP
|
||||
public bool Checked_VMESS_TCP
|
||||
{
|
||||
get => Settings.Types.Contains(XrayType.VMESS_TCP);
|
||||
get => Settings.Types.Contains(RayType.VMESS_TCP);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.VMESS_TCP);
|
||||
CheckBoxChanged(value, RayType.VMESS_TCP);
|
||||
RaisePropertyChanged("Checked_VMESS_TCP");
|
||||
}
|
||||
}
|
||||
|
@ -242,16 +306,17 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
public string VMESS_TCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.VMESS_TCP, Settings);
|
||||
get => ShareLink.Build(RayType.VMESS_TCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
// vmess ws
|
||||
#region VMESS WS
|
||||
public bool Checked_VMESS_WS
|
||||
{
|
||||
get => Settings.Types.Contains(XrayType.VMESS_WS);
|
||||
get => Settings.Types.Contains(RayType.VMESS_WS);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.VMESS_WS);
|
||||
CheckBoxChanged(value, RayType.VMESS_WS);
|
||||
RaisePropertyChanged("Checked_VMESS_WS");
|
||||
}
|
||||
}
|
||||
|
@ -262,10 +327,11 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
public string VMESS_WS_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.VMESS_WS, Settings);
|
||||
get => ShareLink.Build(RayType.VMESS_WS, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
// vmess kcp
|
||||
#region VMESS KCP
|
||||
public string VMESS_KCP_Seed
|
||||
{
|
||||
get => Settings.VMESS_KCP_Seed;
|
||||
|
@ -285,21 +351,71 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
public bool Checked_VMESS_KCP
|
||||
{
|
||||
get => Settings.Types.Contains(XrayType.VMESS_KCP);
|
||||
get => Settings.Types.Contains(RayType.VMESS_KCP);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.VMESS_KCP);
|
||||
CheckBoxChanged(value, RayType.VMESS_KCP);
|
||||
RaisePropertyChanged("Checked_VMESS_KCP");
|
||||
}
|
||||
}
|
||||
public string VMESS_KCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.VMESS_KCP, Settings);
|
||||
get => ShareLink.Build(RayType.VMESS_KCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VMESS QUIC
|
||||
public bool Checked_VMESS_QUIC
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VMESS_QUIC);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VMESS_QUIC);
|
||||
RaisePropertyChanged(nameof(Checked_VMESS_QUIC));
|
||||
}
|
||||
}
|
||||
public string VMESS_QUIC_Key
|
||||
{
|
||||
get => Settings.VMESS_QUIC_Key;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_QUIC_Key = value;
|
||||
RaisePropertyChanged(nameof(VMESS_QUIC_Key));
|
||||
}
|
||||
}
|
||||
public string VMESS_QUIC_Security
|
||||
{
|
||||
get => Settings.VMESS_QUIC_Security;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_QUIC_Security = value;
|
||||
RaisePropertyChanged(nameof(VMESS_QUIC_Security));
|
||||
}
|
||||
}
|
||||
public string VMESS_QUIC_Type
|
||||
{
|
||||
get => Settings.VMESS_QUIC_Type;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_QUIC_Type = value;
|
||||
RaisePropertyChanged(nameof(VMESS_QUIC_Type));
|
||||
}
|
||||
}
|
||||
public int VMESS_QUIC_Port
|
||||
{
|
||||
get => Settings.VMESS_QUIC_Port;
|
||||
set
|
||||
{
|
||||
Settings.VMESS_QUIC_Port = value;
|
||||
RaisePropertyChanged(nameof(VMESS_QUIC_Port));
|
||||
}
|
||||
}
|
||||
public string VMESS_QUIC_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VMESS_QUIC, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private List<string> _kcpTypes = new List<string> { "none", "srtp", "utp", "wechat-video", "dtls", "wireguard", };
|
||||
public List<string> KcpTypes => _kcpTypes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -307,39 +423,51 @@ namespace ProxySuper.Core.ViewModels
|
|||
/// </summary>
|
||||
public partial class XrayEditorViewModel
|
||||
{
|
||||
#region VLESS XTLS
|
||||
|
||||
// vless xtls
|
||||
public bool Checked_VLESS_TCP_XTLS
|
||||
public List<string> FlowList { get => XraySettings.FlowList; }
|
||||
|
||||
public string Flow
|
||||
{
|
||||
get => Settings.Types.Contains(XrayType.VLESS_TCP_XTLS);
|
||||
get => Settings.Flow;
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.VLESS_TCP_XTLS);
|
||||
Settings.Flow = value;
|
||||
RaisePropertyChanged(nameof(Flow));
|
||||
}
|
||||
}
|
||||
public bool Checked_VLESS_TCP_XTLS
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VLESS_TCP_XTLS);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VLESS_TCP_XTLS);
|
||||
RaisePropertyChanged("Checked_VLESS_TCP_XTLS");
|
||||
}
|
||||
}
|
||||
public string VLESS_TCP_XTLS_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.VLESS_TCP_XTLS, Settings);
|
||||
get => ShareLink.Build(RayType.VLESS_TCP_XTLS, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
// vless tcp
|
||||
#region VLESS TCP
|
||||
public bool Checked_VLESS_TCP
|
||||
{
|
||||
get => Settings.Types.Contains(XrayType.VLESS_TCP);
|
||||
get => Settings.Types.Contains(RayType.VLESS_TCP);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.VLESS_TCP);
|
||||
CheckBoxChanged(value, RayType.VLESS_TCP);
|
||||
RaisePropertyChanged("Checked_VLESS_TCP");
|
||||
}
|
||||
}
|
||||
public string VLESS_TCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.VLESS_TCP, Settings);
|
||||
get => ShareLink.Build(RayType.VLESS_TCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
// vless ws
|
||||
#region VLESS WS
|
||||
public string VLESS_WS_Path
|
||||
{
|
||||
get => Settings.VLESS_WS_Path;
|
||||
|
@ -349,24 +477,80 @@ namespace ProxySuper.Core.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
return Settings.Types.Contains(XrayType.VLESS_WS);
|
||||
return Settings.Types.Contains(RayType.VLESS_WS);
|
||||
}
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.VLESS_WS);
|
||||
CheckBoxChanged(value, RayType.VLESS_WS);
|
||||
RaisePropertyChanged("Checked_VLESS_WS");
|
||||
}
|
||||
}
|
||||
public string VLESS_WS_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.VLESS_WS, Settings);
|
||||
get => ShareLink.Build(RayType.VLESS_WS, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
// vless kcp
|
||||
#region VLESS QUIC
|
||||
public string VLESS_QUIC_Key
|
||||
{
|
||||
get => Settings.VLESS_QUIC_Key; set
|
||||
{
|
||||
Settings.VLESS_QUIC_Key = value;
|
||||
RaisePropertyChanged(nameof(VLESS_QUIC_Key));
|
||||
}
|
||||
}
|
||||
public bool Checked_VLESS_QUIC
|
||||
{
|
||||
get => Settings.Types.Contains(RayType.VLESS_QUIC);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, RayType.VLESS_QUIC);
|
||||
RaisePropertyChanged(nameof(Checked_VLESS_QUIC));
|
||||
}
|
||||
}
|
||||
public string VLESS_QUIC_Security
|
||||
{
|
||||
get => Settings.VLESS_QUIC_Security;
|
||||
set
|
||||
{
|
||||
Settings.VLESS_QUIC_Security = value;
|
||||
RaisePropertyChanged(nameof(VLESS_QUIC_Security));
|
||||
}
|
||||
}
|
||||
public string VLESS_QUIC_Type
|
||||
{
|
||||
get => Settings.VLESS_QUIC_Type;
|
||||
set
|
||||
{
|
||||
Settings.VLESS_QUIC_Type = value;
|
||||
RaisePropertyChanged(nameof(VLESS_QUIC_Type));
|
||||
}
|
||||
}
|
||||
public int VLESS_QUIC_Port
|
||||
{
|
||||
get => Settings.VLESS_QUIC_Port;
|
||||
set
|
||||
{
|
||||
Settings.VLESS_QUIC_Port = value;
|
||||
RaisePropertyChanged(nameof(VLESS_QUIC_Port));
|
||||
}
|
||||
}
|
||||
public string VLESS_QUIC_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(RayType.VLESS_QUIC, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VLESS KCP
|
||||
public string VLESS_KCP_Seed
|
||||
{
|
||||
get => Settings.VLESS_KCP_Seed;
|
||||
set => Settings.VLESS_KCP_Seed = value;
|
||||
set
|
||||
{
|
||||
Settings.VLESS_KCP_Seed = value;
|
||||
RaisePropertyChanged(nameof(VLESS_KCP_Seed));
|
||||
}
|
||||
}
|
||||
public string VLESS_KCP_Type
|
||||
{
|
||||
|
@ -382,19 +566,20 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
public bool Checked_VLESS_KCP
|
||||
{
|
||||
get => Settings.Types.Contains(XrayType.VLESS_KCP);
|
||||
get => Settings.Types.Contains(RayType.VLESS_KCP);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.VLESS_KCP);
|
||||
CheckBoxChanged(value, RayType.VLESS_KCP);
|
||||
RaisePropertyChanged("Checked_VLESS_KCP");
|
||||
}
|
||||
}
|
||||
public string VLESS_KCP_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.VLESS_KCP, Settings);
|
||||
get => ShareLink.Build(RayType.VLESS_KCP, Settings);
|
||||
}
|
||||
#endregion
|
||||
|
||||
// vless grpc
|
||||
#region VLESS gRPC
|
||||
public string VLESS_gRPC_ServiceName
|
||||
{
|
||||
get => Settings.VLESS_gRPC_ServiceName;
|
||||
|
@ -407,17 +592,18 @@ namespace ProxySuper.Core.ViewModels
|
|||
}
|
||||
public bool Checked_VLESS_gRPC
|
||||
{
|
||||
get => Settings.Types.Contains(XrayType.VLESS_gRPC);
|
||||
get => Settings.Types.Contains(RayType.VLESS_gRPC);
|
||||
set
|
||||
{
|
||||
CheckBoxChanged(value, XrayType.VLESS_gRPC);
|
||||
CheckBoxChanged(value, RayType.VLESS_gRPC);
|
||||
RaisePropertyChanged("Checked_VLESS_gRPC");
|
||||
}
|
||||
}
|
||||
public string VLESS_gRPC_ShareLink
|
||||
{
|
||||
get => ShareLink.Build(XrayType.VLESS_gRPC, Settings);
|
||||
get => ShareLink.Build(RayType.VLESS_gRPC, Settings);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
|
88
ProxySuper.Core/ViewModels/XrayInstallViewModel.cs
Normal file
88
ProxySuper.Core/ViewModels/XrayInstallViewModel.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using MvvmCross.Commands;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class XrayInstallViewModel : MvxViewModel<Record>
|
||||
{
|
||||
Host _host;
|
||||
|
||||
XraySettings _settings;
|
||||
|
||||
XrayService _xrayService;
|
||||
|
||||
public override void ViewDestroy(bool viewFinishing = true)
|
||||
{
|
||||
_xrayService.Disconnect();
|
||||
this.SaveInstallLog();
|
||||
base.ViewDestroy(viewFinishing);
|
||||
}
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
this._host = parameter.Host;
|
||||
this._settings = parameter.XraySettings;
|
||||
}
|
||||
|
||||
public override Task Initialize()
|
||||
{
|
||||
_xrayService = new XrayService(_host, _settings);
|
||||
_xrayService.Progress.StepUpdate = () => RaisePropertyChanged("Progress");
|
||||
_xrayService.Progress.LogsUpdate = () => RaisePropertyChanged("Logs");
|
||||
_xrayService.Connect();
|
||||
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
public ProjectProgress Progress
|
||||
{
|
||||
get => _xrayService.Progress;
|
||||
}
|
||||
|
||||
public string Logs
|
||||
{
|
||||
get => _xrayService.Progress.Logs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Command
|
||||
|
||||
public IMvxCommand InstallCommand => new MvxCommand(_xrayService.Install);
|
||||
|
||||
public IMvxCommand UpdateSettingsCommand => new MvxCommand(_xrayService.UpdateSettings);
|
||||
|
||||
public IMvxCommand UpdateXrayCoreCommand => new MvxCommand(_xrayService.UpdateXrayCore);
|
||||
|
||||
public IMvxCommand UninstallCommand => new MvxCommand(_xrayService.Uninstall);
|
||||
|
||||
public IMvxCommand UploadCertCommand => new MvxCommand(_xrayService.UploadCert);
|
||||
|
||||
public IMvxCommand UploadWebCommand => new MvxCommand(_xrayService.UploadWeb);
|
||||
|
||||
public IMvxCommand ApplyForCertCommand => new MvxCommand(_xrayService.ApplyForCert);
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using ProxySuper.Core.Models.Hosts;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Renci.SshNet;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ProxySuper.Core.ViewModels
|
||||
{
|
||||
public class XrayInstallerViewModel : MvxViewModel<Record>
|
||||
{
|
||||
|
||||
public Host Host { get; set; }
|
||||
|
||||
public XraySettings Settings { get; set; }
|
||||
|
||||
public override void Prepare(Record parameter)
|
||||
{
|
||||
var record = Utils.DeepClone(parameter);
|
||||
Host = record.Host;
|
||||
Settings = record.XraySettings;
|
||||
}
|
||||
|
||||
|
||||
private bool _connected;
|
||||
public bool Connected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _connected;
|
||||
}
|
||||
set
|
||||
{
|
||||
_connected = value;
|
||||
RaisePropertyChanged("Connected");
|
||||
}
|
||||
}
|
||||
|
||||
public string CommandText { get; set; }
|
||||
|
||||
public string OutputText { get; set; }
|
||||
}
|
||||
}
|
15
ProxySuper.Core/app.config
Normal file
15
ProxySuper.Core/app.config
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -1,7 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MvvmCross" version="7.1.2" targetFramework="net461" />
|
||||
<package id="QRCoder" version="1.4.1" targetFramework="net461" />
|
||||
<package id="SSH.NET" version="2020.0.1" targetFramework="net461" />
|
||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="7.0.0" targetFramework="net472" />
|
||||
<package id="MvvmCross" version="8.0.2" targetFramework="net472" />
|
||||
<package id="QRCoder" version="1.4.3" targetFramework="net472" />
|
||||
<package id="SSH.NET" version="2023.0.0" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Console" version="4.3.1" targetFramework="net461" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||
</packages>
|
|
@ -1,6 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!--Languages-->
|
||||
<!--Language-->
|
||||
<ResourceDictionary Source="/Resources/Languages/zh_cn.xaml" />
|
||||
|
||||
<!--styles-->
|
||||
<!--style-->
|
||||
<ResourceDictionary>
|
||||
<Style TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Padding" Value="5,2" />
|
||||
|
@ -24,7 +24,7 @@
|
|||
</Style>
|
||||
</ResourceDictionary>
|
||||
|
||||
<!--components styles-->
|
||||
<!--component style-->
|
||||
<ResourceDictionary Source="/Resources/Styles/DataGridStyle.xaml" />
|
||||
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
using MvvmCross.Platforms.Wpf.Views;
|
||||
using MvvmCross.Core;
|
||||
using MvvmCross.Platforms.Wpf.Core;
|
||||
using MvvmCross.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using MvvmCross.Platforms.Wpf.Views;
|
||||
|
||||
namespace ProxySuper.WPF
|
||||
{
|
||||
|
@ -18,7 +11,7 @@ namespace ProxySuper.WPF
|
|||
{
|
||||
protected override void RegisterSetup()
|
||||
{
|
||||
this.RegisterSetupType<MvxWpfSetup<Core.App>>();
|
||||
this.RegisterSetupType<Setup>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:local="clr-namespace:ProxySuper.WPF.Controls"
|
||||
xmlns:convert="clr-namespace:ProxySuper.Core.Converters;assembly=ProxySuper.Core"
|
||||
xmlns:host="clr-namespace:ProxySuper.Core.Models.Hosts;assembly=ProxySuper.Core"
|
||||
xmlns:ssh="clr-namespace:Renci.SshNet;assembly=Renci.SshNet"
|
||||
mc:Ignorable="d">
|
||||
|
||||
|
||||
|
@ -16,8 +17,8 @@
|
|||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="330" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<GroupBox Padding="10" Header="{DynamicResource HostGroupName}" Grid.Row="0">
|
||||
|
@ -35,6 +36,7 @@
|
|||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@ -104,7 +106,18 @@
|
|||
Converter={StaticResource SecretTypeConverter},
|
||||
ConverterParameter={x:Static host:LoginSecretType.PrivateKey}
|
||||
}"
|
||||
Content="{DynamicResource HostUploadSecretKey}" />
|
||||
Content="{DynamicResource HostUploadSecretKey}" />
|
||||
|
||||
<Label Content="{DynamicResource HostSertTypePrivateKeyPassPhrase}" Grid.Row="7" Grid.Column="0" />
|
||||
<TextBox Grid.Row="7" Grid.Column="1"
|
||||
Width="170"
|
||||
Text="{Binding Host.PrivateKeyPassPhrase}"
|
||||
IsEnabled="{
|
||||
Binding Host.SecretType,
|
||||
Converter={StaticResource SecretTypeConverter},
|
||||
ConverterParameter={x:Static host:LoginSecretType.PrivateKey}
|
||||
}"
|
||||
VerticalContentAlignment="Center" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
|
@ -129,21 +142,21 @@
|
|||
IsChecked="{
|
||||
Binding Host.Proxy.Type,
|
||||
Converter={StaticResource ProxyTypeConverter},
|
||||
ConverterParameter={x:Static host:LocalProxyType.None}
|
||||
ConverterParameter={x:Static ssh:ProxyTypes.None}
|
||||
}"/>
|
||||
<RadioButton Content="{DynamicResource ProxyTypeHttp}"
|
||||
Margin="5,0"
|
||||
IsChecked="{
|
||||
Binding Host.Proxy.Type,
|
||||
Converter={StaticResource ProxyTypeConverter},
|
||||
ConverterParameter={x:Static host:LocalProxyType.Http}
|
||||
ConverterParameter={x:Static ssh:ProxyTypes.Http}
|
||||
}"/>
|
||||
<RadioButton Content="{DynamicResource ProxyTypeSocks5}"
|
||||
Margin="5,0"
|
||||
IsChecked="{
|
||||
Binding Host.Proxy.Type,
|
||||
Converter={StaticResource ProxyTypeConverter},
|
||||
ConverterParameter={x:Static host:LocalProxyType.Socks5}
|
||||
ConverterParameter={x:Static ssh:ProxyTypes.Socks5}
|
||||
}"/>
|
||||
</StackPanel>
|
||||
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
|
|
53
ProxySuper.WPF/Controls/ProgressControl.xaml
Normal file
53
ProxySuper.WPF/Controls/ProgressControl.xaml
Normal file
|
@ -0,0 +1,53 @@
|
|||
<UserControl x:Class="ProxySuper.WPF.Controls.ProgressControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:ProxySuper.WPF.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid VerticalAlignment="Top" Background="WhiteSmoke" Margin="0,0,0,20" >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="200" />
|
||||
<RowDefinition Height="100" />
|
||||
<RowDefinition Height="1" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBox x:Name="LogsTextBox"
|
||||
Grid.Row="0"
|
||||
Height="200"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Text="{Binding Path=Logs,Mode=OneWay}"
|
||||
VerticalContentAlignment="Top"
|
||||
Padding="10,0"
|
||||
FontSize="13"
|
||||
IsReadOnly="True"
|
||||
FontFamily="微软雅黑"
|
||||
Foreground="GreenYellow"
|
||||
Background="Black" />
|
||||
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Grid.Row="1" Margin="10,10,0,0">
|
||||
<Label Content="{Binding Path=Progress.Step,Mode=OneWay}"
|
||||
FontSize="18"
|
||||
FontWeight="Bold" />
|
||||
|
||||
<Label Content="{Binding Path=Progress.Desc,Mode=OneWay}"
|
||||
Grid.Row="2"
|
||||
VerticalAlignment="Bottom"
|
||||
FontSize="12" />
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ProgressBar Maximum="100"
|
||||
Height="10"
|
||||
Width="200"
|
||||
Value="{Binding Path=Progress.Percentage,Mode=OneWay}" />
|
||||
|
||||
<Label Content="{Binding Path=Progress.Percentage}" />
|
||||
<Label Content="%" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<Border Grid.Row="3" Height="1" Background="Black" />
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -1,5 +1,5 @@
|
|||
using MvvmCross.Platforms.Wpf.Views;
|
||||
using ProxySuper.Core.ViewModels;
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -12,26 +12,26 @@ using System.Windows.Documents;
|
|||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ProxySuper.WPF.Views
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// TrojanGoConfigView.xaml 的交互逻辑
|
||||
/// ProgressControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TrojanGoConfigView : MvxWindow
|
||||
public partial class ProgressControl : UserControl
|
||||
{
|
||||
public TrojanGoConfigView()
|
||||
public ProgressControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
LogsTextBox.TextChanged += LogsTextBox_TextChanged;
|
||||
}
|
||||
|
||||
public new TrojanGoConfigViewModel ViewModel
|
||||
private void LogsTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
get
|
||||
{
|
||||
return (TrojanGoConfigViewModel)base.ViewModel;
|
||||
}
|
||||
LogsTextBox.ScrollToEnd();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
|
|
470
ProxySuper.WPF/Controls/V2raySettingsControl.xaml
Normal file
470
ProxySuper.WPF/Controls/V2raySettingsControl.xaml
Normal file
|
@ -0,0 +1,470 @@
|
|||
<UserControl x:Class="ProxySuper.WPF.Controls.V2raySettingsControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:ProxySuper.WPF.Controls"
|
||||
xmlns:convert="clr-namespace:ProxySuper.Core.Converters;assembly=ProxySuper.Core"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<convert:VisibleConverter x:Key="VisibleConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<StackPanel Orientation="Vertical" Margin="10,0,20,20">
|
||||
<!--节点类型-->
|
||||
<GroupBox Padding="10" Header="{DynamicResource EditorProxyType}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<!--#region VLESS -->
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<!--TCP-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Path=Checked_VLESS_TCP}">
|
||||
<Label Content="{DynamicResource VlessTcpDesc}" FontSize="13" Foreground="LimeGreen" />
|
||||
</CheckBox>
|
||||
|
||||
<!--WebSocket-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Path=Checked_VLESS_WS}">
|
||||
<Label Content="{DynamicResource VlessWsDesc}" FontSize="13" Foreground="LimeGreen" />
|
||||
</CheckBox>
|
||||
|
||||
<!--mKCP-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
Foreground="LimeGreen"
|
||||
IsChecked="{Binding Path=Checked_VLESS_KCP}">
|
||||
<Label Content="{DynamicResource VlessKcpDesc}" FontSize="13" Foreground="LimeGreen" />
|
||||
</CheckBox>
|
||||
|
||||
<!--quic-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
Foreground="LimeGreen"
|
||||
IsChecked="{Binding Path=Checked_VLESS_QUIC}">
|
||||
<Label Content="{DynamicResource VlessQuicDesc}" FontSize="12" Foreground="LimeGreen" />
|
||||
</CheckBox>
|
||||
|
||||
<!--gRPC-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
Foreground="LimeGreen"
|
||||
IsChecked="{Binding Path=Checked_VLESS_gRPC}">
|
||||
<Label Content="{DynamicResource VlessRpcDesc}" FontSize="13" Foreground="LimeGreen" />
|
||||
</CheckBox>
|
||||
</WrapPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region VMESS -->
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<!--WebSocket-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Path=Checked_VMESS_WS}">
|
||||
<Label Content="{DynamicResource VmessWsDesc}" FontSize="13" Foreground="Blue" />
|
||||
</CheckBox>
|
||||
|
||||
<!--mKCP-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Path=Checked_VMESS_KCP}">
|
||||
<Label Foreground="Blue" FontSize="13" Content="{DynamicResource VmessKcpDesc}" />
|
||||
</CheckBox>
|
||||
|
||||
<!--quic-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
Foreground="Blue"
|
||||
IsChecked="{Binding Path=Checked_VMESS_QUIC}">
|
||||
<Label Content="{DynamicResource VmessQuicDesc}" FontSize="12" Foreground="Blue" />
|
||||
</CheckBox>
|
||||
</WrapPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region SS And Trojan -->
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<!--ss-->
|
||||
<CheckBox Width="150"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Path=CheckedShadowSocks}">
|
||||
<Label Content="{DynamicResource SSDesc}" FontSize="13" Foreground="Fuchsia" />
|
||||
</CheckBox>
|
||||
|
||||
<!--Trojan-->
|
||||
<CheckBox Width="150"
|
||||
Foreground="CadetBlue"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Path=Checked_Trojan_TCP}">
|
||||
<Label Content="{DynamicResource TrojanDesc}" FontSize="13" Foreground="CadetBlue" />
|
||||
</CheckBox>
|
||||
</WrapPanel>
|
||||
<!--#endregion-->
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<!--************************** 参数 **************************-->
|
||||
|
||||
<!--参数设置-->
|
||||
<GroupBox Padding="10" Margin="0,10,0,0" Header="{DynamicResource EditorProxyParams}">
|
||||
<StackPanel>
|
||||
<!--#region Common Settings -->
|
||||
<!--Domain-->
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Content="{DynamicResource XrayDomain}" Width="120" />
|
||||
<TextBox Text="{Binding Path=Domain}" Width="200" />
|
||||
</StackPanel>
|
||||
|
||||
<!--UUID-->
|
||||
<StackPanel Margin="0,15,0,0" Orientation="Horizontal">
|
||||
<Label Content="{DynamicResource XrayUUID}" Width="120" />
|
||||
<TextBox Text="{Binding Path=UUID}" Width="200" />
|
||||
<Button Margin="5,0,0,0"
|
||||
Padding="12,3"
|
||||
Command="{Binding Path=RandomUuid}"
|
||||
Content="{DynamicResource Random}" />
|
||||
</StackPanel>
|
||||
|
||||
<!--v2ray prot-->
|
||||
<StackPanel Margin="0,15,0,0" Orientation="Horizontal">
|
||||
<Label Content="{DynamicResource V2rayPort}" Width="120" />
|
||||
<TextBox Text="{Binding Path=Port}" Width="120" />
|
||||
<Label Content="{DynamicResource XrayPortDefault}" Foreground="Red" />
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--more params-->
|
||||
<Expander ExpandDirection="Down" Margin="0,10,0,0">
|
||||
<Expander.Header>
|
||||
<TextBlock Text="{DynamicResource MoreParameters}" FontWeight="Bold" />
|
||||
</Expander.Header>
|
||||
|
||||
<Expander.Content>
|
||||
<StackPanel>
|
||||
<!--#region Cert Settings -->
|
||||
<!--证书-->
|
||||
<StackPanel Margin="0,15,0,0" Orientation="Horizontal">
|
||||
<Label Content="{DynamicResource XrayWithTLS}" Width="120" />
|
||||
<CheckBox IsChecked="{Binding Path=WithTLS}"
|
||||
Content="{DynamicResource XrayWithTLSDesc}"
|
||||
VerticalContentAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--Mask Domain-->
|
||||
<StackPanel Margin="0,15,0,0" Orientation="Horizontal">
|
||||
<Label Content="{DynamicResource XrayMarkDomain}" Width="120" />
|
||||
<TextBox Text="{Binding Path=MaskDomain}" Width="200" />
|
||||
</StackPanel>
|
||||
|
||||
<!--#region VLESS WebSocket Settings -->
|
||||
<!--WebSocket Path-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_WS,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VlessWsPath}" Foreground="LimeGreen" Width="120" />
|
||||
<TextBox Text="{Binding Path=VLESS_WS_Path}" Width="200" />
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region VLESS KCP Settings -->
|
||||
<!--seed-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_KCP,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VlessKcpSeed}" Foreground="LimeGreen" Width="120" />
|
||||
<TextBox Text="{Binding Path=VLESS_KCP_Seed}" Width="200" />
|
||||
</StackPanel>
|
||||
|
||||
<!--kcp type-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_KCP,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}"
|
||||
Orientation="Horizontal">
|
||||
<Label Content="{DynamicResource VlessKcpType}" Foreground="LimeGreen" Width="120" />
|
||||
<ComboBox Width="200"
|
||||
ItemsSource="{Binding Path=KcpTypes}"
|
||||
SelectedValue="{Binding VLESS_KCP_Type,Mode=TwoWay}">
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<!--kcp port-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_KCP,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}"
|
||||
Orientation="Horizontal">
|
||||
<Label Content="{DynamicResource VlessKcpPort}" Width="120" Foreground="LimeGreen" />
|
||||
<TextBox Text="{Binding Path=VLESS_KCP_Port}" Width="200" />
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region VLESS Quic Settings -->
|
||||
<!--quic port-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_QUIC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VlessQuicPort}" Foreground="LimeGreen" Width="120" />
|
||||
<TextBox Text="{Binding Path=VLESS_QUIC_Port}" Width="260" />
|
||||
</StackPanel>
|
||||
|
||||
<!--quic key-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_QUIC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VlessQuicKey}" Foreground="LimeGreen" Width="120" />
|
||||
<TextBox Text="{Binding Path=VLESS_QUIC_Key}" Width="260" />
|
||||
</StackPanel>
|
||||
|
||||
<!--quic security-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_QUIC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VlessQuicSecurity}" Foreground="LimeGreen" Width="120" />
|
||||
<ComboBox Width="260"
|
||||
ItemsSource="{Binding QuicSecurities}"
|
||||
SelectedValue="{Binding VLESS_QUIC_Security}">
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<!--quic type-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_QUIC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VlessQuicType}" Foreground="LimeGreen" Width="120" VerticalAlignment="Bottom"/>
|
||||
<ComboBox Width="260"
|
||||
VerticalAlignment="Bottom"
|
||||
ItemsSource="{Binding Path=QuicTypes}"
|
||||
SelectedValue="{Binding VLESS_QUIC_Type,Mode=TwoWay}">
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region VLESS gRPC Settings -->
|
||||
<!--gRPC Port-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_gRPC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VlessRPCPort}" Width="120" Foreground="LimeGreen" />
|
||||
<TextBox Text="{Binding Path=VLESS_gRPC_Port}" Width="200" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VLESS_gRPC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VlessRPCName}" Width="120" Foreground="LimeGreen" />
|
||||
<TextBox Text="{Binding Path=VLESS_gRPC_ServiceName}" Width="200" />
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region VMESS WebSocket Settings -->
|
||||
<!--WebSocket Path-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VMESS_WS,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VmessWsPath}" Foreground="Blue" Width="120" />
|
||||
<TextBox Text="{Binding Path=VMESS_WS_Path}"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="200" />
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region VMESS KCP Settings -->
|
||||
<!--seed-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VMESS_KCP,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VmessKcpSeed}" Foreground="Blue" Width="120" />
|
||||
<TextBox Text="{Binding Path=VMESS_KCP_Seed}" Width="200" />
|
||||
</StackPanel>
|
||||
|
||||
<!--kcp type-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VMESS_KCP,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VmessKcpType}" Foreground="Blue" Width="120" VerticalAlignment="Bottom"/>
|
||||
<ComboBox Width="200"
|
||||
VerticalAlignment="Bottom"
|
||||
ItemsSource="{Binding Path=KcpTypes}"
|
||||
SelectedValue="{Binding VMESS_KCP_Type,Mode=TwoWay}">
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<!--kcp port-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VMESS_KCP,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VmessKcpPort}" Foreground="Blue" Width="120" />
|
||||
<TextBox Text="{Binding Path=VMESS_KCP_Port}" Width="200" />
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region VMESS Quic Settings -->
|
||||
<!--quic port-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VMESS_QUIC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VmessQuicPort}" Foreground="Blue" Width="120" />
|
||||
<TextBox Text="{Binding Path=VMESS_QUIC_Port}" Width="260" />
|
||||
</StackPanel>
|
||||
|
||||
<!--quic key-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VMESS_QUIC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VmessQuicKey}" Foreground="Blue" Width="120" />
|
||||
<TextBox Text="{Binding Path=VMESS_QUIC_Key}" Width="260" />
|
||||
</StackPanel>
|
||||
|
||||
<!--quic security-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VMESS_QUIC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VmessQuicSecurity}" Foreground="Blue" Width="120" />
|
||||
<ComboBox Width="260"
|
||||
ItemsSource="{Binding QuicSecurities}"
|
||||
SelectedValue="{Binding VMESS_QUIC_Security}">
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<!--quic type-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_VMESS_QUIC,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource VmessQuicType}" Foreground="Blue" Width="120" VerticalAlignment="Bottom"/>
|
||||
<ComboBox Width="260"
|
||||
VerticalAlignment="Bottom"
|
||||
ItemsSource="{Binding Path=QuicTypes}"
|
||||
SelectedValue="{Binding VMESS_QUIC_Type,Mode=TwoWay}">
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region ShadowSocks Settings -->
|
||||
<!--ss密码-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=CheckedShadowSocks,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource SSPassword}" Foreground="Fuchsia" Width="120" />
|
||||
<TextBox Text="{Binding Path=ShadowSocksPassword}" Width="200"/>
|
||||
</StackPanel>
|
||||
|
||||
<!--ss加密方式-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=CheckedShadowSocks,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource SSMethods}" Foreground="Fuchsia" Width="120" />
|
||||
<ComboBox Width="200"
|
||||
ItemsSource="{Binding ShadowSocksMethods}"
|
||||
SelectedValue="{Binding ShadowSocksMethod}">
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<!--ss端口-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=CheckedShadowSocks,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource SSPort}" Foreground="Fuchsia" Width="120" />
|
||||
<TextBox Text="{Binding Path=ShadowSocksPort}" Width="200"/>
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Trojan Settings -->
|
||||
<!--Trojan密码-->
|
||||
<StackPanel Margin="0,15,0,0"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{
|
||||
Binding Path=Checked_Trojan_TCP,
|
||||
Converter={StaticResource VisibleConverter}
|
||||
}">
|
||||
<Label Content="{DynamicResource TrojanPassword}" Foreground="CadetBlue" Width="120" />
|
||||
<TextBox Text="{Binding Path=TrojanPassword}" Width="200" />
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Multiple Users Settings -->
|
||||
<!--多用户-->
|
||||
<StackPanel Margin="0,15,0,0" Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Content="{DynamicResource MultiUser}" Width="120" />
|
||||
|
||||
<TextBox Text="{Binding Path=MultiUUID}"
|
||||
Height="60"
|
||||
TextWrapping="Wrap"
|
||||
Width="200" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="120,3,0,0" Text="{DynamicResource MultiUserHelp}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<!--#endregion-->
|
||||
</StackPanel>
|
||||
</Expander.Content>
|
||||
</Expander>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
|
||||
</UserControl>
|
28
ProxySuper.WPF/Controls/V2raySettingsControl.xaml.cs
Normal file
28
ProxySuper.WPF/Controls/V2raySettingsControl.xaml.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// V2raySettingsControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class V2raySettingsControl : UserControl
|
||||
{
|
||||
public V2raySettingsControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@
|
|||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="伪装域名(host)" Width="140" />
|
||||
<Label Content="域名(host)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
|
|
61
ProxySuper.WPF/Controls/VLESS_QUIC_Control.xaml
Normal file
61
ProxySuper.WPF/Controls/VLESS_QUIC_Control.xaml
Normal file
|
@ -0,0 +1,61 @@
|
|||
<UserControl x:Class="ProxySuper.WPF.Controls.VLESS_QUIC_Control"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:ProxySuper.WPF.Controls"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Content="地址(address)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="端口(port)" Width="140" />
|
||||
<TextBox Text="{Binding Path=Settings.VLESS_QUIC_Port,Mode=OneTime}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="用户ID(id)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.UUID}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="加密(security)" Width="140" />
|
||||
<TextBox Text="none" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="传输协议(network)" Width="140" />
|
||||
<TextBox Text="quic" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="伪装类型(type)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.VLESS_QUIC_Type}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="伪装域名(host)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.VLESS_QUIC_Security}" IsReadOnly="True" Width="300" />
|
||||
<Label Content="QUIC加密方式" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="路径(path)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.VLESS_QUIC_Key}" IsReadOnly="True" Width="300" />
|
||||
<Label Content="QUIC密钥" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="传输安全(tls)" Width="140" />
|
||||
<TextBox Text="" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="分享链接(ShareLink)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.VLESS_QUIC_ShareLink,Mode=OneTime}" Width="300" IsReadOnly="True" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
|
@ -1,5 +1,4 @@
|
|||
using MvvmCross.Platforms.Wpf.Views;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -11,16 +10,17 @@ using System.Windows.Documents;
|
|||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ProxySuper.WPF.Views
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// NaiveProxyEditorView.xaml 的交互逻辑
|
||||
/// VLESS_QUIC_Control.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class NaiveProxyEditorView : MvxWindow
|
||||
public partial class VLESS_QUIC_Control : UserControl
|
||||
{
|
||||
public NaiveProxyEditorView()
|
||||
public VLESS_QUIC_Control()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
|
@ -42,7 +42,7 @@
|
|||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="伪装域名(host)" Width="140" />
|
||||
<Label Content="域名(host)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="伪装域名(host)" Width="140" />
|
||||
<Label Content="域名(host)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
|
|
|
@ -23,7 +23,12 @@
|
|||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="流控(flow)" Width="140" />
|
||||
<TextBox Text="xtls-rprx-direct" IsReadOnly="True" Width="300" />
|
||||
<TextBox Text="{Binding Settings.Flow}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="uTLS" Width="140" />
|
||||
<TextBox Text="{Binding Settings.UTLS}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
|
@ -42,7 +47,7 @@
|
|||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="伪装域名(host)" Width="140" />
|
||||
<Label Content="域名(host)" Width="140" />
|
||||
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
|
@ -53,7 +58,7 @@
|
|||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="传输安全(tls)" Width="140" />
|
||||
<TextBox Text="xtls" IsReadOnly="True" Width="300" />
|
||||
<TextBox Text="tls" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Label Content="伪装域名(host)" Width="140" />
|
||||
<Label Content="域名(host)" Width="140" />
|
||||
<TextBox Text="" IsReadOnly="True" Width="300" />
|
||||
</StackPanel>
|
||||
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ProxySuper.WPF.Controls
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue