Browse Source

- 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
master
bloved 1 month ago
parent
commit
d2f8601185
4 changed files with 29 additions and 3 deletions
  1. +9
    -0
      01.conf.go
  2. +12
    -1
      README.md
  3. +5
    -2
      dns_handler.go
  4. +3
    -0
      main.go

+ 9
- 0
01.conf.go 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 {

+ 12
- 1
README.md 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.

+ 5
- 2
dns_handler.go 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")
}

+ 3
- 0
main.go 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

Loading…
Cancel
Save