Use bufio.Reader in private key reading
This commit is contained in:
parent
8ebf0c9a5b
commit
3af023bda9
1
TODO
1
TODO
|
@ -10,7 +10,6 @@ o compression (only ownernames?)
|
|||
|
||||
o Key2DS, also for offline keys -- need to parse them ofcourse
|
||||
|
||||
o Closing of tcp connections?
|
||||
o Tsig will probably become an interface which has all configuration
|
||||
stuff, but this will come later. Config which has Tsig function
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset RRset) bool {
|
|||
}
|
||||
|
||||
// Use RFC1982 to calculate if a signature period is valid.
|
||||
func (s *RR_RRSIG) PeriodOK() bool {
|
||||
func (s *RR_RRSIG) ValidityPeriod() bool {
|
||||
utc := time.UTC().Seconds()
|
||||
modi := (int64(s.Inception) - utc) / Year68
|
||||
mode := (int64(s.Expiration) - utc) / Year68
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"big"
|
||||
"fmt"
|
||||
"bufio"
|
||||
"strings"
|
||||
"strconv"
|
||||
"crypto/rsa"
|
||||
"crypto/rand"
|
||||
|
@ -89,9 +88,8 @@ func (r *RR_DNSKEY) PrivateKeyString(p PrivateKey) (s string) {
|
|||
}
|
||||
|
||||
// Read a private key (file) string and create a public key. Return the private key.
|
||||
func (k *RR_DNSKEY) PrivateKeySetString(s string) (PrivateKey, os.Error) {
|
||||
func (k *RR_DNSKEY) ReadPrivateKey(r bufio.Reader) (PrivateKey, os.Error) {
|
||||
p := new(rsa.PrivateKey)
|
||||
r := bufio.NewReader(strings.NewReader(s))
|
||||
var left, right string
|
||||
line, _ := r.ReadBytes('\n')
|
||||
// Do we care about the order of things? TODO(mg)
|
||||
|
|
|
@ -45,7 +45,7 @@ Publish: 20101221142359
|
|||
Activate: 20101221142359`
|
||||
|
||||
k := new(RR_DNSKEY)
|
||||
p, _ := k.PrivateKeySetString(a)
|
||||
p, _ := k.ReadPrivateKey(strings.NewReader(a))
|
||||
p = p
|
||||
}
|
||||
|
||||
|
|
11
server.go
11
server.go
|
@ -48,15 +48,10 @@ func HandleTCP(l *net.TCPListener, f func(*Conn, *Msg)) os.Error {
|
|||
d.Addr = c.RemoteAddr()
|
||||
d.Port = d.TCP.RemoteAddr().(*net.TCPAddr).Port
|
||||
|
||||
m := d.NewBuffer()
|
||||
n, e := d.Read(m)
|
||||
if e != nil {
|
||||
continue
|
||||
}
|
||||
m = m[:n]
|
||||
|
||||
msg := new(Msg)
|
||||
if !msg.Unpack(m) {
|
||||
err := d.ReadMsg(msg)
|
||||
|
||||
if err != nil {
|
||||
// Logging??
|
||||
continue
|
||||
}
|
||||
|
|
19
xfr.go
19
xfr.go
|
@ -44,18 +44,11 @@ func (d *Conn) axfrRead(q *Msg, m chan Xfr) {
|
|||
first := true
|
||||
in := new(Msg)
|
||||
for {
|
||||
inb := d.NewBuffer()
|
||||
n, err := d.Read(inb)
|
||||
err := d.ReadMsg(in)
|
||||
if err != nil {
|
||||
m <- Xfr{true, nil, err}
|
||||
return
|
||||
}
|
||||
inb = inb[:n]
|
||||
|
||||
if !in.Unpack(inb) {
|
||||
m <- Xfr{true, nil, &Error{Error: "Failed to unpack"}}
|
||||
return
|
||||
}
|
||||
if in.Id != q.Id {
|
||||
m <- Xfr{true, nil, &Error{Error: "Id mismatch"}}
|
||||
return
|
||||
|
@ -135,18 +128,12 @@ func (d *Conn) ixfrRead(q *Msg, m chan Xfr) {
|
|||
first := true
|
||||
in := new(Msg)
|
||||
for {
|
||||
inb := d.NewBuffer()
|
||||
n, err := d.Read(inb)
|
||||
|
||||
err := d.ReadMsg(in)
|
||||
if err != nil {
|
||||
m <- Xfr{true, nil, err}
|
||||
return
|
||||
}
|
||||
inb = inb[:n]
|
||||
|
||||
if !in.Unpack(inb) {
|
||||
m <- Xfr{true, nil, &Error{Error: "Failed to unpack"}}
|
||||
return
|
||||
}
|
||||
if in.Id != q.Id {
|
||||
m <- Xfr{true, nil, &Error{Error: "Id mismatch"}}
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue