diff --git a/ProxySuper.Core/Models/Projects/BrookSettings.cs b/ProxySuper.Core/Models/Projects/BrookSettings.cs index 71eda20..0de6c4d 100644 --- a/ProxySuper.Core/Models/Projects/BrookSettings.cs +++ b/ProxySuper.Core/Models/Projects/BrookSettings.cs @@ -10,6 +10,8 @@ namespace ProxySuper.Core.Models.Projects { public string Domain { get; set; } + public string IP { get; set; } + public string Password { get; set; } public BrookType BrookType { get; set; } diff --git a/ProxySuper.Core/ProxySuper.Core.csproj b/ProxySuper.Core/ProxySuper.Core.csproj index edee6f9..4976f9c 100644 --- a/ProxySuper.Core/ProxySuper.Core.csproj +++ b/ProxySuper.Core/ProxySuper.Core.csproj @@ -94,6 +94,7 @@ + diff --git a/ProxySuper.Core/Services/BrookProject.cs b/ProxySuper.Core/Services/BrookProject.cs index 36cae78..2bfb69c 100644 --- a/ProxySuper.Core/Services/BrookProject.cs +++ b/ProxySuper.Core/Services/BrookProject.cs @@ -109,7 +109,8 @@ namespace ProxySuper.Core.Services if (Parameters.BrookType == BrookType.socks5) { - return $"/usr/bin/brook socks5 --socks5 :{Parameters.Port}"; + var ip = OnlyIpv6 ? IPv6 : IPv4; + return $"/usr/bin/brook socks5 --socks5 {ip}:{Parameters.Port}"; } return runBrookCmd; @@ -117,12 +118,15 @@ namespace ProxySuper.Core.Services public void Uninstall() { - RunCmd("killall brook"); + RunCmd("systemctl stop brook"); + RunCmd("systemctl disable brook"); + RunCmd("rm -rf /etc/systemd/system/brook.service"); + RunCmd("rm -rf /usr/bin/brook"); Console.WriteLine("关闭端口"); ClosePort(Parameters.FreePorts.ToArray()); - Console.WriteLine("******卸载完成******"); + WriteOutput("******卸载完成******"); } } } diff --git a/ProxySuper.Core/Services/ShareLink.cs b/ProxySuper.Core/Services/ShareLink.cs index 817d833..643bebe 100644 --- a/ProxySuper.Core/Services/ShareLink.cs +++ b/ProxySuper.Core/Services/ShareLink.cs @@ -11,6 +11,37 @@ 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}&ws={address}"; + } + + if (settings.BrookType == BrookType.wssserver) + { + var address = HttpUtility.UrlEncode($"wss://{settings.Domain}:{settings.Port}"); + return $"brook://wssserver?password={password}&wss={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(); diff --git a/ProxySuper.Core/ViewModels/BrookConfigViewModel.cs b/ProxySuper.Core/ViewModels/BrookConfigViewModel.cs new file mode 100644 index 0000000..a8cb2f3 --- /dev/null +++ b/ProxySuper.Core/ViewModels/BrookConfigViewModel.cs @@ -0,0 +1,29 @@ +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 +{ + public class BrookConfigViewModel : MvxViewModel + { + public BrookSettings Settings { get; set; } + + public override void Prepare(BrookSettings parameter) + { + Settings = parameter; + } + + public string Link + { + get + { + return ShareLink.BuildBrook(Settings); + } + } + } +} diff --git a/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs b/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs index de36cf0..cacc32a 100644 --- a/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs +++ b/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs @@ -58,6 +58,7 @@ namespace ProxySuper.Core.ViewModels } RaisePropertyChanged("EnablePort"); RaisePropertyChanged("EnableDomain"); + RaisePropertyChanged("EnableIP"); } } @@ -65,6 +66,8 @@ namespace ProxySuper.Core.ViewModels public bool EnableDomain => Settings.BrookType == BrookType.wssserver; + public bool EnableIP => Settings.BrookType != BrookType.wssserver; + public IMvxCommand SaveCommand => new MvxCommand(() => Save()); public override void Prepare(Record parameter) diff --git a/ProxySuper.Core/ViewModels/HomeViewModel.cs b/ProxySuper.Core/ViewModels/HomeViewModel.cs index 23e7f81..d3e7472 100644 --- a/ProxySuper.Core/ViewModels/HomeViewModel.cs +++ b/ProxySuper.Core/ViewModels/HomeViewModel.cs @@ -210,6 +210,10 @@ namespace ProxySuper.Core.ViewModels { await _navigationService.Navigate(record.NaiveProxySettings); } + if (record.Type == ProjectType.Brook) + { + await _navigationService.Navigate(record.BrookSettings); + } } public async Task GoToInstall(string id) diff --git a/ProxySuper.WPF/ProxySuper.WPF.csproj b/ProxySuper.WPF/ProxySuper.WPF.csproj index 305481a..de1918d 100644 --- a/ProxySuper.WPF/ProxySuper.WPF.csproj +++ b/ProxySuper.WPF/ProxySuper.WPF.csproj @@ -111,12 +111,18 @@ MainWindow.xaml + + BrookConfigView.xaml + BrookEditorView.xaml BrookInstallerView.xaml + + EnableRootView.xaml + HomeView.xaml @@ -207,6 +213,10 @@ MSBuild:Compile PreserveNewest + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -215,6 +225,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/ProxySuper.WPF/Views/BrookConfigView.xaml b/ProxySuper.WPF/Views/BrookConfigView.xaml new file mode 100644 index 0000000..184ca1d --- /dev/null +++ b/ProxySuper.WPF/Views/BrookConfigView.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + diff --git a/ProxySuper.WPF/Views/BrookConfigView.xaml.cs b/ProxySuper.WPF/Views/BrookConfigView.xaml.cs new file mode 100644 index 0000000..963d307 --- /dev/null +++ b/ProxySuper.WPF/Views/BrookConfigView.xaml.cs @@ -0,0 +1,28 @@ +using MvvmCross.Platforms.Wpf.Views; +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.Shapes; + +namespace ProxySuper.WPF.Views +{ + /// + /// BrookConfigView.xaml 的交互逻辑 + /// + public partial class BrookConfigView : MvxWindow + { + public BrookConfigView() + { + InitializeComponent(); + } + } +} diff --git a/ProxySuper.WPF/Views/BrookEditorView.xaml b/ProxySuper.WPF/Views/BrookEditorView.xaml index 44d90dd..52862f2 100644 --- a/ProxySuper.WPF/Views/BrookEditorView.xaml +++ b/ProxySuper.WPF/Views/BrookEditorView.xaml @@ -48,14 +48,17 @@ SelectedValue="{Binding CheckedBrookType,Mode=TwoWay}"> -