From f6d60e9d09514e5610a126c38f5ea7d7e6c21909 Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Fri, 12 May 2023 10:14:06 +0900 Subject: [PATCH] update options --- .../nekohasekai/sagernet/fmt/ConfigBuilder.kt | 3 +- .../java/moe/matsuri/nb4a/SingBoxOptions.java | 651 ++++++++++++------ 2 files changed, 449 insertions(+), 205 deletions(-) diff --git a/app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt b/app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt index 50aa7f1..b7896f2 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt @@ -205,6 +205,7 @@ fun buildConfig( servers = mutableListOf() rules = mutableListOf() + independent_cache = true when (ipv6Mode) { IPv6Mode.DISABLE -> { @@ -568,7 +569,7 @@ fun buildConfig( } } if (rule.network.isNotBlank()) { - network = rule.network + network = listOf(rule.network) } if (rule.source.isNotBlank()) { source_ip_cidr = rule.source.split("\n") diff --git a/app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java b/app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java index 21fe7ba..15d4b1d 100644 --- a/app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java +++ b/app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java @@ -48,14 +48,22 @@ public class SingBoxOptions { public String external_ui; + public String external_ui_download_url; + + public String external_ui_download_detour; + public String secret; public String default_mode; public Boolean store_selected; + public Boolean store_fakeip; + public String cache_file; + public String cache_id; + } public static class SelectorOutboundOptions extends SingBoxOption { @@ -116,6 +124,8 @@ public class SingBoxOptions { public static class DebugOptions extends SingBoxOption { + public String listen; + public Integer gc_percent; public Integer max_stack; @@ -223,6 +233,10 @@ public class SingBoxOptions { @SerializedName("final") public String final_; + public Boolean reverse_mapping; + + public DNSFakeIPOptions fakeip; + // Generate note: nested type DNSClientOptions public String strategy; @@ -230,20 +244,12 @@ public class SingBoxOptions { public Boolean disable_expire; + public Boolean independent_cache; + // End of public DNSClientOptions ; } - public static class DNSClientOptions extends SingBoxOption { - - public String strategy; - - public Boolean disable_cache; - - public Boolean disable_expire; - - } - public static class DNSServerOptions extends SingBoxOption { public String tag; @@ -262,107 +268,25 @@ public class SingBoxOptions { } + public static class DNSClientOptions extends SingBoxOption { - public static class DNSRule extends SingBoxOption { - - public String type; - - // Generate note: option type: public DefaultDNSRule DefaultOptions; - - // Generate note: option type: public LogicalDNSRule LogicalOptions; - - } - - public static class DefaultDNSRule extends SingBoxOption { - - // Generate note: Listable - public List inbound; - - public Integer ip_version; - - // Generate note: Listable - public List query_type; - - public String network; - - // Generate note: Listable - public List auth_user; - - // Generate note: Listable - public List protocol; - - // Generate note: Listable - public List domain; - - // Generate note: Listable - public List domain_suffix; - - // Generate note: Listable - public List domain_keyword; - - // Generate note: Listable - public List domain_regex; - - // Generate note: Listable - public List geosite; - - // Generate note: Listable - public List source_geoip; - - // Generate note: Listable - public List source_ip_cidr; - - // Generate note: Listable - public List source_port; - - // Generate note: Listable - public List source_port_range; - - // Generate note: Listable - public List port; - - // Generate note: Listable - public List port_range; - - // Generate note: Listable - public List process_name; - - // Generate note: Listable - public List process_path; - - // Generate note: Listable - public List package_name; - - // Generate note: Listable - public List user; - - // Generate note: Listable - public List user_id; - - // Generate note: Listable - public List outbound; - - public String clash_mode; - - public Boolean invert; - - public String server; + public String strategy; public Boolean disable_cache; + public Boolean disable_expire; + + public Boolean independent_cache; + } - public static class LogicalDNSRule extends SingBoxOption { + public static class DNSFakeIPOptions extends SingBoxOption { - public String mode; + public Boolean enabled; - public List rules; + public String inet4_range; - public Boolean invert; - - public String server; - - public Boolean disable_cache; + public String inet6_range; } @@ -769,6 +693,8 @@ public class SingBoxOptions { public Integer max_streams; + public Boolean padding; + } public static class OnDemandOptions extends SingBoxOption { @@ -879,6 +805,8 @@ public class SingBoxOptions { public GeositeOptions geosite; + public List ip_rules; + public List rules; @SerializedName("final") @@ -934,7 +862,8 @@ public class SingBoxOptions { public Integer ip_version; - public String network; + // Generate note: Listable + public List network; // Generate note: Listable public List auth_user; @@ -1016,6 +945,198 @@ public class SingBoxOptions { } + + public static class DNSRule extends SingBoxOption { + + public String type; + + // Generate note: option type: public DefaultDNSRule DefaultOptions; + + // Generate note: option type: public LogicalDNSRule LogicalOptions; + + } + + public static class DefaultDNSRule extends SingBoxOption { + + // Generate note: Listable + public List inbound; + + public Integer ip_version; + + // Generate note: Listable + public List query_type; + + // Generate note: Listable + public List network; + + // Generate note: Listable + public List auth_user; + + // Generate note: Listable + public List protocol; + + // Generate note: Listable + public List domain; + + // Generate note: Listable + public List domain_suffix; + + // Generate note: Listable + public List domain_keyword; + + // Generate note: Listable + public List domain_regex; + + // Generate note: Listable + public List geosite; + + // Generate note: Listable + public List source_geoip; + + // Generate note: Listable + public List source_ip_cidr; + + // Generate note: Listable + public List source_port; + + // Generate note: Listable + public List source_port_range; + + // Generate note: Listable + public List port; + + // Generate note: Listable + public List port_range; + + // Generate note: Listable + public List process_name; + + // Generate note: Listable + public List process_path; + + // Generate note: Listable + public List package_name; + + // Generate note: Listable + public List user; + + // Generate note: Listable + public List user_id; + + // Generate note: Listable + public List outbound; + + public String clash_mode; + + public Boolean invert; + + public String server; + + public Boolean disable_cache; + + public Integer rewrite_ttl; + + } + + public static class LogicalDNSRule extends SingBoxOption { + + public String mode; + + public List rules; + + public Boolean invert; + + public String server; + + public Boolean disable_cache; + + public Integer rewrite_ttl; + + } + + + public static class IPRule extends SingBoxOption { + + public String type; + + // Generate note: option type: public DefaultIPRule DefaultOptions; + + // Generate note: option type: public LogicalIPRule LogicalOptions; + + } + + public static class DefaultIPRule extends SingBoxOption { + + // Generate note: Listable + public List inbound; + + public Integer ip_version; + + // Generate note: Listable + public List network; + + // Generate note: Listable + public List domain; + + // Generate note: Listable + public List domain_suffix; + + // Generate note: Listable + public List domain_keyword; + + // Generate note: Listable + public List domain_regex; + + // Generate note: Listable + public List geosite; + + // Generate note: Listable + public List source_geoip; + + // Generate note: Listable + public List geoip; + + // Generate note: Listable + public List source_ip_cidr; + + // Generate note: Listable + public List ip_cidr; + + // Generate note: Listable + public List source_port; + + // Generate note: Listable + public List source_port_range; + + // Generate note: Listable + public List port; + + // Generate note: Listable + public List port_range; + + public Boolean invert; + + public String action; + + public String outbound; + + } + + + public static class LogicalIPRule extends SingBoxOption { + + public String mode; + + public List rules; + + public Boolean invert; + + public String action; + + public String outbound; + + } + public static class ShadowsocksInboundOptions extends SingBoxOption { // Generate note: nested type ListenOptions @@ -1509,6 +1630,10 @@ public class SingBoxOptions { public OutboundTLSOptions tls; + public String path; + + public Map headers; + } public static class SSHOutboundOptions extends SingBoxOption { @@ -1945,6 +2070,8 @@ public class SingBoxOptions { public String stack; + public Boolean experimental_fix_windows_firewall; + public TunPlatformOptions platform; // Generate note: nested type InboundOptions @@ -2165,6 +2292,8 @@ public class SingBoxOptions { public OutboundTLSOptions tls; + public MultiplexOptions multiplex; + public V2RayTransportOptions transport; public String packet_encoding; @@ -2314,13 +2443,6 @@ public class SingBoxOptions { // End of public DialerOptions ; - // Generate note: nested type ServerOptions - public String server; - - public Integer server_port; - - // End of public ServerOptions ; - public Boolean system_interface; public String interface_name; @@ -2330,6 +2452,15 @@ public class SingBoxOptions { public String private_key; + public List peers; + + // Generate note: nested type ServerOptions + public String server; + + public Integer server_port; + + // End of public ServerOptions ; + public String peer_public_key; public String pre_shared_key; @@ -2343,98 +2474,28 @@ public class SingBoxOptions { public String network; - } - - public static class DNSRule_DefaultOptions extends DNSRule { - - // Generate note: Listable - public List inbound; - - public Integer ip_version; - - // Generate note: Listable - public List query_type; - - public String network; - - // Generate note: Listable - public List auth_user; - - // Generate note: Listable - public List protocol; - - // Generate note: Listable - public List domain; - - // Generate note: Listable - public List domain_suffix; - - // Generate note: Listable - public List domain_keyword; - - // Generate note: Listable - public List domain_regex; - - // Generate note: Listable - public List geosite; - - // Generate note: Listable - public List source_geoip; - - // Generate note: Listable - public List source_ip_cidr; - - // Generate note: Listable - public List source_port; - - // Generate note: Listable - public List source_port_range; - - // Generate note: Listable - public List port; - - // Generate note: Listable - public List port_range; - - // Generate note: Listable - public List process_name; - - // Generate note: Listable - public List process_path; - - // Generate note: Listable - public List package_name; - - // Generate note: Listable - public List user; - - // Generate note: Listable - public List user_id; - - // Generate note: Listable - public List outbound; - - public String clash_mode; - - public Boolean invert; - - public String server; - - public Boolean disable_cache; + public Boolean ip_rewrite; } - public static class DNSRule_LogicalOptions extends DNSRule { - - public String mode; - - public List rules; - - public Boolean invert; + public static class WireGuardPeer extends SingBoxOption { + // Generate note: nested type ServerOptions public String server; - public Boolean disable_cache; + public Integer server_port; + + // End of public ServerOptions ; + + public String public_key; + + public String pre_shared_key; + + // Generate note: Listable + public List allowed_ips; + + // Generate note: Base64 String + public String reserved; } @@ -2487,6 +2548,8 @@ public class SingBoxOptions { public String stack; + public Boolean experimental_fix_windows_firewall; + public TunPlatformOptions platform; // Generate note: nested type InboundOptions @@ -3181,6 +3244,10 @@ public class SingBoxOptions { public OutboundTLSOptions tls; + public String path; + + public Map headers; + } public static class Outbound_ShadowsocksOptions extends Outbound { @@ -3374,13 +3441,6 @@ public class SingBoxOptions { // End of public DialerOptions ; - // Generate note: nested type ServerOptions - public String server; - - public Integer server_port; - - // End of public ServerOptions ; - public Boolean system_interface; public String interface_name; @@ -3390,6 +3450,15 @@ public class SingBoxOptions { public String private_key; + public List peers; + + // Generate note: nested type ServerOptions + public String server; + + public Integer server_port; + + // End of public ServerOptions ; + public String peer_public_key; public String pre_shared_key; @@ -3403,6 +3472,8 @@ public class SingBoxOptions { public String network; + public Boolean ip_rewrite; + } public static class Outbound_HysteriaOptions extends Outbound { @@ -3709,6 +3780,8 @@ public class SingBoxOptions { public OutboundTLSOptions tls; + public MultiplexOptions multiplex; + public V2RayTransportOptions transport; public String packet_encoding; @@ -3743,7 +3816,8 @@ public class SingBoxOptions { public Integer ip_version; - public String network; + // Generate note: Listable + public List network; // Generate note: Listable public List auth_user; @@ -3825,6 +3899,175 @@ public class SingBoxOptions { } + public static class DNSRule_DefaultOptions extends DNSRule { + + // Generate note: Listable + public List inbound; + + public Integer ip_version; + + // Generate note: Listable + public List query_type; + + // Generate note: Listable + public List network; + + // Generate note: Listable + public List auth_user; + + // Generate note: Listable + public List protocol; + + // Generate note: Listable + public List domain; + + // Generate note: Listable + public List domain_suffix; + + // Generate note: Listable + public List domain_keyword; + + // Generate note: Listable + public List domain_regex; + + // Generate note: Listable + public List geosite; + + // Generate note: Listable + public List source_geoip; + + // Generate note: Listable + public List source_ip_cidr; + + // Generate note: Listable + public List source_port; + + // Generate note: Listable + public List source_port_range; + + // Generate note: Listable + public List port; + + // Generate note: Listable + public List port_range; + + // Generate note: Listable + public List process_name; + + // Generate note: Listable + public List process_path; + + // Generate note: Listable + public List package_name; + + // Generate note: Listable + public List user; + + // Generate note: Listable + public List user_id; + + // Generate note: Listable + public List outbound; + + public String clash_mode; + + public Boolean invert; + + public String server; + + public Boolean disable_cache; + + public Integer rewrite_ttl; + + } + + public static class DNSRule_LogicalOptions extends DNSRule { + + public String mode; + + public List rules; + + public Boolean invert; + + public String server; + + public Boolean disable_cache; + + public Integer rewrite_ttl; + + } + + public static class IPRule_DefaultOptions extends IPRule { + + // Generate note: Listable + public List inbound; + + public Integer ip_version; + + // Generate note: Listable + public List network; + + // Generate note: Listable + public List domain; + + // Generate note: Listable + public List domain_suffix; + + // Generate note: Listable + public List domain_keyword; + + // Generate note: Listable + public List domain_regex; + + // Generate note: Listable + public List geosite; + + // Generate note: Listable + public List source_geoip; + + // Generate note: Listable + public List geoip; + + // Generate note: Listable + public List source_ip_cidr; + + // Generate note: Listable + public List ip_cidr; + + // Generate note: Listable + public List source_port; + + // Generate note: Listable + public List source_port_range; + + // Generate note: Listable + public List port; + + // Generate note: Listable + public List port_range; + + public Boolean invert; + + public String action; + + public String outbound; + + } + + public static class IPRule_LogicalOptions extends IPRule { + + public String mode; + + public List rules; + + public Boolean invert; + + public String action; + + public String outbound; + + } + public static class V2RayTransportOptions_HTTPOptions extends V2RayTransportOptions { // Generate note: Listable