diff --git a/ProxySuper.Core/Models/Projects/HysteriaSettings.cs b/ProxySuper.Core/Models/Projects/HysteriaSettings.cs new file mode 100644 index 0000000..087884f --- /dev/null +++ b/ProxySuper.Core/Models/Projects/HysteriaSettings.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProxySuper.Core.Models.Projects +{ + public class HysteriaSettings + { + public string Domain { get; set; } = ""; + + public string Obfs { get; set; } = ""; + + public string Email { get; set; } = ""; + + public int Port { get; set; } = 36712; + + public int UpMbps { get; set; } = 300; + + public int DownMbps { get; set; } = 300; + } +} diff --git a/ProxySuper.Core/Models/Projects/ProjectType.cs b/ProxySuper.Core/Models/Projects/ProjectType.cs index 15b3e48..ec2a37d 100644 --- a/ProxySuper.Core/Models/Projects/ProjectType.cs +++ b/ProxySuper.Core/Models/Projects/ProjectType.cs @@ -8,5 +8,6 @@ Brook = 3, V2ray = 4, MTProtoGo = 5, + Hysteria = 6, } } diff --git a/ProxySuper.Core/Models/Record.cs b/ProxySuper.Core/Models/Record.cs index b48001e..54629f5 100644 --- a/ProxySuper.Core/Models/Record.cs +++ b/ProxySuper.Core/Models/Record.cs @@ -51,6 +51,9 @@ namespace ProxySuper.Core.Models [JsonProperty("mtProtoGoSettings")] public MTProtoGoSettings MTProtoGoSettings { get; set; } + [JsonProperty] + public HysteriaSettings HysteriaSettings { get; set; } + [JsonIgnore] public ProjectType Type @@ -67,6 +70,8 @@ namespace ProxySuper.Core.Models if (MTProtoGoSettings != null) return ProjectType.MTProtoGo; + if (HysteriaSettings != null) return ProjectType.Hysteria; + return ProjectType.Brook; } } diff --git a/ProxySuper.Core/ProxySuper.Core.csproj b/ProxySuper.Core/ProxySuper.Core.csproj index 091ab17..d181519 100644 --- a/ProxySuper.Core/ProxySuper.Core.csproj +++ b/ProxySuper.Core/ProxySuper.Core.csproj @@ -90,6 +90,7 @@ + @@ -122,6 +123,8 @@ + + diff --git a/ProxySuper.Core/ViewModels/HysteriaEditorViewModel.cs b/ProxySuper.Core/ViewModels/HysteriaEditorViewModel.cs new file mode 100644 index 0000000..7de577a --- /dev/null +++ b/ProxySuper.Core/ViewModels/HysteriaEditorViewModel.cs @@ -0,0 +1,63 @@ +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 + { + public string Id { get; set; } + + public Host Host { get; set; } + + public HysteriaSettings Settings { get; set; } + + public IMvxNavigationService NavigationService { get; } + + 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(record); + } + } +} diff --git a/ProxySuper.Core/ViewModels/HysteriaInstallViewModel.cs b/ProxySuper.Core/ViewModels/HysteriaInstallViewModel.cs new file mode 100644 index 0000000..ec0d49d --- /dev/null +++ b/ProxySuper.Core/ViewModels/HysteriaInstallViewModel.cs @@ -0,0 +1,25 @@ +using MvvmCross.ViewModels; +using ProxySuper.Core.Models; +using ProxySuper.Core.Models.Hosts; +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 HysteriaInstallViewModel : MvxViewModel + { + public Host Host { get; set; } + + public HysteriaSettings Settings { get; set; } + + public override void Prepare(Record parameter) + { + Host = parameter.Host; + Settings = parameter.HysteriaSettings; + } + } +}