initial commit
This commit is contained in:
commit
5ba52dd285
19 files changed
+639
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"dns_service/utils"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetSettings() (map[string]any, error) {
|
||||
settings := make(map[string]any)
|
||||
data, e := os.ReadFile(os.Getenv("DNSMASQ_CONFIG"))
|
||||
if e != nil {
|
||||
return settings, e
|
||||
}
|
||||
dnsmasqSettings := utils.DecodeSettings(string(data), "\n", "=")
|
||||
if dnsmasqSettings["cache-size"] != "" {
|
||||
cache_size, _ := strconv.ParseInt(dnsmasqSettings["cache-size"], 10, 64)
|
||||
settings["cache_size"] = cache_size
|
||||
}
|
||||
data, e = os.ReadFile(dnsmasqSettings["resolv-file"])
|
||||
if e != nil {
|
||||
return settings, e
|
||||
}
|
||||
resolvSettings := utils.DecodeResolvs(string(data))
|
||||
settings["resolv"] = resolvSettings
|
||||
data, e = os.ReadFile(dnsmasqSettings["addn-hosts"])
|
||||
if e != nil {
|
||||
return settings, e
|
||||
}
|
||||
hosts := utils.DecodeHosts(string(data))
|
||||
settings["hosts"] = hosts
|
||||
return settings, nil
|
||||
}
|
||||
Reference in new issue
Block a user