From d5878079f18822bd00a96adbe659bdf0a94762fd Mon Sep 17 00:00:00 2001 From: autumn Date: Tue, 6 Jul 2021 18:30:14 +0800 Subject: [PATCH] merge --- ProxySuper.Core/Models/Projects/BrookType.cs | 3 +- ProxySuper.Core/ProxySuper.Core.csproj | 1 + ProxySuper.Core/Services/BrookProject.cs | 49 +++--- .../ViewModels/BrookEditorViewModel.cs | 10 +- .../ViewModels/BrookInstallerViewModel.cs | 44 +++++ ProxySuper.Core/ViewModels/HomeViewModel.cs | 12 ++ ProxySuper.WPF/ProxySuper.WPF.csproj | 7 + ProxySuper.WPF/Views/BrookEditorView.xaml | 2 + ProxySuper.WPF/Views/BrookInstallerView.xaml | 34 ++++ .../Views/BrookInstallerView.xaml.cs | 157 ++++++++++++++++++ 10 files changed, 286 insertions(+), 33 deletions(-) create mode 100644 ProxySuper.Core/ViewModels/BrookInstallerViewModel.cs create mode 100644 ProxySuper.WPF/Views/BrookInstallerView.xaml create mode 100644 ProxySuper.WPF/Views/BrookInstallerView.xaml.cs diff --git a/ProxySuper.Core/Models/Projects/BrookType.cs b/ProxySuper.Core/Models/Projects/BrookType.cs index 944a5e9..817d0ec 100644 --- a/ProxySuper.Core/Models/Projects/BrookType.cs +++ b/ProxySuper.Core/Models/Projects/BrookType.cs @@ -10,6 +10,7 @@ namespace ProxySuper.Core.Models.Projects { server, wsserver, - wssserver + wssserver, + socks5 } } diff --git a/ProxySuper.Core/ProxySuper.Core.csproj b/ProxySuper.Core/ProxySuper.Core.csproj index 9067c8a..edee6f9 100644 --- a/ProxySuper.Core/ProxySuper.Core.csproj +++ b/ProxySuper.Core/ProxySuper.Core.csproj @@ -95,6 +95,7 @@ + diff --git a/ProxySuper.Core/Services/BrookProject.cs b/ProxySuper.Core/Services/BrookProject.cs index 3ab4c66..9fb4bfa 100644 --- a/ProxySuper.Core/Services/BrookProject.cs +++ b/ProxySuper.Core/Services/BrookProject.cs @@ -44,64 +44,53 @@ namespace ProxySuper.Core.Services WriteOutput("域名检测完成"); } + InstallBrook(); + Console.WriteLine("*************安装完成,尽情享用吧**********"); } public void InstallBrook() { - Console.WriteLine("安装nami"); - RunCmd("source <(curl -L https://git.io/getnami)"); - Console.WriteLine("安装nami完成"); - Console.WriteLine("安装Brook"); - RunCmd("echo y | nami install github.com/txthinking/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"); Console.WriteLine("安装Brook完成"); - Console.WriteLine("安装joker"); - RunCmd("echo y | nami install github.com/txthinking/joker"); - Console.WriteLine("安装joker完成"); - - Console.WriteLine("安装jinbe"); - RunCmd("echo y | nami install github.com/txthinking/jinbe"); - Console.WriteLine("安装jinbe完成"); - var runBrookCmd = string.Empty; if (Parameters.BrookType == BrookType.server) { - runBrookCmd = $"joker brook server --listen :{Parameters.Port} --password {Parameters.Password}"; + runBrookCmd = $"nohup /usr/bin/brook server --listen :{Parameters.Port} --password {Parameters.Password} &"; } if (Parameters.BrookType == BrookType.wsserver) { - runBrookCmd = $"joker brook wsserver --listen :{Parameters.Port} --password {Parameters.Password}"; + runBrookCmd = $"nohup /usr/bin/brook wsserver --listen :{Parameters.Port} --password {Parameters.Password} &"; } if (Parameters.BrookType == BrookType.wsserver) { - runBrookCmd = $"joker brook wssserver --domain {Parameters.Domain} --password {Parameters.Password}"; + runBrookCmd = $"nohup /usr/bin/brook wssserver --domain {Parameters.Domain} --password {Parameters.Password} &"; } - RunCmd("jinbe " + runBrookCmd); - - Console.WriteLine("*************安装完成,尽情享用吧**********"); + if (Parameters.BrookType == BrookType.socks5) + { + runBrookCmd = $"nohup /usr/bin/brook socks5 --socks5 :{Parameters.Port} &"; + } } public void Uninstall() { - RunCmd("jinbe remove 0"); - RunCmd("killall joker"); - - Console.WriteLine("卸载jinbe"); - RunCmd("echo y | nami remove github.com/txthinking/jinbe"); - - Console.WriteLine("卸载joker"); - RunCmd("echo y | nami remove github.com/txthinking/joker"); - - Console.WriteLine("卸载brook"); - RunCmd("echo y | nami remove github.com/txthinking/brook"); + RunCmd("killall brook"); Console.WriteLine("关闭端口"); ClosePort(Parameters.FreePorts.ToArray()); diff --git a/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs b/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs index 8c9ad58..ca53bb4 100644 --- a/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs +++ b/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs @@ -15,6 +15,13 @@ namespace ProxySuper.Core.ViewModels { public class BrookEditorViewModel : MvxViewModel { + public BrookEditorViewModel(IMvxNavigationService navigationService) + { + NavigationService = navigationService; + } + + public IMvxNavigationService NavigationService { get; } + public string Id { get; set; } public Host Host { get; set; } @@ -29,6 +36,7 @@ namespace ProxySuper.Core.ViewModels BrookType.server.ToString(), BrookType.wsserver.ToString(), BrookType.wssserver.ToString(), + BrookType.socks5.ToString(), }; } } @@ -53,8 +61,6 @@ namespace ProxySuper.Core.ViewModels public IMvxCommand SaveCommand => new MvxCommand(() => Save()); - public IMvxNavigationService NavigationService { get; } - public override void Prepare(Record parameter) { var record = Utils.DeepClone(parameter); diff --git a/ProxySuper.Core/ViewModels/BrookInstallerViewModel.cs b/ProxySuper.Core/ViewModels/BrookInstallerViewModel.cs new file mode 100644 index 0000000..74bae01 --- /dev/null +++ b/ProxySuper.Core/ViewModels/BrookInstallerViewModel.cs @@ -0,0 +1,44 @@ +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 BrookInstallerViewModel : MvxViewModel + { + + public Host Host { get; set; } + + public BrookSettings Settings { get; set; } + + public override void Prepare(Record parameter) + { + var record = Utils.DeepClone(parameter); + Host = record.Host; + Settings = record.BrookSettings; + } + + private bool _connected; + public bool Connected + { + get + { + return _connected; + } + set + { + _connected = value; + RaisePropertyChanged("Connected"); + } + } + + public string CommandText { get; set; } + } +} diff --git a/ProxySuper.Core/ViewModels/HomeViewModel.cs b/ProxySuper.Core/ViewModels/HomeViewModel.cs index 2d09e96..23e7f81 100644 --- a/ProxySuper.Core/ViewModels/HomeViewModel.cs +++ b/ProxySuper.Core/ViewModels/HomeViewModel.cs @@ -166,6 +166,14 @@ namespace ProxySuper.Core.ViewModels record.Host = result.Host; record.NaiveProxySettings = result.NaiveProxySettings; } + if (record.Type == ProjectType.Brook) + { + result = await _navigationService.Navigate(record); + if (result == null) return; + + record.Host = result.Host; + record.BrookSettings = result.BrookSettings; + } SaveToJson(); } @@ -221,6 +229,10 @@ namespace ProxySuper.Core.ViewModels { await _navigationService.Navigate(record); } + if (record.Type == ProjectType.Brook) + { + await _navigationService.Navigate(record); + } } } } diff --git a/ProxySuper.WPF/ProxySuper.WPF.csproj b/ProxySuper.WPF/ProxySuper.WPF.csproj index 7dd0f19..305481a 100644 --- a/ProxySuper.WPF/ProxySuper.WPF.csproj +++ b/ProxySuper.WPF/ProxySuper.WPF.csproj @@ -114,6 +114,9 @@ BrookEditorView.xaml + + BrookInstallerView.xaml + HomeView.xaml @@ -208,6 +211,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/ProxySuper.WPF/Views/BrookEditorView.xaml b/ProxySuper.WPF/Views/BrookEditorView.xaml index d33cd95..44d90dd 100644 --- a/ProxySuper.WPF/Views/BrookEditorView.xaml +++ b/ProxySuper.WPF/Views/BrookEditorView.xaml @@ -9,6 +9,8 @@ mc:Ignorable="d" BorderThickness="0,1,0,0" BorderBrush="#eee" + Icon="/Resources/ProxySU.ico" + WindowStartupLocation="CenterScreen" Title="BrookEditorView" Height="600" Width="1000"> diff --git a/ProxySuper.WPF/Views/BrookInstallerView.xaml b/ProxySuper.WPF/Views/BrookInstallerView.xaml new file mode 100644 index 0000000..bb1c912 --- /dev/null +++ b/ProxySuper.WPF/Views/BrookInstallerView.xaml @@ -0,0 +1,34 @@ + + + + + +