]TranslationFunc
tagCache *tagCache
structCache *structCache
@@ -83,7 +96,7 @@ func New() *Validate {
v := &Validate{
tagName: defaultTagName,
aliases: make(map[string]string, len(bakedInAliases)),
- validations: make(map[string]FuncCtx, len(bakedInValidators)),
+ validations: make(map[string]internalValidationFuncWrapper, len(bakedInValidators)),
tagCache: tc,
structCache: sc,
}
@@ -96,8 +109,14 @@ func New() *Validate {
// must copy validators for separate validations to be used in each instance
for k, val := range bakedInValidators {
- // no need to error check here, baked in will always be valid
- _ = v.registerValidation(k, wrapFunc(val), true)
+ switch k {
+ // these require that even if the value is nil that the validation should run, omitempty still overrides this behaviour
+ case requiredIfTag, requiredUnlessTag, requiredWithTag, requiredWithAllTag, requiredWithoutTag, requiredWithoutAllTag:
+ _ = v.registerValidation(k, wrapFunc(val), true, true)
+ default:
+ // no need to error check here, baked in will always be valid
+ _ = v.registerValidation(k, wrapFunc(val), true, false)
+ }
}
v.pool = &sync.Pool{
@@ -140,18 +159,21 @@ func (v *Validate) RegisterTagNameFunc(fn TagNameFunc) {
// NOTES:
// - if the key already exists, the previous validation function will be replaced.
// - this method is not thread-safe it is intended that these all be registered prior to any validation
-func (v *Validate) RegisterValidation(tag string, fn Func) error {
- return v.RegisterValidationCtx(tag, wrapFunc(fn))
+func (v *Validate) RegisterValidation(tag string, fn Func, callValidationEvenIfNull ...bool) error {
+ return v.RegisterValidationCtx(tag, wrapFunc(fn), callValidationEvenIfNull...)
}
// RegisterValidationCtx does the same as RegisterValidation on accepts a FuncCtx validation
// allowing context.Context validation support.
-func (v *Validate) RegisterValidationCtx(tag string, fn FuncCtx) error {
- return v.registerValidation(tag, fn, false)
+func (v *Validate) RegisterValidationCtx(tag string, fn FuncCtx, callValidationEvenIfNull ...bool) error {
+ var nilCheckable bool
+ if len(callValidationEvenIfNull) > 0 {
+ nilCheckable = callValidationEvenIfNull[0]
+ }
+ return v.registerValidation(tag, fn, false, nilCheckable)
}
-func (v *Validate) registerValidation(tag string, fn FuncCtx, bakedIn bool) error {
-
+func (v *Validate) registerValidation(tag string, fn FuncCtx, bakedIn bool, nilCheckable bool) error {
if len(tag) == 0 {
return errors.New("Function Key cannot be empty")
}
@@ -161,13 +183,10 @@ func (v *Validate) registerValidation(tag string, fn FuncCtx, bakedIn bool) erro
}
_, ok := restrictedTags[tag]
-
if !bakedIn && (ok || strings.ContainsAny(tag, restrictedTagChars)) {
panic(fmt.Sprintf(restrictedTagErr, tag))
}
-
- v.validations[tag] = fn
-
+ v.validations[tag] = internalValidationFuncWrapper{fn: fn, runValidatinOnNil: nilCheckable}
return nil
}
diff --git a/vendor/github.com/gorilla/websocket/.travis.yml b/vendor/github.com/gorilla/websocket/.travis.yml
deleted file mode 100644
index a49db51c43..0000000000
--- a/vendor/github.com/gorilla/websocket/.travis.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-language: go
-sudo: false
-
-matrix:
- include:
- - go: 1.7.x
- - go: 1.8.x
- - go: 1.9.x
- - go: 1.10.x
- - go: 1.11.x
- - go: tip
- allow_failures:
- - go: tip
-
-script:
- - go get -t -v ./...
- - diff -u <(echo -n) <(gofmt -d .)
- - go vet $(go list ./... | grep -v /vendor/)
- - go test -v -race ./...
diff --git a/vendor/github.com/gorilla/websocket/README.md b/vendor/github.com/gorilla/websocket/README.md
index 20e391f865..0827d059c1 100644
--- a/vendor/github.com/gorilla/websocket/README.md
+++ b/vendor/github.com/gorilla/websocket/README.md
@@ -1,11 +1,11 @@
# Gorilla WebSocket
+[](https://godoc.org/github.com/gorilla/websocket)
+[](https://circleci.com/gh/gorilla/websocket)
+
Gorilla WebSocket is a [Go](http://golang.org/) implementation of the
[WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol.
-[](https://travis-ci.org/gorilla/websocket)
-[](https://godoc.org/github.com/gorilla/websocket)
-
### Documentation
* [API Reference](http://godoc.org/github.com/gorilla/websocket)
@@ -27,7 +27,7 @@ package API is stable.
### Protocol Compliance
The Gorilla WebSocket package passes the server tests in the [Autobahn Test
-Suite](http://autobahn.ws/testsuite) using the application in the [examples/autobahn
+Suite](https://github.com/crossbario/autobahn-testsuite) using the application in the [examples/autobahn
subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn).
### Gorilla WebSocket compared with other packages
@@ -40,7 +40,7 @@ subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn
| RFC 6455 Features |
-| Passes Autobahn Test Suite | Yes | No |
+| Passes Autobahn Test Suite | Yes | No |
| Receive fragmented message | Yes | No, see note 1 |
| Send close message | Yes | No |
| Send pings and receive pongs | Yes | No |
diff --git a/vendor/github.com/gorilla/websocket/client.go b/vendor/github.com/gorilla/websocket/client.go
index 2e32fd506e..962c06a391 100644
--- a/vendor/github.com/gorilla/websocket/client.go
+++ b/vendor/github.com/gorilla/websocket/client.go
@@ -70,7 +70,7 @@ type Dialer struct {
// HandshakeTimeout specifies the duration for the handshake to complete.
HandshakeTimeout time.Duration
- // ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
+ // ReadBufferSize and WriteBufferSize specify I/O buffer sizes in bytes. If a buffer
// size is zero, then a useful default size is used. The I/O buffer sizes
// do not limit the size of the messages that can be sent or received.
ReadBufferSize, WriteBufferSize int
@@ -140,7 +140,7 @@ var nilDialer = *DefaultDialer
// Use the response.Header to get the selected subprotocol
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
//
-// The context will be used in the request and in the Dialer
+// The context will be used in the request and in the Dialer.
//
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
// non-nil *http.Response so that callers can handle redirects, authentication,
diff --git a/vendor/github.com/gorilla/websocket/conn.go b/vendor/github.com/gorilla/websocket/conn.go
index d2a21c148b..6f17cd2998 100644
--- a/vendor/github.com/gorilla/websocket/conn.go
+++ b/vendor/github.com/gorilla/websocket/conn.go
@@ -260,10 +260,12 @@ type Conn struct {
newCompressionWriter func(io.WriteCloser, int) io.WriteCloser
// Read fields
- reader io.ReadCloser // the current reader returned to the application
- readErr error
- br *bufio.Reader
- readRemaining int64 // bytes remaining in current frame.
+ reader io.ReadCloser // the current reader returned to the application
+ readErr error
+ br *bufio.Reader
+ // bytes remaining in current frame.
+ // set setReadRemaining to safely update this value and prevent overflow
+ readRemaining int64
readFinal bool // true the current message has more frames.
readLength int64 // Message size.
readLimit int64 // Maximum message size.
@@ -320,6 +322,17 @@ func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int,
return c
}
+// setReadRemaining tracks the number of bytes remaining on the connection. If n
+// overflows, an ErrReadLimit is returned.
+func (c *Conn) setReadRemaining(n int64) error {
+ if n < 0 {
+ return ErrReadLimit
+ }
+
+ c.readRemaining = n
+ return nil
+}
+
// Subprotocol returns the negotiated protocol for the connection.
func (c *Conn) Subprotocol() string {
return c.subprotocol
@@ -451,7 +464,8 @@ func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) er
return err
}
-func (c *Conn) prepWrite(messageType int) error {
+// beginMessage prepares a connection and message writer for a new message.
+func (c *Conn) beginMessage(mw *messageWriter, messageType int) error {
// Close previous writer if not already closed by the application. It's
// probably better to return an error in this situation, but we cannot
// change this without breaking existing applications.
@@ -471,6 +485,10 @@ func (c *Conn) prepWrite(messageType int) error {
return err
}
+ mw.c = c
+ mw.frameType = messageType
+ mw.pos = maxFrameHeaderSize
+
if c.writeBuf == nil {
wpd, ok := c.writePool.Get().(writePoolData)
if ok {
@@ -491,16 +509,11 @@ func (c *Conn) prepWrite(messageType int) error {
// All message types (TextMessage, BinaryMessage, CloseMessage, PingMessage and
// PongMessage) are supported.
func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error) {
- if err := c.prepWrite(messageType); err != nil {
+ var mw messageWriter
+ if err := c.beginMessage(&mw, messageType); err != nil {
return nil, err
}
-
- mw := &messageWriter{
- c: c,
- frameType: messageType,
- pos: maxFrameHeaderSize,
- }
- c.writer = mw
+ c.writer = &mw
if c.newCompressionWriter != nil && c.enableWriteCompression && isData(messageType) {
w := c.newCompressionWriter(c.writer, c.compressionLevel)
mw.compress = true
@@ -517,10 +530,16 @@ type messageWriter struct {
err error
}
-func (w *messageWriter) fatal(err error) error {
+func (w *messageWriter) endMessage(err error) error {
if w.err != nil {
- w.err = err
- w.c.writer = nil
+ return err
+ }
+ c := w.c
+ w.err = err
+ c.writer = nil
+ if c.writePool != nil {
+ c.writePool.Put(writePoolData{buf: c.writeBuf})
+ c.writeBuf = nil
}
return err
}
@@ -534,7 +553,7 @@ func (w *messageWriter) flushFrame(final bool, extra []byte) error {
// Check for invalid control frames.
if isControl(w.frameType) &&
(!final || length > maxControlFramePayloadSize) {
- return w.fatal(errInvalidControlFrame)
+ return w.endMessage(errInvalidControlFrame)
}
b0 := byte(w.frameType)
@@ -579,7 +598,7 @@ func (w *messageWriter) flushFrame(final bool, extra []byte) error {
copy(c.writeBuf[maxFrameHeaderSize-4:], key[:])
maskBytes(key, 0, c.writeBuf[maxFrameHeaderSize:w.pos])
if len(extra) > 0 {
- return c.writeFatal(errors.New("websocket: internal error, extra used in client mode"))
+ return w.endMessage(c.writeFatal(errors.New("websocket: internal error, extra used in client mode")))
}
}
@@ -600,15 +619,11 @@ func (w *messageWriter) flushFrame(final bool, extra []byte) error {
c.isWriting = false
if err != nil {
- return w.fatal(err)
+ return w.endMessage(err)
}
if final {
- c.writer = nil
- if c.writePool != nil {
- c.writePool.Put(writePoolData{buf: c.writeBuf})
- c.writeBuf = nil
- }
+ w.endMessage(errWriteClosed)
return nil
}
@@ -706,11 +721,7 @@ func (w *messageWriter) Close() error {
if w.err != nil {
return w.err
}
- if err := w.flushFrame(true, nil); err != nil {
- return err
- }
- w.err = errWriteClosed
- return nil
+ return w.flushFrame(true, nil)
}
// WritePreparedMessage writes prepared message into connection.
@@ -742,10 +753,10 @@ func (c *Conn) WriteMessage(messageType int, data []byte) error {
if c.isServer && (c.newCompressionWriter == nil || !c.enableWriteCompression) {
// Fast path with no allocations and single frame.
- if err := c.prepWrite(messageType); err != nil {
+ var mw messageWriter
+ if err := c.beginMessage(&mw, messageType); err != nil {
return err
}
- mw := messageWriter{c: c, frameType: messageType, pos: maxFrameHeaderSize}
n := copy(c.writeBuf[mw.pos:], data)
mw.pos += n
data = data[n:]
@@ -792,7 +803,7 @@ func (c *Conn) advanceFrame() (int, error) {
final := p[0]&finalBit != 0
frameType := int(p[0] & 0xf)
mask := p[1]&maskBit != 0
- c.readRemaining = int64(p[1] & 0x7f)
+ c.setReadRemaining(int64(p[1] & 0x7f))
c.readDecompress = false
if c.newDecompressionReader != nil && (p[0]&rsv1Bit) != 0 {
@@ -826,7 +837,17 @@ func (c *Conn) advanceFrame() (int, error) {
return noFrame, c.handleProtocolError("unknown opcode " + strconv.Itoa(frameType))
}
- // 3. Read and parse frame length.
+ // 3. Read and parse frame length as per
+ // https://tools.ietf.org/html/rfc6455#section-5.2
+ //
+ // The length of the "Payload data", in bytes: if 0-125, that is the payload
+ // length.
+ // - If 126, the following 2 bytes interpreted as a 16-bit unsigned
+ // integer are the payload length.
+ // - If 127, the following 8 bytes interpreted as
+ // a 64-bit unsigned integer (the most significant bit MUST be 0) are the
+ // payload length. Multibyte length quantities are expressed in network byte
+ // order.
switch c.readRemaining {
case 126:
@@ -834,13 +855,19 @@ func (c *Conn) advanceFrame() (int, error) {
if err != nil {
return noFrame, err
}
- c.readRemaining = int64(binary.BigEndian.Uint16(p))
+
+ if err := c.setReadRemaining(int64(binary.BigEndian.Uint16(p))); err != nil {
+ return noFrame, err
+ }
case 127:
p, err := c.read(8)
if err != nil {
return noFrame, err
}
- c.readRemaining = int64(binary.BigEndian.Uint64(p))
+
+ if err := c.setReadRemaining(int64(binary.BigEndian.Uint64(p))); err != nil {
+ return noFrame, err
+ }
}
// 4. Handle frame masking.
@@ -863,6 +890,12 @@ func (c *Conn) advanceFrame() (int, error) {
if frameType == continuationFrame || frameType == TextMessage || frameType == BinaryMessage {
c.readLength += c.readRemaining
+ // Don't allow readLength to overflow in the presence of a large readRemaining
+ // counter.
+ if c.readLength < 0 {
+ return noFrame, ErrReadLimit
+ }
+
if c.readLimit > 0 && c.readLength > c.readLimit {
c.WriteControl(CloseMessage, FormatCloseMessage(CloseMessageTooBig, ""), time.Now().Add(writeWait))
return noFrame, ErrReadLimit
@@ -876,7 +909,7 @@ func (c *Conn) advanceFrame() (int, error) {
var payload []byte
if c.readRemaining > 0 {
payload, err = c.read(int(c.readRemaining))
- c.readRemaining = 0
+ c.setReadRemaining(0)
if err != nil {
return noFrame, err
}
@@ -949,6 +982,7 @@ func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
c.readErr = hideTempErr(err)
break
}
+
if frameType == TextMessage || frameType == BinaryMessage {
c.messageReader = &messageReader{c}
c.reader = c.messageReader
@@ -989,7 +1023,9 @@ func (r *messageReader) Read(b []byte) (int, error) {
if c.isServer {
c.readMaskPos = maskBytes(c.readMaskKey, c.readMaskPos, b[:n])
}
- c.readRemaining -= int64(n)
+ rem := c.readRemaining
+ rem -= int64(n)
+ c.setReadRemaining(rem)
if c.readRemaining > 0 && c.readErr == io.EOF {
c.readErr = errUnexpectedEOF
}
@@ -1041,7 +1077,7 @@ func (c *Conn) SetReadDeadline(t time.Time) error {
return c.conn.SetReadDeadline(t)
}
-// SetReadLimit sets the maximum size for a message read from the peer. If a
+// SetReadLimit sets the maximum size in bytes for a message read from the peer. If a
// message exceeds the limit, the connection sends a close message to the peer
// and returns ErrReadLimit to the application.
func (c *Conn) SetReadLimit(limit int64) {
diff --git a/vendor/github.com/gorilla/websocket/doc.go b/vendor/github.com/gorilla/websocket/doc.go
index dcce1a63c0..c6f4df8960 100644
--- a/vendor/github.com/gorilla/websocket/doc.go
+++ b/vendor/github.com/gorilla/websocket/doc.go
@@ -151,6 +151,53 @@
// checking. The application is responsible for checking the Origin header
// before calling the Upgrade function.
//
+// Buffers
+//
+// Connections buffer network input and output to reduce the number
+// of system calls when reading or writing messages.
+//
+// Write buffers are also used for constructing WebSocket frames. See RFC 6455,
+// Section 5 for a discussion of message framing. A WebSocket frame header is
+// written to the network each time a write buffer is flushed to the network.
+// Decreasing the size of the write buffer can increase the amount of framing
+// overhead on the connection.
+//
+// The buffer sizes in bytes are specified by the ReadBufferSize and
+// WriteBufferSize fields in the Dialer and Upgrader. The Dialer uses a default
+// size of 4096 when a buffer size field is set to zero. The Upgrader reuses
+// buffers created by the HTTP server when a buffer size field is set to zero.
+// The HTTP server buffers have a size of 4096 at the time of this writing.
+//
+// The buffer sizes do not limit the size of a message that can be read or
+// written by a connection.
+//
+// Buffers are held for the lifetime of the connection by default. If the
+// Dialer or Upgrader WriteBufferPool field is set, then a connection holds the
+// write buffer only when writing a message.
+//
+// Applications should tune the buffer sizes to balance memory use and
+// performance. Increasing the buffer size uses more memory, but can reduce the
+// number of system calls to read or write the network. In the case of writing,
+// increasing the buffer size can reduce the number of frame headers written to
+// the network.
+//
+// Some guidelines for setting buffer parameters are:
+//
+// Limit the buffer sizes to the maximum expected message size. Buffers larger
+// than the largest message do not provide any benefit.
+//
+// Depending on the distribution of message sizes, setting the buffer size to
+// to a value less than the maximum expected message size can greatly reduce
+// memory use with a small impact on performance. Here's an example: If 99% of
+// the messages are smaller than 256 bytes and the maximum message size is 512
+// bytes, then a buffer size of 256 bytes will result in 1.01 more system calls
+// than a buffer size of 512 bytes. The memory savings is 50%.
+//
+// A write buffer pool is useful when the application has a modest number
+// writes over a large number of connections. when buffers are pooled, a larger
+// buffer size has a reduced impact on total memory use and has the benefit of
+// reducing system calls and frame overhead.
+//
// Compression EXPERIMENTAL
//
// Per message compression extensions (RFC 7692) are experimentally supported
diff --git a/vendor/github.com/gorilla/websocket/go.mod b/vendor/github.com/gorilla/websocket/go.mod
new file mode 100644
index 0000000000..1a7afd5028
--- /dev/null
+++ b/vendor/github.com/gorilla/websocket/go.mod
@@ -0,0 +1,3 @@
+module github.com/gorilla/websocket
+
+go 1.12
diff --git a/vendor/github.com/gorilla/websocket/go.sum b/vendor/github.com/gorilla/websocket/go.sum
new file mode 100644
index 0000000000..cf4fbbaa07
--- /dev/null
+++ b/vendor/github.com/gorilla/websocket/go.sum
@@ -0,0 +1,2 @@
+github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
+github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
diff --git a/vendor/github.com/gorilla/websocket/join.go b/vendor/github.com/gorilla/websocket/join.go
new file mode 100644
index 0000000000..c64f8c8290
--- /dev/null
+++ b/vendor/github.com/gorilla/websocket/join.go
@@ -0,0 +1,42 @@
+// Copyright 2019 The Gorilla WebSocket Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package websocket
+
+import (
+ "io"
+ "strings"
+)
+
+// JoinMessages concatenates received messages to create a single io.Reader.
+// The string term is appended to each message. The returned reader does not
+// support concurrent calls to the Read method.
+func JoinMessages(c *Conn, term string) io.Reader {
+ return &joinReader{c: c, term: term}
+}
+
+type joinReader struct {
+ c *Conn
+ term string
+ r io.Reader
+}
+
+func (r *joinReader) Read(p []byte) (int, error) {
+ if r.r == nil {
+ var err error
+ _, r.r, err = r.c.NextReader()
+ if err != nil {
+ return 0, err
+ }
+ if r.term != "" {
+ r.r = io.MultiReader(r.r, strings.NewReader(r.term))
+ }
+ }
+ n, err := r.r.Read(p)
+ if err == io.EOF {
+ err = nil
+ r.r = nil
+ }
+ return n, err
+}
diff --git a/vendor/github.com/gorilla/websocket/proxy.go b/vendor/github.com/gorilla/websocket/proxy.go
index bf2478e430..e87a8c9f0c 100644
--- a/vendor/github.com/gorilla/websocket/proxy.go
+++ b/vendor/github.com/gorilla/websocket/proxy.go
@@ -22,18 +22,18 @@ func (fn netDialerFunc) Dial(network, addr string) (net.Conn, error) {
func init() {
proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
- return &httpProxyDialer{proxyURL: proxyURL, fowardDial: forwardDialer.Dial}, nil
+ return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial}, nil
})
}
type httpProxyDialer struct {
- proxyURL *url.URL
- fowardDial func(network, addr string) (net.Conn, error)
+ proxyURL *url.URL
+ forwardDial func(network, addr string) (net.Conn, error)
}
func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error) {
hostPort, _ := hostPortNoPort(hpd.proxyURL)
- conn, err := hpd.fowardDial(network, hostPort)
+ conn, err := hpd.forwardDial(network, hostPort)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/gorilla/websocket/server.go b/vendor/github.com/gorilla/websocket/server.go
index a761824b33..887d558918 100644
--- a/vendor/github.com/gorilla/websocket/server.go
+++ b/vendor/github.com/gorilla/websocket/server.go
@@ -27,7 +27,7 @@ type Upgrader struct {
// HandshakeTimeout specifies the duration for the handshake to complete.
HandshakeTimeout time.Duration
- // ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
+ // ReadBufferSize and WriteBufferSize specify I/O buffer sizes in bytes. If a buffer
// size is zero, then buffers allocated by the HTTP server are used. The
// I/O buffer sizes do not limit the size of the messages that can be sent
// or received.
@@ -153,7 +153,7 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
challengeKey := r.Header.Get("Sec-Websocket-Key")
if challengeKey == "" {
- return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: `Sec-WebSocket-Key' header is missing or blank")
+ return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: 'Sec-WebSocket-Key' header is missing or blank")
}
subprotocol := u.selectSubprotocol(r, responseHeader)
diff --git a/vendor/github.com/gorilla/websocket/util.go b/vendor/github.com/gorilla/websocket/util.go
index 354001e1ed..7bf2f66c67 100644
--- a/vendor/github.com/gorilla/websocket/util.go
+++ b/vendor/github.com/gorilla/websocket/util.go
@@ -31,68 +31,113 @@ func generateChallengeKey() (string, error) {
return base64.StdEncoding.EncodeToString(p), nil
}
-// Octet types from RFC 2616.
-var octetTypes [256]byte
-
-const (
- isTokenOctet = 1 << iota
- isSpaceOctet
-)
-
-func init() {
- // From RFC 2616
- //
- // OCTET =
- // CHAR =
- // CTL =
- // CR =
- // LF =
- // SP =
- // HT =
- // <"> =
- // CRLF = CR LF
- // LWS = [CRLF] 1*( SP | HT )
- // TEXT =
- // separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <">
- // | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT
- // token = 1*
- // qdtext = >
-
- for c := 0; c < 256; c++ {
- var t byte
- isCtl := c <= 31 || c == 127
- isChar := 0 <= c && c <= 127
- isSeparator := strings.IndexRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) >= 0
- if strings.IndexRune(" \t\r\n", rune(c)) >= 0 {
- t |= isSpaceOctet
- }
- if isChar && !isCtl && !isSeparator {
- t |= isTokenOctet
- }
- octetTypes[c] = t
- }
+// Token octets per RFC 2616.
+var isTokenOctet = [256]bool{
+ '!': true,
+ '#': true,
+ '$': true,
+ '%': true,
+ '&': true,
+ '\'': true,
+ '*': true,
+ '+': true,
+ '-': true,
+ '.': true,
+ '0': true,
+ '1': true,
+ '2': true,
+ '3': true,
+ '4': true,
+ '5': true,
+ '6': true,
+ '7': true,
+ '8': true,
+ '9': true,
+ 'A': true,
+ 'B': true,
+ 'C': true,
+ 'D': true,
+ 'E': true,
+ 'F': true,
+ 'G': true,
+ 'H': true,
+ 'I': true,
+ 'J': true,
+ 'K': true,
+ 'L': true,
+ 'M': true,
+ 'N': true,
+ 'O': true,
+ 'P': true,
+ 'Q': true,
+ 'R': true,
+ 'S': true,
+ 'T': true,
+ 'U': true,
+ 'W': true,
+ 'V': true,
+ 'X': true,
+ 'Y': true,
+ 'Z': true,
+ '^': true,
+ '_': true,
+ '`': true,
+ 'a': true,
+ 'b': true,
+ 'c': true,
+ 'd': true,
+ 'e': true,
+ 'f': true,
+ 'g': true,
+ 'h': true,
+ 'i': true,
+ 'j': true,
+ 'k': true,
+ 'l': true,
+ 'm': true,
+ 'n': true,
+ 'o': true,
+ 'p': true,
+ 'q': true,
+ 'r': true,
+ 's': true,
+ 't': true,
+ 'u': true,
+ 'v': true,
+ 'w': true,
+ 'x': true,
+ 'y': true,
+ 'z': true,
+ '|': true,
+ '~': true,
}
+// skipSpace returns a slice of the string s with all leading RFC 2616 linear
+// whitespace removed.
func skipSpace(s string) (rest string) {
i := 0
for ; i < len(s); i++ {
- if octetTypes[s[i]]&isSpaceOctet == 0 {
+ if b := s[i]; b != ' ' && b != '\t' {
break
}
}
return s[i:]
}
+// nextToken returns the leading RFC 2616 token of s and the string following
+// the token.
func nextToken(s string) (token, rest string) {
i := 0
for ; i < len(s); i++ {
- if octetTypes[s[i]]&isTokenOctet == 0 {
+ if !isTokenOctet[s[i]] {
break
}
}
return s[:i], s[i:]
}
+// nextTokenOrQuoted returns the leading token or quoted string per RFC 2616
+// and the string following the token or quoted string.
func nextTokenOrQuoted(s string) (value string, rest string) {
if !strings.HasPrefix(s, "\"") {
return nextToken(s)
@@ -128,7 +173,8 @@ func nextTokenOrQuoted(s string) (value string, rest string) {
return "", ""
}
-// equalASCIIFold returns true if s is equal to t with ASCII case folding.
+// equalASCIIFold returns true if s is equal to t with ASCII case folding as
+// defined in RFC 4790.
func equalASCIIFold(s, t string) bool {
for s != "" && t != "" {
sr, size := utf8.DecodeRuneInString(s)
diff --git a/vendor/github.com/leodido/go-urn/.gitignore b/vendor/github.com/leodido/go-urn/.gitignore
index a30b5ab045..5bcf4bade0 100644
--- a/vendor/github.com/leodido/go-urn/.gitignore
+++ b/vendor/github.com/leodido/go-urn/.gitignore
@@ -6,4 +6,6 @@
*.test
*.out
-*.txt
\ No newline at end of file
+*.txt
+
+vendor/
\ No newline at end of file
diff --git a/vendor/github.com/leodido/go-urn/.travis.yml b/vendor/github.com/leodido/go-urn/.travis.yml
index 913b6418b5..e56cf7cc06 100644
--- a/vendor/github.com/leodido/go-urn/.travis.yml
+++ b/vendor/github.com/leodido/go-urn/.travis.yml
@@ -3,6 +3,9 @@ language: go
go:
- 1.9.x
- 1.10.x
+ - 1.11.x
+ - 1.12.x
+ - 1.13.x
- tip
before_install:
diff --git a/vendor/github.com/leodido/go-urn/LICENSE b/vendor/github.com/leodido/go-urn/LICENSE
new file mode 100644
index 0000000000..8c3504a5a9
--- /dev/null
+++ b/vendor/github.com/leodido/go-urn/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Leonardo Di Donato
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/leodido/go-urn/go.mod b/vendor/github.com/leodido/go-urn/go.mod
new file mode 100644
index 0000000000..65bc1caf29
--- /dev/null
+++ b/vendor/github.com/leodido/go-urn/go.mod
@@ -0,0 +1,5 @@
+module github.com/leodido/go-urn
+
+go 1.13
+
+require github.com/stretchr/testify v1.4.0
diff --git a/vendor/github.com/leodido/go-urn/go.sum b/vendor/github.com/leodido/go-urn/go.sum
new file mode 100644
index 0000000000..8fdee5854f
--- /dev/null
+++ b/vendor/github.com/leodido/go-urn/go.sum
@@ -0,0 +1,11 @@
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/github.com/leodido/go-urn/machine.go b/vendor/github.com/leodido/go-urn/machine.go
index d621ea6e41..fe5a0cc861 100644
--- a/vendor/github.com/leodido/go-urn/machine.go
+++ b/vendor/github.com/leodido/go-urn/machine.go
@@ -13,13 +13,11 @@ var (
errParse = "parsing error [col %d]"
)
-
const start int = 1
-const first_final int = 44
-
-const en_fail int = 46
-const en_main int = 1
+const firstFinal int = 44
+const enFail int = 46
+const enMain int = 1
// Machine is the interface representing the FSM
type Machine interface {
@@ -68,109 +66,108 @@ func (m *machine) Parse(input []byte) (*URN, error) {
m.cs = start
}
-
{
if (m.p) == (m.pe) {
- goto _test_eof
+ goto _testEof
}
switch m.cs {
case 1:
- goto st_case_1
+ goto stCase1
case 0:
- goto st_case_0
+ goto stCase0
case 2:
- goto st_case_2
+ goto stCase2
case 3:
- goto st_case_3
+ goto stCase3
case 4:
- goto st_case_4
+ goto stCase4
case 5:
- goto st_case_5
+ goto stCase5
case 6:
- goto st_case_6
+ goto stCase6
case 7:
- goto st_case_7
+ goto stCase7
case 8:
- goto st_case_8
+ goto stCase8
case 9:
- goto st_case_9
+ goto stCase9
case 10:
- goto st_case_10
+ goto stCase10
case 11:
- goto st_case_11
+ goto stCase11
case 12:
- goto st_case_12
+ goto stCase12
case 13:
- goto st_case_13
+ goto stCase13
case 14:
- goto st_case_14
+ goto stCase14
case 15:
- goto st_case_15
+ goto stCase15
case 16:
- goto st_case_16
+ goto stCase16
case 17:
- goto st_case_17
+ goto stCase17
case 18:
- goto st_case_18
+ goto stCase18
case 19:
- goto st_case_19
+ goto stCase19
case 20:
- goto st_case_20
+ goto stCase20
case 21:
- goto st_case_21
+ goto stCase21
case 22:
- goto st_case_22
+ goto stCase22
case 23:
- goto st_case_23
+ goto stCase23
case 24:
- goto st_case_24
+ goto stCase24
case 25:
- goto st_case_25
+ goto stCase25
case 26:
- goto st_case_26
+ goto stCase26
case 27:
- goto st_case_27
+ goto stCase27
case 28:
- goto st_case_28
+ goto stCase28
case 29:
- goto st_case_29
+ goto stCase29
case 30:
- goto st_case_30
+ goto stCase30
case 31:
- goto st_case_31
+ goto stCase31
case 32:
- goto st_case_32
+ goto stCase32
case 33:
- goto st_case_33
+ goto stCase33
case 34:
- goto st_case_34
+ goto stCase34
case 35:
- goto st_case_35
+ goto stCase35
case 36:
- goto st_case_36
+ goto stCase36
case 37:
- goto st_case_37
+ goto stCase37
case 38:
- goto st_case_38
+ goto stCase38
case 44:
- goto st_case_44
+ goto stCase44
case 39:
- goto st_case_39
+ goto stCase39
case 40:
- goto st_case_40
+ goto stCase40
case 45:
- goto st_case_45
+ goto stCase45
case 41:
- goto st_case_41
+ goto stCase41
case 42:
- goto st_case_42
+ goto stCase42
case 43:
- goto st_case_43
+ goto stCase43
case 46:
- goto st_case_46
+ goto stCase46
}
- goto st_out
- st_case_1:
+ goto stOut
+ stCase1:
switch (m.data)[(m.p)] {
case 85:
goto tr1
@@ -179,6 +176,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
goto tr0
tr0:
+
m.err = fmt.Errorf(errParse, m.p)
(m.p)--
@@ -188,6 +186,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto st0
tr3:
+
m.err = fmt.Errorf(errPrefix, m.p)
(m.p)--
@@ -204,6 +203,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto st0
tr6:
+
m.err = fmt.Errorf(errIdentifier, m.p)
(m.p)--
@@ -220,6 +220,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto st0
tr41:
+
m.err = fmt.Errorf(errSpecificString, m.p)
(m.p)--
@@ -236,6 +237,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto st0
tr44:
+
m.err = fmt.Errorf(errHex, m.p)
(m.p)--
@@ -259,6 +261,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto st0
tr50:
+
m.err = fmt.Errorf(errPrefix, m.p)
(m.p)--
@@ -282,6 +285,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto st0
tr52:
+
m.err = fmt.Errorf(errNoUrnWithinID, m.p)
(m.p)--
@@ -304,19 +308,20 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
goto st0
- st_case_0:
+ stCase0:
st0:
m.cs = 0
goto _out
tr1:
+
m.pb = m.p
goto st2
st2:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof2
+ goto _testEof2
}
- st_case_2:
+ stCase2:
switch (m.data)[(m.p)] {
case 82:
goto st3
@@ -326,9 +331,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr0
st3:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof3
+ goto _testEof3
}
- st_case_3:
+ stCase3:
switch (m.data)[(m.p)] {
case 78:
goto st4
@@ -338,22 +343,23 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr3
st4:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof4
+ goto _testEof4
}
- st_case_4:
+ stCase4:
if (m.data)[(m.p)] == 58 {
goto tr5
}
goto tr0
tr5:
+
output.prefix = string(m.text())
goto st5
st5:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof5
+ goto _testEof5
}
- st_case_5:
+ stCase5:
switch (m.data)[(m.p)] {
case 85:
goto tr8
@@ -374,14 +380,15 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
goto tr6
tr7:
+
m.pb = m.p
goto st6
st6:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof6
+ goto _testEof6
}
- st_case_6:
+ stCase6:
switch (m.data)[(m.p)] {
case 45:
goto st7
@@ -403,9 +410,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st7:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof7
+ goto _testEof7
}
- st_case_7:
+ stCase7:
switch (m.data)[(m.p)] {
case 45:
goto st8
@@ -427,9 +434,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st8:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof8
+ goto _testEof8
}
- st_case_8:
+ stCase8:
switch (m.data)[(m.p)] {
case 45:
goto st9
@@ -451,9 +458,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st9:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof9
+ goto _testEof9
}
- st_case_9:
+ stCase9:
switch (m.data)[(m.p)] {
case 45:
goto st10
@@ -475,9 +482,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st10:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof10
+ goto _testEof10
}
- st_case_10:
+ stCase10:
switch (m.data)[(m.p)] {
case 45:
goto st11
@@ -499,9 +506,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st11:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof11
+ goto _testEof11
}
- st_case_11:
+ stCase11:
switch (m.data)[(m.p)] {
case 45:
goto st12
@@ -523,9 +530,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st12:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof12
+ goto _testEof12
}
- st_case_12:
+ stCase12:
switch (m.data)[(m.p)] {
case 45:
goto st13
@@ -547,9 +554,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st13:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof13
+ goto _testEof13
}
- st_case_13:
+ stCase13:
switch (m.data)[(m.p)] {
case 45:
goto st14
@@ -571,9 +578,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st14:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof14
+ goto _testEof14
}
- st_case_14:
+ stCase14:
switch (m.data)[(m.p)] {
case 45:
goto st15
@@ -595,9 +602,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st15:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof15
+ goto _testEof15
}
- st_case_15:
+ stCase15:
switch (m.data)[(m.p)] {
case 45:
goto st16
@@ -619,9 +626,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st16:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof16
+ goto _testEof16
}
- st_case_16:
+ stCase16:
switch (m.data)[(m.p)] {
case 45:
goto st17
@@ -643,9 +650,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st17:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof17
+ goto _testEof17
}
- st_case_17:
+ stCase17:
switch (m.data)[(m.p)] {
case 45:
goto st18
@@ -667,9 +674,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st18:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof18
+ goto _testEof18
}
- st_case_18:
+ stCase18:
switch (m.data)[(m.p)] {
case 45:
goto st19
@@ -691,9 +698,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st19:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof19
+ goto _testEof19
}
- st_case_19:
+ stCase19:
switch (m.data)[(m.p)] {
case 45:
goto st20
@@ -715,9 +722,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st20:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof20
+ goto _testEof20
}
- st_case_20:
+ stCase20:
switch (m.data)[(m.p)] {
case 45:
goto st21
@@ -739,9 +746,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st21:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof21
+ goto _testEof21
}
- st_case_21:
+ stCase21:
switch (m.data)[(m.p)] {
case 45:
goto st22
@@ -763,9 +770,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st22:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof22
+ goto _testEof22
}
- st_case_22:
+ stCase22:
switch (m.data)[(m.p)] {
case 45:
goto st23
@@ -787,9 +794,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st23:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof23
+ goto _testEof23
}
- st_case_23:
+ stCase23:
switch (m.data)[(m.p)] {
case 45:
goto st24
@@ -811,9 +818,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st24:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof24
+ goto _testEof24
}
- st_case_24:
+ stCase24:
switch (m.data)[(m.p)] {
case 45:
goto st25
@@ -835,9 +842,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st25:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof25
+ goto _testEof25
}
- st_case_25:
+ stCase25:
switch (m.data)[(m.p)] {
case 45:
goto st26
@@ -859,9 +866,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st26:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof26
+ goto _testEof26
}
- st_case_26:
+ stCase26:
switch (m.data)[(m.p)] {
case 45:
goto st27
@@ -883,9 +890,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st27:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof27
+ goto _testEof27
}
- st_case_27:
+ stCase27:
switch (m.data)[(m.p)] {
case 45:
goto st28
@@ -907,9 +914,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st28:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof28
+ goto _testEof28
}
- st_case_28:
+ stCase28:
switch (m.data)[(m.p)] {
case 45:
goto st29
@@ -931,9 +938,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st29:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof29
+ goto _testEof29
}
- st_case_29:
+ stCase29:
switch (m.data)[(m.p)] {
case 45:
goto st30
@@ -955,9 +962,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st30:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof30
+ goto _testEof30
}
- st_case_30:
+ stCase30:
switch (m.data)[(m.p)] {
case 45:
goto st31
@@ -979,9 +986,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st31:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof31
+ goto _testEof31
}
- st_case_31:
+ stCase31:
switch (m.data)[(m.p)] {
case 45:
goto st32
@@ -1003,9 +1010,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st32:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof32
+ goto _testEof32
}
- st_case_32:
+ stCase32:
switch (m.data)[(m.p)] {
case 45:
goto st33
@@ -1027,9 +1034,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st33:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof33
+ goto _testEof33
}
- st_case_33:
+ stCase33:
switch (m.data)[(m.p)] {
case 45:
goto st34
@@ -1051,9 +1058,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st34:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof34
+ goto _testEof34
}
- st_case_34:
+ stCase34:
switch (m.data)[(m.p)] {
case 45:
goto st35
@@ -1075,9 +1082,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st35:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof35
+ goto _testEof35
}
- st_case_35:
+ stCase35:
switch (m.data)[(m.p)] {
case 45:
goto st36
@@ -1099,9 +1106,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st36:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof36
+ goto _testEof36
}
- st_case_36:
+ stCase36:
switch (m.data)[(m.p)] {
case 45:
goto st37
@@ -1123,22 +1130,23 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st37:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof37
+ goto _testEof37
}
- st_case_37:
+ stCase37:
if (m.data)[(m.p)] == 58 {
goto tr10
}
goto tr6
tr10:
+
output.ID = string(m.text())
goto st38
st38:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof38
+ goto _testEof38
}
- st_case_38:
+ stCase38:
switch (m.data)[(m.p)] {
case 33:
goto tr42
@@ -1170,14 +1178,15 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
goto tr41
tr42:
+
m.pb = m.p
goto st44
st44:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof44
+ goto _testEof44
}
- st_case_44:
+ stCase44:
switch (m.data)[(m.p)] {
case 33:
goto st44
@@ -1209,14 +1218,15 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
goto tr41
tr43:
+
m.pb = m.p
goto st39
st39:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof39
+ goto _testEof39
}
- st_case_39:
+ stCase39:
switch {
case (m.data)[(m.p)] < 65:
if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
@@ -1231,14 +1241,15 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
goto tr44
tr46:
+
m.tolower = append(m.tolower, m.p-m.pb)
goto st40
st40:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof40
+ goto _testEof40
}
- st_case_40:
+ stCase40:
switch {
case (m.data)[(m.p)] < 65:
if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
@@ -1253,14 +1264,15 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
goto tr44
tr48:
+
m.tolower = append(m.tolower, m.p-m.pb)
goto st45
st45:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof45
+ goto _testEof45
}
- st_case_45:
+ stCase45:
switch (m.data)[(m.p)] {
case 33:
goto st44
@@ -1292,14 +1304,15 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
goto tr44
tr8:
+
m.pb = m.p
goto st41
st41:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof41
+ goto _testEof41
}
- st_case_41:
+ stCase41:
switch (m.data)[(m.p)] {
case 45:
goto st7
@@ -1325,9 +1338,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr6
st42:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof42
+ goto _testEof42
}
- st_case_42:
+ stCase42:
switch (m.data)[(m.p)] {
case 45:
goto st8
@@ -1353,9 +1366,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr50
st43:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof43
+ goto _testEof43
}
- st_case_43:
+ stCase43:
if (m.data)[(m.p)] == 45 {
goto st9
}
@@ -1374,9 +1387,9 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto tr52
st46:
if (m.p)++; (m.p) == (m.pe) {
- goto _test_eof46
+ goto _testEof46
}
- st_case_46:
+ stCase46:
switch (m.data)[(m.p)] {
case 10:
goto st0
@@ -1384,149 +1397,150 @@ func (m *machine) Parse(input []byte) (*URN, error) {
goto st0
}
goto st46
- st_out:
- _test_eof2:
+ stOut:
+ _testEof2:
m.cs = 2
- goto _test_eof
- _test_eof3:
+ goto _testEof
+ _testEof3:
m.cs = 3
- goto _test_eof
- _test_eof4:
+ goto _testEof
+ _testEof4:
m.cs = 4
- goto _test_eof
- _test_eof5:
+ goto _testEof
+ _testEof5:
m.cs = 5
- goto _test_eof
- _test_eof6:
+ goto _testEof
+ _testEof6:
m.cs = 6
- goto _test_eof
- _test_eof7:
+ goto _testEof
+ _testEof7:
m.cs = 7
- goto _test_eof
- _test_eof8:
+ goto _testEof
+ _testEof8:
m.cs = 8
- goto _test_eof
- _test_eof9:
+ goto _testEof
+ _testEof9:
m.cs = 9
- goto _test_eof
- _test_eof10:
+ goto _testEof
+ _testEof10:
m.cs = 10
- goto _test_eof
- _test_eof11:
+ goto _testEof
+ _testEof11:
m.cs = 11
- goto _test_eof
- _test_eof12:
+ goto _testEof
+ _testEof12:
m.cs = 12
- goto _test_eof
- _test_eof13:
+ goto _testEof
+ _testEof13:
m.cs = 13
- goto _test_eof
- _test_eof14:
+ goto _testEof
+ _testEof14:
m.cs = 14
- goto _test_eof
- _test_eof15:
+ goto _testEof
+ _testEof15:
m.cs = 15
- goto _test_eof
- _test_eof16:
+ goto _testEof
+ _testEof16:
m.cs = 16
- goto _test_eof
- _test_eof17:
+ goto _testEof
+ _testEof17:
m.cs = 17
- goto _test_eof
- _test_eof18:
+ goto _testEof
+ _testEof18:
m.cs = 18
- goto _test_eof
- _test_eof19:
+ goto _testEof
+ _testEof19:
m.cs = 19
- goto _test_eof
- _test_eof20:
+ goto _testEof
+ _testEof20:
m.cs = 20
- goto _test_eof
- _test_eof21:
+ goto _testEof
+ _testEof21:
m.cs = 21
- goto _test_eof
- _test_eof22:
+ goto _testEof
+ _testEof22:
m.cs = 22
- goto _test_eof
- _test_eof23:
+ goto _testEof
+ _testEof23:
m.cs = 23
- goto _test_eof
- _test_eof24:
+ goto _testEof
+ _testEof24:
m.cs = 24
- goto _test_eof
- _test_eof25:
+ goto _testEof
+ _testEof25:
m.cs = 25
- goto _test_eof
- _test_eof26:
+ goto _testEof
+ _testEof26:
m.cs = 26
- goto _test_eof
- _test_eof27:
+ goto _testEof
+ _testEof27:
m.cs = 27
- goto _test_eof
- _test_eof28:
+ goto _testEof
+ _testEof28:
m.cs = 28
- goto _test_eof
- _test_eof29:
+ goto _testEof
+ _testEof29:
m.cs = 29
- goto _test_eof
- _test_eof30:
+ goto _testEof
+ _testEof30:
m.cs = 30
- goto _test_eof
- _test_eof31:
+ goto _testEof
+ _testEof31:
m.cs = 31
- goto _test_eof
- _test_eof32:
+ goto _testEof
+ _testEof32:
m.cs = 32
- goto _test_eof
- _test_eof33:
+ goto _testEof
+ _testEof33:
m.cs = 33
- goto _test_eof
- _test_eof34:
+ goto _testEof
+ _testEof34:
m.cs = 34
- goto _test_eof
- _test_eof35:
+ goto _testEof
+ _testEof35:
m.cs = 35
- goto _test_eof
- _test_eof36:
+ goto _testEof
+ _testEof36:
m.cs = 36
- goto _test_eof
- _test_eof37:
+ goto _testEof
+ _testEof37:
m.cs = 37
- goto _test_eof
- _test_eof38:
+ goto _testEof
+ _testEof38:
m.cs = 38
- goto _test_eof
- _test_eof44:
+ goto _testEof
+ _testEof44:
m.cs = 44
- goto _test_eof
- _test_eof39:
+ goto _testEof
+ _testEof39:
m.cs = 39
- goto _test_eof
- _test_eof40:
+ goto _testEof
+ _testEof40:
m.cs = 40
- goto _test_eof
- _test_eof45:
+ goto _testEof
+ _testEof45:
m.cs = 45
- goto _test_eof
- _test_eof41:
+ goto _testEof
+ _testEof41:
m.cs = 41
- goto _test_eof
- _test_eof42:
+ goto _testEof
+ _testEof42:
m.cs = 42
- goto _test_eof
- _test_eof43:
+ goto _testEof
+ _testEof43:
m.cs = 43
- goto _test_eof
- _test_eof46:
+ goto _testEof
+ _testEof46:
m.cs = 46
- goto _test_eof
+ goto _testEof
- _test_eof:
+ _testEof:
{
}
if (m.p) == (m.eof) {
switch m.cs {
case 44, 45:
+
raw := m.text()
output.SS = string(raw)
// Iterate upper letters lowering them
@@ -1536,6 +1550,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
output.norm = string(raw)
case 1, 2, 4:
+
m.err = fmt.Errorf(errParse, m.p)
(m.p)--
@@ -1544,6 +1559,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
case 3:
+
m.err = fmt.Errorf(errPrefix, m.p)
(m.p)--
@@ -1559,6 +1575,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
case 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 41:
+
m.err = fmt.Errorf(errIdentifier, m.p)
(m.p)--
@@ -1574,6 +1591,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
case 38:
+
m.err = fmt.Errorf(errSpecificString, m.p)
(m.p)--
@@ -1589,6 +1607,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
case 42:
+
m.err = fmt.Errorf(errPrefix, m.p)
(m.p)--
@@ -1611,6 +1630,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
case 43:
+
m.err = fmt.Errorf(errNoUrnWithinID, m.p)
(m.p)--
@@ -1633,6 +1653,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
case 39, 40:
+
m.err = fmt.Errorf(errHex, m.p)
(m.p)--
@@ -1662,7 +1683,7 @@ func (m *machine) Parse(input []byte) (*URN, error) {
}
}
- if m.cs < first_final || m.cs == en_fail {
+ if m.cs < firstFinal || m.cs == enFail {
return nil, m.err
}
diff --git a/vendor/github.com/leodido/go-urn/makefile b/vendor/github.com/leodido/go-urn/makefile
index 362137ad29..47026d5099 100644
--- a/vendor/github.com/leodido/go-urn/makefile
+++ b/vendor/github.com/leodido/go-urn/makefile
@@ -1,12 +1,21 @@
SHELL := /bin/bash
+build: machine.go
+
+images: docs/urn.png
+
machine.go: machine.go.rl
ragel -Z -G2 -e -o $@ $<
- @gofmt -w -s $@
@sed -i '/^\/\/line/d' $@
+ @$(MAKE) -s file=$@ snake2camel
+ @gofmt -w -s $@
-.PHONY: build
-build: machine.go
+docs/urn.dot: machine.go.rl
+ @mkdir -p docs
+ ragel -Z -e -Vp $< -o $@
+
+docs/urn.png: docs/urn.dot
+ dot $< -Tpng -o $@
.PHONY: bench
bench: *_test.go machine.go
@@ -14,4 +23,17 @@ bench: *_test.go machine.go
.PHONY: tests
tests: *_test.go machine.go
- go test -race -timeout 10s -coverprofile=coverage.out -covermode=atomic -v ./...
\ No newline at end of file
+ go test -race -timeout 10s -coverprofile=coverage.out -covermode=atomic -v ./...
+
+.PHONY: clean
+clean:
+ @rm -rf docs
+ @rm -f machine.go
+
+.PHONY: snake2camel
+snake2camel:
+ @awk -i inplace '{ \
+ while ( match($$0, /(.*)([a-z]+[0-9]*)_([a-zA-Z0-9])(.*)/, cap) ) \
+ $$0 = cap[1] cap[2] toupper(cap[3]) cap[4]; \
+ print \
+ }' $(file)
\ No newline at end of file
diff --git a/vendor/github.com/mattn/go-isatty/.travis.yml b/vendor/github.com/mattn/go-isatty/.travis.yml
index 5597e026dd..604314dd44 100644
--- a/vendor/github.com/mattn/go-isatty/.travis.yml
+++ b/vendor/github.com/mattn/go-isatty/.travis.yml
@@ -1,13 +1,14 @@
language: go
+sudo: false
go:
+ - 1.13.x
- tip
-os:
- - linux
- - osx
-
before_install:
- - go get github.com/mattn/goveralls
- - go get golang.org/x/tools/cmd/cover
+ - go get -t -v ./...
+
script:
- - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5
+ - ./go.test.sh
+
+after_success:
+ - bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/github.com/mattn/go-isatty/README.md b/vendor/github.com/mattn/go-isatty/README.md
index 1e69004bb0..38418353e3 100644
--- a/vendor/github.com/mattn/go-isatty/README.md
+++ b/vendor/github.com/mattn/go-isatty/README.md
@@ -1,7 +1,7 @@
# go-isatty
[](http://godoc.org/github.com/mattn/go-isatty)
-[](https://travis-ci.org/mattn/go-isatty)
+[](https://codecov.io/gh/mattn/go-isatty)
[](https://coveralls.io/github/mattn/go-isatty?branch=master)
[](https://goreportcard.com/report/mattn/go-isatty)
diff --git a/vendor/github.com/mattn/go-isatty/go.mod b/vendor/github.com/mattn/go-isatty/go.mod
index 3b9b9abfb9..605c4c2210 100644
--- a/vendor/github.com/mattn/go-isatty/go.mod
+++ b/vendor/github.com/mattn/go-isatty/go.mod
@@ -1,3 +1,5 @@
module github.com/mattn/go-isatty
-require golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
+go 1.12
+
+require golang.org/x/sys v0.0.0-20200116001909-b77594299b42
diff --git a/vendor/github.com/mattn/go-isatty/go.sum b/vendor/github.com/mattn/go-isatty/go.sum
index b1bd14d21d..912e29cbc1 100644
--- a/vendor/github.com/mattn/go-isatty/go.sum
+++ b/vendor/github.com/mattn/go-isatty/go.sum
@@ -1,2 +1,2 @@
-golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
-golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/vendor/github.com/mattn/go-isatty/go.test.sh b/vendor/github.com/mattn/go-isatty/go.test.sh
new file mode 100644
index 0000000000..012162b077
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/go.test.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -e
+echo "" > coverage.txt
+
+for d in $(go list ./... | grep -v vendor); do
+ go test -race -coverprofile=profile.out -covermode=atomic "$d"
+ if [ -f profile.out ]; then
+ cat profile.out >> coverage.txt
+ rm profile.out
+ fi
+done
diff --git a/vendor/github.com/mattn/go-isatty/isatty_android.go b/vendor/github.com/mattn/go-isatty/isatty_android.go
deleted file mode 100644
index d3567cb5bf..0000000000
--- a/vendor/github.com/mattn/go-isatty/isatty_android.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// +build android
-
-package isatty
-
-import (
- "syscall"
- "unsafe"
-)
-
-const ioctlReadTermios = syscall.TCGETS
-
-// IsTerminal return true if the file descriptor is terminal.
-func IsTerminal(fd uintptr) bool {
- var termios syscall.Termios
- _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
- return err == 0
-}
-
-// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
-// terminal. This is also always false on this environment.
-func IsCygwinTerminal(fd uintptr) bool {
- return false
-}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_bsd.go b/vendor/github.com/mattn/go-isatty/isatty_bsd.go
index 07e93039db..711f288085 100644
--- a/vendor/github.com/mattn/go-isatty/isatty_bsd.go
+++ b/vendor/github.com/mattn/go-isatty/isatty_bsd.go
@@ -3,18 +3,12 @@
package isatty
-import (
- "syscall"
- "unsafe"
-)
-
-const ioctlReadTermios = syscall.TIOCGETA
+import "golang.org/x/sys/unix"
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
- var termios syscall.Termios
- _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
- return err == 0
+ _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
+ return err == nil
}
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
diff --git a/vendor/github.com/mattn/go-isatty/isatty_plan9.go b/vendor/github.com/mattn/go-isatty/isatty_plan9.go
new file mode 100644
index 0000000000..c5b6e0c084
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/isatty_plan9.go
@@ -0,0 +1,22 @@
+// +build plan9
+
+package isatty
+
+import (
+ "syscall"
+)
+
+// IsTerminal returns true if the given file descriptor is a terminal.
+func IsTerminal(fd uintptr) bool {
+ path, err := syscall.Fd2path(int(fd))
+ if err != nil {
+ return false
+ }
+ return path == "/dev/cons" || path == "/mnt/term/dev/cons"
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_tcgets.go b/vendor/github.com/mattn/go-isatty/isatty_tcgets.go
index 453b025d0d..31a1ca973c 100644
--- a/vendor/github.com/mattn/go-isatty/isatty_tcgets.go
+++ b/vendor/github.com/mattn/go-isatty/isatty_tcgets.go
@@ -1,6 +1,5 @@
// +build linux aix
// +build !appengine
-// +build !android
package isatty
diff --git a/vendor/github.com/mattn/go-isatty/isatty_windows.go b/vendor/github.com/mattn/go-isatty/isatty_windows.go
index af51cbcaa4..1fa8691540 100644
--- a/vendor/github.com/mattn/go-isatty/isatty_windows.go
+++ b/vendor/github.com/mattn/go-isatty/isatty_windows.go
@@ -4,6 +4,7 @@
package isatty
import (
+ "errors"
"strings"
"syscall"
"unicode/utf16"
@@ -11,15 +12,18 @@ import (
)
const (
- fileNameInfo uintptr = 2
- fileTypePipe = 3
+ objectNameInfo uintptr = 1
+ fileNameInfo = 2
+ fileTypePipe = 3
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
+ ntdll = syscall.NewLazyDLL("ntdll.dll")
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
procGetFileType = kernel32.NewProc("GetFileType")
+ procNtQueryObject = ntdll.NewProc("NtQueryObject")
)
func init() {
@@ -45,7 +49,10 @@ func isCygwinPipeName(name string) bool {
return false
}
- if token[0] != `\msys` && token[0] != `\cygwin` {
+ if token[0] != `\msys` &&
+ token[0] != `\cygwin` &&
+ token[0] != `\Device\NamedPipe\msys` &&
+ token[0] != `\Device\NamedPipe\cygwin` {
return false
}
@@ -68,11 +75,35 @@ func isCygwinPipeName(name string) bool {
return true
}
+// getFileNameByHandle use the undocomented ntdll NtQueryObject to get file full name from file handler
+// since GetFileInformationByHandleEx is not avilable under windows Vista and still some old fashion
+// guys are using Windows XP, this is a workaround for those guys, it will also work on system from
+// Windows vista to 10
+// see https://stackoverflow.com/a/18792477 for details
+func getFileNameByHandle(fd uintptr) (string, error) {
+ if procNtQueryObject == nil {
+ return "", errors.New("ntdll.dll: NtQueryObject not supported")
+ }
+
+ var buf [4 + syscall.MAX_PATH]uint16
+ var result int
+ r, _, e := syscall.Syscall6(procNtQueryObject.Addr(), 5,
+ fd, objectNameInfo, uintptr(unsafe.Pointer(&buf)), uintptr(2*len(buf)), uintptr(unsafe.Pointer(&result)), 0)
+ if r != 0 {
+ return "", e
+ }
+ return string(utf16.Decode(buf[4 : 4+buf[0]/2])), nil
+}
+
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal.
func IsCygwinTerminal(fd uintptr) bool {
if procGetFileInformationByHandleEx == nil {
- return false
+ name, err := getFileNameByHandle(fd)
+ if err != nil {
+ return false
+ }
+ return isCygwinPipeName(name)
}
// Cygwin/msys's pty is a pipe.
diff --git a/vendor/github.com/mattn/go-isatty/renovate.json b/vendor/github.com/mattn/go-isatty/renovate.json
new file mode 100644
index 0000000000..5ae9d96b74
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/renovate.json
@@ -0,0 +1,8 @@
+{
+ "extends": [
+ "config:base"
+ ],
+ "postUpdateOptions": [
+ "gomodTidy"
+ ]
+}
diff --git a/vendor/github.com/miekg/dns/.travis.yml b/vendor/github.com/miekg/dns/.travis.yml
index 18259374e5..7661bfd87c 100644
--- a/vendor/github.com/miekg/dns/.travis.yml
+++ b/vendor/github.com/miekg/dns/.travis.yml
@@ -2,14 +2,12 @@ language: go
sudo: false
go:
- - 1.10.x
- - 1.11.x
+ - "1.12.x"
+ - "1.13.x"
- tip
-before_install:
- # don't use the miekg/dns when testing forks
- - mkdir -p $GOPATH/src/github.com/miekg
- - ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/miekg/ || true
+env:
+ - GO111MODULE=on
script:
- go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./...
diff --git a/vendor/github.com/miekg/dns/CODEOWNERS b/vendor/github.com/miekg/dns/CODEOWNERS
new file mode 100644
index 0000000000..e0917031bc
--- /dev/null
+++ b/vendor/github.com/miekg/dns/CODEOWNERS
@@ -0,0 +1 @@
+* @miekg @tmthrgd
diff --git a/vendor/github.com/miekg/dns/Gopkg.lock b/vendor/github.com/miekg/dns/Gopkg.lock
deleted file mode 100644
index 686632207a..0000000000
--- a/vendor/github.com/miekg/dns/Gopkg.lock
+++ /dev/null
@@ -1,57 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
- branch = "master"
- digest = "1:6914c49eed986dfb8dffb33516fa129c49929d4d873f41e073c83c11c372b870"
- name = "golang.org/x/crypto"
- packages = [
- "ed25519",
- "ed25519/internal/edwards25519",
- ]
- pruneopts = ""
- revision = "e3636079e1a4c1f337f212cc5cd2aca108f6c900"
-
-[[projects]]
- branch = "master"
- digest = "1:08e41d63f8dac84d83797368b56cf0b339e42d0224e5e56668963c28aec95685"
- name = "golang.org/x/net"
- packages = [
- "bpf",
- "context",
- "internal/iana",
- "internal/socket",
- "ipv4",
- "ipv6",
- ]
- pruneopts = ""
- revision = "4dfa2610cdf3b287375bbba5b8f2a14d3b01d8de"
-
-[[projects]]
- branch = "master"
- digest = "1:b2ea75de0ccb2db2ac79356407f8a4cd8f798fe15d41b381c00abf3ae8e55ed1"
- name = "golang.org/x/sync"
- packages = ["errgroup"]
- pruneopts = ""
- revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca"
-
-[[projects]]
- branch = "master"
- digest = "1:149a432fabebb8221a80f77731b1cd63597197ded4f14af606ebe3a0959004ec"
- name = "golang.org/x/sys"
- packages = ["unix"]
- pruneopts = ""
- revision = "e4b3c5e9061176387e7cea65e4dc5853801f3fb7"
-
-[solve-meta]
- analyzer-name = "dep"
- analyzer-version = 1
- input-imports = [
- "golang.org/x/crypto/ed25519",
- "golang.org/x/net/ipv4",
- "golang.org/x/net/ipv6",
- "golang.org/x/sync/errgroup",
- "golang.org/x/sys/unix",
- ]
- solver-name = "gps-cdcl"
- solver-version = 1
diff --git a/vendor/github.com/miekg/dns/Gopkg.toml b/vendor/github.com/miekg/dns/Gopkg.toml
deleted file mode 100644
index 85e6ff31b2..0000000000
--- a/vendor/github.com/miekg/dns/Gopkg.toml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-# Gopkg.toml example
-#
-# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
-# for detailed Gopkg.toml documentation.
-#
-# required = ["github.com/user/thing/cmd/thing"]
-# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
-#
-# [[constraint]]
-# name = "github.com/user/project"
-# version = "1.0.0"
-#
-# [[constraint]]
-# name = "github.com/user/project2"
-# branch = "dev"
-# source = "github.com/myfork/project2"
-#
-# [[override]]
-# name = "github.com/x/y"
-# version = "2.4.0"
-
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/crypto"
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/net"
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/sys"
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/sync"
diff --git a/vendor/github.com/miekg/dns/README.md b/vendor/github.com/miekg/dns/README.md
index 39737c78aa..de4afed69a 100644
--- a/vendor/github.com/miekg/dns/README.md
+++ b/vendor/github.com/miekg/dns/README.md
@@ -68,6 +68,8 @@ A not-so-up-to-date-list-that-may-be-actually-current:
* https://blitiri.com.ar/p/dnss ([github mirror](https://github.com/albertito/dnss))
* https://github.com/semihalev/sdns
* https://render.com
+* https://github.com/peterzen/goresolver
+* https://github.com/folbricht/routedns
Send pull request if you want to be listed here.
@@ -151,6 +153,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
* 6844 - CAA record
* 6891 - EDNS0 update
* 6895 - DNS IANA considerations
+* 6944 - DNSSEC DNSKEY Algorithm Status
* 6975 - Algorithm Understanding in DNSSEC
* 7043 - EUI48/EUI64 records
* 7314 - DNS (EDNS) EXPIRE Option
diff --git a/vendor/github.com/miekg/dns/acceptfunc.go b/vendor/github.com/miekg/dns/acceptfunc.go
index 78c076c253..eba7dcd51e 100644
--- a/vendor/github.com/miekg/dns/acceptfunc.go
+++ b/vendor/github.com/miekg/dns/acceptfunc.go
@@ -19,9 +19,10 @@ var DefaultMsgAcceptFunc MsgAcceptFunc = defaultMsgAcceptFunc
type MsgAcceptAction int
const (
- MsgAccept MsgAcceptAction = iota // Accept the message
- MsgReject // Reject the message with a RcodeFormatError
- MsgIgnore // Ignore the error and send nothing back.
+ MsgAccept MsgAcceptAction = iota // Accept the message
+ MsgReject // Reject the message with a RcodeFormatError
+ MsgIgnore // Ignore the error and send nothing back.
+ MsgRejectNotImplemented // Reject the message with a RcodeNotImplemented
)
func defaultMsgAcceptFunc(dh Header) MsgAcceptAction {
@@ -32,12 +33,9 @@ func defaultMsgAcceptFunc(dh Header) MsgAcceptAction {
// Don't allow dynamic updates, because then the sections can contain a whole bunch of RRs.
opcode := int(dh.Bits>>11) & 0xF
if opcode != OpcodeQuery && opcode != OpcodeNotify {
- return MsgReject
+ return MsgRejectNotImplemented
}
- if isZero := dh.Bits&_Z != 0; isZero {
- return MsgReject
- }
if dh.Qdcount != 1 {
return MsgReject
}
diff --git a/vendor/github.com/miekg/dns/client.go b/vendor/github.com/miekg/dns/client.go
index 2393564c52..db2761d45b 100644
--- a/vendor/github.com/miekg/dns/client.go
+++ b/vendor/github.com/miekg/dns/client.go
@@ -3,10 +3,10 @@ package dns
// A client implementation.
import (
- "bytes"
"context"
"crypto/tls"
"encoding/binary"
+ "fmt"
"io"
"net"
"strings"
@@ -129,20 +129,15 @@ func (c *Client) Exchange(m *Msg, address string) (r *Msg, rtt time.Duration, er
return c.exchange(m, address)
}
- t := "nop"
- if t1, ok := TypeToString[m.Question[0].Qtype]; ok {
- t = t1
- }
- cl := "nop"
- if cl1, ok := ClassToString[m.Question[0].Qclass]; ok {
- cl = cl1
- }
- r, rtt, err, shared := c.group.Do(m.Question[0].Name+t+cl, func() (*Msg, time.Duration, error) {
+ q := m.Question[0]
+ key := fmt.Sprintf("%s:%d:%d", q.Name, q.Qtype, q.Qclass)
+ r, rtt, err, shared := c.group.Do(key, func() (*Msg, time.Duration, error) {
return c.exchange(m, address)
})
if r != nil && shared {
r = r.Copy()
}
+
return r, rtt, err
}
@@ -221,24 +216,21 @@ func (co *Conn) ReadMsgHeader(hdr *Header) ([]byte, error) {
err error
)
- switch t := co.Conn.(type) {
- case *net.TCPConn, *tls.Conn:
- r := t.(io.Reader)
-
- // First two bytes specify the length of the entire message.
- l, err := tcpMsgLen(r)
- if err != nil {
- return nil, err
- }
- p = make([]byte, l)
- n, err = tcpRead(r, p)
- default:
+ if _, ok := co.Conn.(net.PacketConn); ok {
if co.UDPSize > MinMsgSize {
p = make([]byte, co.UDPSize)
} else {
p = make([]byte, MinMsgSize)
}
n, err = co.Read(p)
+ } else {
+ var length uint16
+ if err := binary.Read(co.Conn, binary.BigEndian, &length); err != nil {
+ return nil, err
+ }
+
+ p = make([]byte, length)
+ n, err = io.ReadFull(co.Conn, p)
}
if err != nil {
@@ -258,74 +250,26 @@ func (co *Conn) ReadMsgHeader(hdr *Header) ([]byte, error) {
return p, err
}
-// tcpMsgLen is a helper func to read first two bytes of stream as uint16 packet length.
-func tcpMsgLen(t io.Reader) (int, error) {
- p := []byte{0, 0}
- n, err := t.Read(p)
- if err != nil {
- return 0, err
- }
-
- // As seen with my local router/switch, returns 1 byte on the above read,
- // resulting a a ShortRead. Just write it out (instead of loop) and read the
- // other byte.
- if n == 1 {
- n1, err := t.Read(p[1:])
- if err != nil {
- return 0, err
- }
- n += n1
- }
-
- if n != 2 {
- return 0, ErrShortRead
- }
- l := binary.BigEndian.Uint16(p)
- if l == 0 {
- return 0, ErrShortRead
- }
- return int(l), nil
-}
-
-// tcpRead calls TCPConn.Read enough times to fill allocated buffer.
-func tcpRead(t io.Reader, p []byte) (int, error) {
- n, err := t.Read(p)
- if err != nil {
- return n, err
- }
- for n < len(p) {
- j, err := t.Read(p[n:])
- if err != nil {
- return n, err
- }
- n += j
- }
- return n, err
-}
-
// Read implements the net.Conn read method.
func (co *Conn) Read(p []byte) (n int, err error) {
if co.Conn == nil {
return 0, ErrConnEmpty
}
- if len(p) < 2 {
+
+ if _, ok := co.Conn.(net.PacketConn); ok {
+ // UDP connection
+ return co.Conn.Read(p)
+ }
+
+ var length uint16
+ if err := binary.Read(co.Conn, binary.BigEndian, &length); err != nil {
+ return 0, err
+ }
+ if int(length) > len(p) {
return 0, io.ErrShortBuffer
}
- switch t := co.Conn.(type) {
- case *net.TCPConn, *tls.Conn:
- r := t.(io.Reader)
- l, err := tcpMsgLen(r)
- if err != nil {
- return 0, err
- }
- if l > len(p) {
- return l, io.ErrShortBuffer
- }
- return tcpRead(r, p[:l])
- }
- // UDP connection
- return co.Conn.Read(p)
+ return io.ReadFull(co.Conn, p[:length])
}
// WriteMsg sends a message through the connection co.
@@ -352,25 +296,20 @@ func (co *Conn) WriteMsg(m *Msg) (err error) {
}
// Write implements the net.Conn Write method.
-func (co *Conn) Write(p []byte) (n int, err error) {
- switch t := co.Conn.(type) {
- case *net.TCPConn, *tls.Conn:
- w := t.(io.Writer)
-
- lp := len(p)
- if lp < 2 {
- return 0, io.ErrShortBuffer
- }
- if lp > MaxMsgSize {
- return 0, &Error{err: "message too large"}
- }
- l := make([]byte, 2, lp+2)
- binary.BigEndian.PutUint16(l, uint16(lp))
- p = append(l, p...)
- n, err := io.Copy(w, bytes.NewReader(p))
- return int(n), err
+func (co *Conn) Write(p []byte) (int, error) {
+ if len(p) > MaxMsgSize {
+ return 0, &Error{err: "message too large"}
}
- return co.Conn.Write(p)
+
+ if _, ok := co.Conn.(net.PacketConn); ok {
+ return co.Conn.Write(p)
+ }
+
+ l := make([]byte, 2)
+ binary.BigEndian.PutUint16(l, uint16(len(p)))
+
+ n, err := (&net.Buffers{l, p}).WriteTo(co.Conn)
+ return int(n), err
}
// Return the appropriate timeout for a specific request
@@ -413,7 +352,7 @@ func ExchangeContext(ctx context.Context, m *Msg, a string) (r *Msg, err error)
// ExchangeConn performs a synchronous query. It sends the message m via the connection
// c and waits for a reply. The connection c is not closed by ExchangeConn.
-// This function is going away, but can easily be mimicked:
+// Deprecated: This function is going away, but can easily be mimicked:
//
// co := &dns.Conn{Conn: c} // c is your net.Conn
// co.WriteMsg(m)
diff --git a/vendor/github.com/miekg/dns/clientconfig.go b/vendor/github.com/miekg/dns/clientconfig.go
index f13cfa30cb..e11b630df9 100644
--- a/vendor/github.com/miekg/dns/clientconfig.go
+++ b/vendor/github.com/miekg/dns/clientconfig.go
@@ -68,14 +68,10 @@ func ClientConfigFromReader(resolvconf io.Reader) (*ClientConfig, error) {
}
case "search": // set search path to given servers
- c.Search = make([]string, len(f)-1)
- for i := 0; i < len(c.Search); i++ {
- c.Search[i] = f[i+1]
- }
+ c.Search = append([]string(nil), f[1:]...)
case "options": // magic options
- for i := 1; i < len(f); i++ {
- s := f[i]
+ for _, s := range f[1:] {
switch {
case len(s) >= 6 && s[:6] == "ndots:":
n, _ := strconv.Atoi(s[6:])
diff --git a/vendor/github.com/miekg/dns/defaults.go b/vendor/github.com/miekg/dns/defaults.go
index 391d67a2c7..b059f6fc67 100644
--- a/vendor/github.com/miekg/dns/defaults.go
+++ b/vendor/github.com/miekg/dns/defaults.go
@@ -146,10 +146,9 @@ func (dns *Msg) IsTsig() *TSIG {
// record in the additional section will do. It returns the OPT record
// found or nil.
func (dns *Msg) IsEdns0() *OPT {
- // EDNS0 is at the end of the additional section, start there.
- // We might want to change this to *only* look at the last two
- // records. So we see TSIG and/or OPT - this a slightly bigger
- // change though.
+ // RFC 6891, Section 6.1.1 allows the OPT record to appear
+ // anywhere in the additional record section, but it's usually at
+ // the end so start there.
for i := len(dns.Extra) - 1; i >= 0; i-- {
if dns.Extra[i].Header().Rrtype == TypeOPT {
return dns.Extra[i].(*OPT)
@@ -158,6 +157,21 @@ func (dns *Msg) IsEdns0() *OPT {
return nil
}
+// popEdns0 is like IsEdns0, but it removes the record from the message.
+func (dns *Msg) popEdns0() *OPT {
+ // RFC 6891, Section 6.1.1 allows the OPT record to appear
+ // anywhere in the additional record section, but it's usually at
+ // the end so start there.
+ for i := len(dns.Extra) - 1; i >= 0; i-- {
+ if dns.Extra[i].Header().Rrtype == TypeOPT {
+ opt := dns.Extra[i].(*OPT)
+ dns.Extra = append(dns.Extra[:i], dns.Extra[i+1:]...)
+ return opt
+ }
+ }
+ return nil
+}
+
// IsDomainName checks if s is a valid domain name, it returns the number of
// labels and true, when a domain name is valid. Note that non fully qualified
// domain name is considered valid, in this case the last label is counted in
diff --git a/vendor/github.com/miekg/dns/dns.go b/vendor/github.com/miekg/dns/dns.go
index f57337b89e..ad83a27ecf 100644
--- a/vendor/github.com/miekg/dns/dns.go
+++ b/vendor/github.com/miekg/dns/dns.go
@@ -54,7 +54,7 @@ type RR interface {
// parse parses an RR from zone file format.
//
// This will only be called on a new and empty RR type with only the header populated.
- parse(c *zlexer, origin, file string) *ParseError
+ parse(c *zlexer, origin string) *ParseError
// isDuplicate returns whether the two RRs are duplicates.
isDuplicate(r2 RR) bool
@@ -105,7 +105,7 @@ func (h *RR_Header) unpack(msg []byte, off int) (int, error) {
panic("dns: internal error: unpack should never be called on RR_Header")
}
-func (h *RR_Header) parse(c *zlexer, origin, file string) *ParseError {
+func (h *RR_Header) parse(c *zlexer, origin string) *ParseError {
panic("dns: internal error: parse should never be called on RR_Header")
}
diff --git a/vendor/github.com/miekg/dns/dnssec.go b/vendor/github.com/miekg/dns/dnssec.go
index 3954d4198e..12a693f97c 100644
--- a/vendor/github.com/miekg/dns/dnssec.go
+++ b/vendor/github.com/miekg/dns/dnssec.go
@@ -141,8 +141,8 @@ func (k *DNSKEY) KeyTag() uint16 {
switch k.Algorithm {
case RSAMD5:
// Look at the bottom two bytes of the modules, which the last
- // item in the pubkey. We could do this faster by looking directly
- // at the base64 values. But I'm lazy.
+ // item in the pubkey.
+ // This algorithm has been deprecated, but keep this key-tag calculation.
modulus, _ := fromBase64([]byte(k.PublicKey))
if len(modulus) > 1 {
x := binary.BigEndian.Uint16(modulus[len(modulus)-2:])
@@ -318,6 +318,9 @@ func (rr *RRSIG) Sign(k crypto.Signer, rrset []RR) error {
}
rr.Signature = toBase64(signature)
+ case RSAMD5, DSA, DSANSEC3SHA1:
+ // See RFC 6944.
+ return ErrAlg
default:
h := hash.New()
h.Write(signdata)
@@ -556,19 +559,18 @@ func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey {
pubkey := new(rsa.PublicKey)
var expo uint64
- for i := 0; i < int(explen); i++ {
+ // The exponent of length explen is between keyoff and modoff.
+ for _, v := range keybuf[keyoff:modoff] {
expo <<= 8
- expo |= uint64(keybuf[keyoff+i])
+ expo |= uint64(v)
}
if expo > 1<<31-1 {
// Larger exponent than supported by the crypto package.
return nil
}
+
pubkey.E = int(expo)
-
- pubkey.N = big.NewInt(0)
- pubkey.N.SetBytes(keybuf[modoff:])
-
+ pubkey.N = new(big.Int).SetBytes(keybuf[modoff:])
return pubkey
}
@@ -593,10 +595,8 @@ func (k *DNSKEY) publicKeyECDSA() *ecdsa.PublicKey {
return nil
}
}
- pubkey.X = big.NewInt(0)
- pubkey.X.SetBytes(keybuf[:len(keybuf)/2])
- pubkey.Y = big.NewInt(0)
- pubkey.Y.SetBytes(keybuf[len(keybuf)/2:])
+ pubkey.X = new(big.Int).SetBytes(keybuf[:len(keybuf)/2])
+ pubkey.Y = new(big.Int).SetBytes(keybuf[len(keybuf)/2:])
return pubkey
}
@@ -617,10 +617,10 @@ func (k *DNSKEY) publicKeyDSA() *dsa.PublicKey {
p, keybuf := keybuf[:size], keybuf[size:]
g, y := keybuf[:size], keybuf[size:]
pubkey := new(dsa.PublicKey)
- pubkey.Parameters.Q = big.NewInt(0).SetBytes(q)
- pubkey.Parameters.P = big.NewInt(0).SetBytes(p)
- pubkey.Parameters.G = big.NewInt(0).SetBytes(g)
- pubkey.Y = big.NewInt(0).SetBytes(y)
+ pubkey.Parameters.Q = new(big.Int).SetBytes(q)
+ pubkey.Parameters.P = new(big.Int).SetBytes(p)
+ pubkey.Parameters.G = new(big.Int).SetBytes(g)
+ pubkey.Y = new(big.Int).SetBytes(y)
return pubkey
}
diff --git a/vendor/github.com/miekg/dns/dnssec_keygen.go b/vendor/github.com/miekg/dns/dnssec_keygen.go
index 33e913ac52..60737e5b2b 100644
--- a/vendor/github.com/miekg/dns/dnssec_keygen.go
+++ b/vendor/github.com/miekg/dns/dnssec_keygen.go
@@ -2,7 +2,6 @@ package dns
import (
"crypto"
- "crypto/dsa"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
@@ -20,11 +19,9 @@ import (
// bits should be set to the size of the algorithm.
func (k *DNSKEY) Generate(bits int) (crypto.PrivateKey, error) {
switch k.Algorithm {
- case DSA, DSANSEC3SHA1:
- if bits != 1024 {
- return nil, ErrKeySize
- }
- case RSAMD5, RSASHA1, RSASHA256, RSASHA1NSEC3SHA1:
+ case RSAMD5, DSA, DSANSEC3SHA1:
+ return nil, ErrAlg
+ case RSASHA1, RSASHA256, RSASHA1NSEC3SHA1:
if bits < 512 || bits > 4096 {
return nil, ErrKeySize
}
@@ -47,20 +44,7 @@ func (k *DNSKEY) Generate(bits int) (crypto.PrivateKey, error) {
}
switch k.Algorithm {
- case DSA, DSANSEC3SHA1:
- params := new(dsa.Parameters)
- if err := dsa.GenerateParameters(params, rand.Reader, dsa.L1024N160); err != nil {
- return nil, err
- }
- priv := new(dsa.PrivateKey)
- priv.PublicKey.Parameters = *params
- err := dsa.GenerateKey(priv, rand.Reader)
- if err != nil {
- return nil, err
- }
- k.setPublicKeyDSA(params.Q, params.P, params.G, priv.PublicKey.Y)
- return priv, nil
- case RSAMD5, RSASHA1, RSASHA256, RSASHA512, RSASHA1NSEC3SHA1:
+ case RSASHA1, RSASHA256, RSASHA512, RSASHA1NSEC3SHA1:
priv, err := rsa.GenerateKey(rand.Reader, bits)
if err != nil {
return nil, err
@@ -120,16 +104,6 @@ func (k *DNSKEY) setPublicKeyECDSA(_X, _Y *big.Int) bool {
return true
}
-// Set the public key for DSA
-func (k *DNSKEY) setPublicKeyDSA(_Q, _P, _G, _Y *big.Int) bool {
- if _Q == nil || _P == nil || _G == nil || _Y == nil {
- return false
- }
- buf := dsaToBuf(_Q, _P, _G, _Y)
- k.PublicKey = toBase64(buf)
- return true
-}
-
// Set the public key for Ed25519
func (k *DNSKEY) setPublicKeyED25519(_K ed25519.PublicKey) bool {
if _K == nil {
@@ -164,15 +138,3 @@ func curveToBuf(_X, _Y *big.Int, intlen int) []byte {
buf = append(buf, intToBytes(_Y, intlen)...)
return buf
}
-
-// Set the public key for X and Y for Curve. The two
-// values are just concatenated.
-func dsaToBuf(_Q, _P, _G, _Y *big.Int) []byte {
- t := divRoundUp(divRoundUp(_G.BitLen(), 8)-64, 8)
- buf := []byte{byte(t)}
- buf = append(buf, intToBytes(_Q, 20)...)
- buf = append(buf, intToBytes(_P, 64+t*8)...)
- buf = append(buf, intToBytes(_G, 64+t*8)...)
- buf = append(buf, intToBytes(_Y, 64+t*8)...)
- return buf
-}
diff --git a/vendor/github.com/miekg/dns/dnssec_keyscan.go b/vendor/github.com/miekg/dns/dnssec_keyscan.go
index 5e65422301..0e6f320165 100644
--- a/vendor/github.com/miekg/dns/dnssec_keyscan.go
+++ b/vendor/github.com/miekg/dns/dnssec_keyscan.go
@@ -3,7 +3,6 @@ package dns
import (
"bufio"
"crypto"
- "crypto/dsa"
"crypto/ecdsa"
"crypto/rsa"
"io"
@@ -44,19 +43,8 @@ func (k *DNSKEY) ReadPrivateKey(q io.Reader, file string) (crypto.PrivateKey, er
return nil, ErrPrivKey
}
switch uint8(algo) {
- case DSA:
- priv, err := readPrivateKeyDSA(m)
- if err != nil {
- return nil, err
- }
- pub := k.publicKeyDSA()
- if pub == nil {
- return nil, ErrKey
- }
- priv.PublicKey = *pub
- return priv, nil
- case RSAMD5:
- fallthrough
+ case RSAMD5, DSA, DSANSEC3SHA1:
+ return nil, ErrAlg
case RSASHA1:
fallthrough
case RSASHA1NSEC3SHA1:
@@ -109,21 +97,16 @@ func readPrivateKeyRSA(m map[string]string) (*rsa.PrivateKey, error) {
}
switch k {
case "modulus":
- p.PublicKey.N = big.NewInt(0)
- p.PublicKey.N.SetBytes(v1)
+ p.PublicKey.N = new(big.Int).SetBytes(v1)
case "publicexponent":
- i := big.NewInt(0)
- i.SetBytes(v1)
+ i := new(big.Int).SetBytes(v1)
p.PublicKey.E = int(i.Int64()) // int64 should be large enough
case "privateexponent":
- p.D = big.NewInt(0)
- p.D.SetBytes(v1)
+ p.D = new(big.Int).SetBytes(v1)
case "prime1":
- p.Primes[0] = big.NewInt(0)
- p.Primes[0].SetBytes(v1)
+ p.Primes[0] = new(big.Int).SetBytes(v1)
case "prime2":
- p.Primes[1] = big.NewInt(0)
- p.Primes[1].SetBytes(v1)
+ p.Primes[1] = new(big.Int).SetBytes(v1)
}
case "exponent1", "exponent2", "coefficient":
// not used in Go (yet)
@@ -134,27 +117,9 @@ func readPrivateKeyRSA(m map[string]string) (*rsa.PrivateKey, error) {
return p, nil
}
-func readPrivateKeyDSA(m map[string]string) (*dsa.PrivateKey, error) {
- p := new(dsa.PrivateKey)
- p.X = big.NewInt(0)
- for k, v := range m {
- switch k {
- case "private_value(x)":
- v1, err := fromBase64([]byte(v))
- if err != nil {
- return nil, err
- }
- p.X.SetBytes(v1)
- case "created", "publish", "activate":
- /* not used in Go (yet) */
- }
- }
- return p, nil
-}
-
func readPrivateKeyECDSA(m map[string]string) (*ecdsa.PrivateKey, error) {
p := new(ecdsa.PrivateKey)
- p.D = big.NewInt(0)
+ p.D = new(big.Int)
// TODO: validate that the required flags are present
for k, v := range m {
switch k {
@@ -322,6 +287,11 @@ func (kl *klexer) Next() (lex, bool) {
commt = false
}
+ if kl.key && str.Len() == 0 {
+ // ignore empty lines
+ break
+ }
+
kl.key = true
l.value = zValue
diff --git a/vendor/github.com/miekg/dns/dnssec_privkey.go b/vendor/github.com/miekg/dns/dnssec_privkey.go
index 0c65be17bc..4493c9d574 100644
--- a/vendor/github.com/miekg/dns/dnssec_privkey.go
+++ b/vendor/github.com/miekg/dns/dnssec_privkey.go
@@ -13,6 +13,8 @@ import (
const format = "Private-key-format: v1.3\n"
+var bigIntOne = big.NewInt(1)
+
// PrivateKeyString converts a PrivateKey to a string. This string has the same
// format as the private-key-file of BIND9 (Private-key-format: v1.3).
// It needs some info from the key (the algorithm), so its a method of the DNSKEY
@@ -31,12 +33,11 @@ func (r *DNSKEY) PrivateKeyString(p crypto.PrivateKey) string {
prime2 := toBase64(p.Primes[1].Bytes())
// Calculate Exponent1/2 and Coefficient as per: http://en.wikipedia.org/wiki/RSA#Using_the_Chinese_remainder_algorithm
// and from: http://code.google.com/p/go/issues/detail?id=987
- one := big.NewInt(1)
- p1 := big.NewInt(0).Sub(p.Primes[0], one)
- q1 := big.NewInt(0).Sub(p.Primes[1], one)
- exp1 := big.NewInt(0).Mod(p.D, p1)
- exp2 := big.NewInt(0).Mod(p.D, q1)
- coeff := big.NewInt(0).ModInverse(p.Primes[1], p.Primes[0])
+ p1 := new(big.Int).Sub(p.Primes[0], bigIntOne)
+ q1 := new(big.Int).Sub(p.Primes[1], bigIntOne)
+ exp1 := new(big.Int).Mod(p.D, p1)
+ exp2 := new(big.Int).Mod(p.D, q1)
+ coeff := new(big.Int).ModInverse(p.Primes[1], p.Primes[0])
exponent1 := toBase64(exp1.Bytes())
exponent2 := toBase64(exp2.Bytes())
diff --git a/vendor/github.com/miekg/dns/duplicate.go b/vendor/github.com/miekg/dns/duplicate.go
index 05c14aae31..00cda0aa29 100644
--- a/vendor/github.com/miekg/dns/duplicate.go
+++ b/vendor/github.com/miekg/dns/duplicate.go
@@ -27,12 +27,12 @@ func (r1 *RR_Header) isDuplicate(_r2 RR) bool {
if r1.Rrtype != r2.Rrtype {
return false
}
- if !isDulicateName(r1.Name, r2.Name) {
+ if !isDuplicateName(r1.Name, r2.Name) {
return false
}
// ignore TTL
return true
}
-// isDulicateName checks if the domain names s1 and s2 are equal.
-func isDulicateName(s1, s2 string) bool { return equal(s1, s2) }
+// isDuplicateName checks if the domain names s1 and s2 are equal.
+func isDuplicateName(s1, s2 string) bool { return equal(s1, s2) }
diff --git a/vendor/github.com/miekg/dns/edns.go b/vendor/github.com/miekg/dns/edns.go
index 805641b267..d244f7c6d5 100644
--- a/vendor/github.com/miekg/dns/edns.go
+++ b/vendor/github.com/miekg/dns/edns.go
@@ -80,15 +80,15 @@ func (rr *OPT) String() string {
func (rr *OPT) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
- for i := 0; i < len(rr.Option); i++ {
+ for _, o := range rr.Option {
l += 4 // Account for 2-byte option code and 2-byte option length.
- lo, _ := rr.Option[i].pack()
+ lo, _ := o.pack()
l += len(lo)
}
return l
}
-func (rr *OPT) parse(c *zlexer, origin, file string) *ParseError {
+func (rr *OPT) parse(c *zlexer, origin string) *ParseError {
panic("dns: internal error: parse should never be called on OPT")
}
@@ -360,7 +360,7 @@ func (e *EDNS0_COOKIE) copy() EDNS0 { return &EDNS0_COOKIE{e.Code, e.C
// The EDNS0_UL (Update Lease) (draft RFC) option is used to tell the server to set
// an expiration on an update RR. This is helpful for clients that cannot clean
// up after themselves. This is a draft RFC and more information can be found at
-// http://files.dns-sd.org/draft-sekar-dns-ul.txt
+// https://tools.ietf.org/html/draft-sekar-dns-ul-02
//
// o := new(dns.OPT)
// o.Hdr.Name = "."
@@ -370,24 +370,36 @@ func (e *EDNS0_COOKIE) copy() EDNS0 { return &EDNS0_COOKIE{e.Code, e.C
// e.Lease = 120 // in seconds
// o.Option = append(o.Option, e)
type EDNS0_UL struct {
- Code uint16 // Always EDNS0UL
- Lease uint32
+ Code uint16 // Always EDNS0UL
+ Lease uint32
+ KeyLease uint32
}
// Option implements the EDNS0 interface.
func (e *EDNS0_UL) Option() uint16 { return EDNS0UL }
-func (e *EDNS0_UL) String() string { return strconv.FormatUint(uint64(e.Lease), 10) }
-func (e *EDNS0_UL) copy() EDNS0 { return &EDNS0_UL{e.Code, e.Lease} }
+func (e *EDNS0_UL) String() string { return fmt.Sprintf("%d %d", e.Lease, e.KeyLease) }
+func (e *EDNS0_UL) copy() EDNS0 { return &EDNS0_UL{e.Code, e.Lease, e.KeyLease} }
// Copied: http://golang.org/src/pkg/net/dnsmsg.go
func (e *EDNS0_UL) pack() ([]byte, error) {
- b := make([]byte, 4)
+ var b []byte
+ if e.KeyLease == 0 {
+ b = make([]byte, 4)
+ } else {
+ b = make([]byte, 8)
+ binary.BigEndian.PutUint32(b[4:], e.KeyLease)
+ }
binary.BigEndian.PutUint32(b, e.Lease)
return b, nil
}
func (e *EDNS0_UL) unpack(b []byte) error {
- if len(b) < 4 {
+ switch len(b) {
+ case 4:
+ e.KeyLease = 0
+ case 8:
+ e.KeyLease = binary.BigEndian.Uint32(b[4:])
+ default:
return ErrBuf
}
e.Lease = binary.BigEndian.Uint32(b)
@@ -453,11 +465,11 @@ func (e *EDNS0_DAU) unpack(b []byte) error { e.AlgCode = b; return nil }
func (e *EDNS0_DAU) String() string {
s := ""
- for i := 0; i < len(e.AlgCode); i++ {
- if a, ok := AlgorithmToString[e.AlgCode[i]]; ok {
+ for _, alg := range e.AlgCode {
+ if a, ok := AlgorithmToString[alg]; ok {
s += " " + a
} else {
- s += " " + strconv.Itoa(int(e.AlgCode[i]))
+ s += " " + strconv.Itoa(int(alg))
}
}
return s
@@ -477,11 +489,11 @@ func (e *EDNS0_DHU) unpack(b []byte) error { e.AlgCode = b; return nil }
func (e *EDNS0_DHU) String() string {
s := ""
- for i := 0; i < len(e.AlgCode); i++ {
- if a, ok := HashToString[e.AlgCode[i]]; ok {
+ for _, alg := range e.AlgCode {
+ if a, ok := HashToString[alg]; ok {
s += " " + a
} else {
- s += " " + strconv.Itoa(int(e.AlgCode[i]))
+ s += " " + strconv.Itoa(int(alg))
}
}
return s
@@ -502,11 +514,11 @@ func (e *EDNS0_N3U) unpack(b []byte) error { e.AlgCode = b; return nil }
func (e *EDNS0_N3U) String() string {
// Re-use the hash map
s := ""
- for i := 0; i < len(e.AlgCode); i++ {
- if a, ok := HashToString[e.AlgCode[i]]; ok {
+ for _, alg := range e.AlgCode {
+ if a, ok := HashToString[alg]; ok {
s += " " + a
} else {
- s += " " + strconv.Itoa(int(e.AlgCode[i]))
+ s += " " + strconv.Itoa(int(alg))
}
}
return s
diff --git a/vendor/github.com/miekg/dns/format.go b/vendor/github.com/miekg/dns/format.go
index 86057f99b7..0ec79f2fc1 100644
--- a/vendor/github.com/miekg/dns/format.go
+++ b/vendor/github.com/miekg/dns/format.go
@@ -31,6 +31,9 @@ func Field(r RR, i int) string {
switch reflect.ValueOf(r).Elem().Type().Field(i).Tag {
case `dns:"a"`:
// TODO(miek): Hmm store this as 16 bytes
+ if d.Len() < net.IPv4len {
+ return ""
+ }
if d.Len() < net.IPv6len {
return net.IPv4(byte(d.Index(0).Uint()),
byte(d.Index(1).Uint()),
@@ -42,6 +45,9 @@ func Field(r RR, i int) string {
byte(d.Index(14).Uint()),
byte(d.Index(15).Uint())).String()
case `dns:"aaaa"`:
+ if d.Len() < net.IPv6len {
+ return ""
+ }
return net.IP{
byte(d.Index(0).Uint()),
byte(d.Index(1).Uint()),
diff --git a/vendor/github.com/miekg/dns/fuzz.go b/vendor/github.com/miekg/dns/fuzz.go
index a8a09184d4..57410acda7 100644
--- a/vendor/github.com/miekg/dns/fuzz.go
+++ b/vendor/github.com/miekg/dns/fuzz.go
@@ -2,6 +2,8 @@
package dns
+import "strings"
+
func Fuzz(data []byte) int {
msg := new(Msg)
@@ -16,7 +18,14 @@ func Fuzz(data []byte) int {
}
func FuzzNewRR(data []byte) int {
- if _, err := NewRR(string(data)); err != nil {
+ str := string(data)
+ // Do not fuzz lines that include the $INCLUDE keyword and hint the fuzzer
+ // at avoiding them.
+ // See GH#1025 for context.
+ if strings.Contains(strings.ToUpper(str), "$INCLUDE") {
+ return -1
+ }
+ if _, err := NewRR(str); err != nil {
return 0
}
return 1
diff --git a/vendor/github.com/miekg/dns/generate.go b/vendor/github.com/miekg/dns/generate.go
index 97bc39f58a..f7e91a23f7 100644
--- a/vendor/github.com/miekg/dns/generate.go
+++ b/vendor/github.com/miekg/dns/generate.go
@@ -49,11 +49,15 @@ func (zp *ZoneParser) generate(l lex) (RR, bool) {
if err != nil {
return zp.setParseError("bad stop in $GENERATE range", l)
}
- if end < 0 || start < 0 || end < start {
+ if end < 0 || start < 0 || end < start || (end-start)/step > 65535 {
return zp.setParseError("bad range in $GENERATE range", l)
}
- zp.c.Next() // _BLANK
+ // _BLANK
+ l, ok := zp.c.Next()
+ if !ok || l.value != zBlank {
+ return zp.setParseError("garbage after $GENERATE range", l)
+ }
// Create a complete new string, which we then parse again.
var s string
@@ -81,6 +85,7 @@ func (zp *ZoneParser) generate(l lex) (RR, bool) {
}
zp.sub = NewZoneParser(r, zp.origin, zp.file)
zp.sub.includeDepth, zp.sub.includeAllowed = zp.includeDepth, zp.includeAllowed
+ zp.sub.generateDisallowed = true
zp.sub.SetDefaultTTL(defaultTtl)
return zp.subNext()
}
diff --git a/vendor/github.com/miekg/dns/go.mod b/vendor/github.com/miekg/dns/go.mod
new file mode 100644
index 0000000000..5b9e187138
--- /dev/null
+++ b/vendor/github.com/miekg/dns/go.mod
@@ -0,0 +1,12 @@
+module github.com/miekg/dns
+
+go 1.12
+
+require (
+ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392
+ golang.org/x/net v0.0.0-20190923162816-aa69164e4478
+ golang.org/x/sync v0.0.0-20190423024810-112230192c58
+ golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe
+ golang.org/x/text v0.3.2 // indirect
+ golang.org/x/tools v0.0.0-20190907020128-2ca718005c18 // indirect
+)
diff --git a/vendor/github.com/miekg/dns/go.sum b/vendor/github.com/miekg/dns/go.sum
new file mode 100644
index 0000000000..482c403595
--- /dev/null
+++ b/vendor/github.com/miekg/dns/go.sum
@@ -0,0 +1,33 @@
+golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 h1:Vk3wNqEZwyGyei9yq5ekj7frek2u7HUfffJ1/opblzc=
+golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM=
+golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392 h1:ACG4HJsFiNMf47Y4PeRoebLNy/2lXT9EtprMuTFWt1M=
+golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
+golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 h1:dgd4x4kJt7G4k4m93AYLzM8Ni6h2qLTfh9n9vXJT3/0=
+golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
+golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
+golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180928133829-e4b3c5e90611 h1:O33LKL7WyJgjN9CvxfTIomjIClbd/Kq86/iipowHQU0=
+golang.org/x/sys v0.0.0-20180928133829-e4b3c5e90611/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0=
+golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe h1:6fAMxZRR6sl1Uq8U61gxU+kPTs2tR8uOySCbBP7BN/M=
+golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/vendor/github.com/miekg/dns/labels.go b/vendor/github.com/miekg/dns/labels.go
index ca8c204554..10d824718a 100644
--- a/vendor/github.com/miekg/dns/labels.go
+++ b/vendor/github.com/miekg/dns/labels.go
@@ -28,9 +28,7 @@ func SplitDomainName(s string) (labels []string) {
case 1:
// no-op
default:
- end := 0
- for i := 1; i < len(idx); i++ {
- end = idx[i]
+ for _, end := range idx[1:] {
labels = append(labels, s[begin:end-1])
begin = end
}
@@ -128,20 +126,23 @@ func Split(s string) []int {
// The bool end is true when the end of the string has been reached.
// Also see PrevLabel.
func NextLabel(s string, offset int) (i int, end bool) {
- quote := false
+ if s == "" {
+ return 0, true
+ }
for i = offset; i < len(s)-1; i++ {
- switch s[i] {
- case '\\':
- quote = !quote
- default:
- quote = false
- case '.':
- if quote {
- quote = !quote
- continue
- }
- return i + 1, false
+ if s[i] != '.' {
+ continue
}
+ j := i - 1
+ for j >= 0 && s[j] == '\\' {
+ j--
+ }
+
+ if (j-i)%2 == 0 {
+ continue
+ }
+
+ return i + 1, false
}
return i + 1, true
}
@@ -151,17 +152,38 @@ func NextLabel(s string, offset int) (i int, end bool) {
// The bool start is true when the start of the string has been overshot.
// Also see NextLabel.
func PrevLabel(s string, n int) (i int, start bool) {
+ if s == "" {
+ return 0, true
+ }
if n == 0 {
return len(s), false
}
- lab := Split(s)
- if lab == nil {
- return 0, true
+
+ l := len(s) - 1
+ if s[l] == '.' {
+ l--
}
- if n > len(lab) {
- return 0, true
+
+ for ; l >= 0 && n > 0; l-- {
+ if s[l] != '.' {
+ continue
+ }
+ j := l - 1
+ for j >= 0 && s[j] == '\\' {
+ j--
+ }
+
+ if (j-l)%2 == 0 {
+ continue
+ }
+
+ n--
+ if n == 0 {
+ return l + 1, false
+ }
}
- return lab[len(lab)-n], false
+
+ return 0, n > 1
}
// equal compares a and b while ignoring case. It returns true when equal otherwise false.
diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go
index 5191fc06d0..293813005a 100644
--- a/vendor/github.com/miekg/dns/msg.go
+++ b/vendor/github.com/miekg/dns/msg.go
@@ -11,14 +11,12 @@ package dns
//go:generate go run msg_generate.go
import (
- crand "crypto/rand"
+ "crypto/rand"
"encoding/binary"
"fmt"
"math/big"
- "math/rand"
"strconv"
"strings"
- "sync"
)
const (
@@ -73,53 +71,23 @@ var (
ErrTime error = &Error{err: "bad time"} // ErrTime indicates a timing error in TSIG authentication.
)
-// Id by default, returns a 16 bits random number to be used as a
-// message id. The random provided should be good enough. This being a
-// variable the function can be reassigned to a custom function.
-// For instance, to make it return a static value:
+// Id by default returns a 16-bit random number to be used as a message id. The
+// number is drawn from a cryptographically secure random number generator.
+// This being a variable the function can be reassigned to a custom function.
+// For instance, to make it return a static value for testing:
//
// dns.Id = func() uint16 { return 3 }
var Id = id
-var (
- idLock sync.Mutex
- idRand *rand.Rand
-)
-
// id returns a 16 bits random number to be used as a
// message id. The random provided should be good enough.
func id() uint16 {
- idLock.Lock()
-
- if idRand == nil {
- // This (partially) works around
- // https://github.com/golang/go/issues/11833 by only
- // seeding idRand upon the first call to id.
-
- var seed int64
- var buf [8]byte
-
- if _, err := crand.Read(buf[:]); err == nil {
- seed = int64(binary.LittleEndian.Uint64(buf[:]))
- } else {
- seed = rand.Int63()
- }
-
- idRand = rand.New(rand.NewSource(seed))
+ var output uint16
+ err := binary.Read(rand.Reader, binary.BigEndian, &output)
+ if err != nil {
+ panic("dns: reading random id failed: " + err.Error())
}
-
- // The call to idRand.Uint32 must be within the
- // mutex lock because *rand.Rand is not safe for
- // concurrent use.
- //
- // There is no added performance overhead to calling
- // idRand.Uint32 inside a mutex lock over just
- // calling rand.Uint32 as the global math/rand rng
- // is internally protected by a sync.Mutex.
- id := uint16(idRand.Uint32())
-
- idLock.Unlock()
- return id
+ return output
}
// MsgHdr is a a manually-unpacked version of (id, bits).
@@ -429,8 +397,8 @@ Loop:
if budget <= 0 {
return "", lenmsg, ErrLongDomain
}
- for j := off; j < off+c; j++ {
- switch b := msg[j]; b {
+ for _, b := range msg[off : off+c] {
+ switch b {
case '.', '(', ')', ';', ' ', '@':
fallthrough
case '"', '\\':
@@ -489,11 +457,11 @@ func packTxt(txt []string, msg []byte, offset int, tmp []byte) (int, error) {
return offset, nil
}
var err error
- for i := range txt {
- if len(txt[i]) > len(tmp) {
+ for _, s := range txt {
+ if len(s) > len(tmp) {
return offset, ErrBuf
}
- offset, err = packTxtString(txt[i], msg, offset, tmp)
+ offset, err = packTxtString(s, msg, offset, tmp)
if err != nil {
return offset, err
}
@@ -934,31 +902,31 @@ func (dns *Msg) String() string {
s += "ADDITIONAL: " + strconv.Itoa(len(dns.Extra)) + "\n"
if len(dns.Question) > 0 {
s += "\n;; QUESTION SECTION:\n"
- for i := 0; i < len(dns.Question); i++ {
- s += dns.Question[i].String() + "\n"
+ for _, r := range dns.Question {
+ s += r.String() + "\n"
}
}
if len(dns.Answer) > 0 {
s += "\n;; ANSWER SECTION:\n"
- for i := 0; i < len(dns.Answer); i++ {
- if dns.Answer[i] != nil {
- s += dns.Answer[i].String() + "\n"
+ for _, r := range dns.Answer {
+ if r != nil {
+ s += r.String() + "\n"
}
}
}
if len(dns.Ns) > 0 {
s += "\n;; AUTHORITY SECTION:\n"
- for i := 0; i < len(dns.Ns); i++ {
- if dns.Ns[i] != nil {
- s += dns.Ns[i].String() + "\n"
+ for _, r := range dns.Ns {
+ if r != nil {
+ s += r.String() + "\n"
}
}
}
if len(dns.Extra) > 0 {
s += "\n;; ADDITIONAL SECTION:\n"
- for i := 0; i < len(dns.Extra); i++ {
- if dns.Extra[i] != nil {
- s += dns.Extra[i].String() + "\n"
+ for _, r := range dns.Extra {
+ if r != nil {
+ s += r.String() + "\n"
}
}
}
@@ -1091,33 +1059,20 @@ func (dns *Msg) CopyTo(r1 *Msg) *Msg {
}
rrArr := make([]RR, len(dns.Answer)+len(dns.Ns)+len(dns.Extra))
- var rri int
+ r1.Answer, rrArr = rrArr[:0:len(dns.Answer)], rrArr[len(dns.Answer):]
+ r1.Ns, rrArr = rrArr[:0:len(dns.Ns)], rrArr[len(dns.Ns):]
+ r1.Extra = rrArr[:0:len(dns.Extra)]
- if len(dns.Answer) > 0 {
- rrbegin := rri
- for i := 0; i < len(dns.Answer); i++ {
- rrArr[rri] = dns.Answer[i].copy()
- rri++
- }
- r1.Answer = rrArr[rrbegin:rri:rri]
+ for _, r := range dns.Answer {
+ r1.Answer = append(r1.Answer, r.copy())
}
- if len(dns.Ns) > 0 {
- rrbegin := rri
- for i := 0; i < len(dns.Ns); i++ {
- rrArr[rri] = dns.Ns[i].copy()
- rri++
- }
- r1.Ns = rrArr[rrbegin:rri:rri]
+ for _, r := range dns.Ns {
+ r1.Ns = append(r1.Ns, r.copy())
}
- if len(dns.Extra) > 0 {
- rrbegin := rri
- for i := 0; i < len(dns.Extra); i++ {
- rrArr[rri] = dns.Extra[i].copy()
- rri++
- }
- r1.Extra = rrArr[rrbegin:rri:rri]
+ for _, r := range dns.Extra {
+ r1.Extra = append(r1.Extra, r.copy())
}
return r1
diff --git a/vendor/github.com/miekg/dns/msg_helpers.go b/vendor/github.com/miekg/dns/msg_helpers.go
index 527621a001..0e96f0f345 100644
--- a/vendor/github.com/miekg/dns/msg_helpers.go
+++ b/vendor/github.com/miekg/dns/msg_helpers.go
@@ -25,12 +25,13 @@ func unpackDataA(msg []byte, off int) (net.IP, int, error) {
}
func packDataA(a net.IP, msg []byte, off int) (int, error) {
- // It must be a slice of 4, even if it is 16, we encode only the first 4
- if off+net.IPv4len > len(msg) {
- return len(msg), &Error{err: "overflow packing a"}
- }
switch len(a) {
case net.IPv4len, net.IPv6len:
+ // It must be a slice of 4, even if it is 16, we encode only the first 4
+ if off+net.IPv4len > len(msg) {
+ return len(msg), &Error{err: "overflow packing a"}
+ }
+
copy(msg[off:], a.To4())
off += net.IPv4len
case 0:
@@ -51,12 +52,12 @@ func unpackDataAAAA(msg []byte, off int) (net.IP, int, error) {
}
func packDataAAAA(aaaa net.IP, msg []byte, off int) (int, error) {
- if off+net.IPv6len > len(msg) {
- return len(msg), &Error{err: "overflow packing aaaa"}
- }
-
switch len(aaaa) {
case net.IPv6len:
+ if off+net.IPv6len > len(msg) {
+ return len(msg), &Error{err: "overflow packing aaaa"}
+ }
+
copy(msg[off:], aaaa)
off += net.IPv6len
case 0:
@@ -264,24 +265,36 @@ func unpackString(msg []byte, off int) (string, int, error) {
return "", off, &Error{err: "overflow unpacking txt"}
}
l := int(msg[off])
- if off+l+1 > len(msg) {
+ off++
+ if off+l > len(msg) {
return "", off, &Error{err: "overflow unpacking txt"}
}
var s strings.Builder
- s.Grow(l)
- for _, b := range msg[off+1 : off+1+l] {
+ consumed := 0
+ for i, b := range msg[off : off+l] {
switch {
case b == '"' || b == '\\':
+ if consumed == 0 {
+ s.Grow(l * 2)
+ }
+ s.Write(msg[off+consumed : off+i])
s.WriteByte('\\')
s.WriteByte(b)
+ consumed = i + 1
case b < ' ' || b > '~': // unprintable
+ if consumed == 0 {
+ s.Grow(l * 2)
+ }
+ s.Write(msg[off+consumed : off+i])
s.WriteString(escapeByte(b))
- default:
- s.WriteByte(b)
+ consumed = i + 1
}
}
- off += 1 + l
- return s.String(), off, nil
+ if consumed == 0 { // no escaping needed
+ return string(msg[off : off+l]), off + l, nil
+ }
+ s.Write(msg[off+consumed : off+l])
+ return s.String(), off + l, nil
}
func packString(s string, msg []byte, off int) (int, error) {
@@ -494,7 +507,7 @@ Option:
func packDataOpt(options []EDNS0, msg []byte, off int) (int, error) {
for _, el := range options {
b, err := el.pack()
- if err != nil || off+3 > len(msg) {
+ if err != nil || off+4 > len(msg) {
return len(msg), &Error{err: "overflow packing opt"}
}
binary.BigEndian.PutUint16(msg[off:], el.Option()) // Option code
@@ -553,8 +566,7 @@ func unpackDataNsec(msg []byte, off int) ([]uint16, int, error) {
}
// Walk the bytes in the window and extract the type bits
- for j := 0; j < length; j++ {
- b := msg[off+j]
+ for j, b := range msg[off : off+length] {
// Check the bits one by one, and set the type
if b&0x80 == 0x80 {
nsec = append(nsec, uint16(window*256+j*8+0))
@@ -587,13 +599,35 @@ func unpackDataNsec(msg []byte, off int) ([]uint16, int, error) {
return nsec, off, nil
}
+// typeBitMapLen is a helper function which computes the "maximum" length of
+// a the NSEC Type BitMap field.
+func typeBitMapLen(bitmap []uint16) int {
+ var l int
+ var lastwindow, lastlength uint16
+ for _, t := range bitmap {
+ window := t / 256
+ length := (t-window*256)/8 + 1
+ if window > lastwindow && lastlength != 0 { // New window, jump to the new offset
+ l += int(lastlength) + 2
+ lastlength = 0
+ }
+ if window < lastwindow || length < lastlength {
+ // packDataNsec would return Error{err: "nsec bits out of order"} here, but
+ // when computing the length, we want do be liberal.
+ continue
+ }
+ lastwindow, lastlength = window, length
+ }
+ l += int(lastlength) + 2
+ return l
+}
+
func packDataNsec(bitmap []uint16, msg []byte, off int) (int, error) {
if len(bitmap) == 0 {
return off, nil
}
var lastwindow, lastlength uint16
- for j := 0; j < len(bitmap); j++ {
- t := bitmap[j]
+ for _, t := range bitmap {
window := t / 256
length := (t-window*256)/8 + 1
if window > lastwindow && lastlength != 0 { // New window, jump to the new offset
@@ -639,8 +673,8 @@ func unpackDataDomainNames(msg []byte, off, end int) ([]string, int, error) {
func packDataDomainNames(names []string, msg []byte, off int, compression compressionMap, compress bool) (int, error) {
var err error
- for j := 0; j < len(names); j++ {
- off, err = packDomainName(names[j], msg, off, compression, compress)
+ for _, name := range names {
+ off, err = packDomainName(name, msg, off, compression, compress)
if err != nil {
return len(msg), err
}
diff --git a/vendor/github.com/miekg/dns/msg_truncate.go b/vendor/github.com/miekg/dns/msg_truncate.go
new file mode 100644
index 0000000000..89d40757db
--- /dev/null
+++ b/vendor/github.com/miekg/dns/msg_truncate.go
@@ -0,0 +1,111 @@
+package dns
+
+// Truncate ensures the reply message will fit into the requested buffer
+// size by removing records that exceed the requested size.
+//
+// It will first check if the reply fits without compression and then with
+// compression. If it won't fit with compression, Truncate then walks the
+// record adding as many records as possible without exceeding the
+// requested buffer size.
+//
+// The TC bit will be set if any records were excluded from the message.
+// This indicates to that the client should retry over TCP.
+//
+// According to RFC 2181, the TC bit should only be set if not all of the
+// "required" RRs can be included in the response. Unfortunately, we have
+// no way of knowing which RRs are required so we set the TC bit if any RR
+// had to be omitted from the response.
+//
+// The appropriate buffer size can be retrieved from the requests OPT
+// record, if present, and is transport specific otherwise. dns.MinMsgSize
+// should be used for UDP requests without an OPT record, and
+// dns.MaxMsgSize for TCP requests without an OPT record.
+func (dns *Msg) Truncate(size int) {
+ if dns.IsTsig() != nil {
+ // To simplify this implementation, we don't perform
+ // truncation on responses with a TSIG record.
+ return
+ }
+
+ // RFC 6891 mandates that the payload size in an OPT record
+ // less than 512 bytes must be treated as equal to 512 bytes.
+ //
+ // For ease of use, we impose that restriction here.
+ if size < 512 {
+ size = 512
+ }
+
+ l := msgLenWithCompressionMap(dns, nil) // uncompressed length
+ if l <= size {
+ // Don't waste effort compressing this message.
+ dns.Compress = false
+ return
+ }
+
+ dns.Compress = true
+
+ edns0 := dns.popEdns0()
+ if edns0 != nil {
+ // Account for the OPT record that gets added at the end,
+ // by subtracting that length from our budget.
+ //
+ // The EDNS(0) OPT record must have the root domain and
+ // it's length is thus unaffected by compression.
+ size -= Len(edns0)
+ }
+
+ compression := make(map[string]struct{})
+
+ l = headerSize
+ for _, r := range dns.Question {
+ l += r.len(l, compression)
+ }
+
+ var numAnswer int
+ if l < size {
+ l, numAnswer = truncateLoop(dns.Answer, size, l, compression)
+ }
+
+ var numNS int
+ if l < size {
+ l, numNS = truncateLoop(dns.Ns, size, l, compression)
+ }
+
+ var numExtra int
+ if l < size {
+ l, numExtra = truncateLoop(dns.Extra, size, l, compression)
+ }
+
+ // See the function documentation for when we set this.
+ dns.Truncated = len(dns.Answer) > numAnswer ||
+ len(dns.Ns) > numNS || len(dns.Extra) > numExtra
+
+ dns.Answer = dns.Answer[:numAnswer]
+ dns.Ns = dns.Ns[:numNS]
+ dns.Extra = dns.Extra[:numExtra]
+
+ if edns0 != nil {
+ // Add the OPT record back onto the additional section.
+ dns.Extra = append(dns.Extra, edns0)
+ }
+}
+
+func truncateLoop(rrs []RR, size, l int, compression map[string]struct{}) (int, int) {
+ for i, r := range rrs {
+ if r == nil {
+ continue
+ }
+
+ l += r.len(l, compression)
+ if l > size {
+ // Return size, rather than l prior to this record,
+ // to prevent any further records being added.
+ return size, i
+ }
+ if l == size {
+ return l, i + 1
+ }
+ }
+
+ return l, len(rrs)
+}
diff --git a/vendor/github.com/miekg/dns/privaterr.go b/vendor/github.com/miekg/dns/privaterr.go
index d9c0d26774..e28f066374 100644
--- a/vendor/github.com/miekg/dns/privaterr.go
+++ b/vendor/github.com/miekg/dns/privaterr.go
@@ -1,9 +1,6 @@
package dns
-import (
- "fmt"
- "strings"
-)
+import "strings"
// PrivateRdata is an interface used for implementing "Private Use" RR types, see
// RFC 6895. This allows one to experiment with new RR types, without requesting an
@@ -18,7 +15,7 @@ type PrivateRdata interface {
// Unpack is used when unpacking a private RR from a buffer.
// TODO(miek): diff. signature than Pack, see edns0.go for instance.
Unpack([]byte) (int, error)
- // Copy copies the Rdata.
+ // Copy copies the Rdata into the PrivateRdata argument.
Copy(PrivateRdata) error
// Len returns the length in octets of the Rdata.
Len() int
@@ -29,22 +26,8 @@ type PrivateRdata interface {
type PrivateRR struct {
Hdr RR_Header
Data PrivateRdata
-}
-func mkPrivateRR(rrtype uint16) *PrivateRR {
- // Panics if RR is not an instance of PrivateRR.
- rrfunc, ok := TypeToRR[rrtype]
- if !ok {
- panic(fmt.Sprintf("dns: invalid operation with Private RR type %d", rrtype))
- }
-
- anyrr := rrfunc()
- rr, ok := anyrr.(*PrivateRR)
- if !ok {
- panic(fmt.Sprintf("dns: RR is not a PrivateRR, TypeToRR[%d] generator returned %T", rrtype, anyrr))
- }
-
- return rr
+ generator func() PrivateRdata // for copy
}
// Header return the RR header of r.
@@ -61,13 +44,12 @@ func (r *PrivateRR) len(off int, compression map[string]struct{}) int {
func (r *PrivateRR) copy() RR {
// make new RR like this:
- rr := mkPrivateRR(r.Hdr.Rrtype)
- rr.Hdr = r.Hdr
+ rr := &PrivateRR{r.Hdr, r.generator(), r.generator}
- err := r.Data.Copy(rr.Data)
- if err != nil {
- panic("dns: got value that could not be used to copy Private rdata")
+ if err := r.Data.Copy(rr.Data); err != nil {
+ panic("dns: got value that could not be used to copy Private rdata: " + err.Error())
}
+
return rr
}
@@ -86,7 +68,7 @@ func (r *PrivateRR) unpack(msg []byte, off int) (int, error) {
return off, err
}
-func (r *PrivateRR) parse(c *zlexer, origin, file string) *ParseError {
+func (r *PrivateRR) parse(c *zlexer, origin string) *ParseError {
var l lex
text := make([]string, 0, 2) // could be 0..N elements, median is probably 1
Fetch:
@@ -103,7 +85,7 @@ Fetch:
err := r.Data.Parse(text)
if err != nil {
- return &ParseError{file, err.Error(), l}
+ return &ParseError{"", err.Error(), l}
}
return nil
@@ -116,7 +98,7 @@ func (r1 *PrivateRR) isDuplicate(r2 RR) bool { return false }
func PrivateHandle(rtypestr string, rtype uint16, generator func() PrivateRdata) {
rtypestr = strings.ToUpper(rtypestr)
- TypeToRR[rtype] = func() RR { return &PrivateRR{RR_Header{}, generator()} }
+ TypeToRR[rtype] = func() RR { return &PrivateRR{RR_Header{}, generator(), generator} }
TypeToString[rtype] = rtypestr
StringToType[rtypestr] = rtype
}
diff --git a/vendor/github.com/miekg/dns/scan.go b/vendor/github.com/miekg/dns/scan.go
index a8691bca70..671018b1f3 100644
--- a/vendor/github.com/miekg/dns/scan.go
+++ b/vendor/github.com/miekg/dns/scan.go
@@ -134,7 +134,7 @@ func ReadRR(r io.Reader, file string) (RR, error) {
}
// ParseZone reads a RFC 1035 style zonefile from r. It returns
-// *Tokens on the returned channel, each consisting of either a
+// Tokens on the returned channel, each consisting of either a
// parsed RR and optional comment or a nil RR and an error. The
// channel is closed by ParseZone when the end of r is reached.
//
@@ -143,7 +143,8 @@ func ReadRR(r io.Reader, file string) (RR, error) {
// origin, as if the file would start with an $ORIGIN directive.
//
// The directives $INCLUDE, $ORIGIN, $TTL and $GENERATE are all
-// supported.
+// supported. Note that $GENERATE's range support up to a maximum of
+// of 65535 steps.
//
// Basic usage pattern when reading from a string (z) containing the
// zone data:
@@ -203,6 +204,7 @@ func parseZone(r io.Reader, origin, file string, t chan *Token) {
//
// The directives $INCLUDE, $ORIGIN, $TTL and $GENERATE are all
// supported. Although $INCLUDE is disabled by default.
+// Note that $GENERATE's range support up to a maximum of 65535 steps.
//
// Basic usage pattern when reading from a string (z) containing the
// zone data:
@@ -246,6 +248,7 @@ type ZoneParser struct {
includeDepth uint8
includeAllowed bool
+ generateDisallowed bool
}
// NewZoneParser returns an RFC 1035 style zonefile parser that reads
@@ -503,9 +506,8 @@ func (zp *ZoneParser) Next() (RR, bool) {
return zp.setParseError("expecting $TTL value, not this...", l)
}
- if e := slurpRemainder(zp.c, zp.file); e != nil {
- zp.parseErr = e
- return nil, false
+ if err := slurpRemainder(zp.c); err != nil {
+ return zp.setParseError(err.err, err.lex)
}
ttl, ok := stringToTTL(l.token)
@@ -527,9 +529,8 @@ func (zp *ZoneParser) Next() (RR, bool) {
return zp.setParseError("expecting $ORIGIN value, not this...", l)
}
- if e := slurpRemainder(zp.c, zp.file); e != nil {
- zp.parseErr = e
- return nil, false
+ if err := slurpRemainder(zp.c); err != nil {
+ return zp.setParseError(err.err, err.lex)
}
name, ok := toAbsoluteName(l.token, zp.origin)
@@ -547,6 +548,9 @@ func (zp *ZoneParser) Next() (RR, bool) {
st = zExpectDirGenerate
case zExpectDirGenerate:
+ if zp.generateDisallowed {
+ return zp.setParseError("nested $GENERATE directive not allowed", l)
+ }
if l.value != zString {
return zp.setParseError("expecting $GENERATE value, not this...", l)
}
@@ -650,19 +654,44 @@ func (zp *ZoneParser) Next() (RR, bool) {
st = zExpectRdata
case zExpectRdata:
- r, e := setRR(*h, zp.c, zp.origin, zp.file)
- if e != nil {
- // If e.lex is nil than we have encounter a unknown RR type
- // in that case we substitute our current lex token
- if e.lex.token == "" && e.lex.value == 0 {
- e.lex = l // Uh, dirty
- }
-
- zp.parseErr = e
- return nil, false
+ var rr RR
+ if newFn, ok := TypeToRR[h.Rrtype]; ok && canParseAsRR(h.Rrtype) {
+ rr = newFn()
+ *rr.Header() = *h
+ } else {
+ rr = &RFC3597{Hdr: *h}
}
- return r, true
+ _, isPrivate := rr.(*PrivateRR)
+ if !isPrivate && zp.c.Peek().token == "" {
+ // This is a dynamic update rr.
+
+ // TODO(tmthrgd): Previously slurpRemainder was only called
+ // for certain RR types, which may have been important.
+ if err := slurpRemainder(zp.c); err != nil {
+ return zp.setParseError(err.err, err.lex)
+ }
+
+ return rr, true
+ } else if l.value == zNewline {
+ return zp.setParseError("unexpected newline", l)
+ }
+
+ if err := rr.parse(zp.c, zp.origin); err != nil {
+ // err is a concrete *ParseError without the file field set.
+ // The setParseError call below will construct a new
+ // *ParseError with file set to zp.file.
+
+ // If err.lex is nil than we have encounter an unknown RR type
+ // in that case we substitute our current lex token.
+ if err.lex == (lex{}) {
+ return zp.setParseError(err.err, l)
+ }
+
+ return zp.setParseError(err.err, err.lex)
+ }
+
+ return rr, true
}
}
@@ -671,6 +700,18 @@ func (zp *ZoneParser) Next() (RR, bool) {
return nil, false
}
+// canParseAsRR returns true if the record type can be parsed as a
+// concrete RR. It blacklists certain record types that must be parsed
+// according to RFC 3597 because they lack a presentation format.
+func canParseAsRR(rrtype uint16) bool {
+ switch rrtype {
+ case TypeANY, TypeNULL, TypeOPT, TypeTSIG:
+ return false
+ default:
+ return true
+ }
+}
+
type zlexer struct {
br io.ByteReader
@@ -682,7 +723,8 @@ type zlexer struct {
comBuf string
comment string
- l lex
+ l lex
+ cachedL *lex
brace int
quote bool
@@ -748,13 +790,37 @@ func (zl *zlexer) readByte() (byte, bool) {
return c, true
}
+func (zl *zlexer) Peek() lex {
+ if zl.nextL {
+ return zl.l
+ }
+
+ l, ok := zl.Next()
+ if !ok {
+ return l
+ }
+
+ if zl.nextL {
+ // Cache l. Next returns zl.cachedL then zl.l.
+ zl.cachedL = &l
+ } else {
+ // In this case l == zl.l, so we just tell Next to return zl.l.
+ zl.nextL = true
+ }
+
+ return l
+}
+
func (zl *zlexer) Next() (lex, bool) {
l := &zl.l
- if zl.nextL {
+ switch {
+ case zl.cachedL != nil:
+ l, zl.cachedL = zl.cachedL, nil
+ return *l, true
+ case zl.nextL:
zl.nextL = false
return *l, true
- }
- if l.err {
+ case l.err:
// Parsing errors should be sticky.
return lex{value: zEOF}, false
}
@@ -908,6 +974,11 @@ func (zl *zlexer) Next() (lex, bool) {
// was inside braces and we delayed adding it until now.
com[comi] = ' ' // convert newline to space
comi++
+ if comi >= len(com) {
+ l.token = "comment length insufficient for parsing"
+ l.err = true
+ return *l, true
+ }
}
com[comi] = ';'
@@ -1302,18 +1373,18 @@ func locCheckEast(token string, longitude uint32) (uint32, bool) {
}
// "Eat" the rest of the "line"
-func slurpRemainder(c *zlexer, f string) *ParseError {
+func slurpRemainder(c *zlexer) *ParseError {
l, _ := c.Next()
switch l.value {
case zBlank:
l, _ = c.Next()
if l.value != zNewline && l.value != zEOF {
- return &ParseError{f, "garbage after rdata", l}
+ return &ParseError{"", "garbage after rdata", l}
}
case zNewline:
case zEOF:
default:
- return &ParseError{f, "garbage after rdata", l}
+ return &ParseError{"", "garbage after rdata", l}
}
return nil
}
diff --git a/vendor/github.com/miekg/dns/scan_rr.go b/vendor/github.com/miekg/dns/scan_rr.go
index f48ff7890e..93b24a697d 100644
--- a/vendor/github.com/miekg/dns/scan_rr.go
+++ b/vendor/github.com/miekg/dns/scan_rr.go
@@ -7,55 +7,21 @@ import (
"strings"
)
-// Parse the rdata of each rrtype.
-// All data from the channel c is either zString or zBlank.
-// After the rdata there may come a zBlank and then a zNewline
-// or immediately a zNewline. If this is not the case we flag
-// an *ParseError: garbage after rdata.
-func setRR(h RR_Header, c *zlexer, o, f string) (RR, *ParseError) {
- var rr RR
- if newFn, ok := TypeToRR[h.Rrtype]; ok && canParseAsRR(h.Rrtype) {
- rr = newFn()
- *rr.Header() = h
- } else {
- rr = &RFC3597{Hdr: h}
- }
-
- err := rr.parse(c, o, f)
- if err != nil {
- return nil, err
- }
-
- return rr, nil
-}
-
-// canParseAsRR returns true if the record type can be parsed as a
-// concrete RR. It blacklists certain record types that must be parsed
-// according to RFC 3597 because they lack a presentation format.
-func canParseAsRR(rrtype uint16) bool {
- switch rrtype {
- case TypeANY, TypeNULL, TypeOPT, TypeTSIG:
- return false
- default:
- return true
- }
-}
-
// A remainder of the rdata with embedded spaces, return the parsed string (sans the spaces)
// or an error
-func endingToString(c *zlexer, errstr, f string) (string, *ParseError) {
+func endingToString(c *zlexer, errstr string) (string, *ParseError) {
var s string
l, _ := c.Next() // zString
for l.value != zNewline && l.value != zEOF {
if l.err {
- return s, &ParseError{f, errstr, l}
+ return s, &ParseError{"", errstr, l}
}
switch l.value {
case zString:
s += l.token
case zBlank: // Ok
default:
- return "", &ParseError{f, errstr, l}
+ return "", &ParseError{"", errstr, l}
}
l, _ = c.Next()
}
@@ -65,11 +31,11 @@ func endingToString(c *zlexer, errstr, f string) (string, *ParseError) {
// A remainder of the rdata with embedded spaces, split on unquoted whitespace
// and return the parsed string slice or an error
-func endingToTxtSlice(c *zlexer, errstr, f string) ([]string, *ParseError) {
+func endingToTxtSlice(c *zlexer, errstr string) ([]string, *ParseError) {
// Get the remaining data until we see a zNewline
l, _ := c.Next()
if l.err {
- return nil, &ParseError{f, errstr, l}
+ return nil, &ParseError{"", errstr, l}
}
// Build the slice
@@ -78,7 +44,7 @@ func endingToTxtSlice(c *zlexer, errstr, f string) ([]string, *ParseError) {
empty := false
for l.value != zNewline && l.value != zEOF {
if l.err {
- return nil, &ParseError{f, errstr, l}
+ return nil, &ParseError{"", errstr, l}
}
switch l.value {
case zString:
@@ -105,7 +71,7 @@ func endingToTxtSlice(c *zlexer, errstr, f string) ([]string, *ParseError) {
case zBlank:
if quote {
// zBlank can only be seen in between txt parts.
- return nil, &ParseError{f, errstr, l}
+ return nil, &ParseError{"", errstr, l}
}
case zQuote:
if empty && quote {
@@ -114,99 +80,79 @@ func endingToTxtSlice(c *zlexer, errstr, f string) ([]string, *ParseError) {
quote = !quote
empty = true
default:
- return nil, &ParseError{f, errstr, l}
+ return nil, &ParseError{"", errstr, l}
}
l, _ = c.Next()
}
if quote {
- return nil, &ParseError{f, errstr, l}
+ return nil, &ParseError{"", errstr, l}
}
return s, nil
}
-func (rr *A) parse(c *zlexer, o, f string) *ParseError {
+func (rr *A) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
rr.A = net.ParseIP(l.token)
- if rr.A == nil || l.err {
- return &ParseError{f, "bad A A", l}
+ // IPv4 addresses cannot include ":".
+ // We do this rather than use net.IP's To4() because
+ // To4() treats IPv4-mapped IPv6 addresses as being
+ // IPv4.
+ isIPv4 := !strings.Contains(l.token, ":")
+ if rr.A == nil || !isIPv4 || l.err {
+ return &ParseError{"", "bad A A", l}
}
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *AAAA) parse(c *zlexer, o, f string) *ParseError {
+func (rr *AAAA) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
rr.AAAA = net.ParseIP(l.token)
- if rr.AAAA == nil || l.err {
- return &ParseError{f, "bad AAAA AAAA", l}
+ // IPv6 addresses must include ":", and IPv4
+ // addresses cannot include ":".
+ isIPv6 := strings.Contains(l.token, ":")
+ if rr.AAAA == nil || !isIPv6 || l.err {
+ return &ParseError{"", "bad AAAA AAAA", l}
}
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *NS) parse(c *zlexer, o, f string) *ParseError {
+func (rr *NS) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Ns = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad NS Ns", l}
+ return &ParseError{"", "bad NS Ns", l}
}
rr.Ns = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *PTR) parse(c *zlexer, o, f string) *ParseError {
+func (rr *PTR) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Ptr = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad PTR Ptr", l}
+ return &ParseError{"", "bad PTR Ptr", l}
}
rr.Ptr = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *NSAPPTR) parse(c *zlexer, o, f string) *ParseError {
+func (rr *NSAPPTR) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Ptr = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad NSAP-PTR Ptr", l}
+ return &ParseError{"", "bad NSAP-PTR Ptr", l}
}
rr.Ptr = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *RP) parse(c *zlexer, o, f string) *ParseError {
+func (rr *RP) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Mbox = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
mbox, mboxOk := toAbsoluteName(l.token, o)
if l.err || !mboxOk {
- return &ParseError{f, "bad RP Mbox", l}
+ return &ParseError{"", "bad RP Mbox", l}
}
rr.Mbox = mbox
@@ -216,60 +162,45 @@ func (rr *RP) parse(c *zlexer, o, f string) *ParseError {
txt, txtOk := toAbsoluteName(l.token, o)
if l.err || !txtOk {
- return &ParseError{f, "bad RP Txt", l}
+ return &ParseError{"", "bad RP Txt", l}
}
rr.Txt = txt
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *MR) parse(c *zlexer, o, f string) *ParseError {
+func (rr *MR) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Mr = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad MR Mr", l}
+ return &ParseError{"", "bad MR Mr", l}
}
rr.Mr = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *MB) parse(c *zlexer, o, f string) *ParseError {
+func (rr *MB) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Mb = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad MB Mb", l}
+ return &ParseError{"", "bad MB Mb", l}
}
rr.Mb = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *MG) parse(c *zlexer, o, f string) *ParseError {
+func (rr *MG) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Mg = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad MG Mg", l}
+ return &ParseError{"", "bad MG Mg", l}
}
rr.Mg = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *HINFO) parse(c *zlexer, o, f string) *ParseError {
- chunks, e := endingToTxtSlice(c, "bad HINFO Fields", f)
+func (rr *HINFO) parse(c *zlexer, o string) *ParseError {
+ chunks, e := endingToTxtSlice(c, "bad HINFO Fields")
if e != nil {
return e
}
@@ -291,16 +222,11 @@ func (rr *HINFO) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *MINFO) parse(c *zlexer, o, f string) *ParseError {
+func (rr *MINFO) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Rmail = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
rmail, rmailOk := toAbsoluteName(l.token, o)
if l.err || !rmailOk {
- return &ParseError{f, "bad MINFO Rmail", l}
+ return &ParseError{"", "bad MINFO Rmail", l}
}
rr.Rmail = rmail
@@ -310,52 +236,38 @@ func (rr *MINFO) parse(c *zlexer, o, f string) *ParseError {
email, emailOk := toAbsoluteName(l.token, o)
if l.err || !emailOk {
- return &ParseError{f, "bad MINFO Email", l}
+ return &ParseError{"", "bad MINFO Email", l}
}
rr.Email = email
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *MF) parse(c *zlexer, o, f string) *ParseError {
+func (rr *MF) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Mf = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad MF Mf", l}
+ return &ParseError{"", "bad MF Mf", l}
}
rr.Mf = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *MD) parse(c *zlexer, o, f string) *ParseError {
+func (rr *MD) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Md = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad MD Md", l}
+ return &ParseError{"", "bad MD Md", l}
}
rr.Md = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *MX) parse(c *zlexer, o, f string) *ParseError {
+func (rr *MX) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad MX Pref", l}
+ return &ParseError{"", "bad MX Pref", l}
}
rr.Preference = uint16(i)
@@ -365,22 +277,18 @@ func (rr *MX) parse(c *zlexer, o, f string) *ParseError {
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad MX Mx", l}
+ return &ParseError{"", "bad MX Mx", l}
}
rr.Mx = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *RT) parse(c *zlexer, o, f string) *ParseError {
+func (rr *RT) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil {
- return &ParseError{f, "bad RT Preference", l}
+ return &ParseError{"", "bad RT Preference", l}
}
rr.Preference = uint16(i)
@@ -390,22 +298,18 @@ func (rr *RT) parse(c *zlexer, o, f string) *ParseError {
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad RT Host", l}
+ return &ParseError{"", "bad RT Host", l}
}
rr.Host = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *AFSDB) parse(c *zlexer, o, f string) *ParseError {
+func (rr *AFSDB) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad AFSDB Subtype", l}
+ return &ParseError{"", "bad AFSDB Subtype", l}
}
rr.Subtype = uint16(i)
@@ -415,34 +319,26 @@ func (rr *AFSDB) parse(c *zlexer, o, f string) *ParseError {
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad AFSDB Hostname", l}
+ return &ParseError{"", "bad AFSDB Hostname", l}
}
rr.Hostname = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *X25) parse(c *zlexer, o, f string) *ParseError {
+func (rr *X25) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
if l.err {
- return &ParseError{f, "bad X25 PSDNAddress", l}
+ return &ParseError{"", "bad X25 PSDNAddress", l}
}
rr.PSDNAddress = l.token
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *KX) parse(c *zlexer, o, f string) *ParseError {
+func (rr *KX) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad KX Pref", l}
+ return &ParseError{"", "bad KX Pref", l}
}
rr.Preference = uint16(i)
@@ -452,52 +348,37 @@ func (rr *KX) parse(c *zlexer, o, f string) *ParseError {
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad KX Exchanger", l}
+ return &ParseError{"", "bad KX Exchanger", l}
}
rr.Exchanger = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *CNAME) parse(c *zlexer, o, f string) *ParseError {
+func (rr *CNAME) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Target = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad CNAME Target", l}
+ return &ParseError{"", "bad CNAME Target", l}
}
rr.Target = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *DNAME) parse(c *zlexer, o, f string) *ParseError {
+func (rr *DNAME) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Target = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad DNAME Target", l}
+ return &ParseError{"", "bad DNAME Target", l}
}
rr.Target = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *SOA) parse(c *zlexer, o, f string) *ParseError {
+func (rr *SOA) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.Ns = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
ns, nsOk := toAbsoluteName(l.token, o)
if l.err || !nsOk {
- return &ParseError{f, "bad SOA Ns", l}
+ return &ParseError{"", "bad SOA Ns", l}
}
rr.Ns = ns
@@ -507,7 +388,7 @@ func (rr *SOA) parse(c *zlexer, o, f string) *ParseError {
mbox, mboxOk := toAbsoluteName(l.token, o)
if l.err || !mboxOk {
- return &ParseError{f, "bad SOA Mbox", l}
+ return &ParseError{"", "bad SOA Mbox", l}
}
rr.Mbox = mbox
@@ -520,16 +401,16 @@ func (rr *SOA) parse(c *zlexer, o, f string) *ParseError {
for i := 0; i < 5; i++ {
l, _ = c.Next()
if l.err {
- return &ParseError{f, "bad SOA zone parameter", l}
+ return &ParseError{"", "bad SOA zone parameter", l}
}
if j, e := strconv.ParseUint(l.token, 10, 32); e != nil {
if i == 0 {
// Serial must be a number
- return &ParseError{f, "bad SOA zone parameter", l}
+ return &ParseError{"", "bad SOA zone parameter", l}
}
// We allow other fields to be unitful duration strings
if v, ok = stringToTTL(l.token); !ok {
- return &ParseError{f, "bad SOA zone parameter", l}
+ return &ParseError{"", "bad SOA zone parameter", l}
}
} else {
@@ -552,18 +433,14 @@ func (rr *SOA) parse(c *zlexer, o, f string) *ParseError {
rr.Minttl = v
}
}
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *SRV) parse(c *zlexer, o, f string) *ParseError {
+func (rr *SRV) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad SRV Priority", l}
+ return &ParseError{"", "bad SRV Priority", l}
}
rr.Priority = uint16(i)
@@ -571,7 +448,7 @@ func (rr *SRV) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next() // zString
i, e = strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad SRV Weight", l}
+ return &ParseError{"", "bad SRV Weight", l}
}
rr.Weight = uint16(i)
@@ -579,7 +456,7 @@ func (rr *SRV) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next() // zString
i, e = strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad SRV Port", l}
+ return &ParseError{"", "bad SRV Port", l}
}
rr.Port = uint16(i)
@@ -589,21 +466,17 @@ func (rr *SRV) parse(c *zlexer, o, f string) *ParseError {
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad SRV Target", l}
+ return &ParseError{"", "bad SRV Target", l}
}
rr.Target = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *NAPTR) parse(c *zlexer, o, f string) *ParseError {
+func (rr *NAPTR) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad NAPTR Order", l}
+ return &ParseError{"", "bad NAPTR Order", l}
}
rr.Order = uint16(i)
@@ -611,7 +484,7 @@ func (rr *NAPTR) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next() // zString
i, e = strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad NAPTR Preference", l}
+ return &ParseError{"", "bad NAPTR Preference", l}
}
rr.Preference = uint16(i)
@@ -619,57 +492,57 @@ func (rr *NAPTR) parse(c *zlexer, o, f string) *ParseError {
c.Next() // zBlank
l, _ = c.Next() // _QUOTE
if l.value != zQuote {
- return &ParseError{f, "bad NAPTR Flags", l}
+ return &ParseError{"", "bad NAPTR Flags", l}
}
l, _ = c.Next() // Either String or Quote
if l.value == zString {
rr.Flags = l.token
l, _ = c.Next() // _QUOTE
if l.value != zQuote {
- return &ParseError{f, "bad NAPTR Flags", l}
+ return &ParseError{"", "bad NAPTR Flags", l}
}
} else if l.value == zQuote {
rr.Flags = ""
} else {
- return &ParseError{f, "bad NAPTR Flags", l}
+ return &ParseError{"", "bad NAPTR Flags", l}
}
// Service
c.Next() // zBlank
l, _ = c.Next() // _QUOTE
if l.value != zQuote {
- return &ParseError{f, "bad NAPTR Service", l}
+ return &ParseError{"", "bad NAPTR Service", l}
}
l, _ = c.Next() // Either String or Quote
if l.value == zString {
rr.Service = l.token
l, _ = c.Next() // _QUOTE
if l.value != zQuote {
- return &ParseError{f, "bad NAPTR Service", l}
+ return &ParseError{"", "bad NAPTR Service", l}
}
} else if l.value == zQuote {
rr.Service = ""
} else {
- return &ParseError{f, "bad NAPTR Service", l}
+ return &ParseError{"", "bad NAPTR Service", l}
}
// Regexp
c.Next() // zBlank
l, _ = c.Next() // _QUOTE
if l.value != zQuote {
- return &ParseError{f, "bad NAPTR Regexp", l}
+ return &ParseError{"", "bad NAPTR Regexp", l}
}
l, _ = c.Next() // Either String or Quote
if l.value == zString {
rr.Regexp = l.token
l, _ = c.Next() // _QUOTE
if l.value != zQuote {
- return &ParseError{f, "bad NAPTR Regexp", l}
+ return &ParseError{"", "bad NAPTR Regexp", l}
}
} else if l.value == zQuote {
rr.Regexp = ""
} else {
- return &ParseError{f, "bad NAPTR Regexp", l}
+ return &ParseError{"", "bad NAPTR Regexp", l}
}
// After quote no space??
@@ -679,22 +552,17 @@ func (rr *NAPTR) parse(c *zlexer, o, f string) *ParseError {
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad NAPTR Replacement", l}
+ return &ParseError{"", "bad NAPTR Replacement", l}
}
rr.Replacement = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *TALINK) parse(c *zlexer, o, f string) *ParseError {
+func (rr *TALINK) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.PreviousName = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
previousName, previousNameOk := toAbsoluteName(l.token, o)
if l.err || !previousNameOk {
- return &ParseError{f, "bad TALINK PreviousName", l}
+ return &ParseError{"", "bad TALINK PreviousName", l}
}
rr.PreviousName = previousName
@@ -704,14 +572,14 @@ func (rr *TALINK) parse(c *zlexer, o, f string) *ParseError {
nextName, nextNameOk := toAbsoluteName(l.token, o)
if l.err || !nextNameOk {
- return &ParseError{f, "bad TALINK NextName", l}
+ return &ParseError{"", "bad TALINK NextName", l}
}
rr.NextName = nextName
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *LOC) parse(c *zlexer, o, f string) *ParseError {
+func (rr *LOC) parse(c *zlexer, o string) *ParseError {
// Non zero defaults for LOC record, see RFC 1876, Section 3.
rr.HorizPre = 165 // 10000
rr.VertPre = 162 // 10
@@ -720,12 +588,9 @@ func (rr *LOC) parse(c *zlexer, o, f string) *ParseError {
// North
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
i, e := strconv.ParseUint(l.token, 10, 32)
if e != nil || l.err {
- return &ParseError{f, "bad LOC Latitude", l}
+ return &ParseError{"", "bad LOC Latitude", l}
}
rr.Latitude = 1000 * 60 * 60 * uint32(i)
@@ -737,14 +602,14 @@ func (rr *LOC) parse(c *zlexer, o, f string) *ParseError {
}
i, e = strconv.ParseUint(l.token, 10, 32)
if e != nil || l.err {
- return &ParseError{f, "bad LOC Latitude minutes", l}
+ return &ParseError{"", "bad LOC Latitude minutes", l}
}
rr.Latitude += 1000 * 60 * uint32(i)
c.Next() // zBlank
l, _ = c.Next()
if i, e := strconv.ParseFloat(l.token, 32); e != nil || l.err {
- return &ParseError{f, "bad LOC Latitude seconds", l}
+ return &ParseError{"", "bad LOC Latitude seconds", l}
} else {
rr.Latitude += uint32(1000 * i)
}
@@ -755,14 +620,14 @@ func (rr *LOC) parse(c *zlexer, o, f string) *ParseError {
goto East
}
// If still alive, flag an error
- return &ParseError{f, "bad LOC Latitude North/South", l}
+ return &ParseError{"", "bad LOC Latitude North/South", l}
East:
// East
c.Next() // zBlank
l, _ = c.Next()
if i, e := strconv.ParseUint(l.token, 10, 32); e != nil || l.err {
- return &ParseError{f, "bad LOC Longitude", l}
+ return &ParseError{"", "bad LOC Longitude", l}
} else {
rr.Longitude = 1000 * 60 * 60 * uint32(i)
}
@@ -773,14 +638,14 @@ East:
goto Altitude
}
if i, e := strconv.ParseUint(l.token, 10, 32); e != nil || l.err {
- return &ParseError{f, "bad LOC Longitude minutes", l}
+ return &ParseError{"", "bad LOC Longitude minutes", l}
} else {
rr.Longitude += 1000 * 60 * uint32(i)
}
c.Next() // zBlank
l, _ = c.Next()
if i, e := strconv.ParseFloat(l.token, 32); e != nil || l.err {
- return &ParseError{f, "bad LOC Longitude seconds", l}
+ return &ParseError{"", "bad LOC Longitude seconds", l}
} else {
rr.Longitude += uint32(1000 * i)
}
@@ -791,19 +656,19 @@ East:
goto Altitude
}
// If still alive, flag an error
- return &ParseError{f, "bad LOC Longitude East/West", l}
+ return &ParseError{"", "bad LOC Longitude East/West", l}
Altitude:
c.Next() // zBlank
l, _ = c.Next()
if len(l.token) == 0 || l.err {
- return &ParseError{f, "bad LOC Altitude", l}
+ return &ParseError{"", "bad LOC Altitude", l}
}
if l.token[len(l.token)-1] == 'M' || l.token[len(l.token)-1] == 'm' {
l.token = l.token[0 : len(l.token)-1]
}
if i, e := strconv.ParseFloat(l.token, 32); e != nil {
- return &ParseError{f, "bad LOC Altitude", l}
+ return &ParseError{"", "bad LOC Altitude", l}
} else {
rr.Altitude = uint32(i*100.0 + 10000000.0 + 0.5)
}
@@ -818,19 +683,19 @@ Altitude:
case 0: // Size
e, m, ok := stringToCm(l.token)
if !ok {
- return &ParseError{f, "bad LOC Size", l}
+ return &ParseError{"", "bad LOC Size", l}
}
rr.Size = e&0x0f | m<<4&0xf0
case 1: // HorizPre
e, m, ok := stringToCm(l.token)
if !ok {
- return &ParseError{f, "bad LOC HorizPre", l}
+ return &ParseError{"", "bad LOC HorizPre", l}
}
rr.HorizPre = e&0x0f | m<<4&0xf0
case 2: // VertPre
e, m, ok := stringToCm(l.token)
if !ok {
- return &ParseError{f, "bad LOC VertPre", l}
+ return &ParseError{"", "bad LOC VertPre", l}
}
rr.VertPre = e&0x0f | m<<4&0xf0
}
@@ -838,30 +703,26 @@ Altitude:
case zBlank:
// Ok
default:
- return &ParseError{f, "bad LOC Size, HorizPre or VertPre", l}
+ return &ParseError{"", "bad LOC Size, HorizPre or VertPre", l}
}
l, _ = c.Next()
}
return nil
}
-func (rr *HIP) parse(c *zlexer, o, f string) *ParseError {
+func (rr *HIP) parse(c *zlexer, o string) *ParseError {
// HitLength is not represented
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad HIP PublicKeyAlgorithm", l}
+ return &ParseError{"", "bad HIP PublicKeyAlgorithm", l}
}
rr.PublicKeyAlgorithm = uint8(i)
c.Next() // zBlank
l, _ = c.Next() // zString
if len(l.token) == 0 || l.err {
- return &ParseError{f, "bad HIP Hit", l}
+ return &ParseError{"", "bad HIP Hit", l}
}
rr.Hit = l.token // This can not contain spaces, see RFC 5205 Section 6.
rr.HitLength = uint8(len(rr.Hit)) / 2
@@ -869,7 +730,7 @@ func (rr *HIP) parse(c *zlexer, o, f string) *ParseError {
c.Next() // zBlank
l, _ = c.Next() // zString
if len(l.token) == 0 || l.err {
- return &ParseError{f, "bad HIP PublicKey", l}
+ return &ParseError{"", "bad HIP PublicKey", l}
}
rr.PublicKey = l.token // This cannot contain spaces
rr.PublicKeyLength = uint16(base64.StdEncoding.DecodedLen(len(rr.PublicKey)))
@@ -882,13 +743,13 @@ func (rr *HIP) parse(c *zlexer, o, f string) *ParseError {
case zString:
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad HIP RendezvousServers", l}
+ return &ParseError{"", "bad HIP RendezvousServers", l}
}
xs = append(xs, name)
case zBlank:
// Ok
default:
- return &ParseError{f, "bad HIP RendezvousServers", l}
+ return &ParseError{"", "bad HIP RendezvousServers", l}
}
l, _ = c.Next()
}
@@ -897,16 +758,12 @@ func (rr *HIP) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *CERT) parse(c *zlexer, o, f string) *ParseError {
+func (rr *CERT) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
if v, ok := StringToCertType[l.token]; ok {
rr.Type = v
} else if i, e := strconv.ParseUint(l.token, 10, 16); e != nil {
- return &ParseError{f, "bad CERT Type", l}
+ return &ParseError{"", "bad CERT Type", l}
} else {
rr.Type = uint16(i)
}
@@ -914,7 +771,7 @@ func (rr *CERT) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next() // zString
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad CERT KeyTag", l}
+ return &ParseError{"", "bad CERT KeyTag", l}
}
rr.KeyTag = uint16(i)
c.Next() // zBlank
@@ -922,11 +779,11 @@ func (rr *CERT) parse(c *zlexer, o, f string) *ParseError {
if v, ok := StringToAlgorithm[l.token]; ok {
rr.Algorithm = v
} else if i, e := strconv.ParseUint(l.token, 10, 8); e != nil {
- return &ParseError{f, "bad CERT Algorithm", l}
+ return &ParseError{"", "bad CERT Algorithm", l}
} else {
rr.Algorithm = uint8(i)
}
- s, e1 := endingToString(c, "bad CERT Certificate", f)
+ s, e1 := endingToString(c, "bad CERT Certificate")
if e1 != nil {
return e1
}
@@ -934,8 +791,8 @@ func (rr *CERT) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *OPENPGPKEY) parse(c *zlexer, o, f string) *ParseError {
- s, e := endingToString(c, "bad OPENPGPKEY PublicKey", f)
+func (rr *OPENPGPKEY) parse(c *zlexer, o string) *ParseError {
+ s, e := endingToString(c, "bad OPENPGPKEY PublicKey")
if e != nil {
return e
}
@@ -943,15 +800,12 @@ func (rr *OPENPGPKEY) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *CSYNC) parse(c *zlexer, o, f string) *ParseError {
+func (rr *CSYNC) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
j, e := strconv.ParseUint(l.token, 10, 32)
if e != nil {
// Serial must be a number
- return &ParseError{f, "bad CSYNC serial", l}
+ return &ParseError{"", "bad CSYNC serial", l}
}
rr.Serial = uint32(j)
@@ -961,7 +815,7 @@ func (rr *CSYNC) parse(c *zlexer, o, f string) *ParseError {
j, e = strconv.ParseUint(l.token, 10, 16)
if e != nil {
// Serial must be a number
- return &ParseError{f, "bad CSYNC flags", l}
+ return &ParseError{"", "bad CSYNC flags", l}
}
rr.Flags = uint16(j)
@@ -979,38 +833,34 @@ func (rr *CSYNC) parse(c *zlexer, o, f string) *ParseError {
tokenUpper := strings.ToUpper(l.token)
if k, ok = StringToType[tokenUpper]; !ok {
if k, ok = typeToInt(l.token); !ok {
- return &ParseError{f, "bad CSYNC TypeBitMap", l}
+ return &ParseError{"", "bad CSYNC TypeBitMap", l}
}
}
rr.TypeBitMap = append(rr.TypeBitMap, k)
default:
- return &ParseError{f, "bad CSYNC TypeBitMap", l}
+ return &ParseError{"", "bad CSYNC TypeBitMap", l}
}
l, _ = c.Next()
}
return nil
}
-func (rr *SIG) parse(c *zlexer, o, f string) *ParseError {
- return rr.RRSIG.parse(c, o, f)
+func (rr *SIG) parse(c *zlexer, o string) *ParseError {
+ return rr.RRSIG.parse(c, o)
}
-func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
+func (rr *RRSIG) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
tokenUpper := strings.ToUpper(l.token)
if t, ok := StringToType[tokenUpper]; !ok {
if strings.HasPrefix(tokenUpper, "TYPE") {
t, ok = typeToInt(l.token)
if !ok {
- return &ParseError{f, "bad RRSIG Typecovered", l}
+ return &ParseError{"", "bad RRSIG Typecovered", l}
}
rr.TypeCovered = t
} else {
- return &ParseError{f, "bad RRSIG Typecovered", l}
+ return &ParseError{"", "bad RRSIG Typecovered", l}
}
} else {
rr.TypeCovered = t
@@ -1020,7 +870,7 @@ func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next()
i, err := strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
- return &ParseError{f, "bad RRSIG Algorithm", l}
+ return &ParseError{"", "bad RRSIG Algorithm", l}
}
rr.Algorithm = uint8(i)
@@ -1028,7 +878,7 @@ func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next()
i, err = strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
- return &ParseError{f, "bad RRSIG Labels", l}
+ return &ParseError{"", "bad RRSIG Labels", l}
}
rr.Labels = uint8(i)
@@ -1036,7 +886,7 @@ func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next()
i, err = strconv.ParseUint(l.token, 10, 32)
if err != nil || l.err {
- return &ParseError{f, "bad RRSIG OrigTtl", l}
+ return &ParseError{"", "bad RRSIG OrigTtl", l}
}
rr.OrigTtl = uint32(i)
@@ -1048,7 +898,7 @@ func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
// TODO(miek): error out on > MAX_UINT32, same below
rr.Expiration = uint32(i)
} else {
- return &ParseError{f, "bad RRSIG Expiration", l}
+ return &ParseError{"", "bad RRSIG Expiration", l}
}
} else {
rr.Expiration = i
@@ -1060,7 +910,7 @@ func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
if i, err := strconv.ParseInt(l.token, 10, 64); err == nil {
rr.Inception = uint32(i)
} else {
- return &ParseError{f, "bad RRSIG Inception", l}
+ return &ParseError{"", "bad RRSIG Inception", l}
}
} else {
rr.Inception = i
@@ -1070,7 +920,7 @@ func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next()
i, err = strconv.ParseUint(l.token, 10, 16)
if err != nil || l.err {
- return &ParseError{f, "bad RRSIG KeyTag", l}
+ return &ParseError{"", "bad RRSIG KeyTag", l}
}
rr.KeyTag = uint16(i)
@@ -1079,11 +929,11 @@ func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
rr.SignerName = l.token
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad RRSIG SignerName", l}
+ return &ParseError{"", "bad RRSIG SignerName", l}
}
rr.SignerName = name
- s, e := endingToString(c, "bad RRSIG Signature", f)
+ s, e := endingToString(c, "bad RRSIG Signature")
if e != nil {
return e
}
@@ -1092,16 +942,11 @@ func (rr *RRSIG) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *NSEC) parse(c *zlexer, o, f string) *ParseError {
+func (rr *NSEC) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- rr.NextDomain = l.token
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad NSEC NextDomain", l}
+ return &ParseError{"", "bad NSEC NextDomain", l}
}
rr.NextDomain = name
@@ -1119,47 +964,43 @@ func (rr *NSEC) parse(c *zlexer, o, f string) *ParseError {
tokenUpper := strings.ToUpper(l.token)
if k, ok = StringToType[tokenUpper]; !ok {
if k, ok = typeToInt(l.token); !ok {
- return &ParseError{f, "bad NSEC TypeBitMap", l}
+ return &ParseError{"", "bad NSEC TypeBitMap", l}
}
}
rr.TypeBitMap = append(rr.TypeBitMap, k)
default:
- return &ParseError{f, "bad NSEC TypeBitMap", l}
+ return &ParseError{"", "bad NSEC TypeBitMap", l}
}
l, _ = c.Next()
}
return nil
}
-func (rr *NSEC3) parse(c *zlexer, o, f string) *ParseError {
+func (rr *NSEC3) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad NSEC3 Hash", l}
+ return &ParseError{"", "bad NSEC3 Hash", l}
}
rr.Hash = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad NSEC3 Flags", l}
+ return &ParseError{"", "bad NSEC3 Flags", l}
}
rr.Flags = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad NSEC3 Iterations", l}
+ return &ParseError{"", "bad NSEC3 Iterations", l}
}
rr.Iterations = uint16(i)
c.Next()
l, _ = c.Next()
if len(l.token) == 0 || l.err {
- return &ParseError{f, "bad NSEC3 Salt", l}
+ return &ParseError{"", "bad NSEC3 Salt", l}
}
if l.token != "-" {
rr.SaltLength = uint8(len(l.token)) / 2
@@ -1169,7 +1010,7 @@ func (rr *NSEC3) parse(c *zlexer, o, f string) *ParseError {
c.Next()
l, _ = c.Next()
if len(l.token) == 0 || l.err {
- return &ParseError{f, "bad NSEC3 NextDomain", l}
+ return &ParseError{"", "bad NSEC3 NextDomain", l}
}
rr.HashLength = 20 // Fix for NSEC3 (sha1 160 bits)
rr.NextDomain = l.token
@@ -1188,41 +1029,37 @@ func (rr *NSEC3) parse(c *zlexer, o, f string) *ParseError {
tokenUpper := strings.ToUpper(l.token)
if k, ok = StringToType[tokenUpper]; !ok {
if k, ok = typeToInt(l.token); !ok {
- return &ParseError{f, "bad NSEC3 TypeBitMap", l}
+ return &ParseError{"", "bad NSEC3 TypeBitMap", l}
}
}
rr.TypeBitMap = append(rr.TypeBitMap, k)
default:
- return &ParseError{f, "bad NSEC3 TypeBitMap", l}
+ return &ParseError{"", "bad NSEC3 TypeBitMap", l}
}
l, _ = c.Next()
}
return nil
}
-func (rr *NSEC3PARAM) parse(c *zlexer, o, f string) *ParseError {
+func (rr *NSEC3PARAM) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad NSEC3PARAM Hash", l}
+ return &ParseError{"", "bad NSEC3PARAM Hash", l}
}
rr.Hash = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad NSEC3PARAM Flags", l}
+ return &ParseError{"", "bad NSEC3PARAM Flags", l}
}
rr.Flags = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad NSEC3PARAM Iterations", l}
+ return &ParseError{"", "bad NSEC3PARAM Iterations", l}
}
rr.Iterations = uint16(i)
c.Next()
@@ -1231,17 +1068,13 @@ func (rr *NSEC3PARAM) parse(c *zlexer, o, f string) *ParseError {
rr.SaltLength = uint8(len(l.token))
rr.Salt = l.token
}
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *EUI48) parse(c *zlexer, o, f string) *ParseError {
+func (rr *EUI48) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
if len(l.token) != 17 || l.err {
- return &ParseError{f, "bad EUI48 Address", l}
+ return &ParseError{"", "bad EUI48 Address", l}
}
addr := make([]byte, 12)
dash := 0
@@ -1250,7 +1083,7 @@ func (rr *EUI48) parse(c *zlexer, o, f string) *ParseError {
addr[i+1] = l.token[i+1+dash]
dash++
if l.token[i+1+dash] != '-' {
- return &ParseError{f, "bad EUI48 Address", l}
+ return &ParseError{"", "bad EUI48 Address", l}
}
}
addr[10] = l.token[15]
@@ -1258,20 +1091,16 @@ func (rr *EUI48) parse(c *zlexer, o, f string) *ParseError {
i, e := strconv.ParseUint(string(addr), 16, 48)
if e != nil {
- return &ParseError{f, "bad EUI48 Address", l}
+ return &ParseError{"", "bad EUI48 Address", l}
}
rr.Address = i
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *EUI64) parse(c *zlexer, o, f string) *ParseError {
+func (rr *EUI64) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
if len(l.token) != 23 || l.err {
- return &ParseError{f, "bad EUI64 Address", l}
+ return &ParseError{"", "bad EUI64 Address", l}
}
addr := make([]byte, 16)
dash := 0
@@ -1280,7 +1109,7 @@ func (rr *EUI64) parse(c *zlexer, o, f string) *ParseError {
addr[i+1] = l.token[i+1+dash]
dash++
if l.token[i+1+dash] != '-' {
- return &ParseError{f, "bad EUI64 Address", l}
+ return &ParseError{"", "bad EUI64 Address", l}
}
}
addr[14] = l.token[21]
@@ -1288,32 +1117,28 @@ func (rr *EUI64) parse(c *zlexer, o, f string) *ParseError {
i, e := strconv.ParseUint(string(addr), 16, 64)
if e != nil {
- return &ParseError{f, "bad EUI68 Address", l}
+ return &ParseError{"", "bad EUI68 Address", l}
}
rr.Address = i
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *SSHFP) parse(c *zlexer, o, f string) *ParseError {
+func (rr *SSHFP) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad SSHFP Algorithm", l}
+ return &ParseError{"", "bad SSHFP Algorithm", l}
}
rr.Algorithm = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad SSHFP Type", l}
+ return &ParseError{"", "bad SSHFP Type", l}
}
rr.Type = uint8(i)
c.Next() // zBlank
- s, e1 := endingToString(c, "bad SSHFP Fingerprint", f)
+ s, e1 := endingToString(c, "bad SSHFP Fingerprint")
if e1 != nil {
return e1
}
@@ -1321,32 +1146,28 @@ func (rr *SSHFP) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *DNSKEY) parseDNSKEY(c *zlexer, o, f, typ string) *ParseError {
+func (rr *DNSKEY) parseDNSKEY(c *zlexer, o, typ string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad " + typ + " Flags", l}
+ return &ParseError{"", "bad " + typ + " Flags", l}
}
rr.Flags = uint16(i)
c.Next() // zBlank
l, _ = c.Next() // zString
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad " + typ + " Protocol", l}
+ return &ParseError{"", "bad " + typ + " Protocol", l}
}
rr.Protocol = uint8(i)
c.Next() // zBlank
l, _ = c.Next() // zString
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad " + typ + " Algorithm", l}
+ return &ParseError{"", "bad " + typ + " Algorithm", l}
}
rr.Algorithm = uint8(i)
- s, e1 := endingToString(c, "bad "+typ+" PublicKey", f)
+ s, e1 := endingToString(c, "bad "+typ+" PublicKey")
if e1 != nil {
return e1
}
@@ -1354,44 +1175,40 @@ func (rr *DNSKEY) parseDNSKEY(c *zlexer, o, f, typ string) *ParseError {
return nil
}
-func (rr *DNSKEY) parse(c *zlexer, o, f string) *ParseError {
- return rr.parseDNSKEY(c, o, f, "DNSKEY")
+func (rr *DNSKEY) parse(c *zlexer, o string) *ParseError {
+ return rr.parseDNSKEY(c, o, "DNSKEY")
}
-func (rr *KEY) parse(c *zlexer, o, f string) *ParseError {
- return rr.parseDNSKEY(c, o, f, "KEY")
+func (rr *KEY) parse(c *zlexer, o string) *ParseError {
+ return rr.parseDNSKEY(c, o, "KEY")
}
-func (rr *CDNSKEY) parse(c *zlexer, o, f string) *ParseError {
- return rr.parseDNSKEY(c, o, f, "CDNSKEY")
+func (rr *CDNSKEY) parse(c *zlexer, o string) *ParseError {
+ return rr.parseDNSKEY(c, o, "CDNSKEY")
}
-func (rr *RKEY) parse(c *zlexer, o, f string) *ParseError {
+func (rr *RKEY) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad RKEY Flags", l}
+ return &ParseError{"", "bad RKEY Flags", l}
}
rr.Flags = uint16(i)
c.Next() // zBlank
l, _ = c.Next() // zString
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad RKEY Protocol", l}
+ return &ParseError{"", "bad RKEY Protocol", l}
}
rr.Protocol = uint8(i)
c.Next() // zBlank
l, _ = c.Next() // zString
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad RKEY Algorithm", l}
+ return &ParseError{"", "bad RKEY Algorithm", l}
}
rr.Algorithm = uint8(i)
- s, e1 := endingToString(c, "bad RKEY PublicKey", f)
+ s, e1 := endingToString(c, "bad RKEY PublicKey")
if e1 != nil {
return e1
}
@@ -1399,8 +1216,8 @@ func (rr *RKEY) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *EID) parse(c *zlexer, o, f string) *ParseError {
- s, e := endingToString(c, "bad EID Endpoint", f)
+func (rr *EID) parse(c *zlexer, o string) *ParseError {
+ s, e := endingToString(c, "bad EID Endpoint")
if e != nil {
return e
}
@@ -1408,8 +1225,8 @@ func (rr *EID) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *NIMLOC) parse(c *zlexer, o, f string) *ParseError {
- s, e := endingToString(c, "bad NIMLOC Locator", f)
+func (rr *NIMLOC) parse(c *zlexer, o string) *ParseError {
+ s, e := endingToString(c, "bad NIMLOC Locator")
if e != nil {
return e
}
@@ -1417,43 +1234,35 @@ func (rr *NIMLOC) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *GPOS) parse(c *zlexer, o, f string) *ParseError {
+func (rr *GPOS) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
_, e := strconv.ParseFloat(l.token, 64)
if e != nil || l.err {
- return &ParseError{f, "bad GPOS Longitude", l}
+ return &ParseError{"", "bad GPOS Longitude", l}
}
rr.Longitude = l.token
c.Next() // zBlank
l, _ = c.Next()
_, e = strconv.ParseFloat(l.token, 64)
if e != nil || l.err {
- return &ParseError{f, "bad GPOS Latitude", l}
+ return &ParseError{"", "bad GPOS Latitude", l}
}
rr.Latitude = l.token
c.Next() // zBlank
l, _ = c.Next()
_, e = strconv.ParseFloat(l.token, 64)
if e != nil || l.err {
- return &ParseError{f, "bad GPOS Altitude", l}
+ return &ParseError{"", "bad GPOS Altitude", l}
}
rr.Altitude = l.token
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *DS) parseDS(c *zlexer, o, f, typ string) *ParseError {
+func (rr *DS) parseDS(c *zlexer, o, typ string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad " + typ + " KeyTag", l}
+ return &ParseError{"", "bad " + typ + " KeyTag", l}
}
rr.KeyTag = uint16(i)
c.Next() // zBlank
@@ -1462,7 +1271,7 @@ func (rr *DS) parseDS(c *zlexer, o, f, typ string) *ParseError {
tokenUpper := strings.ToUpper(l.token)
i, ok := StringToAlgorithm[tokenUpper]
if !ok || l.err {
- return &ParseError{f, "bad " + typ + " Algorithm", l}
+ return &ParseError{"", "bad " + typ + " Algorithm", l}
}
rr.Algorithm = i
} else {
@@ -1472,10 +1281,10 @@ func (rr *DS) parseDS(c *zlexer, o, f, typ string) *ParseError {
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad " + typ + " DigestType", l}
+ return &ParseError{"", "bad " + typ + " DigestType", l}
}
rr.DigestType = uint8(i)
- s, e1 := endingToString(c, "bad "+typ+" Digest", f)
+ s, e1 := endingToString(c, "bad "+typ+" Digest")
if e1 != nil {
return e1
}
@@ -1483,27 +1292,23 @@ func (rr *DS) parseDS(c *zlexer, o, f, typ string) *ParseError {
return nil
}
-func (rr *DS) parse(c *zlexer, o, f string) *ParseError {
- return rr.parseDS(c, o, f, "DS")
+func (rr *DS) parse(c *zlexer, o string) *ParseError {
+ return rr.parseDS(c, o, "DS")
}
-func (rr *DLV) parse(c *zlexer, o, f string) *ParseError {
- return rr.parseDS(c, o, f, "DLV")
+func (rr *DLV) parse(c *zlexer, o string) *ParseError {
+ return rr.parseDS(c, o, "DLV")
}
-func (rr *CDS) parse(c *zlexer, o, f string) *ParseError {
- return rr.parseDS(c, o, f, "CDS")
+func (rr *CDS) parse(c *zlexer, o string) *ParseError {
+ return rr.parseDS(c, o, "CDS")
}
-func (rr *TA) parse(c *zlexer, o, f string) *ParseError {
+func (rr *TA) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad TA KeyTag", l}
+ return &ParseError{"", "bad TA KeyTag", l}
}
rr.KeyTag = uint16(i)
c.Next() // zBlank
@@ -1512,7 +1317,7 @@ func (rr *TA) parse(c *zlexer, o, f string) *ParseError {
tokenUpper := strings.ToUpper(l.token)
i, ok := StringToAlgorithm[tokenUpper]
if !ok || l.err {
- return &ParseError{f, "bad TA Algorithm", l}
+ return &ParseError{"", "bad TA Algorithm", l}
}
rr.Algorithm = i
} else {
@@ -1522,10 +1327,10 @@ func (rr *TA) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad TA DigestType", l}
+ return &ParseError{"", "bad TA DigestType", l}
}
rr.DigestType = uint8(i)
- s, err := endingToString(c, "bad TA Digest", f)
+ s, err := endingToString(c, "bad TA Digest")
if err != nil {
return err
}
@@ -1533,33 +1338,29 @@ func (rr *TA) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *TLSA) parse(c *zlexer, o, f string) *ParseError {
+func (rr *TLSA) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad TLSA Usage", l}
+ return &ParseError{"", "bad TLSA Usage", l}
}
rr.Usage = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad TLSA Selector", l}
+ return &ParseError{"", "bad TLSA Selector", l}
}
rr.Selector = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad TLSA MatchingType", l}
+ return &ParseError{"", "bad TLSA MatchingType", l}
}
rr.MatchingType = uint8(i)
// So this needs be e2 (i.e. different than e), because...??t
- s, e2 := endingToString(c, "bad TLSA Certificate", f)
+ s, e2 := endingToString(c, "bad TLSA Certificate")
if e2 != nil {
return e2
}
@@ -1567,33 +1368,29 @@ func (rr *TLSA) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *SMIMEA) parse(c *zlexer, o, f string) *ParseError {
+func (rr *SMIMEA) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad SMIMEA Usage", l}
+ return &ParseError{"", "bad SMIMEA Usage", l}
}
rr.Usage = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad SMIMEA Selector", l}
+ return &ParseError{"", "bad SMIMEA Selector", l}
}
rr.Selector = uint8(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 8)
if e != nil || l.err {
- return &ParseError{f, "bad SMIMEA MatchingType", l}
+ return &ParseError{"", "bad SMIMEA MatchingType", l}
}
rr.MatchingType = uint8(i)
// So this needs be e2 (i.e. different than e), because...??t
- s, e2 := endingToString(c, "bad SMIMEA Certificate", f)
+ s, e2 := endingToString(c, "bad SMIMEA Certificate")
if e2 != nil {
return e2
}
@@ -1601,32 +1398,32 @@ func (rr *SMIMEA) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *RFC3597) parse(c *zlexer, o, f string) *ParseError {
+func (rr *RFC3597) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
if l.token != "\\#" {
- return &ParseError{f, "bad RFC3597 Rdata", l}
+ return &ParseError{"", "bad RFC3597 Rdata", l}
}
c.Next() // zBlank
l, _ = c.Next()
rdlength, e := strconv.Atoi(l.token)
if e != nil || l.err {
- return &ParseError{f, "bad RFC3597 Rdata ", l}
+ return &ParseError{"", "bad RFC3597 Rdata ", l}
}
- s, e1 := endingToString(c, "bad RFC3597 Rdata", f)
+ s, e1 := endingToString(c, "bad RFC3597 Rdata")
if e1 != nil {
return e1
}
if rdlength*2 != len(s) {
- return &ParseError{f, "bad RFC3597 Rdata", l}
+ return &ParseError{"", "bad RFC3597 Rdata", l}
}
rr.Rdata = s
return nil
}
-func (rr *SPF) parse(c *zlexer, o, f string) *ParseError {
- s, e := endingToTxtSlice(c, "bad SPF Txt", f)
+func (rr *SPF) parse(c *zlexer, o string) *ParseError {
+ s, e := endingToTxtSlice(c, "bad SPF Txt")
if e != nil {
return e
}
@@ -1634,8 +1431,8 @@ func (rr *SPF) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *AVC) parse(c *zlexer, o, f string) *ParseError {
- s, e := endingToTxtSlice(c, "bad AVC Txt", f)
+func (rr *AVC) parse(c *zlexer, o string) *ParseError {
+ s, e := endingToTxtSlice(c, "bad AVC Txt")
if e != nil {
return e
}
@@ -1643,9 +1440,9 @@ func (rr *AVC) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *TXT) parse(c *zlexer, o, f string) *ParseError {
+func (rr *TXT) parse(c *zlexer, o string) *ParseError {
// no zBlank reading here, because all this rdata is TXT
- s, e := endingToTxtSlice(c, "bad TXT Txt", f)
+ s, e := endingToTxtSlice(c, "bad TXT Txt")
if e != nil {
return e
}
@@ -1654,8 +1451,8 @@ func (rr *TXT) parse(c *zlexer, o, f string) *ParseError {
}
// identical to setTXT
-func (rr *NINFO) parse(c *zlexer, o, f string) *ParseError {
- s, e := endingToTxtSlice(c, "bad NINFO ZSData", f)
+func (rr *NINFO) parse(c *zlexer, o string) *ParseError {
+ s, e := endingToTxtSlice(c, "bad NINFO ZSData")
if e != nil {
return e
}
@@ -1663,40 +1460,36 @@ func (rr *NINFO) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *URI) parse(c *zlexer, o, f string) *ParseError {
+func (rr *URI) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad URI Priority", l}
+ return &ParseError{"", "bad URI Priority", l}
}
rr.Priority = uint16(i)
c.Next() // zBlank
l, _ = c.Next()
i, e = strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad URI Weight", l}
+ return &ParseError{"", "bad URI Weight", l}
}
rr.Weight = uint16(i)
c.Next() // zBlank
- s, err := endingToTxtSlice(c, "bad URI Target", f)
+ s, err := endingToTxtSlice(c, "bad URI Target")
if err != nil {
return err
}
if len(s) != 1 {
- return &ParseError{f, "bad URI Target", l}
+ return &ParseError{"", "bad URI Target", l}
}
rr.Target = s[0]
return nil
}
-func (rr *DHCID) parse(c *zlexer, o, f string) *ParseError {
+func (rr *DHCID) parse(c *zlexer, o string) *ParseError {
// awesome record to parse!
- s, e := endingToString(c, "bad DHCID Digest", f)
+ s, e := endingToString(c, "bad DHCID Digest")
if e != nil {
return e
}
@@ -1704,15 +1497,11 @@ func (rr *DHCID) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *NID) parse(c *zlexer, o, f string) *ParseError {
+func (rr *NID) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad NID Preference", l}
+ return &ParseError{"", "bad NID Preference", l}
}
rr.Preference = uint16(i)
c.Next() // zBlank
@@ -1722,38 +1511,30 @@ func (rr *NID) parse(c *zlexer, o, f string) *ParseError {
return err
}
rr.NodeID = u
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *L32) parse(c *zlexer, o, f string) *ParseError {
+func (rr *L32) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad L32 Preference", l}
+ return &ParseError{"", "bad L32 Preference", l}
}
rr.Preference = uint16(i)
c.Next() // zBlank
l, _ = c.Next() // zString
rr.Locator32 = net.ParseIP(l.token)
if rr.Locator32 == nil || l.err {
- return &ParseError{f, "bad L32 Locator", l}
+ return &ParseError{"", "bad L32 Locator", l}
}
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *LP) parse(c *zlexer, o, f string) *ParseError {
+func (rr *LP) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad LP Preference", l}
+ return &ParseError{"", "bad LP Preference", l}
}
rr.Preference = uint16(i)
@@ -1762,22 +1543,18 @@ func (rr *LP) parse(c *zlexer, o, f string) *ParseError {
rr.Fqdn = l.token
name, nameOk := toAbsoluteName(l.token, o)
if l.err || !nameOk {
- return &ParseError{f, "bad LP Fqdn", l}
+ return &ParseError{"", "bad LP Fqdn", l}
}
rr.Fqdn = name
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *L64) parse(c *zlexer, o, f string) *ParseError {
+func (rr *L64) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad L64 Preference", l}
+ return &ParseError{"", "bad L64 Preference", l}
}
rr.Preference = uint16(i)
c.Next() // zBlank
@@ -1787,39 +1564,31 @@ func (rr *L64) parse(c *zlexer, o, f string) *ParseError {
return err
}
rr.Locator64 = u
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *UID) parse(c *zlexer, o, f string) *ParseError {
+func (rr *UID) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 32)
if e != nil || l.err {
- return &ParseError{f, "bad UID Uid", l}
+ return &ParseError{"", "bad UID Uid", l}
}
rr.Uid = uint32(i)
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *GID) parse(c *zlexer, o, f string) *ParseError {
+func (rr *GID) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 32)
if e != nil || l.err {
- return &ParseError{f, "bad GID Gid", l}
+ return &ParseError{"", "bad GID Gid", l}
}
rr.Gid = uint32(i)
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *UINFO) parse(c *zlexer, o, f string) *ParseError {
- s, e := endingToTxtSlice(c, "bad UINFO Uinfo", f)
+func (rr *UINFO) parse(c *zlexer, o string) *ParseError {
+ s, e := endingToTxtSlice(c, "bad UINFO Uinfo")
if e != nil {
return e
}
@@ -1830,15 +1599,11 @@ func (rr *UINFO) parse(c *zlexer, o, f string) *ParseError {
return nil
}
-func (rr *PX) parse(c *zlexer, o, f string) *ParseError {
+func (rr *PX) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return slurpRemainder(c, f)
- }
-
i, e := strconv.ParseUint(l.token, 10, 16)
if e != nil || l.err {
- return &ParseError{f, "bad PX Preference", l}
+ return &ParseError{"", "bad PX Preference", l}
}
rr.Preference = uint16(i)
@@ -1847,7 +1612,7 @@ func (rr *PX) parse(c *zlexer, o, f string) *ParseError {
rr.Map822 = l.token
map822, map822Ok := toAbsoluteName(l.token, o)
if l.err || !map822Ok {
- return &ParseError{f, "bad PX Map822", l}
+ return &ParseError{"", "bad PX Map822", l}
}
rr.Map822 = map822
@@ -1856,50 +1621,46 @@ func (rr *PX) parse(c *zlexer, o, f string) *ParseError {
rr.Mapx400 = l.token
mapx400, mapx400Ok := toAbsoluteName(l.token, o)
if l.err || !mapx400Ok {
- return &ParseError{f, "bad PX Mapx400", l}
+ return &ParseError{"", "bad PX Mapx400", l}
}
rr.Mapx400 = mapx400
- return slurpRemainder(c, f)
+ return slurpRemainder(c)
}
-func (rr *CAA) parse(c *zlexer, o, f string) *ParseError {
+func (rr *CAA) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
- if len(l.token) == 0 { // dynamic update rr.
- return nil
- }
-
i, err := strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
- return &ParseError{f, "bad CAA Flag", l}
+ return &ParseError{"", "bad CAA Flag", l}
}
rr.Flag = uint8(i)
c.Next() // zBlank
l, _ = c.Next() // zString
if l.value != zString {
- return &ParseError{f, "bad CAA Tag", l}
+ return &ParseError{"", "bad CAA Tag", l}
}
rr.Tag = l.token
c.Next() // zBlank
- s, e := endingToTxtSlice(c, "bad CAA Value", f)
+ s, e := endingToTxtSlice(c, "bad CAA Value")
if e != nil {
return e
}
if len(s) != 1 {
- return &ParseError{f, "bad CAA Value", l}
+ return &ParseError{"", "bad CAA Value", l}
}
rr.Value = s[0]
return nil
}
-func (rr *TKEY) parse(c *zlexer, o, f string) *ParseError {
+func (rr *TKEY) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
// Algorithm
if l.value != zString {
- return &ParseError{f, "bad TKEY algorithm", l}
+ return &ParseError{"", "bad TKEY algorithm", l}
}
rr.Algorithm = l.token
c.Next() // zBlank
@@ -1908,13 +1669,13 @@ func (rr *TKEY) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next()
i, err := strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
- return &ParseError{f, "bad TKEY key length", l}
+ return &ParseError{"", "bad TKEY key length", l}
}
rr.KeySize = uint16(i)
c.Next() // zBlank
l, _ = c.Next()
if l.value != zString {
- return &ParseError{f, "bad TKEY key", l}
+ return &ParseError{"", "bad TKEY key", l}
}
rr.Key = l.token
c.Next() // zBlank
@@ -1923,13 +1684,13 @@ func (rr *TKEY) parse(c *zlexer, o, f string) *ParseError {
l, _ = c.Next()
i, err = strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
- return &ParseError{f, "bad TKEY otherdata length", l}
+ return &ParseError{"", "bad TKEY otherdata length", l}
}
rr.OtherLen = uint16(i)
c.Next() // zBlank
l, _ = c.Next()
if l.value != zString {
- return &ParseError{f, "bad TKEY otherday", l}
+ return &ParseError{"", "bad TKEY otherday", l}
}
rr.OtherData = l.token
diff --git a/vendor/github.com/miekg/dns/serve_mux.go b/vendor/github.com/miekg/dns/serve_mux.go
index ae304db530..69deb33e80 100644
--- a/vendor/github.com/miekg/dns/serve_mux.go
+++ b/vendor/github.com/miekg/dns/serve_mux.go
@@ -36,33 +36,9 @@ func (mux *ServeMux) match(q string, t uint16) Handler {
return nil
}
+ q = strings.ToLower(q)
+
var handler Handler
-
- // TODO(tmthrgd): Once https://go-review.googlesource.com/c/go/+/137575
- // lands in a go release, replace the following with strings.ToLower.
- var sb strings.Builder
- for i := 0; i < len(q); i++ {
- c := q[i]
- if !(c >= 'A' && c <= 'Z') {
- continue
- }
-
- sb.Grow(len(q))
- sb.WriteString(q[:i])
-
- for ; i < len(q); i++ {
- c := q[i]
- if c >= 'A' && c <= 'Z' {
- c += 'a' - 'A'
- }
-
- sb.WriteByte(c)
- }
-
- q = sb.String()
- break
- }
-
for off, end := 0, false; !end; off, end = NextLabel(q, off) {
if h, ok := mux.z[q[off:]]; ok {
if t != TypeDS {
diff --git a/vendor/github.com/miekg/dns/server.go b/vendor/github.com/miekg/dns/server.go
index 882403704a..3cf1a02401 100644
--- a/vendor/github.com/miekg/dns/server.go
+++ b/vendor/github.com/miekg/dns/server.go
@@ -3,7 +3,6 @@
package dns
import (
- "bytes"
"context"
"crypto/tls"
"encoding/binary"
@@ -12,26 +11,12 @@ import (
"net"
"strings"
"sync"
- "sync/atomic"
"time"
)
// Default maximum number of TCP queries before we close the socket.
const maxTCPQueries = 128
-// The maximum number of idle workers.
-//
-// This controls the maximum number of workers that are allowed to stay
-// idle waiting for incoming requests before being torn down.
-//
-// If this limit is reached, the server will just keep spawning new
-// workers (goroutines) for each incoming request. In this case, each
-// worker will only be used for a single request.
-const maxIdleWorkersCount = 10000
-
-// The maximum length of time a worker may idle for before being destroyed.
-const idleWorkerTimeout = 10 * time.Second
-
// aLongTimeAgo is a non-zero time, far in the past, used for
// immediate cancelation of network operations.
var aLongTimeAgo = time.Unix(1, 0)
@@ -81,7 +66,6 @@ type ConnectionStater interface {
}
type response struct {
- msg []byte
closed bool // connection has been closed
hijacked bool // connection has been hijacked by handler
tsigTimersOnly bool
@@ -92,7 +76,6 @@ type response struct {
tcp net.Conn // i/o connection if TCP was used
udpSession *SessionUDP // oob data to get egress interface right
writer Writer // writer to output the raw DNS bits
- wg *sync.WaitGroup // for gracefull shutdown
}
// HandleFailed returns a HandlerFunc that returns SERVFAIL for every request it gets.
@@ -218,11 +201,6 @@ type Server struct {
// By default DefaultMsgAcceptFunc will be used.
MsgAcceptFunc MsgAcceptFunc
- // UDP packet or TCP connection queue
- queue chan *response
- // Workers count
- workersCount int32
-
// Shutdown handling
lock sync.RWMutex
started bool
@@ -240,51 +218,6 @@ func (srv *Server) isStarted() bool {
return started
}
-func (srv *Server) worker(w *response) {
- srv.serve(w)
-
- for {
- count := atomic.LoadInt32(&srv.workersCount)
- if count > maxIdleWorkersCount {
- return
- }
- if atomic.CompareAndSwapInt32(&srv.workersCount, count, count+1) {
- break
- }
- }
-
- defer atomic.AddInt32(&srv.workersCount, -1)
-
- inUse := false
- timeout := time.NewTimer(idleWorkerTimeout)
- defer timeout.Stop()
-LOOP:
- for {
- select {
- case w, ok := <-srv.queue:
- if !ok {
- break LOOP
- }
- inUse = true
- srv.serve(w)
- case <-timeout.C:
- if !inUse {
- break LOOP
- }
- inUse = false
- timeout.Reset(idleWorkerTimeout)
- }
- }
-}
-
-func (srv *Server) spawnWorker(w *response) {
- select {
- case srv.queue <- w:
- default:
- go srv.worker(w)
- }
-}
-
func makeUDPBuffer(size int) func() interface{} {
return func() interface{} {
return make([]byte, size)
@@ -292,8 +225,6 @@ func makeUDPBuffer(size int) func() interface{} {
}
func (srv *Server) init() {
- srv.queue = make(chan *response)
-
srv.shutdown = make(chan struct{})
srv.conns = make(map[net.Conn]struct{})
@@ -301,7 +232,10 @@ func (srv *Server) init() {
srv.UDPSize = MinMsgSize
}
if srv.MsgAcceptFunc == nil {
- srv.MsgAcceptFunc = defaultMsgAcceptFunc
+ srv.MsgAcceptFunc = DefaultMsgAcceptFunc
+ }
+ if srv.Handler == nil {
+ srv.Handler = DefaultServeMux
}
srv.udpPool.New = makeUDPBuffer(srv.UDPSize)
@@ -328,7 +262,6 @@ func (srv *Server) ListenAndServe() error {
}
srv.init()
- defer close(srv.queue)
switch srv.Net {
case "tcp", "tcp4", "tcp6":
@@ -383,7 +316,6 @@ func (srv *Server) ActivateAndServe() error {
}
srv.init()
- defer close(srv.queue)
pConn := srv.PacketConn
l := srv.Listener
@@ -499,11 +431,7 @@ func (srv *Server) serveTCP(l net.Listener) error {
srv.conns[rw] = struct{}{}
srv.lock.Unlock()
wg.Add(1)
- srv.spawnWorker(&response{
- tsigSecret: srv.TsigSecret,
- tcp: rw,
- wg: &wg,
- })
+ go srv.serveTCPConn(&wg, rw)
}
return nil
@@ -548,45 +476,21 @@ func (srv *Server) serveUDP(l *net.UDPConn) error {
continue
}
wg.Add(1)
- srv.spawnWorker(&response{
- msg: m,
- tsigSecret: srv.TsigSecret,
- udp: l,
- udpSession: s,
- wg: &wg,
- })
+ go srv.serveUDPPacket(&wg, m, l, s)
}
return nil
}
-func (srv *Server) serve(w *response) {
+// Serve a new TCP connection.
+func (srv *Server) serveTCPConn(wg *sync.WaitGroup, rw net.Conn) {
+ w := &response{tsigSecret: srv.TsigSecret, tcp: rw}
if srv.DecorateWriter != nil {
w.writer = srv.DecorateWriter(w)
} else {
w.writer = w
}
- if w.udp != nil {
- // serve UDP
- srv.serveDNS(w)
-
- w.wg.Done()
- return
- }
-
- defer func() {
- if !w.hijacked {
- w.Close()
- }
-
- srv.lock.Lock()
- delete(srv.conns, w.tcp)
- srv.lock.Unlock()
-
- w.wg.Done()
- }()
-
reader := Reader(defaultReader{srv})
if srv.DecorateReader != nil {
reader = srv.DecorateReader(reader)
@@ -605,14 +509,13 @@ func (srv *Server) serve(w *response) {
}
for q := 0; (q < limit || limit == -1) && srv.isStarted(); q++ {
- var err error
- w.msg, err = reader.ReadTCP(w.tcp, timeout)
+ m, err := reader.ReadTCP(w.tcp, timeout)
if err != nil {
// TODO(tmthrgd): handle error
break
}
- srv.serveDNS(w)
- if w.tcp == nil {
+ srv.serveDNS(m, w)
+ if w.closed {
break // Close() was called
}
if w.hijacked {
@@ -622,17 +525,33 @@ func (srv *Server) serve(w *response) {
// idle timeout.
timeout = idleTimeout
}
-}
-func (srv *Server) disposeBuffer(w *response) {
- if w.udp != nil && cap(w.msg) == srv.UDPSize {
- srv.udpPool.Put(w.msg[:srv.UDPSize])
+ if !w.hijacked {
+ w.Close()
}
- w.msg = nil
+
+ srv.lock.Lock()
+ delete(srv.conns, w.tcp)
+ srv.lock.Unlock()
+
+ wg.Done()
}
-func (srv *Server) serveDNS(w *response) {
- dh, off, err := unpackMsgHdr(w.msg, 0)
+// Serve a new UDP request.
+func (srv *Server) serveUDPPacket(wg *sync.WaitGroup, m []byte, u *net.UDPConn, s *SessionUDP) {
+ w := &response{tsigSecret: srv.TsigSecret, udp: u, udpSession: s}
+ if srv.DecorateWriter != nil {
+ w.writer = srv.DecorateWriter(w)
+ } else {
+ w.writer = w
+ }
+
+ srv.serveDNS(m, w)
+ wg.Done()
+}
+
+func (srv *Server) serveDNS(m []byte, w *response) {
+ dh, off, err := unpackMsgHdr(m, 0)
if err != nil {
// Let client hang, they are sending crap; any reply can be used to amplify.
return
@@ -641,26 +560,32 @@ func (srv *Server) serveDNS(w *response) {
req := new(Msg)
req.setHdr(dh)
- switch srv.MsgAcceptFunc(dh) {
+ switch action := srv.MsgAcceptFunc(dh); action {
case MsgAccept:
- case MsgIgnore:
- return
- case MsgReject:
+ if req.unpack(dh, m, off) == nil {
+ break
+ }
+
+ fallthrough
+ case MsgReject, MsgRejectNotImplemented:
+ opcode := req.Opcode
req.SetRcodeFormatError(req)
+ req.Zero = false
+ if action == MsgRejectNotImplemented {
+ req.Opcode = opcode
+ req.Rcode = RcodeNotImplemented
+ }
+
// Are we allowed to delete any OPT records here?
req.Ns, req.Answer, req.Extra = nil, nil, nil
w.WriteMsg(req)
- srv.disposeBuffer(w)
- return
- }
+ fallthrough
+ case MsgIgnore:
+ if w.udp != nil && cap(m) == srv.UDPSize {
+ srv.udpPool.Put(m[:srv.UDPSize])
+ }
- if err := req.unpack(dh, w.msg, off); err != nil {
- req.SetRcodeFormatError(req)
- req.Ns, req.Answer, req.Extra = nil, nil, nil
-
- w.WriteMsg(req)
- srv.disposeBuffer(w)
return
}
@@ -668,7 +593,7 @@ func (srv *Server) serveDNS(w *response) {
if w.tsigSecret != nil {
if t := req.IsTsig(); t != nil {
if secret, ok := w.tsigSecret[t.Hdr.Name]; ok {
- w.tsigStatus = TsigVerify(w.msg, secret, "", false)
+ w.tsigStatus = TsigVerify(m, secret, "", false)
} else {
w.tsigStatus = ErrSecret
}
@@ -677,14 +602,11 @@ func (srv *Server) serveDNS(w *response) {
}
}
- srv.disposeBuffer(w)
-
- handler := srv.Handler
- if handler == nil {
- handler = DefaultServeMux
+ if w.udp != nil && cap(m) == srv.UDPSize {
+ srv.udpPool.Put(m[:srv.UDPSize])
}
- handler.ServeDNS(w, req) // Writes back to the client
+ srv.Handler.ServeDNS(w, req) // Writes back to the client
}
func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error) {
@@ -698,36 +620,16 @@ func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error)
}
srv.lock.RUnlock()
- l := make([]byte, 2)
- n, err := conn.Read(l)
- if err != nil || n != 2 {
- if err != nil {
- return nil, err
- }
- return nil, ErrShortRead
+ var length uint16
+ if err := binary.Read(conn, binary.BigEndian, &length); err != nil {
+ return nil, err
}
- length := binary.BigEndian.Uint16(l)
- if length == 0 {
- return nil, ErrShortRead
+
+ m := make([]byte, length)
+ if _, err := io.ReadFull(conn, m); err != nil {
+ return nil, err
}
- m := make([]byte, int(length))
- n, err = conn.Read(m[:int(length)])
- if err != nil || n == 0 {
- if err != nil {
- return nil, err
- }
- return nil, ErrShortRead
- }
- i := n
- for i < int(length) {
- j, err := conn.Read(m[i:int(length)])
- if err != nil {
- return nil, err
- }
- i += j
- }
- n = i
- m = m[:n]
+
return m, nil
}
@@ -784,18 +686,14 @@ func (w *response) Write(m []byte) (int, error) {
case w.udp != nil:
return WriteToSessionUDP(w.udp, m, w.udpSession)
case w.tcp != nil:
- lm := len(m)
- if lm < 2 {
- return 0, io.ErrShortBuffer
- }
- if lm > MaxMsgSize {
+ if len(m) > MaxMsgSize {
return 0, &Error{err: "message too large"}
}
- l := make([]byte, 2, 2+lm)
- binary.BigEndian.PutUint16(l, uint16(lm))
- m = append(l, m...)
- n, err := io.Copy(w.tcp, bytes.NewReader(m))
+ l := make([]byte, 2)
+ binary.BigEndian.PutUint16(l, uint16(len(m)))
+
+ n, err := (&net.Buffers{l, m}).WriteTo(w.tcp)
return int(n), err
default:
panic("dns: internal error: udp and tcp both nil")
diff --git a/vendor/github.com/miekg/dns/sig0.go b/vendor/github.com/miekg/dns/sig0.go
index ec65dd7f95..55cf1c3863 100644
--- a/vendor/github.com/miekg/dns/sig0.go
+++ b/vendor/github.com/miekg/dns/sig0.go
@@ -181,10 +181,8 @@ func (rr *SIG) Verify(k *KEY, buf []byte) error {
case DSA:
pk := k.publicKeyDSA()
sig = sig[1:]
- r := big.NewInt(0)
- r.SetBytes(sig[:len(sig)/2])
- s := big.NewInt(0)
- s.SetBytes(sig[len(sig)/2:])
+ r := new(big.Int).SetBytes(sig[:len(sig)/2])
+ s := new(big.Int).SetBytes(sig[len(sig)/2:])
if pk != nil {
if dsa.Verify(pk, hashed, r, s) {
return nil
@@ -198,10 +196,8 @@ func (rr *SIG) Verify(k *KEY, buf []byte) error {
}
case ECDSAP256SHA256, ECDSAP384SHA384:
pk := k.publicKeyECDSA()
- r := big.NewInt(0)
- r.SetBytes(sig[:len(sig)/2])
- s := big.NewInt(0)
- s.SetBytes(sig[len(sig)/2:])
+ r := new(big.Int).SetBytes(sig[:len(sig)/2])
+ s := new(big.Int).SetBytes(sig[len(sig)/2:])
if pk != nil {
if ecdsa.Verify(pk, hashed, r, s) {
return nil
diff --git a/vendor/github.com/miekg/dns/tsig.go b/vendor/github.com/miekg/dns/tsig.go
index afa462fa07..2c4ef03bac 100644
--- a/vendor/github.com/miekg/dns/tsig.go
+++ b/vendor/github.com/miekg/dns/tsig.go
@@ -54,7 +54,7 @@ func (rr *TSIG) String() string {
return s
}
-func (rr *TSIG) parse(c *zlexer, origin, file string) *ParseError {
+func (rr *TSIG) parse(c *zlexer, origin string) *ParseError {
panic("dns: internal error: parse should never be called on TSIG")
}
diff --git a/vendor/github.com/miekg/dns/types.go b/vendor/github.com/miekg/dns/types.go
index efa342443b..95fce25df7 100644
--- a/vendor/github.com/miekg/dns/types.go
+++ b/vendor/github.com/miekg/dns/types.go
@@ -238,7 +238,7 @@ type ANY struct {
func (rr *ANY) String() string { return rr.Hdr.String() }
-func (rr *ANY) parse(c *zlexer, origin, file string) *ParseError {
+func (rr *ANY) parse(c *zlexer, origin string) *ParseError {
panic("dns: internal error: parse should never be called on ANY")
}
@@ -253,7 +253,7 @@ func (rr *NULL) String() string {
return ";" + rr.Hdr.String() + rr.Data
}
-func (rr *NULL) parse(c *zlexer, origin, file string) *ParseError {
+func (rr *NULL) parse(c *zlexer, origin string) *ParseError {
panic("dns: internal error: parse should never be called on NULL")
}
@@ -404,7 +404,7 @@ type RP struct {
}
func (rr *RP) String() string {
- return rr.Hdr.String() + rr.Mbox + " " + sprintTxt([]string{rr.Txt})
+ return rr.Hdr.String() + sprintName(rr.Mbox) + " " + sprintName(rr.Txt)
}
// SOA RR. See RFC 1035.
@@ -438,25 +438,54 @@ func (rr *TXT) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) }
func sprintName(s string) string {
var dst strings.Builder
- dst.Grow(len(s))
+
for i := 0; i < len(s); {
if i+1 < len(s) && s[i] == '\\' && s[i+1] == '.' {
- dst.WriteString(s[i : i+2])
+ if dst.Len() != 0 {
+ dst.WriteString(s[i : i+2])
+ }
i += 2
continue
}
b, n := nextByte(s, i)
- switch {
- case n == 0:
- i++ // dangling back slash
- case b == '.':
- dst.WriteByte('.')
+ if n == 0 {
+ i++
+ continue
+ }
+ if b == '.' {
+ if dst.Len() != 0 {
+ dst.WriteByte('.')
+ }
+ i += n
+ continue
+ }
+ switch b {
+ case ' ', '\'', '@', ';', '(', ')', '"', '\\': // additional chars to escape
+ if dst.Len() == 0 {
+ dst.Grow(len(s) * 2)
+ dst.WriteString(s[:i])
+ }
+ dst.WriteByte('\\')
+ dst.WriteByte(b)
default:
- writeDomainNameByte(&dst, b)
+ if ' ' <= b && b <= '~' {
+ if dst.Len() != 0 {
+ dst.WriteByte(b)
+ }
+ } else {
+ if dst.Len() == 0 {
+ dst.Grow(len(s) * 2)
+ dst.WriteString(s[:i])
+ }
+ dst.WriteString(escapeByte(b))
+ }
}
i += n
}
+ if dst.Len() == 0 {
+ return s
+ }
return dst.String()
}
@@ -510,16 +539,6 @@ func sprintTxt(txt []string) string {
return out.String()
}
-func writeDomainNameByte(s *strings.Builder, b byte) {
- switch b {
- case '.', ' ', '\'', '@', ';', '(', ')': // additional chars to escape
- s.WriteByte('\\')
- s.WriteByte(b)
- default:
- writeTXTStringByte(s, b)
- }
-}
-
func writeTXTStringByte(s *strings.Builder, b byte) {
switch {
case b == '"' || b == '\\':
@@ -845,8 +864,8 @@ type NSEC struct {
func (rr *NSEC) String() string {
s := rr.Hdr.String() + sprintName(rr.NextDomain)
- for i := 0; i < len(rr.TypeBitMap); i++ {
- s += " " + Type(rr.TypeBitMap[i]).String()
+ for _, t := range rr.TypeBitMap {
+ s += " " + Type(t).String()
}
return s
}
@@ -854,14 +873,7 @@ func (rr *NSEC) String() string {
func (rr *NSEC) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.NextDomain, off+l, compression, false)
- lastwindow := uint32(2 ^ 32 + 1)
- for _, t := range rr.TypeBitMap {
- window := t / 256
- if uint32(window) != lastwindow {
- l += 1 + 32
- }
- lastwindow = uint32(window)
- }
+ l += typeBitMapLen(rr.TypeBitMap)
return l
}
@@ -1011,8 +1023,8 @@ func (rr *NSEC3) String() string {
" " + strconv.Itoa(int(rr.Iterations)) +
" " + saltToString(rr.Salt) +
" " + rr.NextDomain
- for i := 0; i < len(rr.TypeBitMap); i++ {
- s += " " + Type(rr.TypeBitMap[i]).String()
+ for _, t := range rr.TypeBitMap {
+ s += " " + Type(t).String()
}
return s
}
@@ -1020,14 +1032,7 @@ func (rr *NSEC3) String() string {
func (rr *NSEC3) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 6 + len(rr.Salt)/2 + 1 + len(rr.NextDomain) + 1
- lastwindow := uint32(2 ^ 32 + 1)
- for _, t := range rr.TypeBitMap {
- window := t / 256
- if uint32(window) != lastwindow {
- l += 1 + 32
- }
- lastwindow = uint32(window)
- }
+ l += typeBitMapLen(rr.TypeBitMap)
return l
}
@@ -1335,8 +1340,8 @@ type CSYNC struct {
func (rr *CSYNC) String() string {
s := rr.Hdr.String() + strconv.FormatInt(int64(rr.Serial), 10) + " " + strconv.Itoa(int(rr.Flags))
- for i := 0; i < len(rr.TypeBitMap); i++ {
- s += " " + Type(rr.TypeBitMap[i]).String()
+ for _, t := range rr.TypeBitMap {
+ s += " " + Type(t).String()
}
return s
}
@@ -1344,14 +1349,7 @@ func (rr *CSYNC) String() string {
func (rr *CSYNC) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 4 + 2
- lastwindow := uint32(2 ^ 32 + 1)
- for _, t := range rr.TypeBitMap {
- window := t / 256
- if uint32(window) != lastwindow {
- l += 1 + 32
- }
- lastwindow = uint32(window)
- }
+ l += typeBitMapLen(rr.TypeBitMap)
return l
}
diff --git a/vendor/github.com/miekg/dns/version.go b/vendor/github.com/miekg/dns/version.go
index 46d644c58c..74e0a564ad 100644
--- a/vendor/github.com/miekg/dns/version.go
+++ b/vendor/github.com/miekg/dns/version.go
@@ -3,7 +3,7 @@ package dns
import "fmt"
// Version is current version of this library.
-var Version = V{1, 1, 4}
+var Version = V{1, 1, 25}
// V holds the version of this library.
type V struct {
diff --git a/vendor/github.com/miekg/dns/xfr.go b/vendor/github.com/miekg/dns/xfr.go
index 82afc52ea8..bb4ca3d879 100644
--- a/vendor/github.com/miekg/dns/xfr.go
+++ b/vendor/github.com/miekg/dns/xfr.go
@@ -198,11 +198,14 @@ func (t *Transfer) Out(w ResponseWriter, q *Msg, ch chan *Envelope) error {
r.Authoritative = true
// assume it fits TODO(miek): fix
r.Answer = append(r.Answer, x.RR...)
+ if tsig := q.IsTsig(); tsig != nil && w.TsigStatus() == nil {
+ r.SetTsig(tsig.Hdr.Name, tsig.Algorithm, tsig.Fudge, time.Now().Unix())
+ }
if err := w.WriteMsg(r); err != nil {
return err
}
+ w.TsigTimersOnly(true)
}
- w.TsigTimersOnly(true)
return nil
}
diff --git a/vendor/github.com/miekg/dns/zduplicate.go b/vendor/github.com/miekg/dns/zduplicate.go
index 81e99e0d4c..74389162fa 100644
--- a/vendor/github.com/miekg/dns/zduplicate.go
+++ b/vendor/github.com/miekg/dns/zduplicate.go
@@ -37,7 +37,7 @@ func (r1 *AFSDB) isDuplicate(_r2 RR) bool {
if r1.Subtype != r2.Subtype {
return false
}
- if !isDulicateName(r1.Hostname, r2.Hostname) {
+ if !isDuplicateName(r1.Hostname, r2.Hostname) {
return false
}
return true
@@ -114,7 +114,7 @@ func (r1 *CNAME) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Target, r2.Target) {
+ if !isDuplicateName(r1.Target, r2.Target) {
return false
}
return true
@@ -161,7 +161,7 @@ func (r1 *DNAME) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Target, r2.Target) {
+ if !isDuplicateName(r1.Target, r2.Target) {
return false
}
return true
@@ -315,7 +315,7 @@ func (r1 *HIP) isDuplicate(_r2 RR) bool {
return false
}
for i := 0; i < len(r1.RendezvousServers); i++ {
- if !isDulicateName(r1.RendezvousServers[i], r2.RendezvousServers[i]) {
+ if !isDuplicateName(r1.RendezvousServers[i], r2.RendezvousServers[i]) {
return false
}
}
@@ -331,7 +331,7 @@ func (r1 *KX) isDuplicate(_r2 RR) bool {
if r1.Preference != r2.Preference {
return false
}
- if !isDulicateName(r1.Exchanger, r2.Exchanger) {
+ if !isDuplicateName(r1.Exchanger, r2.Exchanger) {
return false
}
return true
@@ -406,7 +406,7 @@ func (r1 *LP) isDuplicate(_r2 RR) bool {
if r1.Preference != r2.Preference {
return false
}
- if !isDulicateName(r1.Fqdn, r2.Fqdn) {
+ if !isDuplicateName(r1.Fqdn, r2.Fqdn) {
return false
}
return true
@@ -418,7 +418,7 @@ func (r1 *MB) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Mb, r2.Mb) {
+ if !isDuplicateName(r1.Mb, r2.Mb) {
return false
}
return true
@@ -430,7 +430,7 @@ func (r1 *MD) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Md, r2.Md) {
+ if !isDuplicateName(r1.Md, r2.Md) {
return false
}
return true
@@ -442,7 +442,7 @@ func (r1 *MF) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Mf, r2.Mf) {
+ if !isDuplicateName(r1.Mf, r2.Mf) {
return false
}
return true
@@ -454,7 +454,7 @@ func (r1 *MG) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Mg, r2.Mg) {
+ if !isDuplicateName(r1.Mg, r2.Mg) {
return false
}
return true
@@ -466,10 +466,10 @@ func (r1 *MINFO) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Rmail, r2.Rmail) {
+ if !isDuplicateName(r1.Rmail, r2.Rmail) {
return false
}
- if !isDulicateName(r1.Email, r2.Email) {
+ if !isDuplicateName(r1.Email, r2.Email) {
return false
}
return true
@@ -481,7 +481,7 @@ func (r1 *MR) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Mr, r2.Mr) {
+ if !isDuplicateName(r1.Mr, r2.Mr) {
return false
}
return true
@@ -496,7 +496,7 @@ func (r1 *MX) isDuplicate(_r2 RR) bool {
if r1.Preference != r2.Preference {
return false
}
- if !isDulicateName(r1.Mx, r2.Mx) {
+ if !isDuplicateName(r1.Mx, r2.Mx) {
return false
}
return true
@@ -523,7 +523,7 @@ func (r1 *NAPTR) isDuplicate(_r2 RR) bool {
if r1.Regexp != r2.Regexp {
return false
}
- if !isDulicateName(r1.Replacement, r2.Replacement) {
+ if !isDuplicateName(r1.Replacement, r2.Replacement) {
return false
}
return true
@@ -579,7 +579,7 @@ func (r1 *NS) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Ns, r2.Ns) {
+ if !isDuplicateName(r1.Ns, r2.Ns) {
return false
}
return true
@@ -591,7 +591,7 @@ func (r1 *NSAPPTR) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Ptr, r2.Ptr) {
+ if !isDuplicateName(r1.Ptr, r2.Ptr) {
return false
}
return true
@@ -603,7 +603,7 @@ func (r1 *NSEC) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.NextDomain, r2.NextDomain) {
+ if !isDuplicateName(r1.NextDomain, r2.NextDomain) {
return false
}
if len(r1.TypeBitMap) != len(r2.TypeBitMap) {
@@ -709,7 +709,7 @@ func (r1 *PTR) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Ptr, r2.Ptr) {
+ if !isDuplicateName(r1.Ptr, r2.Ptr) {
return false
}
return true
@@ -724,10 +724,10 @@ func (r1 *PX) isDuplicate(_r2 RR) bool {
if r1.Preference != r2.Preference {
return false
}
- if !isDulicateName(r1.Map822, r2.Map822) {
+ if !isDuplicateName(r1.Map822, r2.Map822) {
return false
}
- if !isDulicateName(r1.Mapx400, r2.Mapx400) {
+ if !isDuplicateName(r1.Mapx400, r2.Mapx400) {
return false
}
return true
@@ -772,10 +772,10 @@ func (r1 *RP) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Mbox, r2.Mbox) {
+ if !isDuplicateName(r1.Mbox, r2.Mbox) {
return false
}
- if !isDulicateName(r1.Txt, r2.Txt) {
+ if !isDuplicateName(r1.Txt, r2.Txt) {
return false
}
return true
@@ -808,7 +808,7 @@ func (r1 *RRSIG) isDuplicate(_r2 RR) bool {
if r1.KeyTag != r2.KeyTag {
return false
}
- if !isDulicateName(r1.SignerName, r2.SignerName) {
+ if !isDuplicateName(r1.SignerName, r2.SignerName) {
return false
}
if r1.Signature != r2.Signature {
@@ -826,7 +826,7 @@ func (r1 *RT) isDuplicate(_r2 RR) bool {
if r1.Preference != r2.Preference {
return false
}
- if !isDulicateName(r1.Host, r2.Host) {
+ if !isDuplicateName(r1.Host, r2.Host) {
return false
}
return true
@@ -859,10 +859,10 @@ func (r1 *SOA) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Ns, r2.Ns) {
+ if !isDuplicateName(r1.Ns, r2.Ns) {
return false
}
- if !isDulicateName(r1.Mbox, r2.Mbox) {
+ if !isDuplicateName(r1.Mbox, r2.Mbox) {
return false
}
if r1.Serial != r2.Serial {
@@ -915,7 +915,7 @@ func (r1 *SRV) isDuplicate(_r2 RR) bool {
if r1.Port != r2.Port {
return false
}
- if !isDulicateName(r1.Target, r2.Target) {
+ if !isDuplicateName(r1.Target, r2.Target) {
return false
}
return true
@@ -966,10 +966,10 @@ func (r1 *TALINK) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.PreviousName, r2.PreviousName) {
+ if !isDuplicateName(r1.PreviousName, r2.PreviousName) {
return false
}
- if !isDulicateName(r1.NextName, r2.NextName) {
+ if !isDuplicateName(r1.NextName, r2.NextName) {
return false
}
return true
@@ -981,7 +981,7 @@ func (r1 *TKEY) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Algorithm, r2.Algorithm) {
+ if !isDuplicateName(r1.Algorithm, r2.Algorithm) {
return false
}
if r1.Inception != r2.Inception {
@@ -1038,7 +1038,7 @@ func (r1 *TSIG) isDuplicate(_r2 RR) bool {
return false
}
_ = r2
- if !isDulicateName(r1.Algorithm, r2.Algorithm) {
+ if !isDuplicateName(r1.Algorithm, r2.Algorithm) {
return false
}
if r1.TimeSigned != r2.TimeSigned {
diff --git a/vendor/github.com/miekg/dns/ztypes.go b/vendor/github.com/miekg/dns/ztypes.go
index 19a542d33c..f7ec8352fb 100644
--- a/vendor/github.com/miekg/dns/ztypes.go
+++ b/vendor/github.com/miekg/dns/ztypes.go
@@ -240,12 +240,16 @@ func (rr *X25) Header() *RR_Header { return &rr.Hdr }
// len() functions
func (rr *A) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
- l += net.IPv4len // A
+ if len(rr.A) != 0 {
+ l += net.IPv4len
+ }
return l
}
func (rr *AAAA) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
- l += net.IPv6len // AAAA
+ if len(rr.AAAA) != 0 {
+ l += net.IPv6len
+ }
return l
}
func (rr *AFSDB) len(off int, compression map[string]struct{}) int {
@@ -308,12 +312,12 @@ func (rr *DS) len(off int, compression map[string]struct{}) int {
l += 2 // KeyTag
l++ // Algorithm
l++ // DigestType
- l += len(rr.Digest)/2 + 1
+ l += len(rr.Digest) / 2
return l
}
func (rr *EID) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
- l += len(rr.Endpoint)/2 + 1
+ l += len(rr.Endpoint) / 2
return l
}
func (rr *EUI48) len(off int, compression map[string]struct{}) int {
@@ -364,8 +368,10 @@ func (rr *KX) len(off int, compression map[string]struct{}) int {
}
func (rr *L32) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
- l += 2 // Preference
- l += net.IPv4len // Locator32
+ l += 2 // Preference
+ if len(rr.Locator32) != 0 {
+ l += net.IPv4len
+ }
return l
}
func (rr *L64) len(off int, compression map[string]struct{}) int {
@@ -446,7 +452,7 @@ func (rr *NID) len(off int, compression map[string]struct{}) int {
}
func (rr *NIMLOC) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
- l += len(rr.Locator)/2 + 1
+ l += len(rr.Locator) / 2
return l
}
func (rr *NINFO) len(off int, compression map[string]struct{}) int {
@@ -499,7 +505,7 @@ func (rr *PX) len(off int, compression map[string]struct{}) int {
}
func (rr *RFC3597) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
- l += len(rr.Rdata)/2 + 1
+ l += len(rr.Rdata) / 2
return l
}
func (rr *RKEY) len(off int, compression map[string]struct{}) int {
@@ -540,7 +546,7 @@ func (rr *SMIMEA) len(off int, compression map[string]struct{}) int {
l++ // Usage
l++ // Selector
l++ // MatchingType
- l += len(rr.Certificate)/2 + 1
+ l += len(rr.Certificate) / 2
return l
}
func (rr *SOA) len(off int, compression map[string]struct{}) int {
@@ -573,7 +579,7 @@ func (rr *SSHFP) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Algorithm
l++ // Type
- l += len(rr.FingerPrint)/2 + 1
+ l += len(rr.FingerPrint) / 2
return l
}
func (rr *TA) len(off int, compression map[string]struct{}) int {
@@ -581,7 +587,7 @@ func (rr *TA) len(off int, compression map[string]struct{}) int {
l += 2 // KeyTag
l++ // Algorithm
l++ // DigestType
- l += len(rr.Digest)/2 + 1
+ l += len(rr.Digest) / 2
return l
}
func (rr *TALINK) len(off int, compression map[string]struct{}) int {
@@ -608,7 +614,7 @@ func (rr *TLSA) len(off int, compression map[string]struct{}) int {
l++ // Usage
l++ // Selector
l++ // MatchingType
- l += len(rr.Certificate)/2 + 1
+ l += len(rr.Certificate) / 2
return l
}
func (rr *TSIG) len(off int, compression map[string]struct{}) int {
diff --git a/vendor/golang.org/x/crypto/sha3/doc.go b/vendor/golang.org/x/crypto/sha3/doc.go
new file mode 100644
index 0000000000..c2fef30aff
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/doc.go
@@ -0,0 +1,66 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package sha3 implements the SHA-3 fixed-output-length hash functions and
+// the SHAKE variable-output-length hash functions defined by FIPS-202.
+//
+// Both types of hash function use the "sponge" construction and the Keccak
+// permutation. For a detailed specification see http://keccak.noekeon.org/
+//
+//
+// Guidance
+//
+// If you aren't sure what function you need, use SHAKE256 with at least 64
+// bytes of output. The SHAKE instances are faster than the SHA3 instances;
+// the latter have to allocate memory to conform to the hash.Hash interface.
+//
+// If you need a secret-key MAC (message authentication code), prepend the
+// secret key to the input, hash with SHAKE256 and read at least 32 bytes of
+// output.
+//
+//
+// Security strengths
+//
+// The SHA3-x (x equals 224, 256, 384, or 512) functions have a security
+// strength against preimage attacks of x bits. Since they only produce "x"
+// bits of output, their collision-resistance is only "x/2" bits.
+//
+// The SHAKE-256 and -128 functions have a generic security strength of 256 and
+// 128 bits against all attacks, provided that at least 2x bits of their output
+// is used. Requesting more than 64 or 32 bytes of output, respectively, does
+// not increase the collision-resistance of the SHAKE functions.
+//
+//
+// The sponge construction
+//
+// A sponge builds a pseudo-random function from a public pseudo-random
+// permutation, by applying the permutation to a state of "rate + capacity"
+// bytes, but hiding "capacity" of the bytes.
+//
+// A sponge starts out with a zero state. To hash an input using a sponge, up
+// to "rate" bytes of the input are XORed into the sponge's state. The sponge
+// is then "full" and the permutation is applied to "empty" it. This process is
+// repeated until all the input has been "absorbed". The input is then padded.
+// The digest is "squeezed" from the sponge in the same way, except that output
+// is copied out instead of input being XORed in.
+//
+// A sponge is parameterized by its generic security strength, which is equal
+// to half its capacity; capacity + rate is equal to the permutation's width.
+// Since the KeccakF-1600 permutation is 1600 bits (200 bytes) wide, this means
+// that the security strength of a sponge instance is equal to (1600 - bitrate) / 2.
+//
+//
+// Recommendations
+//
+// The SHAKE functions are recommended for most new uses. They can produce
+// output of arbitrary length. SHAKE256, with an output length of at least
+// 64 bytes, provides 256-bit security against all attacks. The Keccak team
+// recommends it for most applications upgrading from SHA2-512. (NIST chose a
+// much stronger, but much slower, sponge instance for SHA3-512.)
+//
+// The SHA-3 functions are "drop-in" replacements for the SHA-2 functions.
+// They produce output of the same length, with the same security strengths
+// against all attacks. This means, in particular, that SHA3-256 only has
+// 128-bit collision resistance, because its output length is 32 bytes.
+package sha3 // import "golang.org/x/crypto/sha3"
diff --git a/vendor/golang.org/x/crypto/sha3/hashes.go b/vendor/golang.org/x/crypto/sha3/hashes.go
new file mode 100644
index 0000000000..0d8043fd2a
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/hashes.go
@@ -0,0 +1,97 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package sha3
+
+// This file provides functions for creating instances of the SHA-3
+// and SHAKE hash functions, as well as utility functions for hashing
+// bytes.
+
+import (
+ "hash"
+)
+
+// New224 creates a new SHA3-224 hash.
+// Its generic security strength is 224 bits against preimage attacks,
+// and 112 bits against collision attacks.
+func New224() hash.Hash {
+ if h := new224Asm(); h != nil {
+ return h
+ }
+ return &state{rate: 144, outputLen: 28, dsbyte: 0x06}
+}
+
+// New256 creates a new SHA3-256 hash.
+// Its generic security strength is 256 bits against preimage attacks,
+// and 128 bits against collision attacks.
+func New256() hash.Hash {
+ if h := new256Asm(); h != nil {
+ return h
+ }
+ return &state{rate: 136, outputLen: 32, dsbyte: 0x06}
+}
+
+// New384 creates a new SHA3-384 hash.
+// Its generic security strength is 384 bits against preimage attacks,
+// and 192 bits against collision attacks.
+func New384() hash.Hash {
+ if h := new384Asm(); h != nil {
+ return h
+ }
+ return &state{rate: 104, outputLen: 48, dsbyte: 0x06}
+}
+
+// New512 creates a new SHA3-512 hash.
+// Its generic security strength is 512 bits against preimage attacks,
+// and 256 bits against collision attacks.
+func New512() hash.Hash {
+ if h := new512Asm(); h != nil {
+ return h
+ }
+ return &state{rate: 72, outputLen: 64, dsbyte: 0x06}
+}
+
+// NewLegacyKeccak256 creates a new Keccak-256 hash.
+//
+// Only use this function if you require compatibility with an existing cryptosystem
+// that uses non-standard padding. All other users should use New256 instead.
+func NewLegacyKeccak256() hash.Hash { return &state{rate: 136, outputLen: 32, dsbyte: 0x01} }
+
+// NewLegacyKeccak512 creates a new Keccak-512 hash.
+//
+// Only use this function if you require compatibility with an existing cryptosystem
+// that uses non-standard padding. All other users should use New512 instead.
+func NewLegacyKeccak512() hash.Hash { return &state{rate: 72, outputLen: 64, dsbyte: 0x01} }
+
+// Sum224 returns the SHA3-224 digest of the data.
+func Sum224(data []byte) (digest [28]byte) {
+ h := New224()
+ h.Write(data)
+ h.Sum(digest[:0])
+ return
+}
+
+// Sum256 returns the SHA3-256 digest of the data.
+func Sum256(data []byte) (digest [32]byte) {
+ h := New256()
+ h.Write(data)
+ h.Sum(digest[:0])
+ return
+}
+
+// Sum384 returns the SHA3-384 digest of the data.
+func Sum384(data []byte) (digest [48]byte) {
+ h := New384()
+ h.Write(data)
+ h.Sum(digest[:0])
+ return
+}
+
+// Sum512 returns the SHA3-512 digest of the data.
+func Sum512(data []byte) (digest [64]byte) {
+ h := New512()
+ h.Write(data)
+ h.Sum(digest[:0])
+ return
+}
diff --git a/vendor/golang.org/x/crypto/sha3/hashes_generic.go b/vendor/golang.org/x/crypto/sha3/hashes_generic.go
new file mode 100644
index 0000000000..f455147d21
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/hashes_generic.go
@@ -0,0 +1,27 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gccgo appengine !s390x
+
+package sha3
+
+import (
+ "hash"
+)
+
+// new224Asm returns an assembly implementation of SHA3-224 if available,
+// otherwise it returns nil.
+func new224Asm() hash.Hash { return nil }
+
+// new256Asm returns an assembly implementation of SHA3-256 if available,
+// otherwise it returns nil.
+func new256Asm() hash.Hash { return nil }
+
+// new384Asm returns an assembly implementation of SHA3-384 if available,
+// otherwise it returns nil.
+func new384Asm() hash.Hash { return nil }
+
+// new512Asm returns an assembly implementation of SHA3-512 if available,
+// otherwise it returns nil.
+func new512Asm() hash.Hash { return nil }
diff --git a/vendor/golang.org/x/crypto/sha3/keccakf.go b/vendor/golang.org/x/crypto/sha3/keccakf.go
new file mode 100644
index 0000000000..46d03ed385
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/keccakf.go
@@ -0,0 +1,412 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !amd64 appengine gccgo
+
+package sha3
+
+// rc stores the round constants for use in the ι step.
+var rc = [24]uint64{
+ 0x0000000000000001,
+ 0x0000000000008082,
+ 0x800000000000808A,
+ 0x8000000080008000,
+ 0x000000000000808B,
+ 0x0000000080000001,
+ 0x8000000080008081,
+ 0x8000000000008009,
+ 0x000000000000008A,
+ 0x0000000000000088,
+ 0x0000000080008009,
+ 0x000000008000000A,
+ 0x000000008000808B,
+ 0x800000000000008B,
+ 0x8000000000008089,
+ 0x8000000000008003,
+ 0x8000000000008002,
+ 0x8000000000000080,
+ 0x000000000000800A,
+ 0x800000008000000A,
+ 0x8000000080008081,
+ 0x8000000000008080,
+ 0x0000000080000001,
+ 0x8000000080008008,
+}
+
+// keccakF1600 applies the Keccak permutation to a 1600b-wide
+// state represented as a slice of 25 uint64s.
+func keccakF1600(a *[25]uint64) {
+ // Implementation translated from Keccak-inplace.c
+ // in the keccak reference code.
+ var t, bc0, bc1, bc2, bc3, bc4, d0, d1, d2, d3, d4 uint64
+
+ for i := 0; i < 24; i += 4 {
+ // Combines the 5 steps in each round into 2 steps.
+ // Unrolls 4 rounds per loop and spreads some steps across rounds.
+
+ // Round 1
+ bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
+ bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
+ bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
+ bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
+ bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
+ d0 = bc4 ^ (bc1<<1 | bc1>>63)
+ d1 = bc0 ^ (bc2<<1 | bc2>>63)
+ d2 = bc1 ^ (bc3<<1 | bc3>>63)
+ d3 = bc2 ^ (bc4<<1 | bc4>>63)
+ d4 = bc3 ^ (bc0<<1 | bc0>>63)
+
+ bc0 = a[0] ^ d0
+ t = a[6] ^ d1
+ bc1 = t<<44 | t>>(64-44)
+ t = a[12] ^ d2
+ bc2 = t<<43 | t>>(64-43)
+ t = a[18] ^ d3
+ bc3 = t<<21 | t>>(64-21)
+ t = a[24] ^ d4
+ bc4 = t<<14 | t>>(64-14)
+ a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i]
+ a[6] = bc1 ^ (bc3 &^ bc2)
+ a[12] = bc2 ^ (bc4 &^ bc3)
+ a[18] = bc3 ^ (bc0 &^ bc4)
+ a[24] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[10] ^ d0
+ bc2 = t<<3 | t>>(64-3)
+ t = a[16] ^ d1
+ bc3 = t<<45 | t>>(64-45)
+ t = a[22] ^ d2
+ bc4 = t<<61 | t>>(64-61)
+ t = a[3] ^ d3
+ bc0 = t<<28 | t>>(64-28)
+ t = a[9] ^ d4
+ bc1 = t<<20 | t>>(64-20)
+ a[10] = bc0 ^ (bc2 &^ bc1)
+ a[16] = bc1 ^ (bc3 &^ bc2)
+ a[22] = bc2 ^ (bc4 &^ bc3)
+ a[3] = bc3 ^ (bc0 &^ bc4)
+ a[9] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[20] ^ d0
+ bc4 = t<<18 | t>>(64-18)
+ t = a[1] ^ d1
+ bc0 = t<<1 | t>>(64-1)
+ t = a[7] ^ d2
+ bc1 = t<<6 | t>>(64-6)
+ t = a[13] ^ d3
+ bc2 = t<<25 | t>>(64-25)
+ t = a[19] ^ d4
+ bc3 = t<<8 | t>>(64-8)
+ a[20] = bc0 ^ (bc2 &^ bc1)
+ a[1] = bc1 ^ (bc3 &^ bc2)
+ a[7] = bc2 ^ (bc4 &^ bc3)
+ a[13] = bc3 ^ (bc0 &^ bc4)
+ a[19] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[5] ^ d0
+ bc1 = t<<36 | t>>(64-36)
+ t = a[11] ^ d1
+ bc2 = t<<10 | t>>(64-10)
+ t = a[17] ^ d2
+ bc3 = t<<15 | t>>(64-15)
+ t = a[23] ^ d3
+ bc4 = t<<56 | t>>(64-56)
+ t = a[4] ^ d4
+ bc0 = t<<27 | t>>(64-27)
+ a[5] = bc0 ^ (bc2 &^ bc1)
+ a[11] = bc1 ^ (bc3 &^ bc2)
+ a[17] = bc2 ^ (bc4 &^ bc3)
+ a[23] = bc3 ^ (bc0 &^ bc4)
+ a[4] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[15] ^ d0
+ bc3 = t<<41 | t>>(64-41)
+ t = a[21] ^ d1
+ bc4 = t<<2 | t>>(64-2)
+ t = a[2] ^ d2
+ bc0 = t<<62 | t>>(64-62)
+ t = a[8] ^ d3
+ bc1 = t<<55 | t>>(64-55)
+ t = a[14] ^ d4
+ bc2 = t<<39 | t>>(64-39)
+ a[15] = bc0 ^ (bc2 &^ bc1)
+ a[21] = bc1 ^ (bc3 &^ bc2)
+ a[2] = bc2 ^ (bc4 &^ bc3)
+ a[8] = bc3 ^ (bc0 &^ bc4)
+ a[14] = bc4 ^ (bc1 &^ bc0)
+
+ // Round 2
+ bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
+ bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
+ bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
+ bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
+ bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
+ d0 = bc4 ^ (bc1<<1 | bc1>>63)
+ d1 = bc0 ^ (bc2<<1 | bc2>>63)
+ d2 = bc1 ^ (bc3<<1 | bc3>>63)
+ d3 = bc2 ^ (bc4<<1 | bc4>>63)
+ d4 = bc3 ^ (bc0<<1 | bc0>>63)
+
+ bc0 = a[0] ^ d0
+ t = a[16] ^ d1
+ bc1 = t<<44 | t>>(64-44)
+ t = a[7] ^ d2
+ bc2 = t<<43 | t>>(64-43)
+ t = a[23] ^ d3
+ bc3 = t<<21 | t>>(64-21)
+ t = a[14] ^ d4
+ bc4 = t<<14 | t>>(64-14)
+ a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+1]
+ a[16] = bc1 ^ (bc3 &^ bc2)
+ a[7] = bc2 ^ (bc4 &^ bc3)
+ a[23] = bc3 ^ (bc0 &^ bc4)
+ a[14] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[20] ^ d0
+ bc2 = t<<3 | t>>(64-3)
+ t = a[11] ^ d1
+ bc3 = t<<45 | t>>(64-45)
+ t = a[2] ^ d2
+ bc4 = t<<61 | t>>(64-61)
+ t = a[18] ^ d3
+ bc0 = t<<28 | t>>(64-28)
+ t = a[9] ^ d4
+ bc1 = t<<20 | t>>(64-20)
+ a[20] = bc0 ^ (bc2 &^ bc1)
+ a[11] = bc1 ^ (bc3 &^ bc2)
+ a[2] = bc2 ^ (bc4 &^ bc3)
+ a[18] = bc3 ^ (bc0 &^ bc4)
+ a[9] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[15] ^ d0
+ bc4 = t<<18 | t>>(64-18)
+ t = a[6] ^ d1
+ bc0 = t<<1 | t>>(64-1)
+ t = a[22] ^ d2
+ bc1 = t<<6 | t>>(64-6)
+ t = a[13] ^ d3
+ bc2 = t<<25 | t>>(64-25)
+ t = a[4] ^ d4
+ bc3 = t<<8 | t>>(64-8)
+ a[15] = bc0 ^ (bc2 &^ bc1)
+ a[6] = bc1 ^ (bc3 &^ bc2)
+ a[22] = bc2 ^ (bc4 &^ bc3)
+ a[13] = bc3 ^ (bc0 &^ bc4)
+ a[4] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[10] ^ d0
+ bc1 = t<<36 | t>>(64-36)
+ t = a[1] ^ d1
+ bc2 = t<<10 | t>>(64-10)
+ t = a[17] ^ d2
+ bc3 = t<<15 | t>>(64-15)
+ t = a[8] ^ d3
+ bc4 = t<<56 | t>>(64-56)
+ t = a[24] ^ d4
+ bc0 = t<<27 | t>>(64-27)
+ a[10] = bc0 ^ (bc2 &^ bc1)
+ a[1] = bc1 ^ (bc3 &^ bc2)
+ a[17] = bc2 ^ (bc4 &^ bc3)
+ a[8] = bc3 ^ (bc0 &^ bc4)
+ a[24] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[5] ^ d0
+ bc3 = t<<41 | t>>(64-41)
+ t = a[21] ^ d1
+ bc4 = t<<2 | t>>(64-2)
+ t = a[12] ^ d2
+ bc0 = t<<62 | t>>(64-62)
+ t = a[3] ^ d3
+ bc1 = t<<55 | t>>(64-55)
+ t = a[19] ^ d4
+ bc2 = t<<39 | t>>(64-39)
+ a[5] = bc0 ^ (bc2 &^ bc1)
+ a[21] = bc1 ^ (bc3 &^ bc2)
+ a[12] = bc2 ^ (bc4 &^ bc3)
+ a[3] = bc3 ^ (bc0 &^ bc4)
+ a[19] = bc4 ^ (bc1 &^ bc0)
+
+ // Round 3
+ bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
+ bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
+ bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
+ bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
+ bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
+ d0 = bc4 ^ (bc1<<1 | bc1>>63)
+ d1 = bc0 ^ (bc2<<1 | bc2>>63)
+ d2 = bc1 ^ (bc3<<1 | bc3>>63)
+ d3 = bc2 ^ (bc4<<1 | bc4>>63)
+ d4 = bc3 ^ (bc0<<1 | bc0>>63)
+
+ bc0 = a[0] ^ d0
+ t = a[11] ^ d1
+ bc1 = t<<44 | t>>(64-44)
+ t = a[22] ^ d2
+ bc2 = t<<43 | t>>(64-43)
+ t = a[8] ^ d3
+ bc3 = t<<21 | t>>(64-21)
+ t = a[19] ^ d4
+ bc4 = t<<14 | t>>(64-14)
+ a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+2]
+ a[11] = bc1 ^ (bc3 &^ bc2)
+ a[22] = bc2 ^ (bc4 &^ bc3)
+ a[8] = bc3 ^ (bc0 &^ bc4)
+ a[19] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[15] ^ d0
+ bc2 = t<<3 | t>>(64-3)
+ t = a[1] ^ d1
+ bc3 = t<<45 | t>>(64-45)
+ t = a[12] ^ d2
+ bc4 = t<<61 | t>>(64-61)
+ t = a[23] ^ d3
+ bc0 = t<<28 | t>>(64-28)
+ t = a[9] ^ d4
+ bc1 = t<<20 | t>>(64-20)
+ a[15] = bc0 ^ (bc2 &^ bc1)
+ a[1] = bc1 ^ (bc3 &^ bc2)
+ a[12] = bc2 ^ (bc4 &^ bc3)
+ a[23] = bc3 ^ (bc0 &^ bc4)
+ a[9] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[5] ^ d0
+ bc4 = t<<18 | t>>(64-18)
+ t = a[16] ^ d1
+ bc0 = t<<1 | t>>(64-1)
+ t = a[2] ^ d2
+ bc1 = t<<6 | t>>(64-6)
+ t = a[13] ^ d3
+ bc2 = t<<25 | t>>(64-25)
+ t = a[24] ^ d4
+ bc3 = t<<8 | t>>(64-8)
+ a[5] = bc0 ^ (bc2 &^ bc1)
+ a[16] = bc1 ^ (bc3 &^ bc2)
+ a[2] = bc2 ^ (bc4 &^ bc3)
+ a[13] = bc3 ^ (bc0 &^ bc4)
+ a[24] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[20] ^ d0
+ bc1 = t<<36 | t>>(64-36)
+ t = a[6] ^ d1
+ bc2 = t<<10 | t>>(64-10)
+ t = a[17] ^ d2
+ bc3 = t<<15 | t>>(64-15)
+ t = a[3] ^ d3
+ bc4 = t<<56 | t>>(64-56)
+ t = a[14] ^ d4
+ bc0 = t<<27 | t>>(64-27)
+ a[20] = bc0 ^ (bc2 &^ bc1)
+ a[6] = bc1 ^ (bc3 &^ bc2)
+ a[17] = bc2 ^ (bc4 &^ bc3)
+ a[3] = bc3 ^ (bc0 &^ bc4)
+ a[14] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[10] ^ d0
+ bc3 = t<<41 | t>>(64-41)
+ t = a[21] ^ d1
+ bc4 = t<<2 | t>>(64-2)
+ t = a[7] ^ d2
+ bc0 = t<<62 | t>>(64-62)
+ t = a[18] ^ d3
+ bc1 = t<<55 | t>>(64-55)
+ t = a[4] ^ d4
+ bc2 = t<<39 | t>>(64-39)
+ a[10] = bc0 ^ (bc2 &^ bc1)
+ a[21] = bc1 ^ (bc3 &^ bc2)
+ a[7] = bc2 ^ (bc4 &^ bc3)
+ a[18] = bc3 ^ (bc0 &^ bc4)
+ a[4] = bc4 ^ (bc1 &^ bc0)
+
+ // Round 4
+ bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
+ bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
+ bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
+ bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
+ bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
+ d0 = bc4 ^ (bc1<<1 | bc1>>63)
+ d1 = bc0 ^ (bc2<<1 | bc2>>63)
+ d2 = bc1 ^ (bc3<<1 | bc3>>63)
+ d3 = bc2 ^ (bc4<<1 | bc4>>63)
+ d4 = bc3 ^ (bc0<<1 | bc0>>63)
+
+ bc0 = a[0] ^ d0
+ t = a[1] ^ d1
+ bc1 = t<<44 | t>>(64-44)
+ t = a[2] ^ d2
+ bc2 = t<<43 | t>>(64-43)
+ t = a[3] ^ d3
+ bc3 = t<<21 | t>>(64-21)
+ t = a[4] ^ d4
+ bc4 = t<<14 | t>>(64-14)
+ a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+3]
+ a[1] = bc1 ^ (bc3 &^ bc2)
+ a[2] = bc2 ^ (bc4 &^ bc3)
+ a[3] = bc3 ^ (bc0 &^ bc4)
+ a[4] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[5] ^ d0
+ bc2 = t<<3 | t>>(64-3)
+ t = a[6] ^ d1
+ bc3 = t<<45 | t>>(64-45)
+ t = a[7] ^ d2
+ bc4 = t<<61 | t>>(64-61)
+ t = a[8] ^ d3
+ bc0 = t<<28 | t>>(64-28)
+ t = a[9] ^ d4
+ bc1 = t<<20 | t>>(64-20)
+ a[5] = bc0 ^ (bc2 &^ bc1)
+ a[6] = bc1 ^ (bc3 &^ bc2)
+ a[7] = bc2 ^ (bc4 &^ bc3)
+ a[8] = bc3 ^ (bc0 &^ bc4)
+ a[9] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[10] ^ d0
+ bc4 = t<<18 | t>>(64-18)
+ t = a[11] ^ d1
+ bc0 = t<<1 | t>>(64-1)
+ t = a[12] ^ d2
+ bc1 = t<<6 | t>>(64-6)
+ t = a[13] ^ d3
+ bc2 = t<<25 | t>>(64-25)
+ t = a[14] ^ d4
+ bc3 = t<<8 | t>>(64-8)
+ a[10] = bc0 ^ (bc2 &^ bc1)
+ a[11] = bc1 ^ (bc3 &^ bc2)
+ a[12] = bc2 ^ (bc4 &^ bc3)
+ a[13] = bc3 ^ (bc0 &^ bc4)
+ a[14] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[15] ^ d0
+ bc1 = t<<36 | t>>(64-36)
+ t = a[16] ^ d1
+ bc2 = t<<10 | t>>(64-10)
+ t = a[17] ^ d2
+ bc3 = t<<15 | t>>(64-15)
+ t = a[18] ^ d3
+ bc4 = t<<56 | t>>(64-56)
+ t = a[19] ^ d4
+ bc0 = t<<27 | t>>(64-27)
+ a[15] = bc0 ^ (bc2 &^ bc1)
+ a[16] = bc1 ^ (bc3 &^ bc2)
+ a[17] = bc2 ^ (bc4 &^ bc3)
+ a[18] = bc3 ^ (bc0 &^ bc4)
+ a[19] = bc4 ^ (bc1 &^ bc0)
+
+ t = a[20] ^ d0
+ bc3 = t<<41 | t>>(64-41)
+ t = a[21] ^ d1
+ bc4 = t<<2 | t>>(64-2)
+ t = a[22] ^ d2
+ bc0 = t<<62 | t>>(64-62)
+ t = a[23] ^ d3
+ bc1 = t<<55 | t>>(64-55)
+ t = a[24] ^ d4
+ bc2 = t<<39 | t>>(64-39)
+ a[20] = bc0 ^ (bc2 &^ bc1)
+ a[21] = bc1 ^ (bc3 &^ bc2)
+ a[22] = bc2 ^ (bc4 &^ bc3)
+ a[23] = bc3 ^ (bc0 &^ bc4)
+ a[24] = bc4 ^ (bc1 &^ bc0)
+ }
+}
diff --git a/vendor/golang.org/x/crypto/sha3/keccakf_amd64.go b/vendor/golang.org/x/crypto/sha3/keccakf_amd64.go
new file mode 100644
index 0000000000..7886795850
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/keccakf_amd64.go
@@ -0,0 +1,13 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,!appengine,!gccgo
+
+package sha3
+
+// This function is implemented in keccakf_amd64.s.
+
+//go:noescape
+
+func keccakF1600(a *[25]uint64)
diff --git a/vendor/golang.org/x/crypto/sha3/keccakf_amd64.s b/vendor/golang.org/x/crypto/sha3/keccakf_amd64.s
new file mode 100644
index 0000000000..f88533accd
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/keccakf_amd64.s
@@ -0,0 +1,390 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,!appengine,!gccgo
+
+// This code was translated into a form compatible with 6a from the public
+// domain sources at https://github.com/gvanas/KeccakCodePackage
+
+// Offsets in state
+#define _ba (0*8)
+#define _be (1*8)
+#define _bi (2*8)
+#define _bo (3*8)
+#define _bu (4*8)
+#define _ga (5*8)
+#define _ge (6*8)
+#define _gi (7*8)
+#define _go (8*8)
+#define _gu (9*8)
+#define _ka (10*8)
+#define _ke (11*8)
+#define _ki (12*8)
+#define _ko (13*8)
+#define _ku (14*8)
+#define _ma (15*8)
+#define _me (16*8)
+#define _mi (17*8)
+#define _mo (18*8)
+#define _mu (19*8)
+#define _sa (20*8)
+#define _se (21*8)
+#define _si (22*8)
+#define _so (23*8)
+#define _su (24*8)
+
+// Temporary registers
+#define rT1 AX
+
+// Round vars
+#define rpState DI
+#define rpStack SP
+
+#define rDa BX
+#define rDe CX
+#define rDi DX
+#define rDo R8
+#define rDu R9
+
+#define rBa R10
+#define rBe R11
+#define rBi R12
+#define rBo R13
+#define rBu R14
+
+#define rCa SI
+#define rCe BP
+#define rCi rBi
+#define rCo rBo
+#define rCu R15
+
+#define MOVQ_RBI_RCE MOVQ rBi, rCe
+#define XORQ_RT1_RCA XORQ rT1, rCa
+#define XORQ_RT1_RCE XORQ rT1, rCe
+#define XORQ_RBA_RCU XORQ rBa, rCu
+#define XORQ_RBE_RCU XORQ rBe, rCu
+#define XORQ_RDU_RCU XORQ rDu, rCu
+#define XORQ_RDA_RCA XORQ rDa, rCa
+#define XORQ_RDE_RCE XORQ rDe, rCe
+
+#define mKeccakRound(iState, oState, rc, B_RBI_RCE, G_RT1_RCA, G_RT1_RCE, G_RBA_RCU, K_RT1_RCA, K_RT1_RCE, K_RBA_RCU, M_RT1_RCA, M_RT1_RCE, M_RBE_RCU, S_RDU_RCU, S_RDA_RCA, S_RDE_RCE) \
+ /* Prepare round */ \
+ MOVQ rCe, rDa; \
+ ROLQ $1, rDa; \
+ \
+ MOVQ _bi(iState), rCi; \
+ XORQ _gi(iState), rDi; \
+ XORQ rCu, rDa; \
+ XORQ _ki(iState), rCi; \
+ XORQ _mi(iState), rDi; \
+ XORQ rDi, rCi; \
+ \
+ MOVQ rCi, rDe; \
+ ROLQ $1, rDe; \
+ \
+ MOVQ _bo(iState), rCo; \
+ XORQ _go(iState), rDo; \
+ XORQ rCa, rDe; \
+ XORQ _ko(iState), rCo; \
+ XORQ _mo(iState), rDo; \
+ XORQ rDo, rCo; \
+ \
+ MOVQ rCo, rDi; \
+ ROLQ $1, rDi; \
+ \
+ MOVQ rCu, rDo; \
+ XORQ rCe, rDi; \
+ ROLQ $1, rDo; \
+ \
+ MOVQ rCa, rDu; \
+ XORQ rCi, rDo; \
+ ROLQ $1, rDu; \
+ \
+ /* Result b */ \
+ MOVQ _ba(iState), rBa; \
+ MOVQ _ge(iState), rBe; \
+ XORQ rCo, rDu; \
+ MOVQ _ki(iState), rBi; \
+ MOVQ _mo(iState), rBo; \
+ MOVQ _su(iState), rBu; \
+ XORQ rDe, rBe; \
+ ROLQ $44, rBe; \
+ XORQ rDi, rBi; \
+ XORQ rDa, rBa; \
+ ROLQ $43, rBi; \
+ \
+ MOVQ rBe, rCa; \
+ MOVQ rc, rT1; \
+ ORQ rBi, rCa; \
+ XORQ rBa, rT1; \
+ XORQ rT1, rCa; \
+ MOVQ rCa, _ba(oState); \
+ \
+ XORQ rDu, rBu; \
+ ROLQ $14, rBu; \
+ MOVQ rBa, rCu; \
+ ANDQ rBe, rCu; \
+ XORQ rBu, rCu; \
+ MOVQ rCu, _bu(oState); \
+ \
+ XORQ rDo, rBo; \
+ ROLQ $21, rBo; \
+ MOVQ rBo, rT1; \
+ ANDQ rBu, rT1; \
+ XORQ rBi, rT1; \
+ MOVQ rT1, _bi(oState); \
+ \
+ NOTQ rBi; \
+ ORQ rBa, rBu; \
+ ORQ rBo, rBi; \
+ XORQ rBo, rBu; \
+ XORQ rBe, rBi; \
+ MOVQ rBu, _bo(oState); \
+ MOVQ rBi, _be(oState); \
+ B_RBI_RCE; \
+ \
+ /* Result g */ \
+ MOVQ _gu(iState), rBe; \
+ XORQ rDu, rBe; \
+ MOVQ _ka(iState), rBi; \
+ ROLQ $20, rBe; \
+ XORQ rDa, rBi; \
+ ROLQ $3, rBi; \
+ MOVQ _bo(iState), rBa; \
+ MOVQ rBe, rT1; \
+ ORQ rBi, rT1; \
+ XORQ rDo, rBa; \
+ MOVQ _me(iState), rBo; \
+ MOVQ _si(iState), rBu; \
+ ROLQ $28, rBa; \
+ XORQ rBa, rT1; \
+ MOVQ rT1, _ga(oState); \
+ G_RT1_RCA; \
+ \
+ XORQ rDe, rBo; \
+ ROLQ $45, rBo; \
+ MOVQ rBi, rT1; \
+ ANDQ rBo, rT1; \
+ XORQ rBe, rT1; \
+ MOVQ rT1, _ge(oState); \
+ G_RT1_RCE; \
+ \
+ XORQ rDi, rBu; \
+ ROLQ $61, rBu; \
+ MOVQ rBu, rT1; \
+ ORQ rBa, rT1; \
+ XORQ rBo, rT1; \
+ MOVQ rT1, _go(oState); \
+ \
+ ANDQ rBe, rBa; \
+ XORQ rBu, rBa; \
+ MOVQ rBa, _gu(oState); \
+ NOTQ rBu; \
+ G_RBA_RCU; \
+ \
+ ORQ rBu, rBo; \
+ XORQ rBi, rBo; \
+ MOVQ rBo, _gi(oState); \
+ \
+ /* Result k */ \
+ MOVQ _be(iState), rBa; \
+ MOVQ _gi(iState), rBe; \
+ MOVQ _ko(iState), rBi; \
+ MOVQ _mu(iState), rBo; \
+ MOVQ _sa(iState), rBu; \
+ XORQ rDi, rBe; \
+ ROLQ $6, rBe; \
+ XORQ rDo, rBi; \
+ ROLQ $25, rBi; \
+ MOVQ rBe, rT1; \
+ ORQ rBi, rT1; \
+ XORQ rDe, rBa; \
+ ROLQ $1, rBa; \
+ XORQ rBa, rT1; \
+ MOVQ rT1, _ka(oState); \
+ K_RT1_RCA; \
+ \
+ XORQ rDu, rBo; \
+ ROLQ $8, rBo; \
+ MOVQ rBi, rT1; \
+ ANDQ rBo, rT1; \
+ XORQ rBe, rT1; \
+ MOVQ rT1, _ke(oState); \
+ K_RT1_RCE; \
+ \
+ XORQ rDa, rBu; \
+ ROLQ $18, rBu; \
+ NOTQ rBo; \
+ MOVQ rBo, rT1; \
+ ANDQ rBu, rT1; \
+ XORQ rBi, rT1; \
+ MOVQ rT1, _ki(oState); \
+ \
+ MOVQ rBu, rT1; \
+ ORQ rBa, rT1; \
+ XORQ rBo, rT1; \
+ MOVQ rT1, _ko(oState); \
+ \
+ ANDQ rBe, rBa; \
+ XORQ rBu, rBa; \
+ MOVQ rBa, _ku(oState); \
+ K_RBA_RCU; \
+ \
+ /* Result m */ \
+ MOVQ _ga(iState), rBe; \
+ XORQ rDa, rBe; \
+ MOVQ _ke(iState), rBi; \
+ ROLQ $36, rBe; \
+ XORQ rDe, rBi; \
+ MOVQ _bu(iState), rBa; \
+ ROLQ $10, rBi; \
+ MOVQ rBe, rT1; \
+ MOVQ _mi(iState), rBo; \
+ ANDQ rBi, rT1; \
+ XORQ rDu, rBa; \
+ MOVQ _so(iState), rBu; \
+ ROLQ $27, rBa; \
+ XORQ rBa, rT1; \
+ MOVQ rT1, _ma(oState); \
+ M_RT1_RCA; \
+ \
+ XORQ rDi, rBo; \
+ ROLQ $15, rBo; \
+ MOVQ rBi, rT1; \
+ ORQ rBo, rT1; \
+ XORQ rBe, rT1; \
+ MOVQ rT1, _me(oState); \
+ M_RT1_RCE; \
+ \
+ XORQ rDo, rBu; \
+ ROLQ $56, rBu; \
+ NOTQ rBo; \
+ MOVQ rBo, rT1; \
+ ORQ rBu, rT1; \
+ XORQ rBi, rT1; \
+ MOVQ rT1, _mi(oState); \
+ \
+ ORQ rBa, rBe; \
+ XORQ rBu, rBe; \
+ MOVQ rBe, _mu(oState); \
+ \
+ ANDQ rBa, rBu; \
+ XORQ rBo, rBu; \
+ MOVQ rBu, _mo(oState); \
+ M_RBE_RCU; \
+ \
+ /* Result s */ \
+ MOVQ _bi(iState), rBa; \
+ MOVQ _go(iState), rBe; \
+ MOVQ _ku(iState), rBi; \
+ XORQ rDi, rBa; \
+ MOVQ _ma(iState), rBo; \
+ ROLQ $62, rBa; \
+ XORQ rDo, rBe; \
+ MOVQ _se(iState), rBu; \
+ ROLQ $55, rBe; \
+ \
+ XORQ rDu, rBi; \
+ MOVQ rBa, rDu; \
+ XORQ rDe, rBu; \
+ ROLQ $2, rBu; \
+ ANDQ rBe, rDu; \
+ XORQ rBu, rDu; \
+ MOVQ rDu, _su(oState); \
+ \
+ ROLQ $39, rBi; \
+ S_RDU_RCU; \
+ NOTQ rBe; \
+ XORQ rDa, rBo; \
+ MOVQ rBe, rDa; \
+ ANDQ rBi, rDa; \
+ XORQ rBa, rDa; \
+ MOVQ rDa, _sa(oState); \
+ S_RDA_RCA; \
+ \
+ ROLQ $41, rBo; \
+ MOVQ rBi, rDe; \
+ ORQ rBo, rDe; \
+ XORQ rBe, rDe; \
+ MOVQ rDe, _se(oState); \
+ S_RDE_RCE; \
+ \
+ MOVQ rBo, rDi; \
+ MOVQ rBu, rDo; \
+ ANDQ rBu, rDi; \
+ ORQ rBa, rDo; \
+ XORQ rBi, rDi; \
+ XORQ rBo, rDo; \
+ MOVQ rDi, _si(oState); \
+ MOVQ rDo, _so(oState) \
+
+// func keccakF1600(state *[25]uint64)
+TEXT ·keccakF1600(SB), 0, $200-8
+ MOVQ state+0(FP), rpState
+
+ // Convert the user state into an internal state
+ NOTQ _be(rpState)
+ NOTQ _bi(rpState)
+ NOTQ _go(rpState)
+ NOTQ _ki(rpState)
+ NOTQ _mi(rpState)
+ NOTQ _sa(rpState)
+
+ // Execute the KeccakF permutation
+ MOVQ _ba(rpState), rCa
+ MOVQ _be(rpState), rCe
+ MOVQ _bu(rpState), rCu
+
+ XORQ _ga(rpState), rCa
+ XORQ _ge(rpState), rCe
+ XORQ _gu(rpState), rCu
+
+ XORQ _ka(rpState), rCa
+ XORQ _ke(rpState), rCe
+ XORQ _ku(rpState), rCu
+
+ XORQ _ma(rpState), rCa
+ XORQ _me(rpState), rCe
+ XORQ _mu(rpState), rCu
+
+ XORQ _sa(rpState), rCa
+ XORQ _se(rpState), rCe
+ MOVQ _si(rpState), rDi
+ MOVQ _so(rpState), rDo
+ XORQ _su(rpState), rCu
+
+ mKeccakRound(rpState, rpStack, $0x0000000000000001, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x0000000000008082, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x800000000000808a, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x8000000080008000, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x000000000000808b, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x0000000080000001, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x8000000080008081, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x8000000000008009, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x000000000000008a, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x0000000000000088, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x0000000080008009, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x000000008000000a, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x000000008000808b, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x800000000000008b, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x8000000000008089, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x8000000000008003, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x8000000000008002, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x8000000000000080, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x000000000000800a, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x800000008000000a, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x8000000080008081, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x8000000000008080, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpState, rpStack, $0x0000000080000001, MOVQ_RBI_RCE, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBA_RCU, XORQ_RT1_RCA, XORQ_RT1_RCE, XORQ_RBE_RCU, XORQ_RDU_RCU, XORQ_RDA_RCA, XORQ_RDE_RCE)
+ mKeccakRound(rpStack, rpState, $0x8000000080008008, NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP)
+
+ // Revert the internal state to the user state
+ NOTQ _be(rpState)
+ NOTQ _bi(rpState)
+ NOTQ _go(rpState)
+ NOTQ _ki(rpState)
+ NOTQ _mi(rpState)
+ NOTQ _sa(rpState)
+
+ RET
diff --git a/vendor/golang.org/x/crypto/sha3/register.go b/vendor/golang.org/x/crypto/sha3/register.go
new file mode 100644
index 0000000000..3cf6a22e09
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/register.go
@@ -0,0 +1,18 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.4
+
+package sha3
+
+import (
+ "crypto"
+)
+
+func init() {
+ crypto.RegisterHash(crypto.SHA3_224, New224)
+ crypto.RegisterHash(crypto.SHA3_256, New256)
+ crypto.RegisterHash(crypto.SHA3_384, New384)
+ crypto.RegisterHash(crypto.SHA3_512, New512)
+}
diff --git a/vendor/golang.org/x/crypto/sha3/sha3.go b/vendor/golang.org/x/crypto/sha3/sha3.go
new file mode 100644
index 0000000000..ba269a0730
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/sha3.go
@@ -0,0 +1,193 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package sha3
+
+// spongeDirection indicates the direction bytes are flowing through the sponge.
+type spongeDirection int
+
+const (
+ // spongeAbsorbing indicates that the sponge is absorbing input.
+ spongeAbsorbing spongeDirection = iota
+ // spongeSqueezing indicates that the sponge is being squeezed.
+ spongeSqueezing
+)
+
+const (
+ // maxRate is the maximum size of the internal buffer. SHAKE-256
+ // currently needs the largest buffer.
+ maxRate = 168
+)
+
+type state struct {
+ // Generic sponge components.
+ a [25]uint64 // main state of the hash
+ buf []byte // points into storage
+ rate int // the number of bytes of state to use
+
+ // dsbyte contains the "domain separation" bits and the first bit of
+ // the padding. Sections 6.1 and 6.2 of [1] separate the outputs of the
+ // SHA-3 and SHAKE functions by appending bitstrings to the message.
+ // Using a little-endian bit-ordering convention, these are "01" for SHA-3
+ // and "1111" for SHAKE, or 00000010b and 00001111b, respectively. Then the
+ // padding rule from section 5.1 is applied to pad the message to a multiple
+ // of the rate, which involves adding a "1" bit, zero or more "0" bits, and
+ // a final "1" bit. We merge the first "1" bit from the padding into dsbyte,
+ // giving 00000110b (0x06) and 00011111b (0x1f).
+ // [1] http://csrc.nist.gov/publications/drafts/fips-202/fips_202_draft.pdf
+ // "Draft FIPS 202: SHA-3 Standard: Permutation-Based Hash and
+ // Extendable-Output Functions (May 2014)"
+ dsbyte byte
+
+ storage storageBuf
+
+ // Specific to SHA-3 and SHAKE.
+ outputLen int // the default output size in bytes
+ state spongeDirection // whether the sponge is absorbing or squeezing
+}
+
+// BlockSize returns the rate of sponge underlying this hash function.
+func (d *state) BlockSize() int { return d.rate }
+
+// Size returns the output size of the hash function in bytes.
+func (d *state) Size() int { return d.outputLen }
+
+// Reset clears the internal state by zeroing the sponge state and
+// the byte buffer, and setting Sponge.state to absorbing.
+func (d *state) Reset() {
+ // Zero the permutation's state.
+ for i := range d.a {
+ d.a[i] = 0
+ }
+ d.state = spongeAbsorbing
+ d.buf = d.storage.asBytes()[:0]
+}
+
+func (d *state) clone() *state {
+ ret := *d
+ if ret.state == spongeAbsorbing {
+ ret.buf = ret.storage.asBytes()[:len(ret.buf)]
+ } else {
+ ret.buf = ret.storage.asBytes()[d.rate-cap(d.buf) : d.rate]
+ }
+
+ return &ret
+}
+
+// permute applies the KeccakF-1600 permutation. It handles
+// any input-output buffering.
+func (d *state) permute() {
+ switch d.state {
+ case spongeAbsorbing:
+ // If we're absorbing, we need to xor the input into the state
+ // before applying the permutation.
+ xorIn(d, d.buf)
+ d.buf = d.storage.asBytes()[:0]
+ keccakF1600(&d.a)
+ case spongeSqueezing:
+ // If we're squeezing, we need to apply the permutatin before
+ // copying more output.
+ keccakF1600(&d.a)
+ d.buf = d.storage.asBytes()[:d.rate]
+ copyOut(d, d.buf)
+ }
+}
+
+// pads appends the domain separation bits in dsbyte, applies
+// the multi-bitrate 10..1 padding rule, and permutes the state.
+func (d *state) padAndPermute(dsbyte byte) {
+ if d.buf == nil {
+ d.buf = d.storage.asBytes()[:0]
+ }
+ // Pad with this instance's domain-separator bits. We know that there's
+ // at least one byte of space in d.buf because, if it were full,
+ // permute would have been called to empty it. dsbyte also contains the
+ // first one bit for the padding. See the comment in the state struct.
+ d.buf = append(d.buf, dsbyte)
+ zerosStart := len(d.buf)
+ d.buf = d.storage.asBytes()[:d.rate]
+ for i := zerosStart; i < d.rate; i++ {
+ d.buf[i] = 0
+ }
+ // This adds the final one bit for the padding. Because of the way that
+ // bits are numbered from the LSB upwards, the final bit is the MSB of
+ // the last byte.
+ d.buf[d.rate-1] ^= 0x80
+ // Apply the permutation
+ d.permute()
+ d.state = spongeSqueezing
+ d.buf = d.storage.asBytes()[:d.rate]
+ copyOut(d, d.buf)
+}
+
+// Write absorbs more data into the hash's state. It produces an error
+// if more data is written to the ShakeHash after writing
+func (d *state) Write(p []byte) (written int, err error) {
+ if d.state != spongeAbsorbing {
+ panic("sha3: write to sponge after read")
+ }
+ if d.buf == nil {
+ d.buf = d.storage.asBytes()[:0]
+ }
+ written = len(p)
+
+ for len(p) > 0 {
+ if len(d.buf) == 0 && len(p) >= d.rate {
+ // The fast path; absorb a full "rate" bytes of input and apply the permutation.
+ xorIn(d, p[:d.rate])
+ p = p[d.rate:]
+ keccakF1600(&d.a)
+ } else {
+ // The slow path; buffer the input until we can fill the sponge, and then xor it in.
+ todo := d.rate - len(d.buf)
+ if todo > len(p) {
+ todo = len(p)
+ }
+ d.buf = append(d.buf, p[:todo]...)
+ p = p[todo:]
+
+ // If the sponge is full, apply the permutation.
+ if len(d.buf) == d.rate {
+ d.permute()
+ }
+ }
+ }
+
+ return
+}
+
+// Read squeezes an arbitrary number of bytes from the sponge.
+func (d *state) Read(out []byte) (n int, err error) {
+ // If we're still absorbing, pad and apply the permutation.
+ if d.state == spongeAbsorbing {
+ d.padAndPermute(d.dsbyte)
+ }
+
+ n = len(out)
+
+ // Now, do the squeezing.
+ for len(out) > 0 {
+ n := copy(out, d.buf)
+ d.buf = d.buf[n:]
+ out = out[n:]
+
+ // Apply the permutation if we've squeezed the sponge dry.
+ if len(d.buf) == 0 {
+ d.permute()
+ }
+ }
+
+ return
+}
+
+// Sum applies padding to the hash state and then squeezes out the desired
+// number of output bytes.
+func (d *state) Sum(in []byte) []byte {
+ // Make a copy of the original hash so that caller can keep writing
+ // and summing.
+ dup := d.clone()
+ hash := make([]byte, dup.outputLen)
+ dup.Read(hash)
+ return append(in, hash...)
+}
diff --git a/vendor/golang.org/x/crypto/sha3/sha3_s390x.go b/vendor/golang.org/x/crypto/sha3/sha3_s390x.go
new file mode 100644
index 0000000000..259ff4dada
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/sha3_s390x.go
@@ -0,0 +1,284 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo,!appengine
+
+package sha3
+
+// This file contains code for using the 'compute intermediate
+// message digest' (KIMD) and 'compute last message digest' (KLMD)
+// instructions to compute SHA-3 and SHAKE hashes on IBM Z.
+
+import (
+ "hash"
+
+ "golang.org/x/sys/cpu"
+)
+
+// codes represent 7-bit KIMD/KLMD function codes as defined in
+// the Principles of Operation.
+type code uint64
+
+const (
+ // function codes for KIMD/KLMD
+ sha3_224 code = 32
+ sha3_256 = 33
+ sha3_384 = 34
+ sha3_512 = 35
+ shake_128 = 36
+ shake_256 = 37
+ nopad = 0x100
+)
+
+// kimd is a wrapper for the 'compute intermediate message digest' instruction.
+// src must be a multiple of the rate for the given function code.
+//go:noescape
+func kimd(function code, chain *[200]byte, src []byte)
+
+// klmd is a wrapper for the 'compute last message digest' instruction.
+// src padding is handled by the instruction.
+//go:noescape
+func klmd(function code, chain *[200]byte, dst, src []byte)
+
+type asmState struct {
+ a [200]byte // 1600 bit state
+ buf []byte // care must be taken to ensure cap(buf) is a multiple of rate
+ rate int // equivalent to block size
+ storage [3072]byte // underlying storage for buf
+ outputLen int // output length if fixed, 0 if not
+ function code // KIMD/KLMD function code
+ state spongeDirection // whether the sponge is absorbing or squeezing
+}
+
+func newAsmState(function code) *asmState {
+ var s asmState
+ s.function = function
+ switch function {
+ case sha3_224:
+ s.rate = 144
+ s.outputLen = 28
+ case sha3_256:
+ s.rate = 136
+ s.outputLen = 32
+ case sha3_384:
+ s.rate = 104
+ s.outputLen = 48
+ case sha3_512:
+ s.rate = 72
+ s.outputLen = 64
+ case shake_128:
+ s.rate = 168
+ case shake_256:
+ s.rate = 136
+ default:
+ panic("sha3: unrecognized function code")
+ }
+
+ // limit s.buf size to a multiple of s.rate
+ s.resetBuf()
+ return &s
+}
+
+func (s *asmState) clone() *asmState {
+ c := *s
+ c.buf = c.storage[:len(s.buf):cap(s.buf)]
+ return &c
+}
+
+// copyIntoBuf copies b into buf. It will panic if there is not enough space to
+// store all of b.
+func (s *asmState) copyIntoBuf(b []byte) {
+ bufLen := len(s.buf)
+ s.buf = s.buf[:len(s.buf)+len(b)]
+ copy(s.buf[bufLen:], b)
+}
+
+// resetBuf points buf at storage, sets the length to 0 and sets cap to be a
+// multiple of the rate.
+func (s *asmState) resetBuf() {
+ max := (cap(s.storage) / s.rate) * s.rate
+ s.buf = s.storage[:0:max]
+}
+
+// Write (via the embedded io.Writer interface) adds more data to the running hash.
+// It never returns an error.
+func (s *asmState) Write(b []byte) (int, error) {
+ if s.state != spongeAbsorbing {
+ panic("sha3: write to sponge after read")
+ }
+ length := len(b)
+ for len(b) > 0 {
+ if len(s.buf) == 0 && len(b) >= cap(s.buf) {
+ // Hash the data directly and push any remaining bytes
+ // into the buffer.
+ remainder := len(b) % s.rate
+ kimd(s.function, &s.a, b[:len(b)-remainder])
+ if remainder != 0 {
+ s.copyIntoBuf(b[len(b)-remainder:])
+ }
+ return length, nil
+ }
+
+ if len(s.buf) == cap(s.buf) {
+ // flush the buffer
+ kimd(s.function, &s.a, s.buf)
+ s.buf = s.buf[:0]
+ }
+
+ // copy as much as we can into the buffer
+ n := len(b)
+ if len(b) > cap(s.buf)-len(s.buf) {
+ n = cap(s.buf) - len(s.buf)
+ }
+ s.copyIntoBuf(b[:n])
+ b = b[n:]
+ }
+ return length, nil
+}
+
+// Read squeezes an arbitrary number of bytes from the sponge.
+func (s *asmState) Read(out []byte) (n int, err error) {
+ n = len(out)
+
+ // need to pad if we were absorbing
+ if s.state == spongeAbsorbing {
+ s.state = spongeSqueezing
+
+ // write hash directly into out if possible
+ if len(out)%s.rate == 0 {
+ klmd(s.function, &s.a, out, s.buf) // len(out) may be 0
+ s.buf = s.buf[:0]
+ return
+ }
+
+ // write hash into buffer
+ max := cap(s.buf)
+ if max > len(out) {
+ max = (len(out)/s.rate)*s.rate + s.rate
+ }
+ klmd(s.function, &s.a, s.buf[:max], s.buf)
+ s.buf = s.buf[:max]
+ }
+
+ for len(out) > 0 {
+ // flush the buffer
+ if len(s.buf) != 0 {
+ c := copy(out, s.buf)
+ out = out[c:]
+ s.buf = s.buf[c:]
+ continue
+ }
+
+ // write hash directly into out if possible
+ if len(out)%s.rate == 0 {
+ klmd(s.function|nopad, &s.a, out, nil)
+ return
+ }
+
+ // write hash into buffer
+ s.resetBuf()
+ if cap(s.buf) > len(out) {
+ s.buf = s.buf[:(len(out)/s.rate)*s.rate+s.rate]
+ }
+ klmd(s.function|nopad, &s.a, s.buf, nil)
+ }
+ return
+}
+
+// Sum appends the current hash to b and returns the resulting slice.
+// It does not change the underlying hash state.
+func (s *asmState) Sum(b []byte) []byte {
+ if s.outputLen == 0 {
+ panic("sha3: cannot call Sum on SHAKE functions")
+ }
+
+ // Copy the state to preserve the original.
+ a := s.a
+
+ // Hash the buffer. Note that we don't clear it because we
+ // aren't updating the state.
+ klmd(s.function, &a, nil, s.buf)
+ return append(b, a[:s.outputLen]...)
+}
+
+// Reset resets the Hash to its initial state.
+func (s *asmState) Reset() {
+ for i := range s.a {
+ s.a[i] = 0
+ }
+ s.resetBuf()
+ s.state = spongeAbsorbing
+}
+
+// Size returns the number of bytes Sum will return.
+func (s *asmState) Size() int {
+ return s.outputLen
+}
+
+// BlockSize returns the hash's underlying block size.
+// The Write method must be able to accept any amount
+// of data, but it may operate more efficiently if all writes
+// are a multiple of the block size.
+func (s *asmState) BlockSize() int {
+ return s.rate
+}
+
+// Clone returns a copy of the ShakeHash in its current state.
+func (s *asmState) Clone() ShakeHash {
+ return s.clone()
+}
+
+// new224Asm returns an assembly implementation of SHA3-224 if available,
+// otherwise it returns nil.
+func new224Asm() hash.Hash {
+ if cpu.S390X.HasSHA3 {
+ return newAsmState(sha3_224)
+ }
+ return nil
+}
+
+// new256Asm returns an assembly implementation of SHA3-256 if available,
+// otherwise it returns nil.
+func new256Asm() hash.Hash {
+ if cpu.S390X.HasSHA3 {
+ return newAsmState(sha3_256)
+ }
+ return nil
+}
+
+// new384Asm returns an assembly implementation of SHA3-384 if available,
+// otherwise it returns nil.
+func new384Asm() hash.Hash {
+ if cpu.S390X.HasSHA3 {
+ return newAsmState(sha3_384)
+ }
+ return nil
+}
+
+// new512Asm returns an assembly implementation of SHA3-512 if available,
+// otherwise it returns nil.
+func new512Asm() hash.Hash {
+ if cpu.S390X.HasSHA3 {
+ return newAsmState(sha3_512)
+ }
+ return nil
+}
+
+// newShake128Asm returns an assembly implementation of SHAKE-128 if available,
+// otherwise it returns nil.
+func newShake128Asm() ShakeHash {
+ if cpu.S390X.HasSHA3 {
+ return newAsmState(shake_128)
+ }
+ return nil
+}
+
+// newShake256Asm returns an assembly implementation of SHAKE-256 if available,
+// otherwise it returns nil.
+func newShake256Asm() ShakeHash {
+ if cpu.S390X.HasSHA3 {
+ return newAsmState(shake_256)
+ }
+ return nil
+}
diff --git a/vendor/golang.org/x/crypto/sha3/sha3_s390x.s b/vendor/golang.org/x/crypto/sha3/sha3_s390x.s
new file mode 100644
index 0000000000..8a4458f63f
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/sha3_s390x.s
@@ -0,0 +1,33 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo,!appengine
+
+#include "textflag.h"
+
+// func kimd(function code, chain *[200]byte, src []byte)
+TEXT ·kimd(SB), NOFRAME|NOSPLIT, $0-40
+ MOVD function+0(FP), R0
+ MOVD chain+8(FP), R1
+ LMG src+16(FP), R2, R3 // R2=base, R3=len
+
+continue:
+ WORD $0xB93E0002 // KIMD --, R2
+ BVS continue // continue if interrupted
+ MOVD $0, R0 // reset R0 for pre-go1.8 compilers
+ RET
+
+// func klmd(function code, chain *[200]byte, dst, src []byte)
+TEXT ·klmd(SB), NOFRAME|NOSPLIT, $0-64
+ // TODO: SHAKE support
+ MOVD function+0(FP), R0
+ MOVD chain+8(FP), R1
+ LMG dst+16(FP), R2, R3 // R2=base, R3=len
+ LMG src+40(FP), R4, R5 // R4=base, R5=len
+
+continue:
+ WORD $0xB93F0024 // KLMD R2, R4
+ BVS continue // continue if interrupted
+ MOVD $0, R0 // reset R0 for pre-go1.8 compilers
+ RET
diff --git a/vendor/golang.org/x/crypto/sha3/shake.go b/vendor/golang.org/x/crypto/sha3/shake.go
new file mode 100644
index 0000000000..d7be2954ab
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/shake.go
@@ -0,0 +1,173 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package sha3
+
+// This file defines the ShakeHash interface, and provides
+// functions for creating SHAKE and cSHAKE instances, as well as utility
+// functions for hashing bytes to arbitrary-length output.
+//
+//
+// SHAKE implementation is based on FIPS PUB 202 [1]
+// cSHAKE implementations is based on NIST SP 800-185 [2]
+//
+// [1] https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
+// [2] https://doi.org/10.6028/NIST.SP.800-185
+
+import (
+ "encoding/binary"
+ "io"
+)
+
+// ShakeHash defines the interface to hash functions that
+// support arbitrary-length output.
+type ShakeHash interface {
+ // Write absorbs more data into the hash's state. It panics if input is
+ // written to it after output has been read from it.
+ io.Writer
+
+ // Read reads more output from the hash; reading affects the hash's
+ // state. (ShakeHash.Read is thus very different from Hash.Sum)
+ // It never returns an error.
+ io.Reader
+
+ // Clone returns a copy of the ShakeHash in its current state.
+ Clone() ShakeHash
+
+ // Reset resets the ShakeHash to its initial state.
+ Reset()
+}
+
+// cSHAKE specific context
+type cshakeState struct {
+ *state // SHA-3 state context and Read/Write operations
+
+ // initBlock is the cSHAKE specific initialization set of bytes. It is initialized
+ // by newCShake function and stores concatenation of N followed by S, encoded
+ // by the method specified in 3.3 of [1].
+ // It is stored here in order for Reset() to be able to put context into
+ // initial state.
+ initBlock []byte
+}
+
+// Consts for configuring initial SHA-3 state
+const (
+ dsbyteShake = 0x1f
+ dsbyteCShake = 0x04
+ rate128 = 168
+ rate256 = 136
+)
+
+func bytepad(input []byte, w int) []byte {
+ // leftEncode always returns max 9 bytes
+ buf := make([]byte, 0, 9+len(input)+w)
+ buf = append(buf, leftEncode(uint64(w))...)
+ buf = append(buf, input...)
+ padlen := w - (len(buf) % w)
+ return append(buf, make([]byte, padlen)...)
+}
+
+func leftEncode(value uint64) []byte {
+ var b [9]byte
+ binary.BigEndian.PutUint64(b[1:], value)
+ // Trim all but last leading zero bytes
+ i := byte(1)
+ for i < 8 && b[i] == 0 {
+ i++
+ }
+ // Prepend number of encoded bytes
+ b[i-1] = 9 - i
+ return b[i-1:]
+}
+
+func newCShake(N, S []byte, rate int, dsbyte byte) ShakeHash {
+ c := cshakeState{state: &state{rate: rate, dsbyte: dsbyte}}
+
+ // leftEncode returns max 9 bytes
+ c.initBlock = make([]byte, 0, 9*2+len(N)+len(S))
+ c.initBlock = append(c.initBlock, leftEncode(uint64(len(N)*8))...)
+ c.initBlock = append(c.initBlock, N...)
+ c.initBlock = append(c.initBlock, leftEncode(uint64(len(S)*8))...)
+ c.initBlock = append(c.initBlock, S...)
+ c.Write(bytepad(c.initBlock, c.rate))
+ return &c
+}
+
+// Reset resets the hash to initial state.
+func (c *cshakeState) Reset() {
+ c.state.Reset()
+ c.Write(bytepad(c.initBlock, c.rate))
+}
+
+// Clone returns copy of a cSHAKE context within its current state.
+func (c *cshakeState) Clone() ShakeHash {
+ b := make([]byte, len(c.initBlock))
+ copy(b, c.initBlock)
+ return &cshakeState{state: c.clone(), initBlock: b}
+}
+
+// Clone returns copy of SHAKE context within its current state.
+func (c *state) Clone() ShakeHash {
+ return c.clone()
+}
+
+// NewShake128 creates a new SHAKE128 variable-output-length ShakeHash.
+// Its generic security strength is 128 bits against all attacks if at
+// least 32 bytes of its output are used.
+func NewShake128() ShakeHash {
+ if h := newShake128Asm(); h != nil {
+ return h
+ }
+ return &state{rate: rate128, dsbyte: dsbyteShake}
+}
+
+// NewShake256 creates a new SHAKE256 variable-output-length ShakeHash.
+// Its generic security strength is 256 bits against all attacks if
+// at least 64 bytes of its output are used.
+func NewShake256() ShakeHash {
+ if h := newShake256Asm(); h != nil {
+ return h
+ }
+ return &state{rate: rate256, dsbyte: dsbyteShake}
+}
+
+// NewCShake128 creates a new instance of cSHAKE128 variable-output-length ShakeHash,
+// a customizable variant of SHAKE128.
+// N is used to define functions based on cSHAKE, it can be empty when plain cSHAKE is
+// desired. S is a customization byte string used for domain separation - two cSHAKE
+// computations on same input with different S yield unrelated outputs.
+// When N and S are both empty, this is equivalent to NewShake128.
+func NewCShake128(N, S []byte) ShakeHash {
+ if len(N) == 0 && len(S) == 0 {
+ return NewShake128()
+ }
+ return newCShake(N, S, rate128, dsbyteCShake)
+}
+
+// NewCShake256 creates a new instance of cSHAKE256 variable-output-length ShakeHash,
+// a customizable variant of SHAKE256.
+// N is used to define functions based on cSHAKE, it can be empty when plain cSHAKE is
+// desired. S is a customization byte string used for domain separation - two cSHAKE
+// computations on same input with different S yield unrelated outputs.
+// When N and S are both empty, this is equivalent to NewShake256.
+func NewCShake256(N, S []byte) ShakeHash {
+ if len(N) == 0 && len(S) == 0 {
+ return NewShake256()
+ }
+ return newCShake(N, S, rate256, dsbyteCShake)
+}
+
+// ShakeSum128 writes an arbitrary-length digest of data into hash.
+func ShakeSum128(hash, data []byte) {
+ h := NewShake128()
+ h.Write(data)
+ h.Read(hash)
+}
+
+// ShakeSum256 writes an arbitrary-length digest of data into hash.
+func ShakeSum256(hash, data []byte) {
+ h := NewShake256()
+ h.Write(data)
+ h.Read(hash)
+}
diff --git a/vendor/golang.org/x/crypto/sha3/shake_generic.go b/vendor/golang.org/x/crypto/sha3/shake_generic.go
new file mode 100644
index 0000000000..add4e73396
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/shake_generic.go
@@ -0,0 +1,19 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gccgo appengine !s390x
+
+package sha3
+
+// newShake128Asm returns an assembly implementation of SHAKE-128 if available,
+// otherwise it returns nil.
+func newShake128Asm() ShakeHash {
+ return nil
+}
+
+// newShake256Asm returns an assembly implementation of SHAKE-256 if available,
+// otherwise it returns nil.
+func newShake256Asm() ShakeHash {
+ return nil
+}
diff --git a/vendor/golang.org/x/crypto/sha3/xor.go b/vendor/golang.org/x/crypto/sha3/xor.go
new file mode 100644
index 0000000000..079b650141
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/xor.go
@@ -0,0 +1,23 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !amd64,!386,!ppc64le appengine
+
+package sha3
+
+// A storageBuf is an aligned array of maxRate bytes.
+type storageBuf [maxRate]byte
+
+func (b *storageBuf) asBytes() *[maxRate]byte {
+ return (*[maxRate]byte)(b)
+}
+
+var (
+ xorIn = xorInGeneric
+ copyOut = copyOutGeneric
+ xorInUnaligned = xorInGeneric
+ copyOutUnaligned = copyOutGeneric
+)
+
+const xorImplementationUnaligned = "generic"
diff --git a/vendor/golang.org/x/crypto/sha3/xor_generic.go b/vendor/golang.org/x/crypto/sha3/xor_generic.go
new file mode 100644
index 0000000000..fd35f02ef6
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/xor_generic.go
@@ -0,0 +1,28 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package sha3
+
+import "encoding/binary"
+
+// xorInGeneric xors the bytes in buf into the state; it
+// makes no non-portable assumptions about memory layout
+// or alignment.
+func xorInGeneric(d *state, buf []byte) {
+ n := len(buf) / 8
+
+ for i := 0; i < n; i++ {
+ a := binary.LittleEndian.Uint64(buf)
+ d.a[i] ^= a
+ buf = buf[8:]
+ }
+}
+
+// copyOutGeneric copies ulint64s to a byte buffer.
+func copyOutGeneric(d *state, b []byte) {
+ for i := 0; len(b) >= 8; i++ {
+ binary.LittleEndian.PutUint64(b, d.a[i])
+ b = b[8:]
+ }
+}
diff --git a/vendor/golang.org/x/crypto/sha3/xor_unaligned.go b/vendor/golang.org/x/crypto/sha3/xor_unaligned.go
new file mode 100644
index 0000000000..5ede2c61b4
--- /dev/null
+++ b/vendor/golang.org/x/crypto/sha3/xor_unaligned.go
@@ -0,0 +1,76 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64 386 ppc64le
+// +build !appengine
+
+package sha3
+
+import "unsafe"
+
+// A storageBuf is an aligned array of maxRate bytes.
+type storageBuf [maxRate / 8]uint64
+
+func (b *storageBuf) asBytes() *[maxRate]byte {
+ return (*[maxRate]byte)(unsafe.Pointer(b))
+}
+
+//go:nocheckptr
+//
+// xorInUnaligned intentionally reads the input buffer as an unaligned slice of
+// integers. The language spec is not clear on whether that is allowed.
+// See:
+// https://golang.org/issue/37644
+// https://golang.org/issue/37298
+// https://golang.org/issue/35381
+
+// xorInUnaligned uses unaligned reads and writes to update d.a to contain d.a
+// XOR buf.
+func xorInUnaligned(d *state, buf []byte) {
+ n := len(buf)
+ bw := (*[maxRate / 8]uint64)(unsafe.Pointer(&buf[0]))[: n/8 : n/8]
+ if n >= 72 {
+ d.a[0] ^= bw[0]
+ d.a[1] ^= bw[1]
+ d.a[2] ^= bw[2]
+ d.a[3] ^= bw[3]
+ d.a[4] ^= bw[4]
+ d.a[5] ^= bw[5]
+ d.a[6] ^= bw[6]
+ d.a[7] ^= bw[7]
+ d.a[8] ^= bw[8]
+ }
+ if n >= 104 {
+ d.a[9] ^= bw[9]
+ d.a[10] ^= bw[10]
+ d.a[11] ^= bw[11]
+ d.a[12] ^= bw[12]
+ }
+ if n >= 136 {
+ d.a[13] ^= bw[13]
+ d.a[14] ^= bw[14]
+ d.a[15] ^= bw[15]
+ d.a[16] ^= bw[16]
+ }
+ if n >= 144 {
+ d.a[17] ^= bw[17]
+ }
+ if n >= 168 {
+ d.a[18] ^= bw[18]
+ d.a[19] ^= bw[19]
+ d.a[20] ^= bw[20]
+ }
+}
+
+func copyOutUnaligned(d *state, buf []byte) {
+ ab := (*[maxRate]uint8)(unsafe.Pointer(&d.a[0]))
+ copy(buf, ab[:])
+}
+
+var (
+ xorIn = xorInUnaligned
+ copyOut = copyOutUnaligned
+)
+
+const xorImplementationUnaligned = "unaligned"
diff --git a/vendor/gopkg.in/go-playground/validator.v9/Makefile b/vendor/gopkg.in/go-playground/validator.v9/Makefile
deleted file mode 100644
index aeeee9da94..0000000000
--- a/vendor/gopkg.in/go-playground/validator.v9/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-GOCMD=go
-
-linters-install:
- $(GOCMD) get -u github.com/alecthomas/gometalinter
- gometalinter --install
-
-lint: linters-install
- gometalinter --vendor --disable-all --enable=vet --enable=vetshadow --enable=golint --enable=maligned --enable=megacheck --enable=ineffassign --enable=misspell --enable=errcheck --enable=goconst ./...
-
-test:
- $(GOCMD) test -cover -race ./...
-
-bench:
- $(GOCMD) test -bench=. -benchmem ./...
-
-.PHONY: test lint linters-install
\ No newline at end of file
diff --git a/vendor/gopkg.in/go-playground/validator.v9/field_level.go b/vendor/gopkg.in/go-playground/validator.v9/field_level.go
deleted file mode 100644
index cbfbc15866..0000000000
--- a/vendor/gopkg.in/go-playground/validator.v9/field_level.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package validator
-
-import "reflect"
-
-// FieldLevel contains all the information and helper functions
-// to validate a field
-type FieldLevel interface {
-
- // returns the top level struct, if any
- Top() reflect.Value
-
- // returns the current fields parent struct, if any or
- // the comparison value if called 'VarWithValue'
- Parent() reflect.Value
-
- // returns current field for validation
- Field() reflect.Value
-
- // returns the field's name with the tag
- // name taking precedence over the fields actual name.
- FieldName() string
-
- // returns the struct field's name
- StructFieldName() string
-
- // returns param for validation against current field
- Param() string
-
- // ExtractType gets the actual underlying type of field value.
- // It will dive into pointers, customTypes and return you the
- // underlying value and it's kind.
- ExtractType(field reflect.Value) (value reflect.Value, kind reflect.Kind, nullable bool)
-
- // traverses the parent struct to retrieve a specific field denoted by the provided namespace
- // in the param and returns the field, field kind and whether is was successful in retrieving
- // the field at all.
- //
- // NOTE: when not successful ok will be false, this can happen when a nested struct is nil and so the field
- // could not be retrieved because it didn't exist.
- GetStructFieldOK() (reflect.Value, reflect.Kind, bool)
-}
-
-var _ FieldLevel = new(validate)
-
-// Field returns current field for validation
-func (v *validate) Field() reflect.Value {
- return v.flField
-}
-
-// FieldName returns the field's name with the tag
-// name takeing precedence over the fields actual name.
-func (v *validate) FieldName() string {
- return v.cf.altName
-}
-
-// StructFieldName returns the struct field's name
-func (v *validate) StructFieldName() string {
- return v.cf.name
-}
-
-// Param returns param for validation against current field
-func (v *validate) Param() string {
- return v.ct.param
-}
-
-// GetStructFieldOK returns Param returns param for validation against current field
-func (v *validate) GetStructFieldOK() (reflect.Value, reflect.Kind, bool) {
- return v.getStructFieldOKInternal(v.slflParent, v.ct.param)
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 4a8d44c084..88d4354e28 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -300,9 +300,10 @@ github.com/fsnotify/fsnotify
github.com/ghodss/yaml
# github.com/gin-contrib/sse v0.1.0
github.com/gin-contrib/sse
-# github.com/gin-gonic/gin v1.5.0
+# github.com/gin-gonic/gin v1.7.0
github.com/gin-gonic/gin
github.com/gin-gonic/gin/binding
+github.com/gin-gonic/gin/internal/bytesconv
github.com/gin-gonic/gin/internal/json
github.com/gin-gonic/gin/render
# github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2
@@ -316,11 +317,13 @@ github.com/go-logr/logr
# github.com/go-ole/go-ole v1.2.2
github.com/go-ole/go-ole
github.com/go-ole/go-ole/oleutil
-# github.com/go-playground/locales v0.12.1
+# github.com/go-playground/locales v0.13.0
github.com/go-playground/locales
github.com/go-playground/locales/currency
-# github.com/go-playground/universal-translator v0.16.0
+# github.com/go-playground/universal-translator v0.17.0
github.com/go-playground/universal-translator
+# github.com/go-playground/validator/v10 v10.4.1
+github.com/go-playground/validator/v10
# github.com/go-sql-driver/mysql v1.5.0
github.com/go-sql-driver/mysql
# github.com/go-yaml/yaml v2.1.0+incompatible
@@ -391,7 +394,7 @@ github.com/googollee/go-socket.io
github.com/gopherjs/gopherjs/js
# github.com/gorilla/mux v1.7.0
github.com/gorilla/mux
-# github.com/gorilla/websocket v1.4.0
+# github.com/gorilla/websocket v1.4.1
github.com/gorilla/websocket
# github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282
github.com/gosuri/uitable
@@ -447,7 +450,7 @@ github.com/konsorten/go-windows-terminal-sequences
github.com/kr/logfmt
# github.com/kr/pty v1.1.5
github.com/kr/pty
-# github.com/leodido/go-urn v1.1.0
+# github.com/leodido/go-urn v1.2.0
github.com/leodido/go-urn
# github.com/lestrrat-go/iter v0.0.0-20200422075355-fc1769541911
github.com/lestrrat-go/iter/arrayiter
@@ -488,7 +491,7 @@ github.com/libvirt/libvirt-go-xml
github.com/ma314smith/signedxml
# github.com/mattn/go-colorable v0.1.2
github.com/mattn/go-colorable
-# github.com/mattn/go-isatty v0.0.9
+# github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-isatty
# github.com/mattn/go-runewidth v0.0.4
github.com/mattn/go-runewidth
@@ -511,7 +514,7 @@ github.com/mholt/caddy
github.com/mholt/caddy/caddyfile
github.com/mholt/caddy/onevent/hook
github.com/mholt/caddy/startupshutdown
-# github.com/miekg/dns v1.1.4
+# github.com/miekg/dns v1.1.25
github.com/miekg/dns
# github.com/minio/minio-go v6.0.14+incompatible
github.com/minio/minio-go
@@ -748,6 +751,7 @@ golang.org/x/crypto/pkcs12
golang.org/x/crypto/pkcs12/internal/rc2
golang.org/x/crypto/poly1305
golang.org/x/crypto/scrypt
+golang.org/x/crypto/sha3
golang.org/x/crypto/ssh
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
golang.org/x/crypto/ssh/terminal
@@ -967,8 +971,6 @@ google.golang.org/protobuf/types/pluginpb
gopkg.in/asn1-ber.v1
# gopkg.in/fatih/set.v0 v0.2.1
gopkg.in/fatih/set.v0
-# gopkg.in/go-playground/validator.v9 v9.29.1
-gopkg.in/go-playground/validator.v9
# gopkg.in/inf.v0 v0.9.1
gopkg.in/inf.v0
# gopkg.in/ini.v1 v1.44.0