- added new setting: default/global timetable ( config->zabov->timetable )

This table will be used for any client that is not already included in an IP group
This commit is contained in:
bloved 2021-01-16 18:54:31 +01:00
parent 85ff0dac52
commit d2f8601185
4 changed files with 29 additions and 3 deletions

View File

@ -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 {

View File

@ -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
}
</pre>
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.

View File

@ -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")
}

View File

@ -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