From 74ab68f94a9410090c47ece7c378a72d613b0057 Mon Sep 17 00:00:00 2001 From: peanut996 Date: Sat, 7 Dec 2024 18:31:09 +0800 Subject: [PATCH 1/4] add custom rule --- src/SingboxConfigBuilder.js | 1 + src/config.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/SingboxConfigBuilder.js b/src/SingboxConfigBuilder.js index 41a1207c..a4f2ce55 100644 --- a/src/SingboxConfigBuilder.js +++ b/src/SingboxConfigBuilder.js @@ -86,6 +86,7 @@ export class ConfigBuilder extends BaseConfigBuilder { domain_suffix: rule.domain_suffix, domain_keyword: rule.domain_keyword, ip_cidr: rule.ip_cidr, + protocol: rule.protocol, outbound: rule.outbound })); // Add any default rules that should always be present diff --git a/src/config.js b/src/config.js index 2e7cd476..2241d5eb 100644 --- a/src/config.js +++ b/src/config.js @@ -181,6 +181,7 @@ export function generateRules(selectedRules = [], customRules = [], pin) { domain_suffix: rule.domain_suffix ? rule.domain_suffix.split(',') : [], domain_keyword: rule.domain_keyword ? rule.domain_keyword.split(',') : [], ip_cidr: rule.ip_cidr ? rule.ip_cidr.split(',') : [], + protocol: rule.protocol ? rule.protocol.split(',') : [], outbound: rule.name }); }); @@ -194,6 +195,7 @@ export function generateRules(selectedRules = [], customRules = [], pin) { domain_suffix: rule.domain_suffix ? rule.domain_suffix.split(',') : [], domain_keyword: rule.domain_keyword ? rule.domain_keyword.split(',') : [], ip_cidr: rule.ip_cidr ? rule.ip_cidr.split(',') : [], + protocol: rule.protocol ? rule.protocol.split(',') : [], outbound: rule.name }); }); From a8ccdb8443f92e3e3d2a711f6c398eabea825fb1 Mon Sep 17 00:00:00 2001 From: peanut996 Date: Sat, 7 Dec 2024 18:37:53 +0800 Subject: [PATCH 2/4] fix logic for protocol --- src/htmlBuilder.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/htmlBuilder.js b/src/htmlBuilder.js index 967a2fd0..b6b40f8f 100644 --- a/src/htmlBuilder.js +++ b/src/htmlBuilder.js @@ -497,7 +497,8 @@ const submitFormFunction = () => ` name: rule.querySelector('input[name="customRuleName[]"]').value, domain_suffix: rule.querySelector('input[name="customRuleDomainSuffix[]"]').value, domain_keyword: rule.querySelector('input[name="customRuleDomainKeyword[]"]').value, - ip_cidr: rule.querySelector('input[name="customRuleIPCIDR[]"]').value + ip_cidr: rule.querySelector('input[name="customRuleIPCIDR[]"]').value, + protocol: rule.querySelector('input[name="customRuleProtocol[]"]').value })); const configParam = configId ? \`&configId=\${configId}\` : ''; @@ -659,6 +660,16 @@ const customRuleFunctions = ` +
+ + + + + Protocol rules for specific traffic types (e.g., dns, http, tls) + + + +
\`; customRulesDiv.appendChild(newRuleDiv); From 7d4aca46f4111ddda12e86fa5983144678ce88a3 Mon Sep 17 00:00:00 2001 From: peanut996 Date: Sat, 7 Dec 2024 19:10:49 +0800 Subject: [PATCH 3/4] update description and docs --- docs/API-doc.md | 2 ++ src/htmlBuilder.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/API-doc.md b/docs/API-doc.md index 51698717..da8e8617 100644 --- a/docs/API-doc.md +++ b/docs/API-doc.md @@ -160,6 +160,7 @@ Singbox 的规则集来自 [https://github.com/lyc8503/sing-box-rules](https://g - `domain_suffix`: 域名后缀规则数组 - `domain_keyword`: 域名关键词规则数组 - `ip_cidr`: IP CIDR 规则数组 +- `protocol`: 协议规则数组 - `outbound`: 出站名称 示例: @@ -172,6 +173,7 @@ Singbox 的规则集来自 [https://github.com/lyc8503/sing-box-rules](https://g "domain_suffix": [".com", ".org"], "domain_keyword": ["Mijia Cloud", "push.apple"], "ip_cidr": ["192.168.0.0/16", "10.0.0.0/8"], + "protocol": ["http", "tls", "dns"], "outbound": "🤪 MyCustomRule" } ] diff --git a/src/htmlBuilder.js b/src/htmlBuilder.js index b6b40f8f..7d084820 100644 --- a/src/htmlBuilder.js +++ b/src/htmlBuilder.js @@ -665,10 +665,10 @@ const customRuleFunctions = ` - Protocol rules for specific traffic types (e.g., dns, http, tls) + Protocol rules for specific traffic types. More details: https://sing-box.sagernet.org/configuration/route/sniff/ - + \`; From ec42238bd9c97778d2b782e3972a8f724ff36308 Mon Sep 17 00:00:00 2001 From: dinggood615 <38004245+dinggood615@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:23:18 +0800 Subject: [PATCH 4/4] Update base-config.md --- docs/base-config.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/base-config.md b/docs/base-config.md index 0d421f62..25820335 100644 --- a/docs/base-config.md +++ b/docs/base-config.md @@ -143,11 +143,11 @@ dns: - https://223.5.5.5/dns-query nameserver-policy: geosite:cn,private: - - https://120.53.53.53/dns-query - - https://223.5.5.5/dns-query + "https://120.53.53.53/dns-query" + "https://223.5.5.5/dns-query" geosite:geolocation-!cn: - - https://dns.cloudflare.com/dns-query - - https://dns.google/dns-query + "https://dns.cloudflare.com/dns-query" + "https://dns.google/dns-query" ``` ## 注意事项