mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-12-10 22:25:49 +01:00
Move captive portals config to a dedicated section
Add examples
This commit is contained in:
parent
dfee2aa546
commit
a713e1a517
@ -59,11 +59,13 @@ func HandleCaptivePortalQuery(msg *dns.Msg, question *dns.Question, ips *Captive
|
||||
}
|
||||
} else if question.Qtype == dns.TypeAAAA {
|
||||
for _, xip := range *ips {
|
||||
if ip := xip.To16(); ip != nil {
|
||||
rr := new(dns.AAAA)
|
||||
rr.Hdr = dns.RR_Header{Name: question.Name, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: ttl}
|
||||
rr.AAAA = ip
|
||||
respMsg.Answer = append(respMsg.Answer, rr)
|
||||
if xip.To4() == nil {
|
||||
if ip := xip.To16(); ip != nil {
|
||||
rr := new(dns.AAAA)
|
||||
rr.Hdr = dns.RR_Header{Name: question.Name, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: ttl}
|
||||
rr.AAAA = ip
|
||||
respMsg.Answer = append(respMsg.Answer, rr)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if question.Qtype == dns.TypeHTTPS {
|
||||
@ -154,10 +156,10 @@ func addColdStartListener(proxy *Proxy, ipsMap *CaptivePortalMap, listenAddrStr
|
||||
}
|
||||
|
||||
func ColdStart(proxy *Proxy) (*CaptivePortalHandler, error) {
|
||||
if len(proxy.captivePortalFile) == 0 {
|
||||
if len(proxy.captivePortalMapFile) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
bin, err := ReadTextFile(proxy.captivePortalFile)
|
||||
bin, err := ReadTextFile(proxy.captivePortalMapFile)
|
||||
if err != nil {
|
||||
dlog.Warn(err)
|
||||
return nil, err
|
||||
|
@ -70,7 +70,7 @@ type Config struct {
|
||||
AllowIP AllowIPConfig `toml:"allowed_ips"`
|
||||
ForwardFile string `toml:"forwarding_rules"`
|
||||
CloakFile string `toml:"cloaking_rules"`
|
||||
CaptivePortalFile string `toml:"captive_portal_handler"`
|
||||
CaptivePortals CaptivePortalsConfig `toml:"captive_portals"`
|
||||
StaticsConfig map[string]StaticConfig `toml:"static"`
|
||||
SourcesConfig map[string]SourceConfig `toml:"sources"`
|
||||
BrokenImplementations BrokenImplementationsConfig `toml:"broken_implementations"`
|
||||
@ -272,6 +272,10 @@ type DNS64Config struct {
|
||||
Resolvers []string `toml:"resolver"`
|
||||
}
|
||||
|
||||
type CaptivePortalsConfig struct {
|
||||
MapFile string `toml:"map_file"`
|
||||
}
|
||||
|
||||
type ConfigFlags struct {
|
||||
List *bool
|
||||
ListAll *bool
|
||||
@ -579,7 +583,7 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error {
|
||||
|
||||
proxy.forwardFile = config.ForwardFile
|
||||
proxy.cloakFile = config.CloakFile
|
||||
proxy.captivePortalFile = config.CaptivePortalFile
|
||||
proxy.captivePortalMapFile = config.CaptivePortals.MapFile
|
||||
|
||||
allWeeklyRanges, err := ParseAllWeeklyRanges(config.AllWeeklyRanges)
|
||||
if err != nil {
|
||||
|
@ -1,7 +0,0 @@
|
||||
captive.apple.com 17.253.109.201,17.253.113.202
|
||||
connectivitycheck.gstatic.com 64.233.165.94
|
||||
connectivitycheck.android.com 172.217.20.110
|
||||
www.msftncsi.com 2.19.98.8,2.19.98.59
|
||||
dns.msftncsi.com 131.107.255.255
|
||||
www.msftconnecttest.com 13.107.4.52
|
||||
ipv4only.arpa 192.0.0.170,192.0.0.171
|
@ -346,6 +346,7 @@ reject_ttl = 600
|
||||
# cloak_ttl = 600
|
||||
|
||||
|
||||
|
||||
###########################
|
||||
# DNS cache #
|
||||
###########################
|
||||
@ -381,6 +382,20 @@ cache_neg_max_ttl = 600
|
||||
|
||||
|
||||
|
||||
########################################
|
||||
# Captive portal handling #
|
||||
########################################
|
||||
|
||||
[captive_portals]
|
||||
|
||||
## A file that contains a set of names used by operating systems to
|
||||
## check for connectivity and captive portals, along with hard-coded
|
||||
## IP addresses to return.
|
||||
|
||||
map_file = "example-captive-portals.txt"
|
||||
|
||||
|
||||
|
||||
##################################
|
||||
# Local DoH server #
|
||||
##################################
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
AppVersion = "2.0.44"
|
||||
AppVersion = "2.0.45"
|
||||
DefaultConfigFileName = "dnscrypt-proxy.toml"
|
||||
)
|
||||
|
||||
|
@ -19,6 +19,7 @@ func (plugin *PluginCaptivePortal) Description() string {
|
||||
|
||||
func (plugin *PluginCaptivePortal) Init(proxy *Proxy) error {
|
||||
plugin.captivePortalMap = proxy.captivePortalMap
|
||||
dlog.Notice("Captive portals handler enabled")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ type Proxy struct {
|
||||
nxLogFormat string
|
||||
localDoHCertFile string
|
||||
localDoHCertKeyFile string
|
||||
captivePortalFile string
|
||||
captivePortalMapFile string
|
||||
localDoHPath string
|
||||
mainProto string
|
||||
cloakFile string
|
||||
|
Loading…
Reference in New Issue
Block a user