2021-07-08 13:37:32 +03:00
|
|
|
|
using MvvmCross.ViewModels;
|
2021-05-16 04:12:47 +03:00
|
|
|
|
using Newtonsoft.Json;
|
2021-05-14 14:07:19 +03:00
|
|
|
|
using ProxySuper.Core.Models.Hosts;
|
|
|
|
|
using ProxySuper.Core.Models.Projects;
|
2021-05-25 13:28:37 +03:00
|
|
|
|
using ProxySuper.Core.Services;
|
2021-05-14 14:07:19 +03:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace ProxySuper.Core.Models
|
|
|
|
|
{
|
2021-05-23 09:24:13 +03:00
|
|
|
|
[JsonObject]
|
2021-05-16 04:12:47 +03:00
|
|
|
|
public class Record : MvxViewModel
|
2021-05-14 14:07:19 +03:00
|
|
|
|
{
|
2021-05-25 13:28:37 +03:00
|
|
|
|
public Record()
|
|
|
|
|
{
|
|
|
|
|
_isChecked = false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-23 09:24:13 +03:00
|
|
|
|
private Host _host;
|
2021-05-25 13:28:37 +03:00
|
|
|
|
private bool _isChecked;
|
2021-05-23 09:24:13 +03:00
|
|
|
|
|
2021-05-16 04:12:47 +03:00
|
|
|
|
[JsonProperty("id")]
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("host")]
|
2021-05-23 09:24:13 +03:00
|
|
|
|
public Host Host
|
|
|
|
|
{
|
|
|
|
|
get { return _host; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_host = value;
|
|
|
|
|
RaisePropertyChanged("Host");
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-14 14:07:19 +03:00
|
|
|
|
|
|
|
|
|
[JsonProperty("settings")]
|
2021-05-16 04:12:47 +03:00
|
|
|
|
public XraySettings XraySettings { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("trojanGoSettings")]
|
|
|
|
|
public TrojanGoSettings TrojanGoSettings { get; set; }
|
2021-05-14 14:07:19 +03:00
|
|
|
|
|
2021-05-25 13:28:37 +03:00
|
|
|
|
[JsonProperty("naiveProxySettings")]
|
|
|
|
|
public NaiveProxySettings NaiveProxySettings { get; set; }
|
|
|
|
|
|
2021-07-02 13:35:25 +03:00
|
|
|
|
[JsonProperty("brook")]
|
|
|
|
|
public BrookSettings BrookSettings { get; set; }
|
|
|
|
|
|
2021-05-14 14:07:19 +03:00
|
|
|
|
|
2021-05-16 04:12:47 +03:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public ProjectType Type
|
2021-05-14 14:07:19 +03:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2021-05-16 04:12:47 +03:00
|
|
|
|
if (XraySettings != null) return ProjectType.Xray;
|
2021-05-25 13:28:37 +03:00
|
|
|
|
|
|
|
|
|
if (TrojanGoSettings != null) return ProjectType.TrojanGo;
|
|
|
|
|
|
2021-07-02 13:35:25 +03:00
|
|
|
|
if (NaiveProxySettings != null) return ProjectType.NaiveProxy;
|
|
|
|
|
|
|
|
|
|
return ProjectType.Brook;
|
2021-05-25 13:28:37 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public bool IsChecked
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _isChecked;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isChecked = value;
|
|
|
|
|
RaisePropertyChanged("IsChecked");
|
2021-05-16 04:12:47 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-25 13:28:37 +03:00
|
|
|
|
public string GetShareLink()
|
|
|
|
|
{
|
|
|
|
|
if (Type == ProjectType.Xray)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder strBuilder = new StringBuilder();
|
|
|
|
|
XraySettings.Types.ForEach(type =>
|
|
|
|
|
{
|
|
|
|
|
var link = ShareLink.Build(type, XraySettings);
|
|
|
|
|
strBuilder.AppendLine(link);
|
|
|
|
|
});
|
|
|
|
|
return strBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Type == ProjectType.TrojanGo)
|
|
|
|
|
{
|
|
|
|
|
return ShareLink.BuildTrojanGo(TrojanGoSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Type == ProjectType.NaiveProxy)
|
|
|
|
|
{
|
|
|
|
|
return ShareLink.BuildNaiveProxy(NaiveProxySettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
2021-05-26 11:22:18 +03:00
|
|
|
|
|
2021-05-14 14:07:19 +03:00
|
|
|
|
}
|
|
|
|
|
}
|