Browse Source

🎡 Cleanup `Shadowsocks.Interop`

- Mark optional fields as nullable
- Add `JsonHelper`
pull/3073/head
database64128 3 years ago
parent
commit
14dc1a2738
No known key found for this signature in database GPG Key ID: 1CA27546BEDB8B01
31 changed files with 212 additions and 230 deletions
  1. +3
    -13
      Shadowsocks.Interop/SsRust/Config.cs
  2. +42
    -0
      Shadowsocks.Interop/Utils/JsonHelper.cs
  3. +7
    -17
      Shadowsocks.Interop/V2Ray/Config.cs
  4. +7
    -0
      Shadowsocks.Interop/V2Ray/DnsObject.cs
  5. +8
    -4
      Shadowsocks.Interop/V2Ray/Inbound/AllocateObject.cs
  6. +5
    -11
      Shadowsocks.Interop/V2Ray/InboundObject.cs
  7. +4
    -9
      Shadowsocks.Interop/V2Ray/OutboundObject.cs
  8. +16
    -16
      Shadowsocks.Interop/V2Ray/Policy/LevelPolicyObject.cs
  9. +2
    -8
      Shadowsocks.Interop/V2Ray/PolicyObject.cs
  10. +2
    -4
      Shadowsocks.Interop/V2Ray/Protocols/Freedom/OutboundConfigurationObject.cs
  11. +2
    -7
      Shadowsocks.Interop/V2Ray/Protocols/Shadowsocks/InboundConfigurationObject.cs
  12. +2
    -10
      Shadowsocks.Interop/V2Ray/Protocols/Shadowsocks/ServerObject.cs
  13. +6
    -14
      Shadowsocks.Interop/V2Ray/Protocols/Socks/InboundConfigurationObject.cs
  14. +12
    -7
      Shadowsocks.Interop/V2Ray/Protocols/Socks/ServerObject.cs
  15. +2
    -4
      Shadowsocks.Interop/V2Ray/Protocols/Trojan/ClientObject.cs
  16. +10
    -6
      Shadowsocks.Interop/V2Ray/Protocols/Trojan/FallbackObject.cs
  17. +2
    -6
      Shadowsocks.Interop/V2Ray/Protocols/Trojan/ServerObject.cs
  18. +2
    -4
      Shadowsocks.Interop/V2Ray/Protocols/VMess/InboundConfigurationObject.cs
  19. +1
    -3
      Shadowsocks.Interop/V2Ray/Protocols/VMess/UserObject.cs
  20. +1
    -2
      Shadowsocks.Interop/V2Ray/Reverse/BridgeObject.cs
  21. +22
    -24
      Shadowsocks.Interop/V2Ray/Routing/RuleObject.cs
  22. +6
    -2
      Shadowsocks.Interop/V2Ray/RoutingObject.cs
  23. +16
    -8
      Shadowsocks.Interop/V2Ray/Transport/CertificateObject.cs
  24. +4
    -6
      Shadowsocks.Interop/V2Ray/Transport/SockoptObject.cs
  25. +9
    -10
      Shadowsocks.Interop/V2Ray/Transport/StreamSettingsObject.cs
  26. +5
    -0
      Shadowsocks.Interop/V2Ray/Transport/TcpObject.cs
  27. +3
    -16
      Shadowsocks.Interop/V2Ray/Transport/TlsObject.cs
  28. +2
    -0
      Shadowsocks.Interop/V2Ray/Transport/WebSocketObject.cs
  29. +6
    -16
      Shadowsocks.Interop/V2Ray/TransportObject.cs
  30. +2
    -2
      Shadowsocks.Net/Shadowsocks.Net.csproj
  31. +1
    -1
      Shadowsocks.Protobuf/Shadowsocks.Protobuf.csproj

+ 3
- 13
Shadowsocks.Interop/SsRust/Config.cs View File

@@ -10,7 +10,6 @@ namespace Shadowsocks.Interop.SsRust
public int Version { get; set; } public int Version { get; set; }


/// <inheritdoc/> /// <inheritdoc/>
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public List<Server> Servers { get; set; } public List<Server> Servers { get; set; }


