mirror of
https://github.com/miekg/dns.git
synced 2025-12-08 13:21:00 +01:00
re-export these - I use them in unbound
This commit is contained in:
parent
6ee385b083
commit
b0fc5a2f22
@ -117,7 +117,7 @@ func (k *RR_DNSKEY) KeyTag() uint16 {
|
|||||||
keywire.Algorithm = k.Algorithm
|
keywire.Algorithm = k.Algorithm
|
||||||
keywire.PublicKey = k.PublicKey
|
keywire.PublicKey = k.PublicKey
|
||||||
wire := make([]byte, DefaultMsgSize)
|
wire := make([]byte, DefaultMsgSize)
|
||||||
n, ok := packStruct(keywire, wire, 0)
|
n, ok := PackStruct(keywire, wire, 0)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ func (k *RR_DNSKEY) ToDS(h int) *RR_DS {
|
|||||||
keywire.Algorithm = k.Algorithm
|
keywire.Algorithm = k.Algorithm
|
||||||
keywire.PublicKey = k.PublicKey
|
keywire.PublicKey = k.PublicKey
|
||||||
wire := make([]byte, DefaultMsgSize)
|
wire := make([]byte, DefaultMsgSize)
|
||||||
n, ok := packStruct(keywire, wire, 0)
|
n, ok := PackStruct(keywire, wire, 0)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset []RR) error {
|
|||||||
|
|
||||||
// Create the desired binary blob
|
// Create the desired binary blob
|
||||||
signdata := make([]byte, DefaultMsgSize)
|
signdata := make([]byte, DefaultMsgSize)
|
||||||
n, ok := packStruct(sigwire, signdata, 0)
|
n, ok := PackStruct(sigwire, signdata, 0)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrPack
|
return ErrPack
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset []RR) error {
|
|||||||
sigwire.SignerName = strings.ToLower(s.SignerName)
|
sigwire.SignerName = strings.ToLower(s.SignerName)
|
||||||
// Create the desired binary blob
|
// Create the desired binary blob
|
||||||
signeddata := make([]byte, DefaultMsgSize)
|
signeddata := make([]byte, DefaultMsgSize)
|
||||||
n, ok := packStruct(sigwire, signeddata, 0)
|
n, ok := PackStruct(sigwire, signeddata, 0)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrPack
|
return ErrPack
|
||||||
}
|
}
|
||||||
|
|||||||
12
msg.go
12
msg.go
@ -650,7 +650,7 @@ func structValue(any interface{}) reflect.Value {
|
|||||||
return reflect.ValueOf(any).Elem()
|
return reflect.ValueOf(any).Elem()
|
||||||
}
|
}
|
||||||
|
|
||||||
func packStruct(any interface{}, msg []byte, off int) (off1 int, ok bool) {
|
func PackStruct(any interface{}, msg []byte, off int) (off1 int, ok bool) {
|
||||||
off, ok = packStructValue(structValue(any), msg, off, nil, false)
|
off, ok = packStructValue(structValue(any), msg, off, nil, false)
|
||||||
return off, ok
|
return off, ok
|
||||||
}
|
}
|
||||||
@ -1011,7 +1011,7 @@ func unpackUint16(msg []byte, off int) (v uint16, off1 int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func unpackStruct(any interface{}, msg []byte, off int) (off1 int, ok bool) {
|
func UnpackStruct(any interface{}, msg []byte, off int) (off1 int, ok bool) {
|
||||||
off, ok = unpackStructValue(structValue(any), msg, off)
|
off, ok = unpackStructValue(structValue(any), msg, off)
|
||||||
return off, ok
|
return off, ok
|
||||||
}
|
}
|
||||||
@ -1075,7 +1075,7 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, ok bool) {
|
|||||||
// unpack just the header, to find the rr type and length
|
// unpack just the header, to find the rr type and length
|
||||||
var h RR_Header
|
var h RR_Header
|
||||||
off0 := off
|
off0 := off
|
||||||
if off, ok = unpackStruct(&h, msg, off); !ok {
|
if off, ok = UnpackStruct(&h, msg, off); !ok {
|
||||||
return nil, len(msg), false
|
return nil, len(msg), false
|
||||||
}
|
}
|
||||||
end := off + int(h.Rdlength)
|
end := off + int(h.Rdlength)
|
||||||
@ -1086,7 +1086,7 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, ok bool) {
|
|||||||
} else {
|
} else {
|
||||||
rr = mk()
|
rr = mk()
|
||||||
}
|
}
|
||||||
off, ok = unpackStruct(rr, msg, off0)
|
off, ok = UnpackStruct(rr, msg, off0)
|
||||||
if off != end {
|
if off != end {
|
||||||
return &h, end, true
|
return &h, end, true
|
||||||
}
|
}
|
||||||
@ -1240,7 +1240,7 @@ func (dns *Msg) Unpack(msg []byte) bool {
|
|||||||
var dh Header
|
var dh Header
|
||||||
off := 0
|
off := 0
|
||||||
var ok bool
|
var ok bool
|
||||||
if off, ok = unpackStruct(&dh, msg, off); !ok {
|
if off, ok = UnpackStruct(&dh, msg, off); !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
dns.Id = dh.Id
|
dns.Id = dh.Id
|
||||||
@ -1262,7 +1262,7 @@ func (dns *Msg) Unpack(msg []byte) bool {
|
|||||||
dns.Extra = make([]RR, dh.Arcount)
|
dns.Extra = make([]RR, dh.Arcount)
|
||||||
|
|
||||||
for i := 0; i < len(dns.Question); i++ {
|
for i := 0; i < len(dns.Question); i++ {
|
||||||
off, ok = unpackStruct(&dns.Question[i], msg, off)
|
off, ok = UnpackStruct(&dns.Question[i], msg, off)
|
||||||
}
|
}
|
||||||
for i := 0; i < len(dns.Answer); i++ {
|
for i := 0; i < len(dns.Answer); i++ {
|
||||||
dns.Answer[i], off, ok = UnpackRR(msg, off)
|
dns.Answer[i], off, ok = UnpackRR(msg, off)
|
||||||
|
|||||||
2
nsecx.go
2
nsecx.go
@ -38,7 +38,7 @@ func HashName(label string, ha uint8, iter uint16, salt string) string {
|
|||||||
saltwire := new(saltWireFmt)
|
saltwire := new(saltWireFmt)
|
||||||
saltwire.Salt = salt
|
saltwire.Salt = salt
|
||||||
wire := make([]byte, DefaultMsgSize)
|
wire := make([]byte, DefaultMsgSize)
|
||||||
n, ok := packStruct(saltwire, wire, 0)
|
n, ok := PackStruct(saltwire, wire, 0)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
10
tsig.go
10
tsig.go
@ -259,7 +259,7 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool)
|
|||||||
m.MACSize = uint16(len(requestMAC) / 2)
|
m.MACSize = uint16(len(requestMAC) / 2)
|
||||||
m.MAC = requestMAC
|
m.MAC = requestMAC
|
||||||
buf = make([]byte, len(requestMAC)) // long enough
|
buf = make([]byte, len(requestMAC)) // long enough
|
||||||
n, _ := packStruct(m, buf, 0)
|
n, _ := PackStruct(m, buf, 0)
|
||||||
buf = buf[:n]
|
buf = buf[:n]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool)
|
|||||||
tsig := new(timerWireFmt)
|
tsig := new(timerWireFmt)
|
||||||
tsig.TimeSigned = rr.TimeSigned
|
tsig.TimeSigned = rr.TimeSigned
|
||||||
tsig.Fudge = rr.Fudge
|
tsig.Fudge = rr.Fudge
|
||||||
n, _ := packStruct(tsig, tsigvar, 0)
|
n, _ := PackStruct(tsig, tsigvar, 0)
|
||||||
tsigvar = tsigvar[:n]
|
tsigvar = tsigvar[:n]
|
||||||
} else {
|
} else {
|
||||||
tsig := new(tsigWireFmt)
|
tsig := new(tsigWireFmt)
|
||||||
@ -281,7 +281,7 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool)
|
|||||||
tsig.Error = rr.Error
|
tsig.Error = rr.Error
|
||||||
tsig.OtherLen = rr.OtherLen
|
tsig.OtherLen = rr.OtherLen
|
||||||
tsig.OtherData = rr.OtherData
|
tsig.OtherData = rr.OtherData
|
||||||
n, _ := packStruct(tsig, tsigvar, 0)
|
n, _ := PackStruct(tsig, tsigvar, 0)
|
||||||
tsigvar = tsigvar[:n]
|
tsigvar = tsigvar[:n]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ func stripTsig(msg []byte) ([]byte, *RR_TSIG, error) {
|
|||||||
off := 0
|
off := 0
|
||||||
tsigoff := 0
|
tsigoff := 0
|
||||||
var ok bool
|
var ok bool
|
||||||
if off, ok = unpackStruct(&dh, msg, off); !ok {
|
if off, ok = UnpackStruct(&dh, msg, off); !ok {
|
||||||
return nil, nil, ErrUnpack
|
return nil, nil, ErrUnpack
|
||||||
}
|
}
|
||||||
if dh.Arcount == 0 {
|
if dh.Arcount == 0 {
|
||||||
@ -322,7 +322,7 @@ func stripTsig(msg []byte) ([]byte, *RR_TSIG, error) {
|
|||||||
dns.Extra = make([]RR, dh.Arcount)
|
dns.Extra = make([]RR, dh.Arcount)
|
||||||
|
|
||||||
for i := 0; i < len(dns.Question); i++ {
|
for i := 0; i < len(dns.Question); i++ {
|
||||||
off, ok = unpackStruct(&dns.Question[i], msg, off)
|
off, ok = UnpackStruct(&dns.Question[i], msg, off)
|
||||||
}
|
}
|
||||||
for i := 0; i < len(dns.Answer); i++ {
|
for i := 0; i < len(dns.Answer); i++ {
|
||||||
dns.Answer[i], off, ok = UnpackRR(msg, off)
|
dns.Answer[i], off, ok = UnpackRR(msg, off)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user