diff --git a/Shadowsocks.Interop/V2Ray/Config.cs b/Shadowsocks.Interop/V2Ray/Config.cs index a6682104..2f23f5d7 100644 --- a/Shadowsocks.Interop/V2Ray/Config.cs +++ b/Shadowsocks.Interop/V2Ray/Config.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Text.Json.Serialization; namespace Shadowsocks.Interop.V2Ray { diff --git a/Shadowsocks.Interop/V2Ray/Dns/ServerObject.cs b/Shadowsocks.Interop/V2Ray/Dns/ServerObject.cs index c9a56681..d340e5b2 100644 --- a/Shadowsocks.Interop/V2Ray/Dns/ServerObject.cs +++ b/Shadowsocks.Interop/V2Ray/Dns/ServerObject.cs @@ -16,6 +16,12 @@ namespace Shadowsocks.Interop.V2Ray.Dns /// public int Port { get; set; } + /// + /// Gets or sets the client IP + /// to include in DNS queries. + /// + public string? ClientIp { get; set; } + /// /// Gets or sets the list of domains /// that prefers this DNS server. diff --git a/Shadowsocks.Interop/V2Ray/DnsObject.cs b/Shadowsocks.Interop/V2Ray/DnsObject.cs index 23381319..1fc15c4f 100644 --- a/Shadowsocks.Interop/V2Ray/DnsObject.cs +++ b/Shadowsocks.Interop/V2Ray/DnsObject.cs @@ -23,6 +23,15 @@ namespace Shadowsocks.Interop.V2Ray /// public string? ClientIp { get; set; } + /// + /// Gets or sets whether to disable internal DNS cache. + /// Defaults to false, or DNS cache is enabled. + /// + public bool DisableCache { get; set; } + + /// + /// Gets or sets the inbound tag for DNS traffic. + /// public string? Tag { get; set; } public DnsObject() diff --git a/Shadowsocks.Interop/V2Ray/FakeDnsObject.cs b/Shadowsocks.Interop/V2Ray/FakeDnsObject.cs new file mode 100644 index 00000000..40af739d --- /dev/null +++ b/Shadowsocks.Interop/V2Ray/FakeDnsObject.cs @@ -0,0 +1,15 @@ +namespace Shadowsocks.Interop.V2Ray +{ + public class FakeDnsObject + { + /// + /// Gets or sets the IP pool CIDR. + /// + public string IpPool { get; set; } = "240.0.0.0/8"; + + /// + /// Gets or sets the IP pool size. + /// + public long PoolSize { get; set; } = 65535L; + } +} diff --git a/Shadowsocks.Interop/V2Ray/Inbound/SniffingObject.cs b/Shadowsocks.Interop/V2Ray/Inbound/SniffingObject.cs index 23c41336..07d97bca 100644 --- a/Shadowsocks.Interop/V2Ray/Inbound/SniffingObject.cs +++ b/Shadowsocks.Interop/V2Ray/Inbound/SniffingObject.cs @@ -15,6 +15,14 @@ namespace Shadowsocks.Interop.V2Ray.Inbound /// public List DestOverride { get; set; } + /// + /// Gets or sets whether the target address is sniffed + /// solely based on metadata. + /// Defaults to false. + /// Change to true to use FakeDNS. + /// + public bool MetadataOnly { get; set; } + public SniffingObject() { Enabled = true; @@ -24,5 +32,27 @@ namespace Shadowsocks.Interop.V2Ray.Inbound "tls", }; } + + public static SniffingObject Default => new() + { + Enabled = false, + DestOverride = new() + { + "http", + "tls", + }, + }; + + public static SniffingObject DefaultFakeDns => new() + { + Enabled = true, + DestOverride = new() + { + "http", + "tls", + "fakedns", + }, + MetadataOnly = true, + }; } } diff --git a/Shadowsocks.Interop/V2Ray/InboundObject.cs b/Shadowsocks.Interop/V2Ray/InboundObject.cs index 94ed120d..9a4afcb1 100644 --- a/Shadowsocks.Interop/V2Ray/InboundObject.cs +++ b/Shadowsocks.Interop/V2Ray/InboundObject.cs @@ -27,10 +27,7 @@ namespace Shadowsocks.Interop.V2Ray Port = 1080, Protocol = "socks", Settings = Protocols.Socks.InboundConfigurationObject.Default, - Sniffing = new() - { - Enabled = false, - }, + Sniffing = SniffingObject.Default, }; public static InboundObject DefaultLocalHttp => new() @@ -39,10 +36,7 @@ namespace Shadowsocks.Interop.V2Ray Listen = "127.0.0.1", Port = 8080, Protocol = "http", - Sniffing = new() - { - Enabled = false, - }, + Sniffing = SniffingObject.Default, }; } } diff --git a/Shadowsocks.Interop/V2Ray/Outbound/ProxySettingsObject.cs b/Shadowsocks.Interop/V2Ray/Outbound/ProxySettingsObject.cs index 6b476d93..2baf2194 100644 --- a/Shadowsocks.Interop/V2Ray/Outbound/ProxySettingsObject.cs +++ b/Shadowsocks.Interop/V2Ray/Outbound/ProxySettingsObject.cs @@ -8,9 +8,23 @@ namespace Shadowsocks.Interop.V2Ray.Outbound /// public string Tag { get; set; } + /// + /// Gets or sets whether to keep the protocol + /// itself's transport layer intact. + /// Defaults to false, or only proxy internal TCP traffic. + /// Set to true to proxy the protocol. + /// The tag will act as a forward proxy. + /// + public bool TransportLayer { get; set; } + public ProxySettingsObject() { Tag = ""; } + + public static ProxySettingsObject Default => new() + { + TransportLayer = true, + }; } } diff --git a/Shadowsocks.Interop/V2Ray/RoutingObject.cs b/Shadowsocks.Interop/V2Ray/RoutingObject.cs index 97aaaea5..093c20e7 100644 --- a/Shadowsocks.Interop/V2Ray/RoutingObject.cs +++ b/Shadowsocks.Interop/V2Ray/RoutingObject.cs @@ -12,6 +12,13 @@ namespace Shadowsocks.Interop.V2Ray /// public string DomainStrategy { get; set; } + /// + /// Gets or sets the domain matcher used for routing. + /// Default value: "" (binary search). + /// Available values: "" | "hybrid" + /// + public string DomainMatcher { get; set; } + /// /// Gets or sets the list of routing rules. /// @@ -25,9 +32,16 @@ namespace Shadowsocks.Interop.V2Ray public RoutingObject() { DomainStrategy = "AsIs"; + DomainMatcher = ""; Rules = new(); } + public static RoutingObject Default => new() + { + DomainStrategy = "IPOnDemand", + DomainMatcher = "hybrid", + }; + public static RoutingObject DefaultBalancers => new() { Balancers = new(),