Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DNSQueryType - Map of replaceable DNS query types StringToQueryType = map[string]uint16{ "A": dns.TypeA, "NS": dns.TypeNS, "CNAME": dns.TypeCNAME, "SOA": dns.TypeSOA, "PTR": dns.TypePTR, "MX": dns.TypeMX, "TXT": dns.TypeTXT, "AAAA": dns.TypeAAAA, "SRV": dns.TypeSRV, "OPT": dns.TypeOPT, "DS": dns.TypeDS, "SSHFP": dns.TypeSSHFP, "RRSIG": dns.TypeRRSIG, "NSEC": dns.TypeNSEC, "DNSKEY": dns.TypeDNSKEY, "NSEC3": dns.TypeNSEC3, "NSEC3PARAM": dns.TypeNSEC3PARAM, "TLSA": dns.TypeTLSA, "HIP": dns.TypeHIP, "CDS": dns.TypeCDS, "CDNSKEY": dns.TypeCDNSKEY, "OPENPGPKEY": dns.TypeOPENPGPKEY, "SPF": dns.TypeSPF, } QueryTypeToString = map[uint16]string{ dns.TypeA: "A", dns.TypeNS: "NS", dns.TypeCNAME: "CNAME", dns.TypeSOA: "SOA", dns.TypePTR: "PTR", dns.TypeMX: "MX", dns.TypeTXT: "TXT", dns.TypeAAAA: "AAAA", dns.TypeSRV: "SRV", dns.TypeOPT: "OPT", dns.TypeDS: "DS", dns.TypeSSHFP: "SSHFP", dns.TypeRRSIG: "RRSIG", dns.TypeNSEC: "NSEC", dns.TypeDNSKEY: "DNSKEY", dns.TypeNSEC3: "NSEC3", dns.TypeNSEC3PARAM: "NSEC3PARAM", dns.TypeTLSA: "TLSA", dns.TypeHIP: "HIP", dns.TypeCDS: "CDS", dns.TypeCDNSKEY: "CDNSKEY", dns.TypeOPENPGPKEY: "OPENPGPKEY", dns.TypeSPF: "SPF", } )
Functions ¶
func CompileRules ¶
func CompileRules(allRules map[string][]*ReplacementRule) error
CompileRules - Compile regex for each rule
func DNSClientConfig ¶
func DNSClientConfig() (*dns.ClientConfig, error)
dnsClientConfig - returns all DNS server addresses associated with the given address on non-windows, we ignore the ip parameter because routing is not insane
Types ¶
type ClientConfig ¶
type GodNS ¶
type GodNS struct {
Rules map[string][]*ReplacementRule
Log *slog.Logger
// contains filtered or unexported fields
}
GodNS - The God Name Server
func NewGodNS ¶
func NewGodNS(config *GodNSConfig, logger *slog.Logger) (*GodNS, error)
NewGodNS - Create a new GodNS instance
func (*GodNS) HandleDNSRequest ¶
func (g *GodNS) HandleDNSRequest(writer dns.ResponseWriter, req *dns.Msg)
HandleDNSRequest - Handle a DNS request
type GodNSConfig ¶
type GodNSConfig struct {
Server *ServerConfig `json:"server" yaml:"server"`
Client *ClientConfig `json:"client" yaml:"client"`
Upstreams []string `json:"upstreams" yaml:"upstreams"`
// Rules - Map [DNS Query Type]->[ReplacementRules]
Rules map[string][]*ReplacementRule `json:"rules" yaml:"rules"`
}
func ParseConfigFile ¶
func ParseConfigFile(filePath string) (*GodNSConfig, error)
ParseConfigFile - Parse a config file from a given path
func ParseJSONConfig ¶
func ParseJSONConfig(data []byte) (*GodNSConfig, error)
ParseJSONConfig - Parse a JSON config file
func ParseYAMLConfig ¶
func ParseYAMLConfig(data []byte) (*GodNSConfig, error)
ParseYAMLConfig - Parse a YAML config file
type ReplacementRule ¶
type ReplacementRule struct {
Priority int `json:"priority" yaml:"priority"`
IsRegExp bool `json:"is_regexp" yaml:"is_regexp"`
Match string `json:"match" yaml:"match"`
SourceIPs []string `json:"source_ips" yaml:"source_ips"`
Spoof string `json:"spoof" yaml:"spoof"`
Block bool `json:"block" yaml:"block"`
// SOA
SpoofMName string `json:"spoof_mname" yaml:"spoof_mname"`
SpoofRName string `json:"spoof_rname" yaml:"spoof_rname"`
SpoofSerial uint32 `json:"spoof_serial" yaml:"spoof_serial"`
SpoofRefresh uint32 `json:"spoof_refresh" yaml:"spoof_refresh"`
SpoofRetry uint32 `json:"spoof_retry" yaml:"spoof_retry"`
SpoofExpire uint32 `json:"spoof_expire" yaml:"spoof_expire"`
SpoofMinTTL uint32 `json:"spoof_minttl" yaml:"spoof_minttl"`
// SRV
SpoofPriority uint16 `json:"spoof_priority" yaml:"spoof_priority"`
SpoofWeight uint16 `json:"spoof_weight" yaml:"spoof_weight"`
SpoofPort uint16 `json:"spoof_port" yaml:"spoof_port"`
// contains filtered or unexported fields
}
type ServerConfig ¶
Click to show internal directories.
Click to hide internal directories.