/// <summary> /// <summary>
@@ -21,14 +20,13 @@ namespace Shadowsocks.Interop.SsRust
/// <summary> /// <summary>
/// Gets or sets the listening port. /// Gets or sets the listening port.
/// </summary> /// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int LocalPort { get; set; } public int LocalPort { get; set; }


/// <summary> /// <summary>
/// Gets or sets the timeout for UDP associations in seconds. /// Gets or sets the timeout for UDP associations in seconds.
/// Defaults to 300 seconds (5 minutes). /// Defaults to 300 seconds (5 minutes).
/// </summary> /// </summary>
public int UdpTimeout { get; set; }
public int? UdpTimeout { get; set; }


/// <summary> /// <summary>
/// Gets or sets the maximum number of UDP associations. /// Gets or sets the maximum number of UDP associations.
@@ -39,7 +37,7 @@ namespace Shadowsocks.Interop.SsRust
/// <summary> /// <summary>
/// Gets or sets the server manager address. /// Gets or sets the server manager address.
/// </summary> /// </summary>
public string ManagerAddress { get; set; }
public string? ManagerAddress { get; set; }


/// <summary> /// <summary>
/// Gets or sets the server manager port. /// Gets or sets the server manager port.
@@ -49,7 +47,7 @@ namespace Shadowsocks.Interop.SsRust
/// <summary> /// <summary>
/// Gets or sets the DNS server used to resolve hostnames. /// Gets or sets the DNS server used to resolve hostnames.
/// </summary> /// </summary>
public string Dns { get; set; }
public string? Dns { get; set; }


/// <summary> /// <summary>
/// Gets or sets the mode. /// Gets or sets the mode.
@@ -81,15 +79,7 @@ namespace Shadowsocks.Interop.SsRust
Servers = new(); Servers = new();
LocalAddress = ""; LocalAddress = "";
LocalPort = 1080; LocalPort = 1080;
UdpTimeout = 300;
UdpMaxAssociations = 0;
ManagerAddress = "";
ManagerPort = 0;
Dns = "";
Mode = "tcp_only"; Mode = "tcp_only";
NoDelay = false;
Nofile = 0;
Ipv6First = false;
} }


/// <summary> /// <summary>


+ 42
- 0
Shadowsocks.Interop/Utils/JsonHelper.cs View File

@@ -0,0 +1,42 @@
using Shadowsocks.Models;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Shadowsocks.Interop.Utils
{
public static class JsonHelper
{
public static readonly JsonSerializerOptions camelCaseJsonSerializerOptions = new JsonSerializerOptions()
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
};

public static readonly JsonSerializerOptions snakeCaseJsonSerializerOptions = new JsonSerializerOptions()
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
PropertyNamingPolicy = new JsonSnakeCaseNamingPolicy(),
WriteIndented = true,
};

public static readonly JsonSerializerOptions camelCaseJsonDeserializerOptions = new JsonSerializerOptions()
{
AllowTrailingCommas = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
ReadCommentHandling = JsonCommentHandling.Skip,
WriteIndented = true,
};

public static readonly JsonSerializerOptions snakeCaseJsonDeserializerOptions = new JsonSerializerOptions()
{
AllowTrailingCommas = true,
PropertyNamingPolicy = new JsonSnakeCaseNamingPolicy(),
ReadCommentHandling = JsonCommentHandling.Skip,
WriteIndented = true,
};
}
}

+ 7
- 17
Shadowsocks.Interop/V2Ray/Config.cs View File

