mirror of
https://github.com/miekg/dns.git
synced 2025-08-12 20:46:57 +02:00
Fix funkensturm signing
make LabelCount public account.
This commit is contained in:
parent
5777e140c0
commit
7cc28a94e9
@ -6,14 +6,14 @@ import (
|
|||||||
|
|
||||||
func match(m *dns.Msg, d int) (*dns.Msg, bool) {
|
func match(m *dns.Msg, d int) (*dns.Msg, bool) {
|
||||||
// Matching criteria
|
// Matching criteria
|
||||||
switch d {
|
switch d {
|
||||||
case IN:
|
case IN:
|
||||||
// nothing
|
// nothing
|
||||||
case OUT:
|
case OUT:
|
||||||
// Note that when sending back only the mangling is important
|
// Note that when sending back only the mangling is important
|
||||||
// the actual return code of these function isn't checked by
|
// the actual return code of these function isn't checked by
|
||||||
// funkensturm
|
// funkensturm
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packet Mangling
|
// Packet Mangling
|
||||||
switch d {
|
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) {
|
func send(m *dns.Msg, ok bool) (o *dns.Msg) {
|
||||||
for _, c := range qr {
|
for _, c := range qr {
|
||||||
o = c.Client.Exchange(m, c.Addr)
|
o = c.Client.Exchange(m, c.Addr)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the configration
|
// Return the configration
|
||||||
func funkensturm() *Funkensturm {
|
func funkensturm() *Funkensturm {
|
||||||
f := new(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 = make([]Match, 1)
|
||||||
f.Matches[0].Op = AND
|
f.Matches[0].Op = AND
|
||||||
f.Matches[0].Func = match
|
f.Matches[0].Func = match
|
||||||
|
|
||||||
// 1 action
|
// 1 action
|
||||||
f.Actions = make([]Action, 1)
|
f.Actions = make([]Action, 1)
|
||||||
f.Actions[0].Func = send
|
f.Actions[0].Func = send
|
||||||
return f
|
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.
|
// We could also use one 1 key for multiple domains.
|
||||||
import (
|
import (
|
||||||
"dns"
|
"dns"
|
||||||
|
"strings"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,15 +59,11 @@ func match(m *dns.Msg, d int) (*dns.Msg, bool) {
|
|||||||
return m, true
|
return m, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func send(m *dns.Msg, ok bool) (out *dns.Msg) {
|
func send(m *dns.Msg, ok bool) (o *dns.Msg) {
|
||||||
switch ok {
|
for _, c := range qr {
|
||||||
case true, false:
|
o = c.Client.Exchange(m, c.Addr)
|
||||||
for _, r := range qr {
|
}
|
||||||
out, _ = r.Query(m)
|
return
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var pubkey *dns.RR_DNSKEY
|
var pubkey *dns.RR_DNSKEY
|
||||||
@ -87,7 +84,7 @@ Created: 20110122104659
|
|||||||
Publish: 20110122104659
|
Publish: 20110122104659
|
||||||
Activate: 20110122104659`
|
Activate: 20110122104659`
|
||||||
pubkey = new(dns.RR_DNSKEY)
|
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.Hdr = dns.RR_Header{"miek.nl.", dns.TypeDNSKEY, dns.ClassINET, 3600, 0}
|
||||||
pubkey.Protocol = 3
|
pubkey.Protocol = 3
|
||||||
pubkey.Flags = 256
|
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.
|
// Return the number of labels in a domain name.
|
||||||
// Need to add these kind of function in a structured way. TODO(mg)
|
// 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
|
// walk the string and count the dots
|
||||||
// except when it is escaped
|
// except when it is escaped
|
||||||
esc := false
|
esc := false
|
||||||
|
@ -174,7 +174,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) bool {
|
|||||||
s.OrigTtl = rrset[0].Header().Ttl
|
s.OrigTtl = rrset[0].Header().Ttl
|
||||||
s.TypeCovered = rrset[0].Header().Rrtype
|
s.TypeCovered = rrset[0].Header().Rrtype
|
||||||
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, "*") {
|
if strings.HasPrefix(rrset[0].Header().Name, "*") {
|
||||||
s.Labels-- // wildcards, remove from label count
|
s.Labels-- // wildcards, remove from label count
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user