1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-23 05:36:08 +03:00
ProxySU/ProxySU_Core/ViewModels/XraySettingsViewModel.cs

272 lines
7.3 KiB
C#
Raw Normal View History

2021-03-16 12:22:00 +03:00
using Newtonsoft.Json;
using ProxySU_Core.Common;
using ProxySU_Core.Models;
2021-03-04 11:25:36 +03:00
using System;
using System.Collections.Generic;
2021-03-26 13:13:32 +03:00
using System.Collections.ObjectModel;
2021-03-04 11:25:36 +03:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2021-03-15 12:58:20 +03:00
using System.Web;
2021-03-04 11:25:36 +03:00
using System.Windows;
2021-03-26 13:13:32 +03:00
using System.Windows.Controls;
2021-03-04 11:25:36 +03:00
namespace ProxySU_Core.ViewModels
{
2021-03-26 13:13:32 +03:00
public partial class XraySettingsViewModel : BaseViewModel
2021-03-04 11:25:36 +03:00
{
2021-03-04 13:25:52 +03:00
public XraySettings settings;
2021-03-04 11:25:36 +03:00
public XraySettingsViewModel(XraySettings parameters)
{
2021-03-04 13:25:52 +03:00
this.settings = parameters;
2021-03-26 13:13:32 +03:00
Notify("VMESS_KCP_Type");
2021-03-04 11:25:36 +03:00
}
public string UUID
{
2021-03-04 13:25:52 +03:00
get => settings.UUID;
2021-03-26 06:28:41 +03:00
set
{
settings.UUID = value;
Notify("UUID");
}
2021-03-04 11:25:36 +03:00
}
public string Domain
{
2021-03-04 13:25:52 +03:00
get => settings.Domain;
set => settings.Domain = value;
2021-03-04 11:25:36 +03:00
}
public string MaskDomain
{
2021-03-04 13:25:52 +03:00
get => settings.MaskDomain;
set => settings.MaskDomain = value;
2021-03-04 11:25:36 +03:00
}
2021-03-18 10:17:07 +03:00
2021-03-04 11:25:36 +03:00
public string TrojanPassword
{
2021-03-04 13:25:52 +03:00
get => settings.TrojanPassword;
set => settings.TrojanPassword = value;
2021-03-04 11:25:36 +03:00
}
2021-03-26 13:13:32 +03:00
public bool Checked_Trojan_TCP
2021-03-04 11:25:36 +03:00
{
get
{
2021-03-26 13:13:32 +03:00
return settings.Types.Contains(XrayType.Trojan_TCP);
2021-03-04 11:25:36 +03:00
}
set
{
if (value == true)
{
2021-03-26 13:13:32 +03:00
if (!settings.Types.Contains(XrayType.Trojan_TCP))
settings.Types.Add(XrayType.Trojan_TCP);
2021-03-04 11:25:36 +03:00
}
else
{
2021-03-26 13:13:32 +03:00
settings.Types.Remove(XrayType.Trojan_TCP);
2021-03-04 11:25:36 +03:00
}
2021-03-26 13:13:32 +03:00
Notify("Checked_Trojan_TCP");
2021-03-04 11:25:36 +03:00
}
}
2021-03-26 13:13:32 +03:00
public string Trojan_TCP_ShareLink
{
get => ShareLink.Build(XrayType.Trojan_TCP, settings);
}
2021-03-04 11:25:36 +03:00
2021-03-26 13:13:32 +03:00
private List<string> _ssMethods = new List<string> { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305" };
public List<string> ShadowSocksMethods => _ssMethods;
public bool CheckedShadowSocks
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.Types.Contains(XrayType.ShadowsocksAEAD);
2021-03-04 11:25:36 +03:00
set
{
2021-03-26 13:13:32 +03:00
CheckBoxChanged(value, XrayType.ShadowsocksAEAD);
Notify("CheckedShadowSocks");
2021-03-04 11:25:36 +03:00
}
}
2021-03-26 13:13:32 +03:00
public string ShadowSocksPassword
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.ShadowsocksPassword;
set => settings.ShadowsocksPassword = value;
}
public string ShadowSocksMethod
{
get => settings.ShadowsocksMethod;
2021-03-04 11:25:36 +03:00
set
{
2021-03-26 13:13:32 +03:00
var namespaceStr = typeof(ComboBoxItem).FullName + ":";
var trimValue = value.Replace(namespaceStr, "");
trimValue = trimValue.Trim();
settings.ShadowsocksMethod = trimValue;
Notify("ShadowSocksMethod");
2021-03-04 11:25:36 +03:00
}
}
2021-03-26 13:13:32 +03:00
public string ShadowSocksShareLink
{
get => ShareLink.Build(XrayType.ShadowsocksAEAD, settings);
}
2021-03-04 11:25:36 +03:00
2021-03-26 13:13:32 +03:00
private void CheckBoxChanged(bool value, XrayType type)
2021-03-18 10:17:07 +03:00
{
2021-03-26 13:13:32 +03:00
if (value == true)
2021-03-18 10:17:07 +03:00
{
2021-03-26 13:13:32 +03:00
if (!settings.Types.Contains(type))
2021-03-18 10:17:07 +03:00
{
2021-03-26 13:13:32 +03:00
settings.Types.Add(type);
2021-03-18 10:17:07 +03:00
}
2021-03-26 13:13:32 +03:00
}
else
{
settings.Types.RemoveAll(x => x == type);
2021-03-18 10:17:07 +03:00
}
}
2021-03-26 13:13:32 +03:00
}
public partial class XraySettingsViewModel
{
// vmess tcp
2021-03-04 11:25:36 +03:00
public bool Checked_VMESS_TCP
{
2021-03-26 13:13:32 +03:00
get => settings.Types.Contains(XrayType.VMESS_TCP);
2021-03-04 11:25:36 +03:00
set
{
2021-03-26 13:13:32 +03:00
CheckBoxChanged(value, XrayType.VMESS_TCP);
2021-03-04 11:25:36 +03:00
Notify("Checked_VMESS_TCP");
}
}
2021-03-26 13:13:32 +03:00
public string VMESS_TCP_Path
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.VMESS_TCP_Path;
set => settings.VMESS_TCP_Path = value;
2021-03-04 11:25:36 +03:00
}
2021-03-26 13:13:32 +03:00
public string VMESS_TCP_ShareLink
2021-03-18 10:17:07 +03:00
{
2021-03-26 13:13:32 +03:00
get => ShareLink.Build(XrayType.VMESS_TCP, settings);
2021-03-18 10:17:07 +03:00
}
2021-03-26 13:13:32 +03:00
// vmess ws
public bool Checked_VMESS_WS
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.Types.Contains(XrayType.VMESS_WS);
2021-03-04 11:25:36 +03:00
set
{
2021-03-26 13:13:32 +03:00
CheckBoxChanged(value, XrayType.VMESS_WS);
Notify("Checked_VMESS_WS");
2021-03-04 11:25:36 +03:00
}
}
2021-03-26 13:13:32 +03:00
public string VMESS_WS_Path
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.VMESS_WS_Path;
set => settings.VMESS_WS_Path = value;
2021-03-04 11:25:36 +03:00
}
2021-03-26 13:13:32 +03:00
public string VMESS_WS_TLS_ShareLink
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => ShareLink.Build(XrayType.VMESS_WS, settings);
2021-03-04 11:25:36 +03:00
}
2021-03-26 13:13:32 +03:00
// vmess kcp
public string VMESS_KCP_Seed
2021-03-18 10:17:07 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.VMESS_KCP_Seed;
set => settings.VMESS_KCP_Seed = value;
2021-03-18 10:17:07 +03:00
}
2021-03-26 13:13:32 +03:00
public string VMESS_KCP_Type
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.VMESS_KCP_Type;
set
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
var namespaceStr = typeof(ComboBoxItem).FullName + ":";
var trimValue = value.Replace(namespaceStr, "");
trimValue = trimValue.Trim();
settings.VMESS_KCP_Type = trimValue;
Notify("VMESS_KCP_Type");
2021-03-04 11:25:36 +03:00
}
}
2021-03-26 13:13:32 +03:00
public bool Checked_VMESS_KCP
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.Types.Contains(XrayType.VMESS_KCP);
set
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
CheckBoxChanged(value, XrayType.VMESS_KCP);
Notify("Checked_VMESS_KCP");
2021-03-04 11:25:36 +03:00
}
}
2021-03-26 13:13:32 +03:00
public string VMESS_KCP_ShareLink
2021-03-18 10:17:07 +03:00
{
2021-03-26 13:13:32 +03:00
get => ShareLink.Build(XrayType.VMESS_KCP, settings);
2021-03-18 10:17:07 +03:00
}
2021-03-26 13:13:32 +03:00
private List<string> _kcpTypes = new List<string> { "none", "srtp", "utp", "wechat-video", "dtls", "wireguard", };
public List<string> KcpTypes => _kcpTypes;
}
public partial class XraySettingsViewModel
{
// vless xtls
public bool Checked_VLESS_TCP_XTLS
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.Types.Contains(XrayType.VLESS_TCP_XTLS);
set
2021-03-04 11:25:36 +03:00
{
2021-03-26 13:13:32 +03:00
CheckBoxChanged(value, XrayType.VLESS_TCP_XTLS);
Notify("Checked_VLESS_XTLS");
2021-03-04 11:25:36 +03:00
}
}
2021-03-15 12:58:20 +03:00
public string VLESS_TCP_XTLS_ShareLink
{
2021-03-17 06:58:56 +03:00
get => ShareLink.Build(XrayType.VLESS_TCP_XTLS, settings);
2021-03-15 12:58:20 +03:00
}
2021-03-26 13:13:32 +03:00
// vless tcp
public bool Checked_VLESS_TCP
2021-03-18 10:17:07 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.Types.Contains(XrayType.VLESS_TCP);
set
{
CheckBoxChanged(value, XrayType.VLESS_TCP);
Notify("Checked_VLESS_TCP");
}
2021-03-18 10:17:07 +03:00
}
2021-03-26 13:13:32 +03:00
public string VLESS_TCP_ShareLink
2021-03-15 12:58:20 +03:00
{
2021-03-26 13:13:32 +03:00
get => ShareLink.Build(XrayType.VLESS_TCP, settings);
2021-03-15 12:58:20 +03:00
}
2021-03-26 13:13:32 +03:00
// vless ws
public string VLESS_WS_Path
2021-03-15 12:58:20 +03:00
{
2021-03-26 13:13:32 +03:00
get => settings.VLESS_WS_Path;
set => settings.VLESS_WS_Path = value;
2021-03-15 12:58:20 +03:00
}
2021-03-26 13:13:32 +03:00
public bool Checked_VLESS_WS
2021-03-18 10:17:07 +03:00
{
2021-03-26 13:13:32 +03:00
get
{
return settings.Types.Contains(XrayType.VLESS_WS);
}
set
{
CheckBoxChanged(value, XrayType.VLESS_WS);
Notify("Checked_VLESS_WS");
}
2021-03-18 10:17:07 +03:00
}
2021-03-26 13:13:32 +03:00
public string VLESS_WS_ShareLink
2021-03-15 12:58:20 +03:00
{
2021-03-26 13:13:32 +03:00
get => ShareLink.Build(XrayType.VLESS_WS, settings);
2021-03-15 12:58:20 +03:00
}
2021-03-04 11:25:36 +03:00
}
2021-03-16 12:22:00 +03:00
2021-03-04 11:25:36 +03:00
}