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; }

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

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

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

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

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

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

/// <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 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 PolicyObject Policy { get; set; }
public PolicyObject? Policy { get; set; }
public InboundObject Inbounds { 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 ReverseObject Reverse { get; set; }
public ReverseObject? Reverse { get; set; }
public Config(bool stats = true)
public Config()
{
Log = new();
Api = new();
Dns = new();
Routing = new();
Policy = new();
Inbounds = new();
Outbounds = new();
Transport = new();
Stats = stats ? new() : null;
Reverse = new();
}

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

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

@@ -18,6 +18,13 @@ namespace Shadowsocks.Interop.V2Ray
/// </summary>
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()
{
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.
/// Defaults to 5 minutes.
/// </summary>
public int Refresh { get; set; }
public int? Refresh { get; set; }

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

public AllocateObject()
{
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 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 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()
{
Tag = "";
Listen = "0.0.0.0";
Port = "";
Protocol = "";
Settings = null;
StreamSettings = new();
Sniffing = new();
Allocate = 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 string Tag { get; set; }
public string SendThrough { get; set; }
public string? SendThrough { get; set; }
public string Protocol { 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()
{
Tag = "";
SendThrough = "0.0.0.0";
Protocol = "";
Settings = null;
StreamSettings = new();
ProxySettings = new();
Mux = new();
}

/// <summary>


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

@@ -2,23 +2,23 @@ namespace Shadowsocks.Interop.V2Ray.Policy
{
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 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>
/// 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 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()
{
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 string Email { get; set; }
public string? Email { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Method { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
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 InboundConfigurationObject()
{
Email = "";
Method = "chacha20-ietf-poly1305";
Password = new Guid().ToString();
Level = 0;
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 string Email { get; set; }
public string? Email { get; set; }

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

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

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

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

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

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

public ServerObject(string address, int port, string method, string password)
{
Email = "";
Address = address;
Port = port;
Method = method;
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 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()
{
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 int Port { get; set; }
public List<UserObject> Users { get; set; }
public List<UserObject>? Users { get; set; }

public ServerObject()
{
Address = "";
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;
Port = socksEndPoint.Port;
Users = new();
var hasCredential = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password);
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 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()
{
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 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 int Xver { get; set; }
public int? Xver { get; set; }

public FallbackObject()
{
Alpn = "";
Path = "";
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 int Port { 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()
{
Address = "";
Port = 0;
Password = "";
Email = "";
Level = 0;
}

public ServerObject(string address, int port, string password)
@@ -22,8 +20,6 @@ namespace Shadowsocks.Interop.V2Ray.Protocols.Trojan
Address = address;
Port = port;
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 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()
{
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 string Id { get; set; }
public string Email { get; set; }
public string? Email { get; set; }
public int Level { get; set; }

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

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.
/// Can be omitted.
/// </summary>
public string Domain { get; set; }
public string? Domain { get; set; }

public BridgeObject()
{
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)]
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()
{
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>
/// Gets or sets the list of load balancers.
/// </summary>
public List<BalancerObject> Balancers { get; set; }
public List<BalancerObject>? Balancers { get; set; }

public RoutingObject()
{
DomainStrategy = "AsIs";
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 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()
{
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 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".
/// Available values: "tcp" | "kcp" | "ws" | "http" | "domainsocket" | "quic"
/// </summary>
public string Network { get; set; }
public string? Network { get; set; }

/// <summary>
/// Gets or sets the transport encryption type.
/// Defaults to "none" (no encryption).
/// Available values: "none" | "tls"
/// </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;
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 string ServerName { get; set; }
public string? ServerName { 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 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>
/// Gets or sets the HTTP query path.
/// Defaults to "/".
/// </summary>
public string Path { get; set; }

/// <summary>
/// Gets or sets HTTP header key-value pairs.
/// Defaults to empty.
/// </summary>
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 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>

<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>


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

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

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

</Project>

Loading…
Cancel
Save