parent
5777e140c0
commit
7cc28a94e9
|
@ -6,14 +6,14 @@ import (
|
|||
|
||||
func match(m *dns.Msg, d int) (*dns.Msg, bool) {
|
||||
// Matching criteria
|
||||
switch d {
|
||||
case IN:
|
||||
// nothing
|
||||
case OUT:
|
||||
// Note that when sending back only the mangling is important
|
||||
// the actual return code of these function isn't checked by
|
||||
// funkensturm
|
||||
}
|
||||
switch d {
|
||||
case IN:
|
||||
// nothing
|
||||
case OUT:
|
||||
// Note that when sending back only the mangling is important
|
||||
// the actual return code of these function isn't checked by
|
||||
// funkensturm
|
||||
}
|
||||
|
||||
// Packet Mangling
|
||||
switch d {
|
||||
|
@ -26,23 +26,23 @@ func match(m *dns.Msg, d int) (*dns.Msg, bool) {
|
|||
}
|
||||
|
||||
func send(m *dns.Msg, ok bool) (o *dns.Msg) {
|
||||
for _, c := range qr {
|
||||
o = c.Client.Exchange(m, c.Addr)
|
||||
}
|
||||
for _, c := range qr {
|
||||
o = c.Client.Exchange(m, c.Addr)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Return the configration
|
||||
func funkensturm() *Funkensturm {
|
||||
f := new(Funkensturm)
|
||||
f.Setup = func() bool { return true } // no setup
|
||||
f.Setup = func() bool { return true } // no setup
|
||||
|
||||
// 1 match function, use AND as op (doesn't matter in this case)
|
||||
// 1 match function, use AND as op (doesn't matter in this case)
|
||||
f.Matches = make([]Match, 1)
|
||||
f.Matches[0].Op = AND
|
||||
f.Matches[0].Func = match
|
||||
|
||||
// 1 action
|
||||
// 1 action
|
||||
f.Actions = make([]Action, 1)
|
||||
f.Actions[0].Func = send
|
||||
return f
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"dns"
|
||||
)
|
||||
|
||||
func match(m *dns.Msg, d int) (*dns.Msg, bool) {
|
||||
// Matching criteria
|
||||
switch d {
|
||||
case IN:
|
||||
// nothing
|
||||
case OUT:
|
||||
// Note that when sending back only the mangling is important
|
||||
// the actual return code of these function isn't checked by
|
||||
// funkensturm
|
||||
}
|
||||
|
||||
// Packet Mangling
|
||||
switch d {
|
||||
case IN:
|
||||
// nothing
|
||||
case OUT:
|
||||
// nothing
|
||||
}
|
||||
return m, true
|
||||
}
|
||||
|
||||
func send(m *dns.Msg, ok bool) (out *dns.Msg) {
|
||||
switch ok {
|
||||
case true, false:
|
||||
for _, r := range qr {
|
||||
out, _ = r.Query(m)
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Return the configration
|
||||
func funkensturm() *Funkensturm {
|
||||
f := new(Funkensturm)
|
||||
|
||||
// Nothing to set up
|
||||
f.Setup = func() bool { return true }
|
||||
|
||||
// 1 match function, use AND as op (doesn't matter in this case)
|
||||
f.Matches = make([]Match, 1)
|
||||
f.Matches[0].Op = AND
|
||||
f.Matches[0].Func = match
|
||||
|
||||
// 1 action
|
||||
f.Actions = make([]Action, 1)
|
||||
f.Actions[0].Func = send
|
||||
return f
|
||||
}
|
|
@ -7,6 +7,7 @@ package main
|
|||
// We could also use one 1 key for multiple domains.
|
||||
import (
|
||||
"dns"
|
||||
"strings"
|
||||
"crypto/rsa"
|
||||
)
|
||||
|
||||
|
@ -58,15 +59,11 @@ func match(m *dns.Msg, d int) (*dns.Msg, bool) {
|
|||
return m, true
|
||||
}
|
||||
|
||||
func send(m *dns.Msg, ok bool) (out *dns.Msg) {
|
||||
switch ok {
|
||||
case true, false:
|
||||
for _, r := range qr {
|
||||
out, _ = r.Query(m)
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
func send(m *dns.Msg, ok bool) (o *dns.Msg) {
|
||||
for _, c := range qr {
|
||||
o = c.Client.Exchange(m, c.Addr)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var pubkey *dns.RR_DNSKEY
|
||||
|
@ -87,7 +84,7 @@ Created: 20110122104659
|
|||
Publish: 20110122104659
|
||||
Activate: 20110122104659`
|
||||
pubkey = new(dns.RR_DNSKEY)
|
||||
privkey, _ = pubkey.PrivateKeySetString(privdata)
|
||||
privkey, _ = pubkey.ReadPrivateKey(strings.NewReader(privdata))
|
||||
pubkey.Hdr = dns.RR_Header{"miek.nl.", dns.TypeDNSKEY, dns.ClassINET, 3600, 0}
|
||||
pubkey.Protocol = 3
|
||||
pubkey.Flags = 256
|
||||
|
|
2
dns.go
2
dns.go
|
@ -143,7 +143,7 @@ func (h *RR_Header) String() string {
|
|||
|
||||
// Return the number of labels in a domain name.
|
||||
// Need to add these kind of function in a structured way. TODO(mg)
|
||||
func labelCount(a string) (c uint8) {
|
||||
func LabelCount(a string) (c uint8) {
|
||||
// walk the string and count the dots
|
||||
// except when it is escaped
|
||||
esc := false
|
||||
|
|
|
@ -174,7 +174,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) bool {
|
|||
s.OrigTtl = rrset[0].Header().Ttl
|
||||
s.TypeCovered = rrset[0].Header().Rrtype
|
||||
s.TypeCovered = rrset[0].Header().Rrtype
|
||||
s.Labels = labelCount(rrset[0].Header().Name)
|
||||
s.Labels = LabelCount(rrset[0].Header().Name)
|
||||
if strings.HasPrefix(rrset[0].Header().Name, "*") {
|
||||
s.Labels-- // wildcards, remove from label count
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue