代码拉取完成,页面将自动刷新
package main
import (
"flag"
"fmt"
"github.com/BurntSushi/toml"
"os"
"strconv"
)
var (
settings Settings
)
type Settings struct {
Version string
Debug bool
Server DNSServerSettings `toml:"server"`
ResolvConfig ResolvSettings `toml:"resolv"`
Redis RedisSettings `toml:"redis"`
Log LogSettings `toml:"log"`
Cache CacheSettings `toml:"cache"`
Hosts HostsSettings `toml:"hosts"`
SpecServers map[string]SpecServerSettings `toml:"specservers"`
}
type SpecServerSettings struct {
DnsServer string
Domain string
Port string
Search string
}
type ResolvSettings struct {
ResolvFile string `toml:"resolv-file"`
Timeout int
}
type DNSServerSettings struct {
Host string
Port int
}
type RedisSettings struct {
Host string
Port int
DB int
Password string
Enable bool
}
func (s RedisSettings) Addr() string {
return s.Host + ":" + strconv.Itoa(s.Port)
}
type LogSettings struct {
File string
}
type CacheSettings struct {
Backend string
Expire int
Maxcount int
}
type HostsSettings struct {
Enable bool
HostsFile string `toml:"host-file"`
RedisKey string `toml:"redis-key"`
TTL uint32 `toml:"ttl"`
}
func init() {
var configFile string
flag.StringVar(&configFile, "c", "godns.conf", "Look for godns toml-formatting config file in this directory")
flag.Parse()
if _, err := toml.DecodeFile(configFile, &settings); err != nil {
fmt.Printf("%s is not a valid toml config file\n", configFile)
fmt.Println(err)
os.Exit(1)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。