diff --git a/01.conf.go b/01.conf.go index 1b76029..580e115 100644 --- a/01.conf.go +++ b/01.conf.go @@ -216,6 +216,15 @@ func init() { ZabovIPGroups = append(ZabovIPGroups, groupStruct) } + if zabov["timetable"] != nil { + ZabovDefaultTimetable = zabov["timetable"].(string) + _, ok := ZabovTimetables[ZabovDefaultTimetable] + if !ok { + log.Println("inexistent timetable:", ZabovDefaultTimetable) + os.Exit(1) + } + } + localresponder := MyConf["localresponder"].(map[string]interface{}) if localresponder != nil { diff --git a/README.md b/README.md index 2fbb528..a1db98f 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,9 @@ Advanced configuration includes support for multiple configurations based on IP "proto":"udp", "ipaddr":"0.0.0.0", "cachettl": 1, - "killfilettl": 12 + "killfilettl": 12, + "debug":"false", + "timetable":"tt_default" }, "localresponder":{ "responder":"192.168.178.1:53", @@ -117,6 +119,11 @@ Advanced configuration includes support for multiple configurations based on IP "cfgin":"children_restricted", "cfgout":"default" } + "tt_default":{ + "tables":[{"times":"8:30-22:30", "days":"Su"}], + "cfgin":"children", + "cfgout":"default" + } }, "configs":{ "default":{ @@ -144,6 +151,10 @@ Advanced configuration includes support for multiple configurations based on IP } +Global zabov settings: + +- timetable: sets the global/default timetable. This table will be used for any client that is not already included in an IP group + localresponder: - allows to set a local DNS to respond for "local" domains. A domain name is handled as "local" if dosen't contains "." (dots) or if it ends with a well known prefix, such as ".local". Note: the cache is not used for local responder. diff --git a/dns_handler.go b/dns_handler.go index 51db447..bafd375 100644 --- a/dns_handler.go +++ b/dns_handler.go @@ -178,7 +178,6 @@ func confFromTimeTable(timetable string) string { } func confFromIP(clientIP net.IP) (string, string) { - for _, ipgroup := range ZabovIPGroups { for _, ip := range ipgroup.ips { if clientIP.Equal(ip) { @@ -186,12 +185,16 @@ func confFromIP(clientIP net.IP) (string, string) { return confFromTimeTable(ipgroup.timetable), ipgroup.timetable } if ZabovDebug { - log.Println("confFromIP: ipgroup.cfg") + log.Println("confFromIP: ipgroup.cfg", ipgroup.cfg) } return ipgroup.cfg, "" } } } + if len(ZabovDefaultTimetable) > 0 { + return confFromTimeTable(ZabovDefaultTimetable), ZabovDefaultTimetable + } + if ZabovDebug { log.Println("confFromIP: return default") } diff --git a/main.go b/main.go index aa65e20..3f778ce 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,9 @@ var ZabovLocalResponder string //ZabovLocalDomain is the default local domain (global) var ZabovLocalDomain string +//ZabovDefaultTimetable is the default timetable, applied to any client that is not already in any IP Group (global) +var ZabovDefaultTimetable string + //ZabovDebug activate more logging if set to true (global) var ZabovDebug bool