Kill xfrprxy for now

This commit is contained in:
Miek Gieben 2011-07-06 19:56:28 +02:00
parent 4baa1df115
commit 5777e140c0
4 changed files with 2 additions and 212 deletions

View File

@ -3,10 +3,8 @@ chaos \
key2ds \
axfr \
reflect \
q
# these need to be fixed
#xfrprx \
#funkensturm
q \
funkensturm
all:
for i in $(EXAMPLES); do gomake -C $$i; done

View File

@ -1,9 +0,0 @@
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
include $(GOROOT)/src/Make.inc
TARG=xfrprx
GOFILES=xfrprx.go\
xfr.go
DEPS=../../
include $(GOROOT)/src/Make.cmd

View File

@ -1,101 +0,0 @@
package main
import (
"os"
"dns"
"fmt"
)
func handleXfrOut(d *dns.Conn, i *dns.Msg) os.Error {
if i.IsAxfr() {
fmt.Printf("Incoming Axfr request seen\n")
if i.Question[0].Name == Zone.name {
fmt.Printf("Matches current zone\n")
if !Zone.correct {
fmt.Printf("Zone was not deemed correct\n")
if err := d.WriteMsg(i); err != nil {
return err
}
return nil
} else {
fmt.Printf("Zone was correct\n")
}
m := make(chan *dns.Xfr)
e := make(chan os.Error)
go d.XfrWrite(i, m, e)
for j := 0; j < Zone.size; j++ {
select {
case m <- &dns.Xfr{Add: true, RR: Zone.rrs[j]}: //
case err := <-e:
return err
}
}
close(m)
} else {
fmt.Printf("No matching zone found\n")
if err := d.WriteMsg(i); err != nil {
return err
}
}
}
return nil
}
func handleNotify(d *dns.Conn, i *dns.Msg) os.Error {
if i.IsNotify() {
fmt.Printf("Incoming notify seen\n")
q := new(dns.Msg)
q.SetReply(i)
err := d.WriteMsg(q)
if err != nil {
return err
}
err = handleXfrIn(i)
if err != nil {
return err
}
}
return nil
}
func handleXfrIn(i *dns.Msg) os.Error {
q := new(dns.Msg)
q.SetAxfr(i.Question[0].Name)
m := make(chan *dns.Xfr)
fmt.Printf("Preparing Xfr for %s\n", i.Question[0].Name)
d := new(dns.Conn)
d.RemoteAddr = "127.0.0.1:53"
err := d.Dial("tcp")
if err != nil {
return err
}
defer d.Close()
fmt.Printf("Calling 127.0.0.1 successful\n")
go d.XfrRead(q, m)
Zone.name = i.Question[0].Name
j := 0
for x := range m {
Zone.rrs[j] = x.RR
j++
}
fmt.Printf("Success retrieved %s\n", Zone.name)
Zone.size = j
return nil
}
func handleNotifyOut(addr string) {
if Zone.name == "" || !Zone.correct {
return
}
d := new(dns.Conn)
d.RemoteAddr = addr
m := new(dns.Msg)
m.SetNotify(Zone.name)
fmt.Printf("Sending notifies: zone is ok\n")
dns.QueryRequest <- &dns.Query{Conn: d, Query: m}
}

View File

@ -1,98 +0,0 @@
package main
// Xfrprx is a proxy that intercepts notify messages
// and then performs a ixfr/axfr to get the new
// zone contents.
// This zone is then checked cryptographically is
// everything is correct.
// When the message is deemed correct a remote
// server is sent a notify to retrieve the ixfr/axfr.
// If a new DNSKEY record is seen for the apex and
// it validates it writes this record to disk and
// this new key will be used in future validations.
import (
"os"
"os/signal"
"fmt"
"dns"
)
// Static amount of RRs...
type zone struct {
name string
rrs [10000]dns.RR
size int
correct bool
}
var Zone zone
func handle(d *dns.Conn, i *dns.Msg) {
if i.MsgHdr.Response == true {
return
}
if err := handleNotify(d, i); err != nil {
fmt.Printf("err %v\n", err)
}
// handleNotifyOut("127.0.0.1:53") //
if err := handleXfrOut(d, i); err != nil {
fmt.Printf("err %v\n", err)
}
if Zone.name != "" {
// We have transfered a zone and can check it. For now assume ok.
Zone.correct = false
}
}
func listen(tcp string, addr string, e chan os.Error) {
switch tcp {
case "tcp":
err := dns.ListenAndServeTCP(addr, handle)
e <- err
case "udp":
err := dns.ListenAndServeUDP(addr, handle)
e <- err
}
}
func query(tcp string, e chan os.Error) {
switch tcp {
case "tcp":
err := dns.QueryAndServeTCP(dns.HandleQuery)
e <- err
case "udp":
err := dns.QueryAndServeUDP(dns.HandleQuery)
e <- err
}
}
func main() {
err := make(chan os.Error)
// Outgoing queries
dns.InitQueryChannels()
go query("tcp", err)
go query("udp", err)
// Incoming queries
go listen("tcp", "127.0.0.1:8053", err)
go listen("tcp", "[::1]:8053", err)
go listen("udp", "127.0.0.1:8053", err)
go listen("udp", "[::1]:8053", err)
forever:
for {
select {
case e := <-err:
fmt.Printf("Error received, stopping: %s\n", e.String())
break forever
case <-signal.Incoming:
fmt.Printf("Signal received, stopping\n")
break forever
case q := <-dns.QueryReply:
fmt.Printf("Query received:\n%v\n", q.Reply)
}
}
close(err)
}