@@ -4,30 +4,22 @@ namespace Shadowsocks.Interop.V2Ray
{ {
public class Config public class Config
{ {
public LogObject Log { get; set; }
public ApiObject Api { get; set; }
public DnsObject Dns { get; set; }
public LogObject? Log { get; set; }
public ApiObject? Api { get; set; }
public DnsObject? Dns { get; set; }
public RoutingObject Routing { get; set; } public RoutingObject Routing { get; set; }
public PolicyObject Policy { get; set; }
public PolicyObject? Policy { get; set; }
public InboundObject Inbounds { get; set; } public InboundObject Inbounds { get; set; }
public OutboundObject Outbounds { get; set; } public OutboundObject Outbounds { get; set; }
public TransportObject Transport { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public TransportObject? Transport { get; set; }
public StatsObject? Stats { get; set; } public StatsObject? Stats { get; set; }
public ReverseObject Reverse { get; set; }
public ReverseObject? Reverse { get; set; }
public Config(bool stats = true)
public Config()
{ {
Log = new();
Api = new();
Dns = new();
Routing = new(); Routing = new();
Policy = new();
Inbounds = new(); Inbounds = new();
Outbounds = new(); Outbounds = new();
Transport = new();
Stats = stats ? new() : null;
Reverse = new();
} }


/// <summary> /// <summary>
@@ -42,9 +34,7 @@ namespace Shadowsocks.Interop.V2Ray
Policy = PolicyObject.Default, Policy = PolicyObject.Default,
Inbounds = new(), Inbounds = new(),
Outbounds = new(), Outbounds = new(),
Transport = new(),
Stats = new(), Stats = new(),
Reverse = new(),
}; };
} }
} }

+ 7
- 0
Shadowsocks.Interop/V2Ray/DnsObject.cs View File

@@ -18,6 +18,13 @@ namespace Shadowsocks.Interop.V2Ray
/// </summary> /// </summary>
public List<object> Servers { get; set; } public List<object> Servers { get; set; }


/// <summary>
/// Gets or sets the client IP used when sending requests to DNS server.
/// </summary>
public string? ClientIp { get; set; }

public string? Tag { get; set; }

public DnsObject() public DnsObject()
{ {
Hosts = new(); Hosts = new();


+ 8
- 4
Shadowsocks.Interop/V2Ray/Inbound/AllocateObject.cs View File

@@ -13,19 +13,23 @@ namespace Shadowsocks.Interop.V2Ray.Inbound
/// Gets or sets the random port refreshing interval in minutes. /// Gets or sets the random port refreshing interval in minutes.
/// Defaults to 5 minutes. /// Defaults to 5 minutes.
/// </summary> /// </summary>
public int Refresh { get; set; }
public int? Refresh { get; set; }


/// <summary> /// <summary>
/// Gets or sets the number of random ports. /// Gets or sets the number of random ports.
/// Defaults to 3. /// Defaults to 3.
/// </summary> /// </summary>
public int Concurrency { get; set; }
public int? Concurrency { get; set; }


public AllocateObject() public AllocateObject()
{ {
Strategy = "always"; Strategy = "always";
Refresh = 5;
Concurrency = 3;
} }

public static AllocateObject Default => new()
{
Refresh = 5,
Concurrency = 3,
};
} }
} }

+ 5
- 11
Shadowsocks.Interop/V2Ray/InboundObject.cs View File

