forked from mirror/serenity
Add template.custom_fakeip
This commit is contained in:
parent
ea777c25b0
commit
774257d003
@ -22,6 +22,7 @@
|
||||
"enable_fakeip": false,
|
||||
"pre_dns_rules": [],
|
||||
"custom_dns_rules": [],
|
||||
"custom_fakeip": {},
|
||||
|
||||
// Inbound
|
||||
|
||||
@ -158,6 +159,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.
|
||||
|
||||
#### custom_fakeip
|
||||
|
||||
Custom [FakeIP](https://sing-box.sagernet.org/configuration/dns/fakeip/) template.
|
||||
|
||||
#### inbounds
|
||||
|
||||
List of [Inbound](https://sing-box.sagernet.org/configuration/inbound/).
|
||||
|
@ -35,6 +35,7 @@ type _Template struct {
|
||||
DisableDNSLeak bool `json:"disable_dns_leak,omitempty"`
|
||||
PreDNSRules []option.DNSRule `json:"pre_dns_rules,omitempty"`
|
||||
CustomDNSRules []option.DNSRule `json:"custom_dns_rules,omitempty"`
|
||||
CustomFakeIP *option.DNSFakeIPOptions `json:"custom_fakeip,omitempty"`
|
||||
|
||||
// Inbound
|
||||
Inbounds []option.Inbound `json:"inbounds,omitempty"`
|
||||
|
@ -94,11 +94,15 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error
|
||||
})
|
||||
}
|
||||
if t.EnableFakeIP {
|
||||
options.DNS.FakeIP = &option.DNSFakeIPOptions{
|
||||
Enabled: true,
|
||||
Inet4Range: common.Ptr(netip.MustParsePrefix("198.18.0.0/15")),
|
||||
options.DNS.FakeIP = t.CustomFakeIP
|
||||
if options.DNS.FakeIP == nil {
|
||||
options.DNS.FakeIP = &option.DNSFakeIPOptions{}
|
||||
}
|
||||
if !t.DisableIPv6() {
|
||||
options.DNS.FakeIP.Enabled = true
|
||||
if !options.DNS.FakeIP.Inet4Range.IsValid() {
|
||||
options.DNS.FakeIP.Inet4Range = common.Ptr(netip.MustParsePrefix("198.18.0.0/15"))
|
||||
}
|
||||
if !t.DisableIPv6() && !options.DNS.FakeIP.Inet6Range.IsValid() {
|
||||
options.DNS.FakeIP.Inet6Range = common.Ptr(netip.MustParsePrefix("fc00::/18"))
|
||||
}
|
||||
options.DNS.Servers = append(options.DNS.Servers, option.DNSServerOptions{
|
||||
|
Loading…
Reference in New Issue
Block a user