1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-27 07:36:06 +03:00
ProxySU/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs

92 lines
2.1 KiB
C#
Raw Normal View History

2021-05-23 12:40:06 +03:00
using Newtonsoft.Json;
using System;
2021-05-13 04:58:45 +03:00
using System.Collections.Generic;
2021-07-12 12:58:51 +03:00
using System.Linq;
2021-05-13 04:58:45 +03:00
2021-05-14 14:07:19 +03:00
namespace ProxySuper.Core.Models.Projects
2021-05-13 04:58:45 +03:00
{
public class TrojanGoSettings : IProjectSettings
{
2021-05-23 09:24:13 +03:00
public TrojanGoSettings()
{
2021-08-19 12:54:23 +03:00
WithTLS = true;
2021-05-23 09:24:13 +03:00
Port = 443;
2021-05-24 13:57:17 +03:00
WebSocketPath = "/ws";
2021-06-17 13:54:07 +03:00
Password = Guid.NewGuid().ToString();
2021-05-23 09:24:13 +03:00
}
2021-05-20 13:32:17 +03:00
public List<int> FreePorts
2021-05-13 04:58:45 +03:00
{
get
{
2021-07-12 12:58:51 +03:00
return new List<int> { 80, 443, Port }.Distinct().ToList();
2021-05-13 04:58:45 +03:00
}
}
2021-05-20 13:32:17 +03:00
public ProjectType Type { get; set; } = ProjectType.TrojanGo;
2021-05-14 14:07:19 +03:00
2021-08-19 12:54:23 +03:00
/// <summary>
/// 是否安装TLS证书
/// </summary>
public bool WithTLS { get; set; }
2021-05-13 04:58:45 +03:00
/// <summary>
/// 域名
/// </summary>
2021-05-20 13:32:17 +03:00
public string Domain { get; set; }
2021-05-13 04:58:45 +03:00
/// <summary>
/// 端口
/// </summary>
2021-05-20 13:32:17 +03:00
public int Port { get; set; }
2021-05-13 04:58:45 +03:00
/// <summary>
/// 密码
/// </summary>
public string Password { get; set; }
/// <summary>
/// 伪装域名
/// </summary>
public string MaskDomain { get; set; }
2021-05-20 13:32:17 +03:00
/// <summary>
/// 是否开启WebSocket
/// </summary>
2021-05-23 12:40:06 +03:00
[JsonIgnore]
2021-05-20 13:32:17 +03:00
public bool EnableWebSocket
{
get
{
2021-05-24 13:57:17 +03:00
return !string.IsNullOrEmpty(WebSocketPath);
2021-05-20 13:32:17 +03:00
}
}
/// <summary>
/// websocket路径
/// </summary>
public string WebSocketPath { get; set; }
2021-06-17 13:54:07 +03:00
[JsonIgnore]
public string Email
{
get
{
if (!string.IsNullOrEmpty(Domain))
{
var arr = Domain.Split('.');
if (arr.Length == 3)
{
return $"{arr[0]}@{arr[1]}.{arr[2]}";
}
}
var prefix = Password.Length > 7 ? Password.Substring(0, 7) : Password;
return $"{prefix}@gmail.com";
}
}
2021-05-13 04:58:45 +03:00
}
}