Add template.inbounds

This commit is contained in:
世界 2024-05-09 20:21:54 +08:00
parent c2f71a1d26
commit 260981ee31
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
3 changed files with 21 additions and 14 deletions

View File

@ -3,32 +3,33 @@
```json ```json
{ {
"name": "", "name": "",
// Global // Global
"log": {}, "log": {},
"domain_strategy": "", "domain_strategy": "",
"disable_traffic_bypass": false, "disable_traffic_bypass": false,
"disable_rule_set": false, "disable_rule_set": false,
"remote_resolve": false, "remote_resolve": false,
// DNS // DNS
"dns_default": "", "dns_default": "",
"dns_local": "", "dns_local": "",
"enable_fakeip": false, "enable_fakeip": false,
"pre_dns_rules": [], "pre_dns_rules": [],
"custom_dns_rules": [], "custom_dns_rules": [],
// Inbound // Inbound
"inbounds": [],
"disable_tun": false, "disable_tun": false,
"disable_system_proxy": false, "disable_system_proxy": false,
"custom_tun": {}, "custom_tun": {},
"custom_mixed": {}, "custom_mixed": {},
// Outbound // Outbound
"extra_groups": [ "extra_groups": [
{ {
"tag": "", "tag": "",
@ -46,9 +47,9 @@
"custom_direct": {}, "custom_direct": {},
"custom_selector": {}, "custom_selector": {},
"custom_urltest": {}, "custom_urltest": {},
// Route // Route
"disable_default_rules": false, "disable_default_rules": false,
"pre_rules": [], "pre_rules": [],
"custom_rules": [], "custom_rules": [],
@ -57,18 +58,18 @@
"custom_geosite": {}, "custom_geosite": {},
"custom_rule_set": [], "custom_rule_set": [],
"post_custom_rule_set": [], "post_custom_rule_set": [],
// Experimental // Experimental
"disable_cache_file": false, "disable_cache_file": false,
"disable_clash_mode": false, "disable_clash_mode": false,
"clash_mode_rule": "", "clash_mode_rule": "",
"clash_mode_global": "", "clash_mode_global": "",
"clash_mode_direct": "", "clash_mode_direct": "",
"custom_clash_api": {}, "custom_clash_api": {},
// Debug // Debug
"pprof_listen": "", "pprof_listen": "",
"memory_limit": "" "memory_limit": ""
} }
@ -136,6 +137,10 @@ List of [DNS Rule](https://sing-box.sagernet.org/configuration/dns/rule/).
No default traffic bypassing DNS rules will be generated if not empty. No default traffic bypassing DNS rules will be generated if not empty.
#### inbounds
List of [Inbound](https://sing-box.sagernet.org/configuration/inbound/).
#### disable_tun #### disable_tun
Don't generate TUN inbound. Don't generate TUN inbound.

View File

@ -27,6 +27,7 @@ type Template struct {
CustomDNSRules []option.DNSRule `json:"custom_dns_rules,omitempty"` CustomDNSRules []option.DNSRule `json:"custom_dns_rules,omitempty"`
// Inbound // Inbound
Inbounds []option.Inbound `json:"inbounds,omitempty"`
DisableTUN bool `json:"disable_tun,omitempty"` DisableTUN bool `json:"disable_tun,omitempty"`
DisableSystemProxy bool `json:"disable_system_proxy,omitempty"` DisableSystemProxy bool `json:"disable_system_proxy,omitempty"`
CustomTUN *TypedMessage[option.TunInboundOptions] `json:"custom_tun,omitempty"` CustomTUN *TypedMessage[option.TunInboundOptions] `json:"custom_tun,omitempty"`

View File

@ -12,6 +12,7 @@ import (
) )
func (t *Template) renderInbounds(metadata M.Metadata, options *option.Options) error { func (t *Template) renderInbounds(metadata M.Metadata, options *option.Options) error {
options.Inbounds = t.Inbounds
var needSniff bool var needSniff bool
if !t.DisableTrafficBypass { if !t.DisableTrafficBypass {
needSniff = true needSniff = true