mirror of https://git.keinpfusch.net/loweel/zabov
- removed unused/commented code
- ZabovCreateKDB is called only on active configurations
This commit is contained in:
parent
d2f8601185
commit
740e0a387b
|
@ -7,9 +7,6 @@ import (
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
)
|
)
|
||||||
|
|
||||||
//MyZabovKDB is the storage where we'll put domains to block (obsolete)
|
|
||||||
//var MyZabovKDB *leveldb.DB
|
|
||||||
|
|
||||||
//MyZabovCDB is the storage where we'll put domains to cache (global for all configs)
|
//MyZabovCDB is the storage where we'll put domains to cache (global for all configs)
|
||||||
var MyZabovCDB *leveldb.DB
|
var MyZabovCDB *leveldb.DB
|
||||||
|
|
||||||
|
@ -23,13 +20,6 @@ func init() {
|
||||||
os.RemoveAll("./db")
|
os.RemoveAll("./db")
|
||||||
|
|
||||||
os.MkdirAll("./db", 0755)
|
os.MkdirAll("./db", 0755)
|
||||||
/*
|
|
||||||
MyZabovKDB, err = leveldb.OpenFile("./db/killfile", nil)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Cannot create Killfile db: ", err.Error())
|
|
||||||
} else {
|
|
||||||
fmt.Println("Killfile DB created")
|
|
||||||
}*/
|
|
||||||
|
|
||||||
MyZabovCDB, err = leveldb.OpenFile("./db/cache", nil)
|
MyZabovCDB, err = leveldb.OpenFile("./db/cache", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
30
01.conf.go
30
01.conf.go
|
@ -38,6 +38,9 @@ func init() {
|
||||||
|
|
||||||
MyConf := MyConfRaw.(map[string]interface{})
|
MyConf := MyConfRaw.(map[string]interface{})
|
||||||
|
|
||||||
|
//******************************
|
||||||
|
// zabov section (global config)
|
||||||
|
//******************************
|
||||||
zabov := MyConf["zabov"].(map[string]interface{})
|
zabov := MyConf["zabov"].(map[string]interface{})
|
||||||
|
|
||||||
ZabovPort := zabov["port"].(string)
|
ZabovPort := zabov["port"].(string)
|
||||||
|
@ -82,6 +85,9 @@ func init() {
|
||||||
ZabovTimetables = map[string]*ZabovTimetable{}
|
ZabovTimetables = map[string]*ZabovTimetable{}
|
||||||
ZabovIPAliases = map[string]string{}
|
ZabovIPAliases = map[string]string{}
|
||||||
|
|
||||||
|
//*******************
|
||||||
|
// IP aliases section
|
||||||
|
//*******************
|
||||||
IPAliasesRaw := MyConf["ipaliases"].(map[string]interface{})
|
IPAliasesRaw := MyConf["ipaliases"].(map[string]interface{})
|
||||||
|
|
||||||
for alias, ip := range IPAliasesRaw {
|
for alias, ip := range IPAliasesRaw {
|
||||||
|
@ -89,6 +95,9 @@ func init() {
|
||||||
ZabovIPAliases[alias] = ip.(string)
|
ZabovIPAliases[alias] = ip.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//****************
|
||||||
|
// configs section
|
||||||
|
//****************
|
||||||
for name, v := range configs {
|
for name, v := range configs {
|
||||||
fmt.Println("evaluaing config name:", name)
|
fmt.Println("evaluaing config name:", name)
|
||||||
confRaw := v.(map[string]interface{})
|
confRaw := v.(map[string]interface{})
|
||||||
|
@ -101,11 +110,15 @@ func init() {
|
||||||
|
|
||||||
conf.ZabovDNSArray = fileByLines(conf.ZabovUpDNS)
|
conf.ZabovDNSArray = fileByLines(conf.ZabovUpDNS)
|
||||||
ZabovConfigs[name] = &conf
|
ZabovConfigs[name] = &conf
|
||||||
ZabovCreateKDB(name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default config is mandatory
|
||||||
ZabovConfigs["default"].references++
|
ZabovConfigs["default"].references++
|
||||||
|
|
||||||
|
//*******************
|
||||||
|
// timetables section
|
||||||
|
//*******************
|
||||||
timetables := MyConf["timetables"].(map[string]interface{})
|
timetables := MyConf["timetables"].(map[string]interface{})
|
||||||
|
|
||||||
for name, v := range timetables {
|
for name, v := range timetables {
|
||||||
|
@ -174,6 +187,9 @@ func init() {
|
||||||
ZabovTimetables[name] = &timetable
|
ZabovTimetables[name] = &timetable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//******************
|
||||||
|
// IP groups section
|
||||||
|
//******************
|
||||||
IPGroups := MyConf["ipgroups"].([]interface{})
|
IPGroups := MyConf["ipgroups"].([]interface{})
|
||||||
|
|
||||||
fmt.Println("evaluating IP Groups: ", len(IPGroups))
|
fmt.Println("evaluating IP Groups: ", len(IPGroups))
|
||||||
|
@ -225,6 +241,9 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//************************
|
||||||
|
// Local responser section
|
||||||
|
//************************
|
||||||
localresponder := MyConf["localresponder"].(map[string]interface{})
|
localresponder := MyConf["localresponder"].(map[string]interface{})
|
||||||
|
|
||||||
if localresponder != nil {
|
if localresponder != nil {
|
||||||
|
@ -241,15 +260,16 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//******************************************
|
||||||
|
// clearing unused config to save resources
|
||||||
|
//******************************************
|
||||||
for name, conf := range ZabovConfigs {
|
for name, conf := range ZabovConfigs {
|
||||||
if conf.references == 0 {
|
if conf.references == 0 {
|
||||||
log.Println("WARNING: disabling unused configuration:", name)
|
log.Println("WARNING: disabling unused configuration:", name)
|
||||||
delete(ZabovConfigs, name)
|
delete(ZabovConfigs, name)
|
||||||
|
} else {
|
||||||
|
ZabovCreateKDB(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fmt.Println("ZabovConfigs:", ZabovConfigs)
|
|
||||||
//fmt.Println("ZabovTimetables:", ZabovTimetables)
|
|
||||||
//fmt.Println("ZabovIPAliases:", ZabovIPAliases)
|
|
||||||
//fmt.Println("ZabovIPGroups:", ZabovIPGroups)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue