Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
7Sageer committed Dec 27, 2024
2 parents b30a6f6 + ee23ff9 commit 53df4b6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/API-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Singbox 的规则集来自 [https://github.com/lyc8503/sing-box-rules](https://g
- `domain_suffix`: 域名后缀规则数组
- `domain_keyword`: 域名关键词规则数组
- `ip_cidr`: IP CIDR 规则数组
- `protocol`: 协议规则数组
- `outbound`: 出站名称

示例:
Expand All @@ -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"
}
]
Expand Down
8 changes: 4 additions & 4 deletions docs/base-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
## 注意事项
Expand Down
1 change: 1 addition & 0 deletions src/SingboxConfigBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});
Expand All @@ -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
});
});
Expand Down
13 changes: 12 additions & 1 deletion src/htmlBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}\` : '';
Expand Down Expand Up @@ -659,6 +660,16 @@ const customRuleFunctions = `
<label class="form-label">IP CIDR</label>
<input type="text" class="form-control mb-2" name="customRuleIPCIDR[]" placeholder="IP CIDR (comma separated)">
</div>
<div class="mb-2">
<label class="form-label">Protocol</label>
<span class="tooltip-icon">
<i class="fas fa-question-circle"></i>
<span class="tooltip-content">
Protocol rules for specific traffic types. More details: https://sing-box.sagernet.org/configuration/route/sniff/
</span>
</span>
<input type="text" class="form-control mb-2" name="customRuleProtocol[]" placeholder="Protocol (comma separated, e.g, http,ssh,dns)">
</div>
<button type="button" class="btn btn-danger btn-sm" onclick="removeCustomRule(this)">Remove</button>
\`;
customRulesDiv.appendChild(newRuleDiv);
Expand Down

0 comments on commit 53df4b6

Please sign in to comment.