mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-25 06:36:08 +03:00
merge hysteria
This commit is contained in:
parent
f371277362
commit
6a67a3e685
@ -26,7 +26,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return new List<int> { Port };
|
return new List<int> { Port, 80 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@
|
|||||||
<Compile Include="ViewModels\BrookInstallViewModel.cs" />
|
<Compile Include="ViewModels\BrookInstallViewModel.cs" />
|
||||||
<Compile Include="ViewModels\EnableRootViewModel.cs" />
|
<Compile Include="ViewModels\EnableRootViewModel.cs" />
|
||||||
<Compile Include="ViewModels\HomeViewModel.cs" />
|
<Compile Include="ViewModels\HomeViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\HysteriaConfigViewModel.cs" />
|
||||||
<Compile Include="ViewModels\HysteriaEditorViewModel.cs" />
|
<Compile Include="ViewModels\HysteriaEditorViewModel.cs" />
|
||||||
<Compile Include="ViewModels\HysteriaInstallViewModel.cs" />
|
<Compile Include="ViewModels\HysteriaInstallViewModel.cs" />
|
||||||
<Compile Include="ViewModels\MTProtoGoConfigViewModel.cs" />
|
<Compile Include="ViewModels\MTProtoGoConfigViewModel.cs" />
|
||||||
|
@ -24,40 +24,43 @@ namespace ProxySuper.Core.Services
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Progress.Step = "安装Hysteria";
|
Task.Factory.StartNew(() =>
|
||||||
Progress.Percentage = 0;
|
{
|
||||||
|
Progress.Step = "安装Hysteria";
|
||||||
|
Progress.Percentage = 0;
|
||||||
|
|
||||||
|
|
||||||
Progress.Desc = "检测系统环境";
|
Progress.Desc = "检测系统环境";
|
||||||
EnsureRootUser();
|
EnsureRootUser();
|
||||||
EnsureSystemEnv();
|
EnsureSystemEnv();
|
||||||
Progress.Percentage = 20;
|
Progress.Percentage = 20;
|
||||||
|
|
||||||
Progress.Desc = "安装必要的系统工具";
|
Progress.Desc = "安装必要的系统工具";
|
||||||
InstallSystemTools();
|
InstallSystemTools();
|
||||||
Progress.Percentage = 40;
|
Progress.Percentage = 40;
|
||||||
|
|
||||||
Progress.Desc = "配置防火墙";
|
Progress.Desc = "配置防火墙";
|
||||||
ConfigFirewalld();
|
ConfigFirewalld();
|
||||||
Progress.Percentage = 50;
|
Progress.Percentage = 50;
|
||||||
|
|
||||||
Progress.Step = "检测网络环境";
|
Progress.Step = "检测网络环境";
|
||||||
EnsureNetwork();
|
EnsureNetwork();
|
||||||
Progress.Percentage = 60;
|
Progress.Percentage = 60;
|
||||||
|
|
||||||
|
|
||||||
Progress.Desc = "检测域名是否绑定本机IP";
|
Progress.Desc = "检测域名是否绑定本机IP";
|
||||||
ValidateDomain();
|
ValidateDomain();
|
||||||
Progress.Percentage = 80;
|
Progress.Percentage = 80;
|
||||||
|
|
||||||
Progress.Step = "上传Hysteria配置文件";
|
Progress.Step = "上传Hysteria配置文件";
|
||||||
UploadConfigFile();
|
UploadConfigFile();
|
||||||
Progress.Step = "安装Hysteria服务";
|
Progress.Step = "安装Hysteria服务";
|
||||||
InstallHysteria();
|
InstallHysteria();
|
||||||
|
|
||||||
Progress.Percentage = 100;
|
Progress.Percentage = 100;
|
||||||
Progress.Step = "安装Hysteria成功";
|
Progress.Step = "安装Hysteria成功";
|
||||||
Progress.Desc = "安装Hysteria成功";
|
Progress.Desc = "安装Hysteria成功";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -113,8 +116,8 @@ namespace ProxySuper.Core.Services
|
|||||||
private void InstallHysteria()
|
private void InstallHysteria()
|
||||||
{
|
{
|
||||||
Progress.Desc = "执行Hysteria安装文件";
|
Progress.Desc = "执行Hysteria安装文件";
|
||||||
string url = "https://github.com/apernet/hysteria/releases/download/v1.3.3/hysteria-linux-386";
|
string url = "https://github.com/apernet/hysteria/releases/download/v1.3.4/hysteria-linux-386";
|
||||||
string targetPath = "/user/bin/hysteria/hysteria-linux-386";
|
string targetPath = "/usr/bin/hysteria/hysteria-linux-386";
|
||||||
|
|
||||||
if (ArchType == ArchType.arm)
|
if (ArchType == ArchType.arm)
|
||||||
{
|
{
|
||||||
@ -122,11 +125,11 @@ namespace ProxySuper.Core.Services
|
|||||||
targetPath = targetPath.Replace("hysteria-linux-386", "hysteria-linux-arm");
|
targetPath = targetPath.Replace("hysteria-linux-386", "hysteria-linux-arm");
|
||||||
}
|
}
|
||||||
|
|
||||||
RunCmd($"curl -L {url} -o /usr/bin/hysteria");
|
RunCmd($"curl -L {url} -o {targetPath}");
|
||||||
RunCmd("chmod +x /usr/bin/hysteria");
|
RunCmd($"chmod +x {targetPath}");
|
||||||
|
|
||||||
Progress.Desc = "设置Hysteria服务";
|
Progress.Desc = "设置Hysteria服务";
|
||||||
var cmd = targetPath + " server";
|
var cmd = targetPath + " -c /usr/bin/hysteria/config.json server";
|
||||||
var hysteriaService = HysteriaServiceTemp.Replace("##run_cmd##", cmd);
|
var hysteriaService = HysteriaServiceTemp.Replace("##run_cmd##", cmd);
|
||||||
|
|
||||||
RunCmd("rm -rf /etc/systemd/system/hysteria.service");
|
RunCmd("rm -rf /etc/systemd/system/hysteria.service");
|
||||||
@ -149,7 +152,7 @@ namespace ProxySuper.Core.Services
|
|||||||
var obj = JToken.FromObject(json) as dynamic;
|
var obj = JToken.FromObject(json) as dynamic;
|
||||||
|
|
||||||
|
|
||||||
obj["listen"] = Settings.Port;
|
obj["listen"] = $":{Settings.Port}";
|
||||||
obj["acme"]["domains"][0] = Settings.Domain;
|
obj["acme"]["domains"][0] = Settings.Domain;
|
||||||
obj["email"] = Settings.Email;
|
obj["email"] = Settings.Email;
|
||||||
obj["obfs"] = Settings.Obfs;
|
obj["obfs"] = Settings.Obfs;
|
||||||
@ -162,7 +165,8 @@ namespace ProxySuper.Core.Services
|
|||||||
NullValueHandling = NullValueHandling.Ignore
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
});
|
});
|
||||||
|
|
||||||
WriteToFile(configJson, "/user/bin/hysteria/config.json");
|
RunCmd("mkdir /usr/bin/hysteria");
|
||||||
|
WriteToFile(configJson, "/usr/bin/hysteria/config.json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,6 +276,14 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
record.Host = result.Host;
|
record.Host = result.Host;
|
||||||
record.MTProtoGoSettings = result.MTProtoGoSettings;
|
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();
|
SaveToJson();
|
||||||
}
|
}
|
||||||
@ -324,6 +332,10 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
{
|
{
|
||||||
await _navigationService.Navigate<MTProtoGoConfigViewModel, MTProtoGoSettings>(record.MTProtoGoSettings);
|
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)
|
public async Task GoToInstall(string id)
|
||||||
@ -356,6 +368,10 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
{
|
{
|
||||||
await _navigationService.Navigate<MTProtoGoInstallViewModel, Record>(record);
|
await _navigationService.Navigate<MTProtoGoInstallViewModel, Record>(record);
|
||||||
}
|
}
|
||||||
|
if (record.Type == ProjectType.Hysteria)
|
||||||
|
{
|
||||||
|
await _navigationService.Navigate<HysteriaInstallViewModel, Record>(record);
|
||||||
|
}
|
||||||
|
|
||||||
SaveToJson();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -158,9 +158,15 @@
|
|||||||
<Compile Include="Views\HomeView.xaml.cs">
|
<Compile Include="Views\HomeView.xaml.cs">
|
||||||
<DependentUpon>HomeView.xaml</DependentUpon>
|
<DependentUpon>HomeView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\Hysteria\HysteriaConfigView.xaml.cs">
|
||||||
|
<DependentUpon>HysteriaConfigView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\Hysteria\HysteriaEditorView.xaml.cs">
|
<Compile Include="Views\Hysteria\HysteriaEditorView.xaml.cs">
|
||||||
<DependentUpon>HysteriaEditorView.xaml</DependentUpon>
|
<DependentUpon>HysteriaEditorView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\Hysteria\HysteriaInstallView.xaml.cs">
|
||||||
|
<DependentUpon>HysteriaInstallView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\MTProxyGo\MTProxyGoConfigView.xaml.cs">
|
<Compile Include="Views\MTProxyGo\MTProxyGoConfigView.xaml.cs">
|
||||||
<DependentUpon>MTProxyGoConfigView.xaml</DependentUpon>
|
<DependentUpon>MTProxyGoConfigView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -321,10 +327,18 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Hysteria\HysteriaConfigView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Hysteria\HysteriaEditorView.xaml">
|
<Page Include="Views\Hysteria\HysteriaEditorView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Hysteria\HysteriaInstallView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\MTProxyGo\MTProxyGoConfigView.xaml">
|
<Page Include="Views\MTProxyGo\MTProxyGoConfigView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
14
ProxySuper.WPF/Views/Hysteria/HysteriaConfigView.xaml
Normal file
14
ProxySuper.WPF/Views/Hysteria/HysteriaConfigView.xaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<views:MvxWindow x:Class="ProxySuper.WPF.Views.Hysteria.HysteriaConfigView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:ProxySuper.WPF.Views.Hysteria"
|
||||||
|
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
Title="Hysteria配置" Height="450" Width="800">
|
||||||
|
<StackPanel Margin="20">
|
||||||
|
<TextBox Height="360" Text="{Binding ClientJson, Mode=OneWay}" IsReadOnly="True" />
|
||||||
|
</StackPanel>
|
||||||
|
</views:MvxWindow>
|
30
ProxySuper.WPF/Views/Hysteria/HysteriaConfigView.xaml.cs
Normal file
30
ProxySuper.WPF/Views/Hysteria/HysteriaConfigView.xaml.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using MvvmCross.Platforms.Wpf.Presenters.Attributes;
|
||||||
|
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.Hysteria
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// HysteriaConfigView.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
[MvxWindowPresentation]
|
||||||
|
public partial class HysteriaConfigView : MvxWindow
|
||||||
|
{
|
||||||
|
public HysteriaConfigView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,5 +23,7 @@ namespace ProxySuper.WPF.Views.Hysteria
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
34
ProxySuper.WPF/Views/Hysteria/HysteriaInstallView.xaml
Normal file
34
ProxySuper.WPF/Views/Hysteria/HysteriaInstallView.xaml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<views:MvxWindow x:Class="ProxySuper.WPF.Views.Hysteria.HysteriaInstallView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:ProxySuper.WPF.Views.Hysteria"
|
||||||
|
xmlns:ctrl="clr-namespace:ProxySuper.WPF.Controls"
|
||||||
|
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
Title="Hysteria安装" Height="450" Width="800">
|
||||||
|
<StackPanel>
|
||||||
|
<ctrl:ProgressControl />
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="20,0,0,0">
|
||||||
|
<Label Content="{DynamicResource Install}" FontWeight="Bold" FontSize="14" />
|
||||||
|
|
||||||
|
<Button Content="{DynamicResource XrayInstallerInstall}"
|
||||||
|
Command="{Binding Path=InstallCommand}"
|
||||||
|
Padding="10,3"
|
||||||
|
Margin="10,0,0,0" />
|
||||||
|
|
||||||
|
<!--<Button Content="{DynamicResource XrayInstallerUpdateSettings}"
|
||||||
|
Command="{Binding Path=UpdateSettingsCommand}"
|
||||||
|
Padding="10,3"
|
||||||
|
Margin="10,0,0,0" />-->
|
||||||
|
|
||||||
|
<Button Content="{DynamicResource XrayInstallerUninstall}"
|
||||||
|
Command="{Binding Path=UninstallCommand}"
|
||||||
|
Padding="10,3"
|
||||||
|
Margin="10,0,0,0" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</views:MvxWindow>
|
30
ProxySuper.WPF/Views/Hysteria/HysteriaInstallView.xaml.cs
Normal file
30
ProxySuper.WPF/Views/Hysteria/HysteriaInstallView.xaml.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using MvvmCross.Platforms.Wpf.Presenters.Attributes;
|
||||||
|
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.Hysteria
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// HysteriaInstallView.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
[MvxWindowPresentation]
|
||||||
|
public partial class HysteriaInstallView : MvxWindow
|
||||||
|
{
|
||||||
|
public HysteriaInstallView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user