mirror of
https://github.com/miekg/dns.git
synced 2025-12-17 01:31:00 +01:00
Fixes the latest weekly
This commit is contained in:
parent
f00b7ec494
commit
22a467e718
@ -4,7 +4,6 @@ package main
|
||||
import (
|
||||
"dns"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@ -64,7 +63,7 @@ func sendProbe(c *dns.Client, addr string, f *fingerprint, q dns.Question) *fing
|
||||
|
||||
// This leads to strings like: "QUERY,NOERROR,qr,aa,tc,RD,ad,cd,z,1,0,0,1,DO,4096,NSID"
|
||||
type fingerprint struct {
|
||||
Error os.Error
|
||||
Error error
|
||||
Opcode int
|
||||
Rcode int
|
||||
Response bool
|
||||
@ -187,10 +186,10 @@ func (f *fingerprint) error() string {
|
||||
if f.Error == nil {
|
||||
panic("error is nil")
|
||||
}
|
||||
return f.Error.String()
|
||||
return f.Error.Error()
|
||||
}
|
||||
|
||||
func errorToFingerprint(e os.Error) *fingerprint {
|
||||
func errorToFingerprint(e error) *fingerprint {
|
||||
f := new(fingerprint)
|
||||
f.Error = e
|
||||
return f
|
||||
|
||||
29
client.go
29
client.go
@ -8,7 +8,6 @@ package dns
|
||||
// when the query returns.
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io"
|
||||
"net"
|
||||
)
|
||||
@ -22,10 +21,10 @@ type QueryHandler interface {
|
||||
// construct a DNS request.
|
||||
type RequestWriter interface {
|
||||
Write(*Msg)
|
||||
Send(*Msg) os.Error
|
||||
Receive() (*Msg, os.Error)
|
||||
Close() os.Error
|
||||
Dial() os.Error
|
||||
Send(*Msg) error
|
||||
Receive() (*Msg, error)
|
||||
Close() error
|
||||
Dial() error
|
||||
}
|
||||
|
||||
// hijacked connections...?
|
||||
@ -152,7 +151,7 @@ type Query struct {
|
||||
Handler QueryHandler // handler to invoke, dns.DefaultQueryMux if nil
|
||||
}
|
||||
|
||||
func (q *Query) Query() os.Error {
|
||||
func (q *Query) Query() error {
|
||||
handler := q.Handler
|
||||
if handler == nil {
|
||||
handler = DefaultQueryMux
|
||||
@ -171,7 +170,7 @@ func (q *Query) Query() os.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *Query) ListenAndQuery() os.Error {
|
||||
func (q *Query) ListenAndQuery() error {
|
||||
if q.QueryChan == nil {
|
||||
q.QueryChan = DefaultQueryChan
|
||||
}
|
||||
@ -200,7 +199,7 @@ func (c *Client) Do(m *Msg, a string) {
|
||||
|
||||
// ExchangeBuffer performs a synchronous query. It sends the buffer m to the
|
||||
// address (net.Addr?) contained in a
|
||||
func (c *Client) ExchangeBuffer(inbuf []byte, a string, outbuf []byte) (n int, err os.Error) {
|
||||
func (c *Client) ExchangeBuffer(inbuf []byte, a string, outbuf []byte) (n int, err error) {
|
||||
w := new(reply)
|
||||
w.client = c
|
||||
w.addr = a
|
||||
@ -224,7 +223,7 @@ func (c *Client) ExchangeBuffer(inbuf []byte, a string, outbuf []byte) (n int, e
|
||||
|
||||
// Exchange performs an synchronous query. It sends the message m to the address
|
||||
// contained in a and waits for an reply.
|
||||
func (c *Client) Exchange(m *Msg, a string) (r *Msg, err os.Error) {
|
||||
func (c *Client) Exchange(m *Msg, a string) (r *Msg, err error) {
|
||||
var n int
|
||||
out, ok := m.Pack()
|
||||
if !ok {
|
||||
@ -248,7 +247,7 @@ func (c *Client) Exchange(m *Msg, a string) (r *Msg, err os.Error) {
|
||||
}
|
||||
|
||||
// Dial connects to the address addr for the network set in c.Net
|
||||
func (w *reply) Dial() os.Error {
|
||||
func (w *reply) Dial() error {
|
||||
conn, err := net.Dial(w.Client().Net, w.addr)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -258,7 +257,7 @@ func (w *reply) Dial() os.Error {
|
||||
}
|
||||
|
||||
// UDP/TCP stuff big TODO
|
||||
func (w *reply) Close() (err os.Error) {
|
||||
func (w *reply) Close() (err error) {
|
||||
return w.conn.Close()
|
||||
}
|
||||
|
||||
@ -270,7 +269,7 @@ func (w *reply) Request() *Msg {
|
||||
return w.req
|
||||
}
|
||||
|
||||
func (w *reply) Receive() (*Msg, os.Error) {
|
||||
func (w *reply) Receive() (*Msg, error) {
|
||||
var p []byte
|
||||
m := new(Msg)
|
||||
switch w.Client().Net {
|
||||
@ -304,7 +303,7 @@ func (w *reply) Receive() (*Msg, os.Error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (w *reply) readClient(p []byte) (n int, err os.Error) {
|
||||
func (w *reply) readClient(p []byte) (n int, err error) {
|
||||
if w.conn == nil {
|
||||
return 0, ErrConnEmpty
|
||||
//panic("no connection")
|
||||
@ -350,7 +349,7 @@ func (w *reply) readClient(p []byte) (n int, err os.Error) {
|
||||
// Send sends a dns msg to the address specified in w.
|
||||
// If the message m contains a TSIG record the transaction
|
||||
// signature is calculated.
|
||||
func (w *reply) Send(m *Msg) os.Error {
|
||||
func (w *reply) Send(m *Msg) error {
|
||||
if m.IsTsig() {
|
||||
secret := m.Extra[len(m.Extra)-1].(*RR_TSIG).Hdr.Name
|
||||
_, ok := w.Client().TsigSecret[secret]
|
||||
@ -373,7 +372,7 @@ func (w *reply) Send(m *Msg) os.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *reply) writeClient(p []byte) (n int, err os.Error) {
|
||||
func (w *reply) writeClient(p []byte) (n int, err error) {
|
||||
if w.Client().Attempts == 0 {
|
||||
panic("c.Attempts 0")
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ type ClientConfig struct {
|
||||
// See resolv.conf(5) on a Linux machine.
|
||||
// Parse a /etc/resolv.conf like file and return a filled out ClientConfig. Note
|
||||
// that all nameservers will have the default port number appended (:53)
|
||||
func ClientConfigFromFile(conf string) (*ClientConfig, os.Error) {
|
||||
func ClientConfigFromFile(conf string) (*ClientConfig, error) {
|
||||
file, err := os.Open(conf)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
|
||||
9
dns.go
9
dns.go
@ -52,7 +52,6 @@ package dns
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@ -65,17 +64,17 @@ const (
|
||||
|
||||
// Error represents a DNS error
|
||||
type Error struct {
|
||||
Error string
|
||||
Err string
|
||||
Name string
|
||||
Server net.Addr
|
||||
Timeout bool
|
||||
}
|
||||
|
||||
func (e *Error) String() string {
|
||||
func (e *Error) Error() string {
|
||||
if e == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return e.Error
|
||||
return e.Err
|
||||
}
|
||||
|
||||
type RR interface {
|
||||
@ -155,7 +154,7 @@ func (s RRset) Ok() bool {
|
||||
type Exchange struct {
|
||||
Request *Msg // The question sent.
|
||||
Reply *Msg // The answer to the question that was sent.
|
||||
Error os.Error // If something when wrong, this contains the error.
|
||||
Error error // If something when wrong, this contains the error.
|
||||
}
|
||||
|
||||
// DNS resource records.
|
||||
|
||||
@ -18,7 +18,6 @@ import (
|
||||
"big"
|
||||
"sort"
|
||||
"strings"
|
||||
"os"
|
||||
)
|
||||
|
||||
// DNSSEC encryption algorithm codes.
|
||||
@ -172,7 +171,7 @@ func (k *RR_DNSKEY) ToDS(h int) *RR_DS {
|
||||
// otherwise false.
|
||||
// The signature data in the RRSIG is filled by this method.
|
||||
// There is no check if RRSet is a proper (RFC 2181) RRSet.
|
||||
func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) os.Error {
|
||||
func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) error {
|
||||
if k == nil {
|
||||
return ErrPrivKey
|
||||
}
|
||||
@ -263,7 +262,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) os.Error {
|
||||
|
||||
// Verify validates an RRSet with the signature and key. This is only the
|
||||
// cryptographic test, the signature validity period most be checked separately.
|
||||
func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset RRset) os.Error {
|
||||
func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset RRset) error {
|
||||
// Frist the easy checks
|
||||
if s.KeyTag != k.KeyTag() {
|
||||
return ErrKey
|
||||
|
||||
11
keygen.go
11
keygen.go
@ -1,7 +1,6 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io"
|
||||
"big"
|
||||
"strconv"
|
||||
@ -21,7 +20,7 @@ type PrivateKey interface{}
|
||||
// what kind of DNSKEY will be generated.
|
||||
// The ECDSA algorithms imply a fixed keysize, in that case
|
||||
// bits should be set to the size of the algorithm.
|
||||
func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, os.Error) {
|
||||
func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, error) {
|
||||
switch r.Algorithm {
|
||||
case RSAMD5, RSASHA1, RSASHA256, RSASHA1NSEC3SHA1:
|
||||
if bits < 512 || bits > 4096 {
|
||||
@ -113,7 +112,7 @@ func (r *RR_DNSKEY) PrivateKeyString(p PrivateKey) (s string) {
|
||||
}
|
||||
|
||||
// Read reads a DNSKEY from the io.Reader q.
|
||||
func (k *RR_DNSKEY) Read(q io.Reader) os.Error {
|
||||
func (k *RR_DNSKEY) Read(q io.Reader) error {
|
||||
p := NewParser(q)
|
||||
r, err := p.First()
|
||||
if err != nil {
|
||||
@ -131,7 +130,7 @@ func (k *RR_DNSKEY) Read(q io.Reader) os.Error {
|
||||
}
|
||||
|
||||
// ReadPrivateKey reads a private key from the io.Reader q.
|
||||
func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader) (PrivateKey, os.Error) {
|
||||
func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader) (PrivateKey, error) {
|
||||
p := NewParser(q)
|
||||
kv, _ := p.PrivateKey()
|
||||
if kv == nil {
|
||||
@ -153,7 +152,7 @@ func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader) (PrivateKey, os.Error) {
|
||||
}
|
||||
|
||||
// Read a private key (file) string and create a public key. Return the private key.
|
||||
func (k *RR_DNSKEY) readPrivateKeyRSA(kv map[string]string) (PrivateKey, os.Error) {
|
||||
func (k *RR_DNSKEY) readPrivateKeyRSA(kv map[string]string) (PrivateKey, error) {
|
||||
p := new(rsa.PrivateKey)
|
||||
p.Primes = []*big.Int{nil, nil}
|
||||
for k, v := range kv {
|
||||
@ -190,7 +189,7 @@ func (k *RR_DNSKEY) readPrivateKeyRSA(kv map[string]string) (PrivateKey, os.Erro
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (k *RR_DNSKEY) readPrivateKeyECDSA(kv map[string]string) (PrivateKey, os.Error) {
|
||||
func (k *RR_DNSKEY) readPrivateKeyECDSA(kv map[string]string) (PrivateKey, error) {
|
||||
p := new(ecdsa.PrivateKey)
|
||||
p.D = big.NewInt(0)
|
||||
// Need to check if we have everything
|
||||
|
||||
10
kparse.go
10
kparse.go
@ -3,11 +3,7 @@ package dns
|
||||
|
||||
// Parse private key files
|
||||
|
||||
import (
|
||||
"os"
|
||||
// "strings"
|
||||
)
|
||||
|
||||
|
||||
// line 14 "kparse.go"
|
||||
var k_start int = 111
|
||||
@ -16,16 +12,14 @@ var k_error int = 0
|
||||
|
||||
var k_en_main int = 111
|
||||
|
||||
|
||||
// line 13 "kparse.rl"
|
||||
|
||||
|
||||
// PrivateKey parses a private key file as defined in XXX.
|
||||
// A map[string]string is returned with the values. All the keys are
|
||||
// converted to lowercase. All values are returned as-is, except
|
||||
// the algorithm [e.g. 5 (RSASHA1)] is returned as: m[algorithm] = "RSASHA1"
|
||||
func (kp *Parser) PrivateKey() (m map[string]string, err os.Error) {
|
||||
//off Ragel generate illegal code now
|
||||
func (kp *Parser) PrivateKey() (m map[string]string, err error) {
|
||||
//off Ragel generate illegal code now
|
||||
/*
|
||||
m = make(map[string]string)
|
||||
var (
|
||||
|
||||
55
msg.go
55
msg.go
@ -15,7 +15,6 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
"net"
|
||||
"rand"
|
||||
@ -27,31 +26,31 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrUnpack os.Error = &Error{Error: "unpacking failed"}
|
||||
ErrPack os.Error = &Error{Error: "packing failed"}
|
||||
ErrId os.Error = &Error{Error: "id mismatch"}
|
||||
ErrShortRead os.Error = &Error{Error: "short read"}
|
||||
ErrConn os.Error = &Error{Error: "conn holds both UDP and TCP connection"}
|
||||
ErrConnEmpty os.Error = &Error{Error: "conn has no connection"}
|
||||
ErrServ os.Error = &Error{Error: "no servers could be reached"}
|
||||
ErrKey os.Error = &Error{Error: "bad key"}
|
||||
ErrPrivKey os.Error = &Error{Error: "bad private key"}
|
||||
ErrKeySize os.Error = &Error{Error: "bad key size"}
|
||||
ErrKeyAlg os.Error = &Error{Error: "bad key algorithm"}
|
||||
ErrAlg os.Error = &Error{Error: "bad algorithm"}
|
||||
ErrTime os.Error = &Error{Error: "bad time"}
|
||||
ErrNoSig os.Error = &Error{Error: "no signature found"}
|
||||
ErrSig os.Error = &Error{Error: "bad signature"}
|
||||
ErrSecret os.Error = &Error{Error: "no secret defined"}
|
||||
ErrSigGen os.Error = &Error{Error: "bad signature generation"}
|
||||
ErrAuth os.Error = &Error{Error: "bad authentication"}
|
||||
ErrXfrSoa os.Error = &Error{Error: "no SOA seen"}
|
||||
ErrXfrLast os.Error = &Error{Error: "last SOA"}
|
||||
ErrXfrType os.Error = &Error{Error: "no ixfr, nor axfr"}
|
||||
ErrHandle os.Error = &Error{Error: "handle is nil"}
|
||||
ErrChan os.Error = &Error{Error: "channel is nil"}
|
||||
ErrName os.Error = &Error{Error: "type not found for name"}
|
||||
ErrRRset os.Error = &Error{Error: "invalid rrset"}
|
||||
ErrUnpack error = &Error{Err: "unpacking failed"}
|
||||
ErrPack error = &Error{Err: "packing failed"}
|
||||
ErrId error = &Error{Err: "id mismatch"}
|
||||
ErrShortRead error = &Error{Err: "short read"}
|
||||
ErrConn error = &Error{Err: "conn holds both UDP and TCP connection"}
|
||||
ErrConnEmpty error = &Error{Err: "conn has no connection"}
|
||||
ErrServ error = &Error{Err: "no servers could be reached"}
|
||||
ErrKey error = &Error{Err: "bad key"}
|
||||
ErrPrivKey error = &Error{Err: "bad private key"}
|
||||
ErrKeySize error = &Error{Err: "bad key size"}
|
||||
ErrKeyAlg error = &Error{Err: "bad key algorithm"}
|
||||
ErrAlg error = &Error{Err: "bad algorithm"}
|
||||
ErrTime error = &Error{Err: "bad time"}
|
||||
ErrNoSig error = &Error{Err: "no signature found"}
|
||||
ErrSig error = &Error{Err: "bad signature"}
|
||||
ErrSecret error = &Error{Err: "no secret defined"}
|
||||
ErrSigGen error = &Error{Err: "bad signature generation"}
|
||||
ErrAuth error = &Error{Err: "bad authentication"}
|
||||
ErrXfrSoa error = &Error{Err: "no SOA seen"}
|
||||
ErrXfrLast error = &Error{Err: "last SOA"}
|
||||
ErrXfrType error = &Error{Err: "no ixfr, nor axfr"}
|
||||
ErrHandle error = &Error{Err: "handle is nil"}
|
||||
ErrChan error = &Error{Err: "channel is nil"}
|
||||
ErrName error = &Error{Err: "type not found for name"}
|
||||
ErrRRset error = &Error{Err: "invalid rrset"}
|
||||
)
|
||||
|
||||
// A manually-unpacked version of (id, bits).
|
||||
@ -793,7 +792,7 @@ func packUint16(i uint16) (byte, byte) {
|
||||
return byte(i >> 8), byte(i)
|
||||
}
|
||||
|
||||
func packBase64(s []byte) ([]byte, os.Error) {
|
||||
func packBase64(s []byte) ([]byte, error) {
|
||||
b64len := base64.StdEncoding.DecodedLen(len(s))
|
||||
buf := make([]byte, b64len)
|
||||
n, err := base64.StdEncoding.Decode(buf, []byte(s))
|
||||
@ -805,7 +804,7 @@ func packBase64(s []byte) ([]byte, os.Error) {
|
||||
}
|
||||
|
||||
// Helper function for packing, mostly used in dnssec.go
|
||||
func packBase32(s []byte) ([]byte, os.Error) {
|
||||
func packBase32(s []byte) ([]byte, error) {
|
||||
b32len := base32.HexEncoding.DecodedLen(len(s))
|
||||
buf := make([]byte, b32len)
|
||||
n, err := base32.HexEncoding.Decode(buf, []byte(s))
|
||||
|
||||
5
nsec3.go
5
nsec3.go
@ -5,7 +5,6 @@ import (
|
||||
"hash"
|
||||
"strings"
|
||||
"crypto/sha1"
|
||||
"os"
|
||||
)
|
||||
|
||||
type saltWireFmt struct {
|
||||
@ -63,13 +62,13 @@ func (nsec3 *RR_NSEC3) HashNames() {
|
||||
// the message m.
|
||||
// NsecVerify returns nil when the NSECs in the message contain
|
||||
// the correct proof. This function does not validates the NSECs
|
||||
func (m *Msg) NsecVerify(q Question) os.Error {
|
||||
func (m *Msg) NsecVerify(q Question) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Nsec3Verify verifies ...
|
||||
func (m *Msg) Nsec3Verify(q Question) os.Error {
|
||||
func (m *Msg) Nsec3Verify(q Question) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
19
server.go
19
server.go
@ -8,7 +8,6 @@ package dns
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"net"
|
||||
)
|
||||
|
||||
@ -26,7 +25,7 @@ type ResponseWriter interface {
|
||||
// RemoteAddr returns the net.Addr of the client that sent the current request.
|
||||
RemoteAddr() net.Addr
|
||||
// Write a reply back to the client.
|
||||
Write([]byte) (int, os.Error)
|
||||
Write([]byte) (int, error)
|
||||
}
|
||||
|
||||
// port?
|
||||
@ -82,7 +81,7 @@ func Refused(w ResponseWriter, r *Msg) {
|
||||
func RefusedHandler() Handler { return HandlerFunc(Refused) }
|
||||
|
||||
// ...
|
||||
func ListenAndServe(addr string, network string, handler Handler) os.Error {
|
||||
func ListenAndServe(addr string, network string, handler Handler) error {
|
||||
server := &Server{Addr: addr, Net: network, Handler: handler}
|
||||
return server.ListenAndServe()
|
||||
}
|
||||
@ -148,7 +147,7 @@ type Server struct {
|
||||
}
|
||||
|
||||
// ...
|
||||
func (srv *Server) ListenAndServe() os.Error {
|
||||
func (srv *Server) ListenAndServe() error {
|
||||
addr := srv.Addr
|
||||
if addr == "" {
|
||||
addr = ":domain"
|
||||
@ -178,7 +177,7 @@ func (srv *Server) ListenAndServe() os.Error {
|
||||
return nil // os.Error with wrong network
|
||||
}
|
||||
|
||||
func (srv *Server) ServeTCP(l *net.TCPListener) os.Error {
|
||||
func (srv *Server) ServeTCP(l *net.TCPListener) error {
|
||||
defer l.Close()
|
||||
handler := srv.Handler
|
||||
if handler == nil {
|
||||
@ -228,7 +227,7 @@ forever:
|
||||
panic("not reached")
|
||||
}
|
||||
|
||||
func (srv *Server) ServeUDP(l *net.UDPConn) os.Error {
|
||||
func (srv *Server) ServeUDP(l *net.UDPConn) error {
|
||||
defer l.Close()
|
||||
handler := srv.Handler
|
||||
if handler == nil {
|
||||
@ -257,7 +256,7 @@ func (srv *Server) ServeUDP(l *net.UDPConn) os.Error {
|
||||
panic("not reached")
|
||||
}
|
||||
|
||||
func newConn(t *net.TCPConn, u *net.UDPConn, a net.Addr, buf []byte, handler Handler) (*conn, os.Error) {
|
||||
func newConn(t *net.TCPConn, u *net.UDPConn, a net.Addr, buf []byte, handler Handler) (*conn, error) {
|
||||
c := new(conn)
|
||||
c.handler = handler
|
||||
c._TCP = t
|
||||
@ -267,7 +266,6 @@ func newConn(t *net.TCPConn, u *net.UDPConn, a net.Addr, buf []byte, handler Han
|
||||
return c, nil
|
||||
}
|
||||
|
||||
|
||||
// Close the connection.
|
||||
func (c *conn) close() {
|
||||
switch {
|
||||
@ -307,13 +305,12 @@ func (c *conn) serve() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (w *response) Write(data []byte) (n int, err os.Error) {
|
||||
func (w *response) Write(data []byte) (n int, err error) {
|
||||
switch {
|
||||
case w.conn._UDP != nil:
|
||||
n, err = w.conn._UDP.WriteTo(data, w.conn.remoteAddr)
|
||||
if err != nil {
|
||||
println(err.String())
|
||||
println(err.Error())
|
||||
return 0, err
|
||||
}
|
||||
case w.conn._TCP != nil:
|
||||
|
||||
9
tsig.go
9
tsig.go
@ -34,7 +34,6 @@ package dns
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
"strings"
|
||||
"crypto/hmac"
|
||||
@ -82,7 +81,7 @@ type timerWireFmt struct {
|
||||
// in the Tsig RR that is added. When TsigGenerate is called for the
|
||||
// first time requestMAC is set to the empty string.
|
||||
// If something goes wrong an error is returned, otherwise it is nil.
|
||||
func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) os.Error {
|
||||
func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) error {
|
||||
if !m.IsTsig() {
|
||||
// panic? panic?
|
||||
panic("TSIG not last RR in additional")
|
||||
@ -119,7 +118,7 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) os.Error {
|
||||
// TsigVerify verifies the TSIG on a message.
|
||||
// If the signature does not validate err contains the
|
||||
// error, otherwise it is nil.
|
||||
func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) os.Error {
|
||||
func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) error {
|
||||
rawsecret, err := packBase64([]byte(secret))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -139,7 +138,7 @@ func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) os.Error
|
||||
|
||||
h := hmac.NewMD5([]byte(rawsecret))
|
||||
io.WriteString(h, string(buf))
|
||||
if (strings.ToUpper(hex.EncodeToString(h.Sum())) != strings.ToUpper(tsig.MAC)) {
|
||||
if strings.ToUpper(hex.EncodeToString(h.Sum())) != strings.ToUpper(tsig.MAC) {
|
||||
return ErrSig
|
||||
}
|
||||
return nil
|
||||
@ -198,7 +197,7 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool)
|
||||
}
|
||||
|
||||
// Strip the TSIG from the raw message
|
||||
func stripTsig(msg []byte) ([]byte, *RR_TSIG, os.Error) {
|
||||
func stripTsig(msg []byte) ([]byte, *RR_TSIG, error) {
|
||||
// Copied from msg.go's Unpack()
|
||||
// Header.
|
||||
var dh Header
|
||||
|
||||
3
types.go
3
types.go
@ -6,7 +6,6 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"os"
|
||||
"net"
|
||||
"time"
|
||||
"strconv"
|
||||
@ -148,7 +147,7 @@ func (q *Question) String() string {
|
||||
}
|
||||
|
||||
// NewRRString returns the last RR contained in s.
|
||||
func NewRRString(s string) (RR, os.Error) {
|
||||
func NewRRString(s string) (RR, error) {
|
||||
p := NewParser(strings.NewReader(s))
|
||||
return p.First()
|
||||
}
|
||||
|
||||
10
xfr.go
10
xfr.go
@ -1,15 +1,11 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// XfrReceives requests an incoming Ixfr or Axfr. If the message q's question
|
||||
// section contains an AXFR type an Axfr is performed, if it is IXFR it does an Ixfr.
|
||||
// Each message will be send along the Client's reply channel as it is received.
|
||||
// The last message send has Exchange.Error set to ErrXfrLast
|
||||
// to signal there is nothing more to come.
|
||||
func (c *Client) XfrReceive(q *Msg, a string) os.Error {
|
||||
func (c *Client) XfrReceive(q *Msg, a string) error {
|
||||
w := new(reply)
|
||||
w.client = c
|
||||
w.addr = a
|
||||
@ -117,10 +113,10 @@ func (w *reply) ixfrReceive() {
|
||||
|
||||
// XfrSend performs an outgoing Ixfr or Axfr. The function is xfr agnostic, it is
|
||||
// up to the caller to correctly send the sequence of messages.
|
||||
func XfrSend(w ResponseWriter, q *Msg, a string) os.Error {
|
||||
func XfrSend(w ResponseWriter, q *Msg, a string) error {
|
||||
switch q.Question[0].Qtype {
|
||||
case TypeAXFR, TypeIXFR:
|
||||
// go d.xfrWrite(q, m, e)
|
||||
// go d.xfrWrite(q, m, e)
|
||||
default:
|
||||
return ErrXfrType
|
||||
}
|
||||
|
||||
17
zparse.go
17
zparse.go
@ -5,9 +5,8 @@ package dns
|
||||
// With the thankful help of gdnsd and the Go examples for Ragel.
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io"
|
||||
// "net"
|
||||
// "net"
|
||||
"time"
|
||||
"strings"
|
||||
"strconv"
|
||||
@ -23,18 +22,18 @@ type Parser struct {
|
||||
}
|
||||
|
||||
type ParseError struct {
|
||||
Error string
|
||||
Err string
|
||||
name string
|
||||
line int
|
||||
}
|
||||
|
||||
func (e *ParseError) String() string {
|
||||
s := e.Error + ": \"" + e.name + "\" at line: " + strconv.Itoa(e.line)
|
||||
func (e *ParseError) Error() string {
|
||||
s := e.Err + ": \"" + e.name + "\" at line: " + strconv.Itoa(e.line)
|
||||
return s
|
||||
}
|
||||
|
||||
// First will return the first RR found when parsing.
|
||||
func (zp *Parser) First() (RR, os.Error) {
|
||||
func (zp *Parser) First() (RR, error) {
|
||||
// defer close something
|
||||
return nil, nil
|
||||
}
|
||||
@ -59,7 +58,7 @@ func NewParser(r io.Reader) *Parser {
|
||||
// Translate the RRSIG's incep. and expir. times from
|
||||
// string values ("20110403154150") to an integer.
|
||||
// Taking into account serial arithmetic (RFC 1982)
|
||||
func dateToTime(s string) (uint32, os.Error) {
|
||||
func dateToTime(s string) (uint32, error) {
|
||||
t, e := time.Parse("20060102150405", s)
|
||||
if e != nil {
|
||||
return 0, e
|
||||
@ -86,7 +85,6 @@ func fields(s string, i int) (rdf []string) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// line 86 "zparse.go"
|
||||
var z_start int = 141
|
||||
var z_first_final int = 141
|
||||
@ -94,11 +92,10 @@ var z_error int = 0
|
||||
|
||||
var z_en_main int = 141
|
||||
|
||||
|
||||
// line 85 "zparse.rl"
|
||||
|
||||
// Zone parses an DNS master zone file.
|
||||
func (zp *Parser) Zone() (err os.Error) {
|
||||
func (zp *Parser) Zone() (err error) {
|
||||
/*
|
||||
z = NewZone()
|
||||
data := string(zp.buf)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user