misc: updated dependencies

This commit is contained in:
evilsocket 2019-01-17 19:59:37 +01:00
commit 34db9e5978
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
174 changed files with 32222 additions and 6989 deletions

View file

@ -21,6 +21,7 @@ func NewResponse(r *http.Request, contentType string, status int, body string) *
resp.Header = make(http.Header)
resp.Header.Add("Content-Type", contentType)
resp.StatusCode = status
resp.Status = http.StatusText(status)
buf := bytes.NewBufferString(body)
resp.ContentLength = int64(buf.Len())
resp.Body = ioutil.NopCloser(buf)

View file

@ -4,7 +4,7 @@ go:
os:
- linux
before_install:
- go get github.com/golang/lint/golint
- go get golang.org/x/lint/golint
- go get honnef.co/go/tools/cmd/staticcheck
- go get -d ./...
script:

View file

@ -110,9 +110,6 @@ func (o *Options) UnmarshalBinary(p []byte) error {
// n bytes: data
code := OptionCode(buf.Read16())
length := buf.Read16()
if length == 0 {
continue
}
// N bytes: option data
data := buf.Consume(int(length))

View file

@ -5,7 +5,7 @@ os:
- linux
- osx
before_install:
- go get github.com/golang/lint/golint
- go get golang.org/x/lint/golint
- go get honnef.co/go/tools/cmd/staticcheck
- go get -d -t ./...
script:

View file

@ -7,7 +7,6 @@ import (
"os"
"sync"
"sync/atomic"
"syscall"
"time"
"unsafe"
@ -44,12 +43,12 @@ type packetConn struct {
// socket is an interface which enables swapping out socket syscalls for
// testing.
type socket interface {
Bind(syscall.Sockaddr) error
Bind(unix.Sockaddr) error
Close() error
FD() int
GetSockopt(level, name int, v unsafe.Pointer, l uintptr) error
Recvfrom([]byte, int) (int, syscall.Sockaddr, error)
Sendto([]byte, int, syscall.Sockaddr) error
Recvfrom([]byte, int) (int, unix.Sockaddr, error)
Sendto([]byte, int, unix.Sockaddr) error
SetSockopt(level, name int, v unsafe.Pointer, l uint32) error
SetTimeout(time.Duration) error
}
@ -61,13 +60,13 @@ func listenPacket(ifi *net.Interface, proto uint16, cfg Config) (*packetConn, er
pbe := htons(proto)
// Enabling overriding the socket type via config.
typ := syscall.SOCK_RAW
typ := unix.SOCK_RAW
if cfg.LinuxSockDGRAM {
typ = syscall.SOCK_DGRAM
typ = unix.SOCK_DGRAM
}
// Open a packet socket using specified socket and protocol types.
sock, err := syscall.Socket(syscall.AF_PACKET, typ, int(pbe))
sock, err := unix.Socket(unix.AF_PACKET, typ, int(pbe))
if err != nil {
return nil, err
}
@ -92,7 +91,7 @@ func newPacketConn(ifi *net.Interface, s socket, pbe uint16) (*packetConn, error
// packet(7):
// Only the sll_protocol and the sll_ifindex address fields are used for
// purposes of binding.
err := s.Bind(&syscall.SockaddrLinklayer{
err := s.Bind(&unix.SockaddrLinklayer{
Protocol: pbe,
Ifindex: ifi.Index,
})
@ -114,9 +113,9 @@ func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
p.timeoutMu.Unlock()
var (
// Information returned by syscall.Recvfrom.
// Information returned by unix.Recvfrom.
n int
addr syscall.Sockaddr
addr unix.Sockaddr
err error
// Timeout for a single loop iteration.
@ -144,7 +143,7 @@ func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
switch err {
case nil:
// Got data, break this loop shortly.
case syscall.EAGAIN:
case unix.EAGAIN:
// Hit a timeout, keep looping.
continue
default:
@ -157,9 +156,9 @@ func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
}
// Retrieve hardware address and other information from addr.
sa, ok := addr.(*syscall.SockaddrLinklayer)
sa, ok := addr.(*unix.SockaddrLinklayer)
if !ok || sa.Halen < 6 {
return n, nil, syscall.EINVAL
return n, nil, unix.EINVAL
}
// Use length specified to convert byte array into a hardware address slice.
@ -181,7 +180,7 @@ func (p *packetConn) WriteTo(b []byte, addr net.Addr) (int, error) {
// Ensure correct Addr type.
a, ok := addr.(*Addr)
if !ok || a.HardwareAddr == nil || len(a.HardwareAddr) < 6 {
return 0, syscall.EINVAL
return 0, unix.EINVAL
}
// Convert hardware address back to byte array form.
@ -193,8 +192,8 @@ func (p *packetConn) WriteTo(b []byte, addr net.Addr) (int, error) {
// When you send packets it is enough to specify sll_family, sll_addr,
// sll_halen, sll_ifindex, and sll_protocol. The other fields should
// be 0.
// In this case, sll_family is taken care of automatically by syscall.
err := p.s.Sendto(b, 0, &syscall.SockaddrLinklayer{
// In this case, sll_family is taken care of automatically by unix.
err := p.s.Sendto(b, 0, &unix.SockaddrLinklayer{
Ifindex: p.ifi.Index,
Halen: uint8(len(a.HardwareAddr)),
Addr: baddr,
@ -235,14 +234,14 @@ func (p *packetConn) SetWriteDeadline(t time.Time) error {
// SetBPF attaches an assembled BPF program to a raw net.PacketConn.
func (p *packetConn) SetBPF(filter []bpf.RawInstruction) error {
prog := syscall.SockFprog{
prog := unix.SockFprog{
Len: uint16(len(filter)),
Filter: (*syscall.SockFilter)(unsafe.Pointer(&filter[0])),
Filter: (*unix.SockFilter)(unsafe.Pointer(&filter[0])),
}
err := p.s.SetSockopt(
syscall.SOL_SOCKET,
syscall.SO_ATTACH_FILTER,
unix.SOL_SOCKET,
unix.SO_ATTACH_FILTER,
unsafe.Pointer(&prog),
uint32(unsafe.Sizeof(prog)),
)
@ -309,26 +308,26 @@ type sysSocket struct {
// Method implementations simply invoke the syscall of the same name, but pass
// the file descriptor stored in the sysSocket as the socket to use.
func (s *sysSocket) Bind(sa syscall.Sockaddr) error { return syscall.Bind(s.fd, sa) }
func (s *sysSocket) Close() error { return syscall.Close(s.fd) }
func (s *sysSocket) FD() int { return s.fd }
func (s *sysSocket) Bind(sa unix.Sockaddr) error { return unix.Bind(s.fd, sa) }
func (s *sysSocket) Close() error { return unix.Close(s.fd) }
func (s *sysSocket) FD() int { return s.fd }
func (s *sysSocket) GetSockopt(level, name int, v unsafe.Pointer, l uintptr) error {
_, _, err := syscall.Syscall6(syscall.SYS_GETSOCKOPT, uintptr(s.fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(&l)), 0)
_, _, err := unix.Syscall6(unix.SYS_GETSOCKOPT, uintptr(s.fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(&l)), 0)
if err != 0 {
return syscall.Errno(err)
return unix.Errno(err)
}
return nil
}
func (s *sysSocket) Recvfrom(p []byte, flags int) (int, syscall.Sockaddr, error) {
return syscall.Recvfrom(s.fd, p, flags)
func (s *sysSocket) Recvfrom(p []byte, flags int) (int, unix.Sockaddr, error) {
return unix.Recvfrom(s.fd, p, flags)
}
func (s *sysSocket) Sendto(p []byte, flags int, to syscall.Sockaddr) error {
return syscall.Sendto(s.fd, p, flags, to)
func (s *sysSocket) Sendto(p []byte, flags int, to unix.Sockaddr) error {
return unix.Sendto(s.fd, p, flags, to)
}
func (s *sysSocket) SetSockopt(level, name int, v unsafe.Pointer, l uint32) error {
_, _, err := syscall.Syscall6(syscall.SYS_SETSOCKOPT, uintptr(s.fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0)
_, _, err := unix.Syscall6(unix.SYS_SETSOCKOPT, uintptr(s.fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0)
if err != 0 {
return syscall.Errno(err)
return unix.Errno(err)
}
return nil
}
@ -337,5 +336,5 @@ func (s *sysSocket) SetTimeout(timeout time.Duration) error {
if err != nil {
return err
}
return syscall.SetsockoptTimeval(s.fd, syscall.SOL_SOCKET, syscall.SO_RCVTIMEO, tv)
return unix.SetsockoptTimeval(s.fd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, tv)
}

View file

@ -1,19 +1,20 @@
// +build !darwin,!arm,!windows,!mipsle,!mips
// +build !darwin,!arm,!windows,!mipsle,!mips,!386
package raw
import (
"syscall"
"time"
"golang.org/x/sys/unix"
)
// newTimeval transforms a duration into a syscall.Timeval struct.
// newTimeval transforms a duration into a unix.Timeval struct.
// An error is returned in case of zero time value.
func newTimeval(timeout time.Duration) (*syscall.Timeval, error) {
func newTimeval(timeout time.Duration) (*unix.Timeval, error) {
if timeout < time.Microsecond {
return nil, &timeoutError{}
}
return &syscall.Timeval{
return &unix.Timeval{
Sec: int64(timeout / time.Second),
Usec: int64(timeout % time.Second / time.Microsecond),
}, nil

View file

@ -1,19 +1,20 @@
// +build arm mipsle mips
// +build arm mipsle mips 386
package raw
import (
"syscall"
"time"
"golang.org/x/sys/unix"
)
// newTimeval transforms a duration into a syscall.Timeval struct.
// newTimeval transforms a duration into a unix.Timeval struct.
// An error is returned in case of zero time value.
func newTimeval(timeout time.Duration) (*syscall.Timeval, error) {
func newTimeval(timeout time.Duration) (*unix.Timeval, error) {
if timeout < time.Microsecond {
return nil, &timeoutError{}
}
return &syscall.Timeval{
return &unix.Timeval{
Sec: int32(timeout / time.Second),
Usec: int32(timeout % time.Second / time.Microsecond),
}, nil

View file

@ -1,10 +1,14 @@
language: go
go_import_path: github.com/pkg/errors
go:
- 1.4.3
- 1.5.4
- 1.6.2
- 1.7.1
- 1.4.x
- 1.5.x
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- tip
script:

View file

@ -1,4 +1,4 @@
# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors)
# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge)
Package errors provides simple error handling primitives.
@ -47,6 +47,6 @@ We welcome pull requests, bug fixes and issue reports. With that said, the bar f
Before proposing a change, please discuss your change by raising an issue.
## Licence
## License
BSD-2-Clause

View file

@ -6,7 +6,7 @@
// return err
// }
//
// which applied recursively up the call stack results in error reports
// which when applied recursively up the call stack results in error reports
// without context or debugging information. The errors package allows
// programmers to add context to the failure path in their code in a way
// that does not destroy the original value of the error.
@ -15,16 +15,17 @@
//
// The errors.Wrap function returns a new error that adds context to the
// original error by recording a stack trace at the point Wrap is called,
// and the supplied message. For example
// together with the supplied message. For example
//
// _, err := ioutil.ReadAll(r)
// if err != nil {
// return errors.Wrap(err, "read failed")
// }
//
// If additional control is required the errors.WithStack and errors.WithMessage
// functions destructure errors.Wrap into its component operations of annotating
// an error with a stack trace and an a message, respectively.
// If additional control is required, the errors.WithStack and
// errors.WithMessage functions destructure errors.Wrap into its component
// operations: annotating an error with a stack trace and with a message,
// respectively.
//
// Retrieving the cause of an error
//
@ -38,7 +39,7 @@
// }
//
// can be inspected by errors.Cause. errors.Cause will recursively retrieve
// the topmost error which does not implement causer, which is assumed to be
// the topmost error that does not implement causer, which is assumed to be
// the original cause. For example:
//
// switch err := errors.Cause(err).(type) {
@ -48,16 +49,16 @@
// // unknown error
// }
//
// causer interface is not exported by this package, but is considered a part
// of stable public API.
// Although the causer interface is not exported by this package, it is
// considered a part of its stable public interface.
//
// Formatted printing of errors
//
// All error values returned from this package implement fmt.Formatter and can
// be formatted by the fmt package. The following verbs are supported
// be formatted by the fmt package. The following verbs are supported:
//
// %s print the error. If the error has a Cause it will be
// printed recursively
// printed recursively.
// %v see %s
// %+v extended format. Each Frame of the error's StackTrace will
// be printed in detail.
@ -65,13 +66,13 @@
// Retrieving the stack trace of an error or wrapper
//
// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are
// invoked. This information can be retrieved with the following interface.
// invoked. This information can be retrieved with the following interface:
//
// type stackTracer interface {
// StackTrace() errors.StackTrace
// }
//
// Where errors.StackTrace is defined as
// The returned errors.StackTrace type is defined as
//
// type StackTrace []Frame
//
@ -85,8 +86,8 @@
// }
// }
//
// stackTracer interface is not exported by this package, but is considered a part
// of stable public API.
// Although the stackTracer interface is not exported by this package, it is
// considered a part of its stable public interface.
//
// See the documentation for Frame.Format for more details.
package errors
@ -192,7 +193,7 @@ func Wrap(err error, message string) error {
}
// Wrapf returns an error annotating err with a stack trace
// at the point Wrapf is call, and the format specifier.
// at the point Wrapf is called, and the format specifier.
// If err is nil, Wrapf returns nil.
func Wrapf(err error, format string, args ...interface{}) error {
if err == nil {
@ -220,6 +221,18 @@ func WithMessage(err error, message string) error {
}
}
// WithMessagef annotates err with the format specifier.
// If err is nil, WithMessagef returns nil.
func WithMessagef(err error, format string, args ...interface{}) error {
if err == nil {
return nil
}
return &withMessage{
cause: err,
msg: fmt.Sprintf(format, args...),
}
}
type withMessage struct {
cause error
msg string

View file

@ -46,7 +46,8 @@ func (f Frame) line() int {
//
// Format accepts flags that alter the printing of some verbs, as follows:
//
// %+s path of source file relative to the compile time GOPATH
// %+s function name and path of source file relative to the compile time
// GOPATH separated by \n\t (<funcname>\n\t<path>)
// %+v equivalent to %+s:%d
func (f Frame) Format(s fmt.State, verb rune) {
switch verb {
@ -79,6 +80,14 @@ func (f Frame) Format(s fmt.State, verb rune) {
// StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
type StackTrace []Frame
// Format formats the stack of Frames according to the fmt.Formatter interface.
//
// %s lists source files for each Frame in the stack
// %v lists the source file and line number for each Frame in the stack
//
// Format accepts flags that alter the printing of some verbs, as follows:
//
// %+v Prints filename, function, and line number for each Frame in the stack.
func (st StackTrace) Format(s fmt.State, verb rune) {
switch verb {
case 'v':
@ -136,43 +145,3 @@ func funcname(name string) string {
i = strings.Index(name, ".")
return name[i+1:]
}
func trimGOPATH(name, file string) string {
// Here we want to get the source file path relative to the compile time
// GOPATH. As of Go 1.6.x there is no direct way to know the compiled
// GOPATH at runtime, but we can infer the number of path segments in the
// GOPATH. We note that fn.Name() returns the function name qualified by
// the import path, which does not include the GOPATH. Thus we can trim
// segments from the beginning of the file path until the number of path
// separators remaining is one more than the number of path separators in
// the function name. For example, given:
//
// GOPATH /home/user
// file /home/user/src/pkg/sub/file.go
// fn.Name() pkg/sub.Type.Method
//
// We want to produce:
//
// pkg/sub/file.go
//
// From this we can easily see that fn.Name() has one less path separator
// than our desired output. We count separators from the end of the file
// path until it finds two more than in the function name and then move
// one character forward to preserve the initial path segment without a
// leading separator.
const sep = "/"
goal := strings.Count(name, sep) + 2
i := len(file)
for n := 0; n < goal; n++ {
i = strings.LastIndex(file[:i], sep)
if i == -1 {
// not enough separators found, set i so that the slice expression
// below leaves file unmodified
i = -len(sep)
break
}
}
// get back to 0 or trim the leading separator
file = file[i+len(sep):]
return file
}