- FIX: optional settings were not optional

- Dockerfile: updated golang image to 1.15.6
- config.json: restored minimal settings
- added config.sample.json with all advanced settings
- urls-domains-updated.txt: removed/updated obsolete urls (CHEF-KOCH, malwaredomains.com)
pull/1/head
bloved 2021-01-17 15:28:20 +01:00
parent 740e0a387b
commit 749029ba5b
7 changed files with 184 additions and 158 deletions

View File

@ -88,11 +88,13 @@ func init() {
//******************* //*******************
// IP aliases section // IP aliases section
//******************* //*******************
IPAliasesRaw := MyConf["ipaliases"].(map[string]interface{}) if MyConf["ipaliases"] != nil {
IPAliasesRaw := MyConf["ipaliases"].(map[string]interface{})
for alias, ip := range IPAliasesRaw { for alias, ip := range IPAliasesRaw {
fmt.Println("IP Alias:", alias, ip) fmt.Println("IP Alias:", alias, ip)
ZabovIPAliases[alias] = ip.(string) ZabovIPAliases[alias] = ip.(string)
}
} }
//**************** //****************
@ -119,117 +121,121 @@ func init() {
//******************* //*******************
// timetables section // timetables section
//******************* //*******************
timetables := MyConf["timetables"].(map[string]interface{}) if MyConf["timetables"] != nil {
timetables := MyConf["timetables"].(map[string]interface{})
for name, v := range timetables { for name, v := range timetables {
fmt.Println("evaluaing timetable name:", name) fmt.Println("evaluaing timetable name:", name)
timetableRaw := v.(map[string]interface{}) timetableRaw := v.(map[string]interface{})
var timetable ZabovTimetable var timetable ZabovTimetable
timetable.cfgin = timetableRaw["cfgin"].(string) timetable.cfgin = timetableRaw["cfgin"].(string)
timetable.cfgout = timetableRaw["cfgout"].(string) timetable.cfgout = timetableRaw["cfgout"].(string)
if timetable.cfgin == "" { if timetable.cfgin == "" {
timetable.cfgin = "default" timetable.cfgin = "default"
} }
if timetable.cfgout == "" { if timetable.cfgout == "" {
timetable.cfgout = "default" timetable.cfgout = "default"
} }
refConfig, ok := ZabovConfigs[timetable.cfgin] refConfig, ok := ZabovConfigs[timetable.cfgin]
if !ok { if !ok {
log.Println("timetable: inexistent cfgin:", timetable.cfgin) log.Println("timetable: inexistent cfgin:", timetable.cfgin)
os.Exit(1) os.Exit(1)
} }
refConfig.references++ refConfig.references++
refConfig, ok = ZabovConfigs[timetable.cfgout] refConfig, ok = ZabovConfigs[timetable.cfgout]
if !ok { if !ok {
log.Println("timetable: inexistent cfgout:", timetable.cfgout) log.Println("timetable: inexistent cfgout:", timetable.cfgout)
os.Exit(1) os.Exit(1)
} }
refConfig.references++ refConfig.references++
tables := timetableRaw["tables"].([]interface{}) tables := timetableRaw["tables"].([]interface{})
for i := range tables { for i := range tables {
table := tables[i].(map[string]interface{}) table := tables[i].(map[string]interface{})
var ttEntry ZabovTimetableEntry var ttEntry ZabovTimetableEntry
ttEntry.times = []*ZabovTimeRange{} ttEntry.times = []*ZabovTimeRange{}
for _, tRaw := range strings.Split(table["times"].(string), ";") { for _, tRaw := range strings.Split(table["times"].(string), ";") {
tRawArr := strings.Split(tRaw, "-") tRawArr := strings.Split(tRaw, "-")
if len(tRawArr) > 1 { if len(tRawArr) > 1 {
startArr := strings.Split(tRawArr[0], ":") startArr := strings.Split(tRawArr[0], ":")
stopArr := strings.Split(tRawArr[1], ":") stopArr := strings.Split(tRawArr[1], ":")
if len(startArr) > 1 && len(stopArr) > 1 { if len(startArr) > 1 && len(stopArr) > 1 {
hourStart, _ := strconv.Atoi(startArr[0]) hourStart, _ := strconv.Atoi(startArr[0])
minuteStart, _ := strconv.Atoi(startArr[1]) minuteStart, _ := strconv.Atoi(startArr[1])
start := ZabovTime{hour: hourStart, minute: minuteStart} start := ZabovTime{hour: hourStart, minute: minuteStart}
hourStop, _ := strconv.Atoi(stopArr[0]) hourStop, _ := strconv.Atoi(stopArr[0])
minuteStop, _ := strconv.Atoi(stopArr[1]) minuteStop, _ := strconv.Atoi(stopArr[1])
stop := ZabovTime{hour: hourStop, minute: minuteStop} stop := ZabovTime{hour: hourStop, minute: minuteStop}
t := ZabovTimeRange{start: start, stop: stop} t := ZabovTimeRange{start: start, stop: stop}
ttEntry.times = append(ttEntry.times, &t) ttEntry.times = append(ttEntry.times, &t)
}
} }
} }
} ttEntry.days = map[string]bool{}
for _, day := range strings.Split(table["days"].(string), ";") {
ttEntry.days[day] = true
}
ttEntry.days = map[string]bool{} timetable.table = append(timetable.table, &ttEntry)
for _, day := range strings.Split(table["days"].(string), ";") {
ttEntry.days[day] = true
} }
ZabovTimetables[name] = &timetable
timetable.table = append(timetable.table, &ttEntry)
} }
ZabovTimetables[name] = &timetable
} }
//****************** //******************
// IP groups section // IP groups section
//****************** //******************
IPGroups := MyConf["ipgroups"].([]interface{}) if MyConf["ipgroups"] != nil {
IPGroups := MyConf["ipgroups"].([]interface{})
fmt.Println("evaluating IP Groups: ", len(IPGroups)) fmt.Println("evaluating IP Groups: ", len(IPGroups))
for i := range IPGroups { for i := range IPGroups {
fmt.Println("evaluating IP Group n.", i) fmt.Println("evaluating IP Group n.", i)
var groupStruct ZabovIPGroup var groupStruct ZabovIPGroup
groupMap := IPGroups[i].(map[string]interface{}) groupMap := IPGroups[i].(map[string]interface{})
IPsRaw := groupMap["ips"].([]interface{}) IPsRaw := groupMap["ips"].([]interface{})
groupStruct.ips = []net.IP{} groupStruct.ips = []net.IP{}
for x := range IPsRaw { for x := range IPsRaw {
ipRaw := IPsRaw[x].(string) ipRaw := IPsRaw[x].(string)
ip := net.ParseIP(ipRaw) ip := net.ParseIP(ipRaw)
fmt.Println("adding IP ", ipRaw) fmt.Println("adding IP ", ipRaw)
alias, ok := ZabovIPAliases[ipRaw] alias, ok := ZabovIPAliases[ipRaw]
if ok { if ok {
fmt.Println("IP alias: ", ipRaw, alias) fmt.Println("IP alias: ", ipRaw, alias)
ip = net.ParseIP(alias) ip = net.ParseIP(alias)
}
groupStruct.ips = append(groupStruct.ips, ip)
} }
groupStruct.ips = append(groupStruct.ips, ip) groupStruct.cfg = groupMap["cfg"].(string)
} groupStruct.timetable = groupMap["timetable"].(string)
groupStruct.cfg = groupMap["cfg"].(string) if len(groupStruct.cfg) > 0 {
groupStruct.timetable = groupMap["timetable"].(string) refConfig, ok := ZabovConfigs[groupStruct.cfg]
if len(groupStruct.cfg) > 0 { if !ok {
refConfig, ok := ZabovConfigs[groupStruct.cfg] log.Println("ipgroups: inexistent cfg:", groupStruct.cfg)
os.Exit(1)
} else {
refConfig.references++
}
}
fmt.Println("cfg:", groupStruct.cfg)
fmt.Println("timetable:", groupStruct.timetable)
_, ok := ZabovTimetables[groupStruct.timetable]
if !ok { if !ok {
log.Println("ipgroups: inexistent cfg:", groupStruct.cfg) log.Println("inexistent timetable:", groupStruct.timetable)
os.Exit(1) os.Exit(1)
} else {
refConfig.references++
} }
ZabovIPGroups = append(ZabovIPGroups, groupStruct)
} }
fmt.Println("cfg:", groupStruct.cfg)
fmt.Println("timetable:", groupStruct.timetable)
_, ok := ZabovTimetables[groupStruct.timetable]
if !ok {
log.Println("inexistent timetable:", groupStruct.timetable)
os.Exit(1)
}
ZabovIPGroups = append(ZabovIPGroups, groupStruct)
} }
if zabov["timetable"] != nil { if zabov["timetable"] != nil {
@ -244,24 +250,25 @@ func init() {
//************************ //************************
// Local responser section // Local responser section
//************************ //************************
localresponder := MyConf["localresponder"].(map[string]interface{}) if MyConf["localresponder"] != nil {
localresponder := MyConf["localresponder"].(map[string]interface{})
if localresponder != nil { if localresponder != nil {
if localresponder["responder"] != nil { if localresponder["responder"] != nil {
ZabovLocalResponder = localresponder["responder"].(string) ZabovLocalResponder = localresponder["responder"].(string)
if len(ZabovLocalResponder) > 0 { if len(ZabovLocalResponder) > 0 {
local := ZabovConfig{ZabovDNSArray: []string{ZabovLocalResponder}, references: 1} local := ZabovConfig{ZabovDNSArray: []string{ZabovLocalResponder}, references: 1}
ZabovConfigs["__localresponder__"] = &local ZabovConfigs["__localresponder__"] = &local
fmt.Println("ZabovLocalResponder:", ZabovLocalResponder) fmt.Println("ZabovLocalResponder:", ZabovLocalResponder)
}
}
if localresponder["localdomain"] != nil {
ZabovLocalDomain = localresponder["localdomain"].(string)
} }
} }
if localresponder["localdomain"] != nil {
ZabovLocalDomain = localresponder["localdomain"].(string)
}
} }
//****************************************** //******************************************
// clearing unused config to save resources // clearing unused configs to save resources
//****************************************** //******************************************
for name, conf := range ZabovConfigs { for name, conf := range ZabovConfigs {
if conf.references == 0 { if conf.references == 0 {

View File

@ -1,4 +1,4 @@
FROM golang:1.14.1 AS builder FROM arm64v8/golang:1.15.6 AS builder
RUN apt install git -y RUN apt install git -y
RUN mkdir -p /go/src/zabov RUN mkdir -p /go/src/zabov
RUN git clone https://git.keinpfusch.net/loweel/zabov /go/src/zabov RUN git clone https://git.keinpfusch.net/loweel/zabov /go/src/zabov
@ -17,4 +17,3 @@ COPY --from=builder /go/src/zabov /opt/zabov
EXPOSE 53/udp EXPOSE 53/udp
ENV TZ Europe/Rome ENV TZ Europe/Rome
ENTRYPOINT ["/opt/zabov/zabov"] ENTRYPOINT ["/opt/zabov/zabov"]

View File

@ -1,4 +1,4 @@
FROM arm32v7/golang:1.14.1 AS builder FROM arm64v8/golang:1.15.6 AS builder
RUN apt install git -y RUN apt install git -y
RUN mkdir -p /go/src/zabov RUN mkdir -p /go/src/zabov
RUN git clone https://git.keinpfusch.net/loweel/zabov /go/src/zabov RUN git clone https://git.keinpfusch.net/loweel/zabov /go/src/zabov

View File

@ -1,4 +1,4 @@
FROM arm64v8/golang:1.14.1 AS builder FROM arm64v8/golang:1.15.6 AS builder
RUN apt install git -y RUN apt install git -y
RUN mkdir -p /go/src/zabov RUN mkdir -p /go/src/zabov
RUN git clone https://git.keinpfusch.net/loweel/zabov /go/src/zabov RUN git clone https://git.keinpfusch.net/loweel/zabov /go/src/zabov

View File

@ -6,28 +6,6 @@
"cachettl": 1, "cachettl": 1,
"killfilettl": 12 "killfilettl": 12
}, },
"localresponder":{
"responder":"192.168.178.1:53",
"localdomain":"fritz.box"
},
"ipaliases":{
"pc8":"192.168.178.29",
"localhost":"127.0.0.1"
},
"ipgroups":[
{
"ips":["localhost", "::1", "192.168.178.30", "192.168.178.31", "pc8"],
"cfg":"",
"timetable":"tt_children"
}
],
"timetables":{
"tt_children":{
"tables":[{"times":"00:00-05:00;8:30-12:30;18:30-22:59", "days":"Mo;Tu;We;Th;Fr;Sa;Su"}],
"cfgin":"children_restricted",
"cfgout":"children"
}
},
"configs":{ "configs":{
"default":{ "default":{
"upstream":"./dns-upstream.txt", "upstream":"./dns-upstream.txt",
@ -35,21 +13,6 @@
"doublefilters":"./urls-hosts.txt", "doublefilters":"./urls-hosts.txt",
"blackholeip":"127.0.0.1", "blackholeip":"127.0.0.1",
"hostsfile":"./urls-local.txt" "hostsfile":"./urls-local.txt"
},
"children":{
"upstream":"./dns-upstream.txt",
"singlefilters":"./urls-domains.txt",
"doublefilters":"./urls-hosts.txt",
"blackholeip":"127.0.0.1",
"hostsfile":"./urls-local.txt"
},
"children_restricted":{
"upstream":"./dns-upstream.txt",
"singlefilters":"./urls-domains.txt",
"doublefilters":"./urls-hosts.txt",
"blackholeip":"127.0.0.1",
"hostsfile":"./urls-local.txt"
} }
} }
} }

57
config.sample.json Normal file
View File

@ -0,0 +1,57 @@
{
"zabov":{
"port":"53",
"proto":"udp",
"ipaddr":"0.0.0.0",
"cachettl": 1,
"killfilettl": 12,
"debug":"true",
"debugdbpath":"./logs",
"timetable":""
},
"localresponder":{
"responder":"192.168.1.1:53",
"localdomain":".local"
},
"ipaliases":{
"pc8":"192.168.1.2",
},
"ipgroups":[
{
"ips":["pc8"],
"cfg":"",
"timetable":"tt_children"
}
],
"timetables":{
"tt_children":{
"tables":[{"times":"9:30-11:30", "days":"Mo;Tu;We;Th;Fr;Sa"}],
"cfgin":"children_restricted",
"cfgout":"children"
}
},
"configs":{
"default":{
"upstream":"./dns-upstream.txt",
"singlefilters":"./urls-domains-updated.txt",
"doublefilters":"./urls-hosts-normal.txt",
"blackholeip":"127.0.0.1",
"hostsfile":"./urls-local-normal.txt"
},
"children":{
"upstream":"./dns-familyscreen.txt",
"singlefilters":"./urls-domains-updated.txt",
"doublefilters":"./urls-hosts-nofb.txt",
"blackholeip":"127.0.0.1",
"hostsfile":"./urls-local-normal.txt"
},
"children_restricted":{
"upstream":"./dns-familyscreen.txt",
"singlefilters":"./urls-domains-updated.txt",
"doublefilters":"./urls-hosts-nofb.txt",
"blackholeip":"127.0.0.1",
"hostsfile":"./urls-local-restricted.txt"
}
}
}

View File

@ -1,12 +1,8 @@
https://mirror1.malwaredomains.com/files/justdomains
https://raw.githubusercontent.com/hectorm/hmirror/master/data/adaway.org/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/adaway.org/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/adblock-nocoin-list/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/adblock-nocoin-list/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/adguard-simplified/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/adguard-simplified/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/anudeepnd-adservers/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/antipopads/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/disconnect.me-ad/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/digitalside-threat-intel/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/disconnect.me-malvertising/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/disconnect.me-malware/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/disconnect.me-tracking/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/easylist/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/easylist/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/easyprivacy/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/easyprivacy/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/eth-phishing-detect/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/eth-phishing-detect/list.txt
@ -14,24 +10,28 @@ https://raw.githubusercontent.com/hectorm/hmirror/master/data/fademind-add.2o7ne
https://raw.githubusercontent.com/hectorm/hmirror/master/data/fademind-add.dead/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/fademind-add.dead/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/fademind-add.risk/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/fademind-add.risk/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/fademind-add.spam/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/fademind-add.spam/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/gfrogeye-firstparty-trackers/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/hostsvn/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/kadhosts/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/kadhosts/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/malwaredomainlist.com/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/lightswitch05-ads-and-tracking/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/malwaredomains.com-immortaldomains/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/malwaredomains.com-justdomains/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/matomo.org-spammers/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/matomo.org-spammers/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/mitchellkrogza-badd-boyz-hosts/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/mitchellkrogza-badd-boyz-hosts/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/pgl.yoyo.org/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/pgl.yoyo.org/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/ransomwaretracker.abuse.ch/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/phishing.army/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/socram8888-notonmyshift/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/someonewhocares.org/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/someonewhocares.org/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/spam404.com/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/spam404.com/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/stevenblack/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/stevenblack/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/ublock/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/ublock-abuse/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/ublock-badware/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/ublock-privacy/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/urlhaus/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/winhelp2002.mvps.org/list.txt https://raw.githubusercontent.com/hectorm/hmirror/master/data/winhelp2002.mvps.org/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/zerodot1-coinblockerlists-browser/list.txt
https://raw.githubusercontent.com/hectorm/hmirror/master/data/zeustracker.abuse.ch/list.txt
https://raw.githubusercontent.com/CHEF-KOCH/Audio-fingerprint-pages/master/AudioFp.txt
https://raw.githubusercontent.com/CHEF-KOCH/Canvas-fingerprinting-pages/master/Canvas.txt
https://raw.githubusercontent.com/CHEF-KOCH/WebRTC-tracking/master/WebRTC.txt
https://raw.githubusercontent.com/CHEF-KOCH/CKs-FilterList/master/Anti-Corp/hosts/NSABlocklist.txt
https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-blocklist.txt https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-blocklist.txt
https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt
https://www.stopforumspam.com/downloads/toxic_domains_whole.txt https://www.stopforumspam.com/downloads/toxic_domains_whole.txt
https://mirror.cedia.org.ec/malwaredomains/immortal_domains.txt