You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zabov/00.database.go

49 lines
944 B

2 years ago
package main
import (
"fmt"
"os"
"github.com/syndtr/goleveldb/leveldb"
)
//MyZabovCDB is the storage where we'll put domains to cache (global for all configs)
2 years ago
var MyZabovCDB *leveldb.DB
//MyZabovKDBs is the storage where we'll put domains to block (one for each config)
var MyZabovKDBs map[string]*leveldb.DB
2 years ago
func init() {
var err error
os.RemoveAll("./db")
os.MkdirAll("./db", 0755)
MyZabovCDB, err = leveldb.OpenFile("./db/cache", nil)
2 years ago
if err != nil {
fmt.Println("Cannot create Cache db: ", err.Error())
2 years ago
} else {
fmt.Println("Cache DB created")
2 years ago
}
MyZabovKDBs = map[string]*leveldb.DB{}
}
// ZabovCreateKDB creates Kill DBs
func ZabovCreateKDB(conf string) {
var err error
dbname := "./db/killfile_" + conf
KDB, err := leveldb.OpenFile(dbname, nil)
2 years ago
if err != nil {
fmt.Println("Cannot create Killfile db: ", err.Error())
2 years ago
} else {
fmt.Println("Killfile DB created:", dbname)
2 years ago
}
MyZabovKDBs[conf] = KDB
2 years ago
}