@@ -6,24 +6,18 @@ namespace Shadowsocks.Interop.V2Ray
public class InboundObject public class InboundObject
{ {
public string Tag { get; set; } public string Tag { get; set; }
public string Listen { get; set; }
public object Port { get; set; }
public string? Listen { get; set; }
public object? Port { get; set; }
public string Protocol { get; set; } public string Protocol { get; set; }
public object? Settings { get; set; } public object? Settings { get; set; }
public StreamSettingsObject StreamSettings { get; set; }
public SniffingObject Sniffing { get; set; }
public AllocateObject Allocate { get; set; }
public StreamSettingsObject? StreamSettings { get; set; }
public SniffingObject? Sniffing { get; set; }
public AllocateObject? Allocate { get; set; }


public InboundObject() public InboundObject()
{ {
Tag = ""; Tag = "";
Listen = "0.0.0.0";
Port = "";
Protocol = ""; Protocol = "";
Settings = null;
StreamSettings = new();
Sniffing = new();
Allocate = new();
} }


public static InboundObject DefaultLocalSocks => new() public static InboundObject DefaultLocalSocks => new()


+ 4
- 9
Shadowsocks.Interop/V2Ray/OutboundObject.cs View File

@@ -8,22 +8,17 @@ namespace Shadowsocks.Interop.V2Ray
public class OutboundObject public class OutboundObject
{ {
public string Tag { get; set; } public string Tag { get; set; }
public string SendThrough { get; set; }
public string? SendThrough { get; set; }
public string Protocol { get; set; } public string Protocol { get; set; }
public object? Settings { get; set; } public object? Settings { get; set; }
public StreamSettingsObject StreamSettings { get; set; }
public ProxySettingsObject ProxySettings { get; set; }
public MuxObject Mux { get; set; }
public StreamSettingsObject? StreamSettings { get; set; }
public ProxySettingsObject? ProxySettings { get; set; }
public MuxObject? Mux { get; set; }


public OutboundObject() public OutboundObject()
{ {
Tag = ""; Tag = "";
SendThrough = "0.0.0.0";
Protocol = ""; Protocol = "";
Settings = null;
StreamSettings = new();
ProxySettings = new();
Mux = new();
} }


/// <summary> /// <summary>


+ 16
- 16
Shadowsocks.Interop/V2Ray/Policy/LevelPolicyObject.cs View File

@@ -2,23 +2,23 @@ namespace Shadowsocks.Interop.V2Ray.Policy
{ {
public class LevelPolicyObject public class LevelPolicyObject
{ {
public int Handshake { get; set; }
public int ConnIdle { get; set; }
public int UplinkOnly { get; set; }
public int DownlinkOnly { get; set; }
public bool StatsUserUplink { get; set; }
public bool StatsUserDownlink { get; set; }
public int BufferSize { get; set; }
public int? Handshake { get; set; }
public int? ConnIdle { get; set; }
public int? UplinkOnly { get; set; }
public int? DownlinkOnly { get; set; }
public bool? StatsUserUplink { get; set; }
public bool? StatsUserDownlink { get; set; }
public int? BufferSize { get; set; }


public LevelPolicyObject()
public static LevelPolicyObject Default => new()
{ {
Handshake = 4;
ConnIdle = 300;
UplinkOnly = 2;
DownlinkOnly = 5;
StatsUserUplink = false;
StatsUserDownlink = false;
BufferSize = 512;
}
Handshake = 4,
ConnIdle = 300,
UplinkOnly = 2,
DownlinkOnly = 5,
StatsUserUplink = false,
StatsUserDownlink = false,
BufferSize = 512,
};
} }
} }

+ 2
- 8
Shadowsocks.Interop/V2Ray/PolicyObject.cs View File

@@ -5,14 +5,8 @@ namespace Shadowsocks.Interop.V2Ray
{ {
public class PolicyObject public class PolicyObject
{ {
public Dictionary<string, LevelPolicyObject> Levels { get; set; }
public SystemPolicyObject System { get; set; }

public PolicyObject()
{
Levels = new();
System = new();
}
public Dictionary<string, LevelPolicyObject>? Levels { get; set; }
public SystemPolicyObject? System { get; set; }


/// <summary> /// <summary>
/// Gets the default policy object. /// Gets the default policy object.


+ 2
- 4
Shadowsocks.Interop/V2Ray/Protocols/Freedom/OutboundConfigurationObject.cs View File

@@ -3,14 +3,12 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Freedom
public class OutboundConfigurationObject public class OutboundConfigurationObject
{ {
public string DomainStrategy { get; set; } public string DomainStrategy { get; set; }
public string Redirect { get; set; }
public int UserLevel { get; set; }
public string? Redirect { get; set; }
public int? UserLevel { get; set; }


public OutboundConfigurationObject() public OutboundConfigurationObject()
{ {
DomainStrategy = "AsIs"; DomainStrategy = "AsIs";
Redirect = "";
UserLevel = 0;
} }
} }
} }

+ 2
- 7
Shadowsocks.Interop/V2Ray/Protocols/Shadowsocks/InboundConfigurationObject.cs View File

@@ -5,25 +5,20 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Shadowsocks
{ {
public class InboundConfigurationObject public class InboundConfigurationObject
{ {
public string Email { get; set; }
public string? Email { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Method { get; set; } public string Method { get; set; }


[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Password { get; set; } public string Password { get; set; }


public int Level { get; set; }
public int? Level { get; set; }


[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Network { get; set; } public string Network { get; set; }


public InboundConfigurationObject() public InboundConfigurationObject()
{ {
Email = "";
Method = "chacha20-ietf-poly1305"; Method = "chacha20-ietf-poly1305";
Password = new Guid().ToString(); Password = new Guid().ToString();
Level = 0;
Network = "tcp,udp"; Network = "tcp,udp";
} }
} }


+ 2
- 10
Shadowsocks.Interop/V2Ray/Protocols/Shadowsocks/ServerObject.cs View File

@@ -4,40 +4,32 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Shadowsocks
{ {
public class ServerObject public class ServerObject
{ {
public string Email { get; set; }
public string? Email { get; set; }


[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Address { get; set; } public string Address { get; set; }


[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Port { get; set; } public int Port { get; set; }


[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Method { get; set; } public string Method { get; set; }


[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Password { get; set; } public string Password { get; set; }


public int Level { get; set; }
public int? Level { get; set; }


public ServerObject() public ServerObject()
{ {
Email = "";
Address = ""; Address = "";
Port = 8388; Port = 8388;
Method = "chacha20-ietf-poly1305"; Method = "chacha20-ietf-poly1305";
Password = ""; Password = "";
Level = 0;
} }


public ServerObject(string address, int port, string method, string password) public ServerObject(string address, int port, string method, string password)
{ {
Email = "";
Address = address; Address = address;
Port = port; Port = port;
Method = method; Method = method;
Password = password; Password = password;
Level = 0;
} }
} }
} }

+ 6
- 14
Shadowsocks.Interop/V2Ray/Protocols/Socks/InboundConfigurationObject.cs View File

@@ -4,24 +4,16 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Socks
{ {
public class InboundConfigurationObject public class InboundConfigurationObject
{ {
public string Auth { get; set; }
public List<AccountObject> Accounts { get; set; }
public bool Udp { get; set; }
public string Ip { get; set; }
public int UserLevel { get; set; }

public InboundConfigurationObject()
{
Auth = "noauth";
Accounts = new();
Udp = false;
Ip = "127.0.0.1";
UserLevel = 0;
}
public string? Auth { get; set; }
public List<AccountObject>? Accounts { get; set; }
public bool? Udp { get; set; }
public string? Ip { get; set; }
public int? UserLevel { get; set; }


public static InboundConfigurationObject Default => new() public static InboundConfigurationObject Default => new()
{ {
Udp = true, Udp = true,
Ip = "127.0.0.1",
}; };
} }
} }

+ 12
- 7
Shadowsocks.Interop/V2Ray/Protocols/Socks/ServerObject.cs View File

@@ -7,27 +7,32 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Socks
{ {
public string Address { get; set; } public string Address { get; set; }
public int Port { get; set; } public int Port { get; set; }
public List<UserObject> Users { get; set; }
public List<UserObject>? Users { get; set; }


public ServerObject() public ServerObject()
{ {
Address = ""; Address = "";
Port = 0; Port = 0;
Users = new();
} }


public ServerObject(DnsEndPoint socksEndPoint, string username = "", string password = "")
public ServerObject(DnsEndPoint socksEndPoint, string? username = null, string? password = null)
{ {
Address = socksEndPoint.Host; Address = socksEndPoint.Host;
Port = socksEndPoint.Port; Port = socksEndPoint.Port;
Users = new(); Users = new();
var hasCredential = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password); var hasCredential = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password);
if (hasCredential) if (hasCredential)
Users.Add(new()
{
var user = new UserObject()
{
User = username!, // null check already performed at line 23.
Pass = password!,
};
Users = new()
{ {
User = username,
Pass = password,
});
user,
};
}
} }
} }
} }

+ 2
- 4
Shadowsocks.Interop/V2Ray/Protocols/Trojan/ClientObject.cs View File

@@ -3,14 +3,12 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Trojan
public class ClientObject public class ClientObject
{ {
public string Password { get; set; } public string Password { get; set; }
public string Email { get; set; }
public int Level { get; set; }
public string? Email { get; set; }
public int? Level { get; set; }


public ClientObject() public ClientObject()
{ {
Password = ""; Password = "";
Email = "";
Level = 0;
} }
} }
} }

+ 10
- 6
Shadowsocks.Interop/V2Ray/Protocols/Trojan/FallbackObject.cs View File

@@ -2,17 +2,21 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Trojan
{ {
public class FallbackObject public class FallbackObject
{ {
public string Alpn { get; set; }
public string Path { get; set; }
public string? Alpn { get; set; }
public string? Path { get; set; }
public object Dest { get; set; } public object Dest { get; set; }
public int Xver { get; set; }
public int? Xver { get; set; }


public FallbackObject() public FallbackObject()
{ {
Alpn = "";
Path = "";
Dest = 0; Dest = 0;
Xver = 0;
} }

public static FallbackObject Default => new()
{
Alpn = "",
Path = "",
Xver = 0,
};
} }
} }

+ 2
- 6
Shadowsocks.Interop/V2Ray/Protocols/Trojan/ServerObject.cs View File

@@ -5,16 +5,14 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Trojan
public string Address { get; set; } public string Address { get; set; }
public int Port { get; set; } public int Port { get; set; }
public string Password { get; set; } public string Password { get; set; }
public string Email { get; set; }
public int Level { get; set; }
public string? Email { get; set; }
public int? Level { get; set; }


public ServerObject() public ServerObject()
{ {
Address = ""; Address = "";
Port = 0; Port = 0;
Password = ""; Password = "";
Email = "";
Level = 0;
} }


public ServerObject(string address, int port, string password) public ServerObject(string address, int port, string password)
@@ -22,8 +20,6 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Trojan
Address = address; Address = address;
Port = port; Port = port;
Password = password; Password = password;
Email = "";
Level = 0;
} }
} }
} }

+ 2
- 4
Shadowsocks.Interop/V2Ray/Protocols/VMess/InboundConfigurationObject.cs View File

@@ -5,14 +5,12 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.VMess
public class InboundConfigurationObject public class InboundConfigurationObject
{ {
public List<UserObject> Clients { get; set; } public List<UserObject> Clients { get; set; }
public UserObject Default { get; set; }
public DetourObject Detour { get; set; }
public UserObject? Default { get; set; }
public DetourObject? Detour { get; set; }


public InboundConfigurationObject() public InboundConfigurationObject()
{ {
Clients = new(); Clients = new();
Default = new();
Detour = new();
} }
} }
} }

+ 1
- 3
Shadowsocks.Interop/V2Ray/Protocols/VMess/UserObject.cs View File

@@ -8,14 +8,12 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.VMess
public class UserObject public class UserObject
{ {
public string Id { get; set; } public string Id { get; set; }
public string Email { get; set; }
public string? Email { get; set; }
public int Level { get; set; } public int Level { get; set; }


public UserObject(string id = "") public UserObject(string id = "")
{ {
Id = id; Id = id;
Email = "";
Level = 0;
} }


public static UserObject Default => new() public static UserObject Default => new()


+ 1
- 2
Shadowsocks.Interop/V2Ray/Reverse/BridgeObject.cs View File

@@ -11,12 +11,11 @@ namespace Shadowsocks.Interop.V2Ray.Reverse
/// Gets or sets the domain name for the bridge. /// Gets or sets the domain name for the bridge.
/// Can be omitted. /// Can be omitted.
/// </summary> /// </summary>
public string Domain { get; set; }
public string? Domain { get; set; }


public BridgeObject() public BridgeObject()
{ {
Tag = ""; Tag = "";
Domain = "";
} }
} }
} }

+ 22
- 24
Shadowsocks.Interop/V2Ray/Routing/RuleObject.cs View File

@@ -7,34 +7,32 @@ namespace Shadowsocks.Interop.V2Ray.Routing
{ {
[JsonIgnore(Condition = JsonIgnoreCondition.Never)] [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Type { get; set; } public string Type { get; set; }
public List<string> Domain { get; set; }
public List<string> Ip { get; set; }
public object Port { get; set; }
public object SourcePort { get; set; }
public string Network { get; set; }
public List<string> Source { get; set; }
public List<string> User { get; set; }
public List<string> InboundTag { get; set; }
public List<string> Protocol { get; set; }
public string Attrs { get; set; }
public string OutboundTag { get; set; }
public string BalancerTag { get; set; }
public List<string>? Domain { get; set; }
public List<string>? Ip { get; set; }
public object? Port { get; set; }
public object? SourcePort { get; set; }
public string? Network { get; set; }
public List<string>? Source { get; set; }
public List<string>? User { get; set; }
public List<string>? InboundTag { get; set; }
public List<string>? Protocol { get; set; }
public string? Attrs { get; set; }
public string? OutboundTag { get; set; }
public string? BalancerTag { get; set; }


public RuleObject() public RuleObject()
{ {
Type = "field"; Type = "field";
Domain = new();
Ip = new();
Port = "";
SourcePort = "";
Network = "";
Source = new();
User = new();
InboundTag = new();
Protocol = new();
Attrs = "";
OutboundTag = "";
BalancerTag = "";
} }

public static RuleObject DefaultOutbound => new()
{
OutboundTag = "",
};

public static RuleObject DefaultBalancer => new()
{
BalancerTag = "",
};
} }
} }

+ 6
- 2
Shadowsocks.Interop/V2Ray/RoutingObject.cs View File

@@ -20,13 +20,17 @@ namespace Shadowsocks.Interop.V2Ray
/// <summary> /// <summary>
/// Gets or sets the list of load balancers. /// Gets or sets the list of load balancers.
/// </summary> /// </summary>
public List<BalancerObject> Balancers { get; set; }
public List<BalancerObject>? Balancers { get; set; }


public RoutingObject() public RoutingObject()
{ {
DomainStrategy = "AsIs"; DomainStrategy = "AsIs";
Rules = new(); Rules = new();
Balancers = new();
} }

public static RoutingObject DefaultBalancers => new()
{
Balancers = new(),
};
} }
} }

+ 16
- 8
Shadowsocks.Interop/V2Ray/Transport/CertificateObject.cs View File

@@ -5,18 +5,26 @@ namespace Shadowsocks.Interop.V2Ray.Transport
public class CertificateObject public class CertificateObject
{ {
public string Usage { get; set; } public string Usage { get; set; }
public string CertificateFile { get; set; }
public string KeyFile { get; set; }
public List<string> Certificate { get; set; }
public List<string> Key { get; set; }
public string? CertificateFile { get; set; }
public string? KeyFile { get; set; }
public List<string>? Certificate { get; set; }
public List<string>? Key { get; set; }


public CertificateObject() public CertificateObject()
{ {
Usage = "encipherment"; Usage = "encipherment";
CertificateFile = "";
KeyFile = "";
Certificate = new();
Key = new();
} }

public static CertificateObject DefaultFromFile => new()
{
CertificateFile = "",
KeyFile = "",
};

public static CertificateObject DefaultEmbedded => new()
{
Certificate = new(),
Key = new(),
};
} }
} }

+ 4
- 6
Shadowsocks.Interop/V2Ray/Transport/SockoptObject.cs View File

@@ -4,13 +4,11 @@ namespace Shadowsocks.Interop.V2Ray.Transport
{ {
public int Mark { get; set; } public int Mark { get; set; }
public bool TcpFastOpen { get; set; } public bool TcpFastOpen { get; set; }
public string Tproxy { get; set; }
public string? Tproxy { get; set; }


public SockoptObject()
public static SockoptObject DefaultLinux => new()
{ {
Mark = 0;
TcpFastOpen = false;
Tproxy = "off";
}
Tproxy = "off",
};
} }
} }

+ 9
- 10
Shadowsocks.Interop/V2Ray/Transport/StreamSettingsObject.cs View File

@@ -7,24 +7,23 @@ namespace Shadowsocks.Interop.V2Ray.Transport
/// Defaults to "tcp". /// Defaults to "tcp".
/// Available values: "tcp" | "kcp" | "ws" | "http" | "domainsocket" | "quic" /// Available values: "tcp" | "kcp" | "ws" | "http" | "domainsocket" | "quic"
/// </summary> /// </summary>
public string Network { get; set; }
public string? Network { get; set; }


/// <summary> /// <summary>
/// Gets or sets the transport encryption type. /// Gets or sets the transport encryption type.
/// Defaults to "none" (no encryption). /// Defaults to "none" (no encryption).
/// Available values: "none" | "tls" /// Available values: "none" | "tls"
/// </summary> /// </summary>
public string Security { get; set; }
public string? Security { get; set; }


public TlsObject TlsSettings { get; set; }
public SockoptObject Sockopt { get; set; }
public TlsObject? TlsSettings { get; set; }
public SockoptObject? Sockopt { get; set; }


public StreamSettingsObject()
public static StreamSettingsObject DefaultWsTls => new()
{ {
Network = "tcp";
Security = "none";
TlsSettings = new();
Sockopt = new();
}
Network = "ws",
Security = "tls",
TlsSettings = new(),
};
} }
} }

+ 5
- 0
Shadowsocks.Interop/V2Ray/Transport/TcpObject.cs View File

@@ -19,5 +19,10 @@ namespace Shadowsocks.Interop.V2Ray.Transport
AcceptProxyProtocol = false; AcceptProxyProtocol = false;
Header = new HeaderObject(); Header = new HeaderObject();
} }

public static TcpObject DefaultHttp => new()
{
Header = new HttpHeaderObject(),
};
} }
} }

+ 3
- 16
Shadowsocks.Interop/V2Ray/Transport/TlsObject.cs View File

@@ -4,23 +4,10 @@ namespace Shadowsocks.Interop.V2Ray.Transport
{ {
public class TlsObject public class TlsObject
{ {
public string ServerName { get; set; }
public string? ServerName { get; set; }
public bool AllowInsecure { get; set; } public bool AllowInsecure { get; set; }
public List<string> Alpn { get; set; }
public List<CertificateObject> Certificates { get; set; }
public List<string>? Alpn { get; set; }
public List<CertificateObject>? Certificates { get; set; }
public bool DisableSystemRoot { get; set; } public bool DisableSystemRoot { get; set; }

public TlsObject()
{
ServerName = "";
AllowInsecure = false;
Alpn = new()
{
"h2",
"http/1.1",
};
Certificates = new();
DisableSystemRoot = false;
}
} }
} }

+ 2
- 0
Shadowsocks.Interop/V2Ray/Transport/WebSocketObject.cs View File

@@ -11,11 +11,13 @@ namespace Shadowsocks.Interop.V2Ray.Transport


/// <summary> /// <summary>
/// Gets or sets the HTTP query path. /// Gets or sets the HTTP query path.
/// Defaults to "/".
/// </summary> /// </summary>
public string Path { get; set; } public string Path { get; set; }


/// <summary> /// <summary>
/// Gets or sets HTTP header key-value pairs. /// Gets or sets HTTP header key-value pairs.
/// Defaults to empty.
/// </summary> /// </summary>
public Dictionary<string, string> Headers { get; set; } public Dictionary<string, string> Headers { get; set; }




+ 6
- 16
Shadowsocks.Interop/V2Ray/TransportObject.cs View File

@@ -4,21 +4,11 @@ namespace Shadowsocks.Interop.V2Ray
{ {
public class TransportObject public class TransportObject
{ {
public TcpObject TcpSettings { get; set; }
public KcpObject KcpSettings { get; set; }
public WebSocketObject WsSettings { get; set; }
public HttpObject HttpSettings { get; set; }
public QuicObject QuicSettings { get; set; }
public DomainSocketObject DsSettings { get; set; }

public TransportObject()
{
TcpSettings = new();
KcpSettings = new();
WsSettings = new();
HttpSettings = new();
QuicSettings = new();
DsSettings = new();
}
public TcpObject? TcpSettings { get; set; }
public KcpObject? KcpSettings { get; set; }
public WebSocketObject? WsSettings { get; set; }
public HttpObject? HttpSettings { get; set; }
public QuicObject? QuicSettings { get; set; }
public DomainSocketObject? DsSettings { get; set; }
} }
} }

+ 2
- 2
Shadowsocks.Net/Shadowsocks.Net.csproj View File

@@ -5,8 +5,8 @@
</PropertyGroup> </PropertyGroup>


<ItemGroup> <ItemGroup>
<PackageReference Include="BouncyCastle.NetCore" Version="1.8.6" />
<PackageReference Include="Splat" Version="9.6.1" />
<PackageReference Include="BouncyCastle.NetCore" Version="1.8.8" />
<PackageReference Include="Splat" Version="9.8.1" />
</ItemGroup> </ItemGroup>


<ItemGroup> <ItemGroup>


+ 1
- 1
Shadowsocks.Protobuf/Shadowsocks.Protobuf.csproj View File

@@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>


<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.13.0" />
<PackageReference Include="Google.Protobuf" Version="3.14.0" />
</ItemGroup> </ItemGroup>


</Project> </Project>

Loading…
Cancel
Save