Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add dynamic zone reading

  • Loading branch information...
commit eaec51df725dd34597a9a4d6afc0be82b2ae5a19 1 parent 26bbfdf
@miekg authored
View
3  ex/fksd/TODO
@@ -7,3 +7,6 @@
* dynamic updates
* zone transfers
* incremental zone transfers
+* configuration
+ * journal
+ * ...
View
13 ex/fksd/config.go
@@ -22,9 +22,12 @@ func config(w dns.ResponseWriter, req *dns.Msg, c *Config) {
// tsig signed, key = user
// config stuff in Auth section (just as dynamic updates (*hint* *hint*)
// SUBSYSTEM. IN TXT "OPERATION<SPACE>OPTIONS..."
- // ZONE. IN TXT "READ origin. /z/bloep" - absolute path in fs
+ // ZONE. IN TXT "READ origin /z/bloep" - absolute path in fs
// TODO: check tsig
+ if *l {
+ log.Printf("fksd: config commmand")
+ }
for _, rr := range req.Ns {
t, ok := rr.(*dns.RR_TXT)
@@ -51,12 +54,14 @@ func configZONE(t *dns.RR_TXT, c *Config) error {
switch strings.ToUpper(sx[0]) {
case "READ":
if *l {
- log.Printf("fksd: config: READ %s %s\n", sx[1], sx[2])
+ log.Printf("fksd: config: READ %s %s\n", dns.Fqdn(sx[1]), sx[2])
}
- if e := c.ReadZone(sx[1], sx[2]); e != nil {
+ if e := c.ReadZone(dns.Fqdn(sx[1]), sx[2]); e != nil {
+ if *l {
+ log.Printf("fksd: failed to read %s: %s\n", sx[2], e.Error())
+ }
return e
}
- dns.HandleFunc(sx[1], func(w dns.ResponseWriter, req *dns.Msg) { serve(w, req, c.Zones[sx[1]]) })
return nil
}
return nil
View
10 ex/fksd/main.go
@@ -15,19 +15,19 @@ func main() {
flag.Parse()
conf := NewConfig()
go func() {
- err := dns.ListenAndServe(":8053", "udp", nil)
+ err := dns.ListenAndServe(":1053", "udp", nil)
if err != nil {
- log.Fatal("fksd: could not start config listener")
+ log.Fatal("fksd: could not start server listener: %s", err.Error())
}
}()
go func() {
- err := dns.ListenAndServe(":5353", "udp", nil)
+ err := dns.ListenAndServe(":8053", "tcp", nil)
if err != nil {
- log.Fatal("fksd: could not start server listener")
+ log.Fatal("fksd: could not start config listener: %s", err.Error())
}
}()
// Yes, we HIJACK zone. ... not sure on how to make this "private"
- dns.HandleFunc("zone.", func(w dns.ResponseWriter, req *dns.Msg) { config(w, req, conf) })
+ dns.HandleFunc("ZONE.", func(w dns.ResponseWriter, req *dns.Msg) { config(w, req, conf) })
sig := make(chan os.Signal)
forever:
View
4 ex/fksd/serve.go
@@ -19,10 +19,10 @@ func ednsFromRequest(req, m *dns.Msg) {
func serve(w dns.ResponseWriter, req *dns.Msg, z *dns.Zone) {
if z == nil {
- panic("fks: no zone")
+ panic("fksd: no zone")
}
if *l {
- log.Printf("fks: [zone %s] incoming %s %s %d from %s\n", z.Origin, req.Question[0].Name, dns.Rr_str[req.Question[0].Qtype], req.MsgHdr.Id, w.RemoteAddr())
+ log.Printf("fksd: [zone %s] incoming %s %s %d from %s\n", z.Origin, req.Question[0].Name, dns.Rr_str[req.Question[0].Qtype], req.MsgHdr.Id, w.RemoteAddr())
}
// Ds Handling
// Referral
View
5 ex/fksd/zone.go
@@ -11,7 +11,7 @@ import (
func (c *Config) ReadZone(origin, file string) error {
z := dns.NewZone(origin)
if z == nil {
- return errors.New("fks: failed to open zone file")
+ return errors.New("fksd: failed to open zone file")
}
f, e := os.Open(file)
if e != nil {
@@ -21,9 +21,10 @@ func (c *Config) ReadZone(origin, file string) error {
if rr.Error == nil {
z.Insert(rr.RR)
} else {
- log.Printf("fks: failed to parse: %s\n", rr.Error.Error())
+ log.Printf("fksd: failed to parse: %s\n", rr.Error.Error())
}
}
c.Zones[origin] = z
+ dns.HandleFunc(origin, func(w dns.ResponseWriter, req *dns.Msg) { serve(w, req, c.Zones[origin]) })
return nil
}
Please sign in to comment.
Something went wrong with that request. Please try again.