From 260981ee31b225624bb51b1d31a8b8faf44ba9c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 9 May 2024 20:21:54 +0800 Subject: [PATCH] Add `template.inbounds` --- docs/configuration/template.md | 33 +++++++++++++++++++-------------- option/template.go | 1 + template/render_inbounds.go | 1 + 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/docs/configuration/template.md b/docs/configuration/template.md index e1ba259..c4bfdd4 100644 --- a/docs/configuration/template.md +++ b/docs/configuration/template.md @@ -3,32 +3,33 @@ ```json { "name": "", - + // Global - + "log": {}, "domain_strategy": "", "disable_traffic_bypass": false, "disable_rule_set": false, "remote_resolve": false, - + // DNS - + "dns_default": "", "dns_local": "", "enable_fakeip": false, "pre_dns_rules": [], "custom_dns_rules": [], - + // Inbound - + + "inbounds": [], "disable_tun": false, "disable_system_proxy": false, "custom_tun": {}, "custom_mixed": {}, - + // Outbound - + "extra_groups": [ { "tag": "", @@ -46,9 +47,9 @@ "custom_direct": {}, "custom_selector": {}, "custom_urltest": {}, - + // Route - + "disable_default_rules": false, "pre_rules": [], "custom_rules": [], @@ -57,18 +58,18 @@ "custom_geosite": {}, "custom_rule_set": [], "post_custom_rule_set": [], - + // Experimental - + "disable_cache_file": false, "disable_clash_mode": false, "clash_mode_rule": "", "clash_mode_global": "", "clash_mode_direct": "", "custom_clash_api": {}, - + // Debug - + "pprof_listen": "", "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. +#### inbounds + +List of [Inbound](https://sing-box.sagernet.org/configuration/inbound/). + #### disable_tun Don't generate TUN inbound. diff --git a/option/template.go b/option/template.go index c018cd7..f08265f 100644 --- a/option/template.go +++ b/option/template.go @@ -27,6 +27,7 @@ type Template struct { CustomDNSRules []option.DNSRule `json:"custom_dns_rules,omitempty"` // Inbound + Inbounds []option.Inbound `json:"inbounds,omitempty"` DisableTUN bool `json:"disable_tun,omitempty"` DisableSystemProxy bool `json:"disable_system_proxy,omitempty"` CustomTUN *TypedMessage[option.TunInboundOptions] `json:"custom_tun,omitempty"` diff --git a/template/render_inbounds.go b/template/render_inbounds.go index ecd69f3..d6d39f4 100644 --- a/template/render_inbounds.go +++ b/template/render_inbounds.go @@ -12,6 +12,7 @@ import ( ) func (t *Template) renderInbounds(metadata M.Metadata, options *option.Options) error { + options.Inbounds = t.Inbounds var needSniff bool if !t.DisableTrafficBypass { needSniff = true