mirror of
https://github.com/bettercap/bettercap
synced 2025-07-12 08:07:00 -07:00
misc: updated dependencies
This commit is contained in:
parent
56922c9be6
commit
5cc9db802c
31 changed files with 367 additions and 179 deletions
28
Gopkg.lock
generated
28
Gopkg.lock
generated
|
@ -83,7 +83,7 @@
|
|||
revision = "2ce16c963a8ac5bd6af851d4877e38701346983f"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:cbae049ade5f135f52da4cc6e3fd6aca532dffbde65160ad1510dee6c3e8dc4f"
|
||||
digest = "1:a5fab5a807cac4da733996f46b917283fe43aac5fd32798a3c9279a44eb5156c"
|
||||
name = "github.com/evilsocket/islazy"
|
||||
packages = [
|
||||
"data",
|
||||
|
@ -96,8 +96,8 @@
|
|||
"zip",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "949884336bbf7e535e4e0e6a3f75af89091488e5"
|
||||
version = "v1.10.1"
|
||||
revision = "e6f5e33089826f0d17eaab3c8c3603048d615a0e"
|
||||
version = "v1.10.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -193,20 +193,20 @@
|
|||
version = "v0.9.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:0f96ec4151a24d7bfd4298fc13cc320a000e31b4e5431cf88e3ffc961db846fd"
|
||||
digest = "1:2fa7b0155cd54479a755c629de26f888a918e13f8857a2c442205d825368e084"
|
||||
name = "github.com/mattn/go-colorable"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "efa589957cd060542a26d2dd7832fd6a6c6c3ade"
|
||||
version = "v0.1.0"
|
||||
revision = "3a70a971f94a22f2fa562ffcc7a0eb45f5daf045"
|
||||
version = "v0.1.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
|
||||
digest = "1:3bb9c8451d199650bfd303e0068d86f135952fead374ad87c09a9b8a2cc4bd7c"
|
||||
name = "github.com/mattn/go-isatty"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
|
||||
version = "v0.0.4"
|
||||
revision = "369ecd8cea9851e459abb67eb171853e3986591e"
|
||||
version = "v0.0.6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -222,11 +222,11 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:34fe44dd2bbe5723068e0a7a266847965a88297d383fe611e0358e556d82de09"
|
||||
digest = "1:7b8a07084a265123ced4a06172044402febe04f9f7d39d7269901d556cbd769e"
|
||||
name = "github.com/mdlayher/raw"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "480b93709cce56651807d3fdeb260a5a7c4e2d5f"
|
||||
revision = "81144197cf93eb7382abd04a6a15154cfce2e65c"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -282,15 +282,15 @@
|
|||
name = "golang.org/x/net"
|
||||
packages = ["bpf"]
|
||||
pruneopts = "UT"
|
||||
revision = "3a22650c66bd7f4fb6d1e8072ffd7b75c8a27898"
|
||||
revision = "16b79f2e4e95ea23b2bf9903c9809ff7b013ce85"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:7a8067e267a25694dd7bdde6e5016053a3f61bb7141448bf8e0025a84eb7d11c"
|
||||
digest = "1:a2bc6cb1f4e1d0b512e1d47d392ead580006b5bdade6ffde16271759fe609b34"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix"]
|
||||
pruneopts = "UT"
|
||||
revision = "a9d3bda3a223baa6bba6ef412cb273f0fd163c05"
|
||||
revision = "b6889370fb1098ed892bd3400d189bb6a3355813"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e"
|
||||
|
|
21
vendor/github.com/evilsocket/islazy/tui/table.go
generated
vendored
21
vendor/github.com/evilsocket/islazy/tui/table.go
generated
vendored
|
@ -99,20 +99,23 @@ func lineSeparator(num int, columns []string, rows [][]string) string {
|
|||
// and prints on the writer an ASCII based datagrid of such
|
||||
// data.
|
||||
func Table(w io.Writer, columns []string, rows [][]string) {
|
||||
headers := make([]string, len(columns))
|
||||
for i, col := range columns {
|
||||
columns[i] = fmt.Sprintf(" %s", col)
|
||||
headers[i] = fmt.Sprintf(" %s", col)
|
||||
}
|
||||
|
||||
cells := make([][]string, len(rows))
|
||||
for i, row := range rows {
|
||||
cells[i] = make([]string, len(row))
|
||||
for j, cell := range row {
|
||||
rows[i][j] = fmt.Sprintf(" %s", cell)
|
||||
cells[i][j] = fmt.Sprintf(" %s", cell)
|
||||
}
|
||||
}
|
||||
|
||||
colPaddings := make([]int, 0)
|
||||
for colIndex, colHeader := range columns {
|
||||
for colIndex, colHeader := range headers {
|
||||
column := []string{colHeader}
|
||||
for _, row := range rows {
|
||||
for _, row := range cells {
|
||||
column = append(column, row[colIndex])
|
||||
}
|
||||
mLen := maxLen(column)
|
||||
|
@ -122,16 +125,16 @@ func Table(w io.Writer, columns []string, rows [][]string) {
|
|||
table := "\n"
|
||||
|
||||
// header
|
||||
table += fmt.Sprintf("%s\n", lineSeparator(0, columns, rows))
|
||||
for colIndex, colHeader := range columns {
|
||||
table += fmt.Sprintf("%s\n", lineSeparator(0, headers, cells))
|
||||
for colIndex, colHeader := range headers {
|
||||
table += fmt.Sprintf("│%s", padded(colHeader, colPaddings[colIndex], alignCenter))
|
||||
}
|
||||
table += fmt.Sprintf("│\n")
|
||||
|
||||
table += fmt.Sprintf("%s\n", lineSeparator(1, columns, rows))
|
||||
table += fmt.Sprintf("%s\n", lineSeparator(1, headers, cells))
|
||||
|
||||
// rows
|
||||
for _, row := range rows {
|
||||
for _, row := range cells {
|
||||
for colIndex, cell := range row {
|
||||
table += fmt.Sprintf("│%s", padded(cell, colPaddings[colIndex], alignLeft))
|
||||
}
|
||||
|
@ -139,7 +142,7 @@ func Table(w io.Writer, columns []string, rows [][]string) {
|
|||
}
|
||||
|
||||
// footer
|
||||
table += fmt.Sprintf("%s\n", lineSeparator(2, columns, rows))
|
||||
table += fmt.Sprintf("%s\n", lineSeparator(2, headers, cells))
|
||||
|
||||
fmt.Fprintf(w, "%s", table)
|
||||
}
|
||||
|
|
3
vendor/github.com/mattn/go-colorable/go.mod
generated
vendored
Normal file
3
vendor/github.com/mattn/go-colorable/go.mod
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
module github.com/mattn/go-colorable
|
||||
|
||||
require github.com/mattn/go-isatty v0.0.5
|
4
vendor/github.com/mattn/go-colorable/go.sum
generated
vendored
Normal file
4
vendor/github.com/mattn/go-colorable/go.sum
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
3
vendor/github.com/mattn/go-isatty/go.mod
generated
vendored
Normal file
3
vendor/github.com/mattn/go-isatty/go.mod
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
module github.com/mattn/go-isatty
|
||||
|
||||
require golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
|
2
vendor/github.com/mattn/go-isatty/go.sum
generated
vendored
Normal file
2
vendor/github.com/mattn/go-isatty/go.sum
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
@ -1,12 +1,10 @@
|
|||
// +build linux
|
||||
// +build ppc64 ppc64le
|
||||
// +build android
|
||||
|
||||
package isatty
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
syscall "golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const ioctlReadTermios = syscall.TCGETS
|
15
vendor/github.com/mattn/go-isatty/isatty_appengine.go
generated
vendored
15
vendor/github.com/mattn/go-isatty/isatty_appengine.go
generated
vendored
|
@ -1,15 +0,0 @@
|
|||
// +build appengine
|
||||
|
||||
package isatty
|
||||
|
||||
// IsTerminal returns true if the file descriptor is terminal which
|
||||
// is always false on on appengine classic which is a sandboxed PaaS.
|
||||
func IsTerminal(fd uintptr) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
6
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
6
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
|
@ -16,3 +16,9 @@ func IsTerminal(fd uintptr) bool {
|
|||
_, _, 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
|
||||
}
|
||||
|
|
21
vendor/github.com/mattn/go-isatty/isatty_linux.go
generated
vendored
21
vendor/github.com/mattn/go-isatty/isatty_linux.go
generated
vendored
|
@ -1,18 +1,19 @@
|
|||
// +build linux
|
||||
// +build !appengine,!ppc64,!ppc64le
|
||||
// +build !appengine
|
||||
// +build !android
|
||||
|
||||
package isatty
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const ioctlReadTermios = syscall.TCGETS
|
||||
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.TCGETS)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
11
vendor/github.com/mattn/go-isatty/isatty_others.go
generated
vendored
11
vendor/github.com/mattn/go-isatty/isatty_others.go
generated
vendored
|
@ -1,9 +1,14 @@
|
|||
// +build !windows
|
||||
// +build !appengine
|
||||
// +build appengine js
|
||||
|
||||
package isatty
|
||||
|
||||
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||
// IsTerminal returns true if the file descriptor is terminal which
|
||||
// is always false on js and appengine classic which is a sandboxed PaaS.
|
||||
func IsTerminal(fd uintptr) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
6
vendor/github.com/mattn/go-isatty/isatty_solaris.go
generated
vendored
6
vendor/github.com/mattn/go-isatty/isatty_solaris.go
generated
vendored
|
@ -14,3 +14,9 @@ func IsTerminal(fd uintptr) bool {
|
|||
err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
30
vendor/github.com/mdlayher/raw/raw.go
generated
vendored
30
vendor/github.com/mdlayher/raw/raw.go
generated
vendored
|
@ -10,12 +10,6 @@ import (
|
|||
"golang.org/x/net/bpf"
|
||||
)
|
||||
|
||||
const (
|
||||
// Maximum read timeout per syscall.
|
||||
// It is required because read/recvfrom won't be interrupted on closing of the file descriptor.
|
||||
readTimeout = 200 * time.Millisecond
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrNotImplemented is returned when certain functionality is not yet
|
||||
// implemented for the host operating system.
|
||||
|
@ -149,17 +143,6 @@ type Config struct {
|
|||
// Has no effect on other operating systems.
|
||||
LinuxSockDGRAM bool
|
||||
|
||||
// Experimental: Linux only (for now, but can be ported to BSD):
|
||||
// disables repeated socket reads due to internal timeouts, at the expense
|
||||
// of losing the ability to cancel a ReadFrom operation by calling the Close
|
||||
// method of the net.PacketConn.
|
||||
//
|
||||
// Not recommended for programs which may need to open and close multiple
|
||||
// sockets during program runs. This may save some CPU time by avoiding a
|
||||
// busy loop for programs which do not need timeouts, or programs which keep
|
||||
// a single socket open for the entire duration of the program.
|
||||
NoTimeouts bool
|
||||
|
||||
// Linux only: do not accumulate packet socket statistic counters. Packet
|
||||
// socket statistics are reset on each call to retrieve them via getsockopt,
|
||||
// but this package's default behavior is to continue accumulating the
|
||||
|
@ -167,16 +150,3 @@ type Config struct {
|
|||
// resetting statistics on each call to Stats, set this value to true.
|
||||
NoCumulativeStats bool
|
||||
}
|
||||
|
||||
// Copyright (c) 2012 The Go Authors. All rights reserved.
|
||||
// Source code in this file is based on src/net/interface_linux.go,
|
||||
// from the Go standard library. The Go license can be found here:
|
||||
// https://golang.org/LICENSE.
|
||||
|
||||
// Taken from:
|
||||
// https://github.com/golang/go/blob/master/src/net/net.go#L417-L421.
|
||||
type timeoutError struct{}
|
||||
|
||||
func (e *timeoutError) Error() string { return "i/o timeout" }
|
||||
func (e *timeoutError) Timeout() bool { return true }
|
||||
func (e *timeoutError) Temporary() bool { return true }
|
||||
|
|
197
vendor/github.com/mdlayher/raw/raw_linux.go
generated
vendored
197
vendor/github.com/mdlayher/raw/raw_linux.go
generated
vendored
|
@ -5,8 +5,8 @@ package raw
|
|||
import (
|
||||
"net"
|
||||
"os"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
|
@ -26,18 +26,11 @@ type packetConn struct {
|
|||
s socket
|
||||
pbe uint16
|
||||
|
||||
// Should timeouts be set at all?
|
||||
noTimeouts bool
|
||||
|
||||
// Should stats be accumulated instead of reset on each call?
|
||||
noCumulativeStats bool
|
||||
|
||||
// Internal storage for cumulative stats.
|
||||
stats Stats
|
||||
|
||||
// Timeouts set via Set{Read,}Deadline, guarded by mutex.
|
||||
timeoutMu sync.RWMutex
|
||||
rtimeout time.Time
|
||||
}
|
||||
|
||||
// socket is an interface which enables swapping out socket syscalls for
|
||||
|
@ -45,12 +38,13 @@ type packetConn struct {
|
|||
type socket interface {
|
||||
Bind(unix.Sockaddr) error
|
||||
Close() error
|
||||
FD() int
|
||||
GetSockopt(level, name int, v unsafe.Pointer, l uintptr) 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
|
||||
SetDeadline(time.Time) error
|
||||
SetReadDeadline(time.Time) error
|
||||
SetWriteDeadline(time.Time) error
|
||||
}
|
||||
|
||||
// htons converts a short (uint16) from host-to-network byte order.
|
||||
|
@ -66,9 +60,11 @@ func listenPacket(ifi *net.Interface, proto uint16, cfg Config) (*packetConn, er
|
|||
// Convert proto to big endian.
|
||||
pbe := htons(proto)
|
||||
|
||||
filename := "eth-packet-socket"
|
||||
// Enabling overriding the socket type via config.
|
||||
typ := unix.SOCK_RAW
|
||||
if cfg.LinuxSockDGRAM {
|
||||
filename = "packet-socket"
|
||||
typ = unix.SOCK_DGRAM
|
||||
}
|
||||
|
||||
|
@ -78,13 +74,28 @@ func listenPacket(ifi *net.Interface, proto uint16, cfg Config) (*packetConn, er
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Wrap raw socket in socket interface.
|
||||
pc, err := newPacketConn(ifi, &sysSocket{fd: sock}, pbe)
|
||||
if err := unix.SetNonblock(sock, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// When using Go 1.12+, the SetNonblock call we just did puts the file
|
||||
// descriptor into non-blocking mode. In that case, os.NewFile
|
||||
// registers the file descriptor with the runtime poller, which is then
|
||||
// used for all subsequent operations.
|
||||
//
|
||||
// See also: https://golang.org/pkg/os/#NewFile
|
||||
f := os.NewFile(uintptr(sock), filename)
|
||||
sc, err := f.SyscallConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Wrap raw socket in socket interface.
|
||||
pc, err := newPacketConn(ifi, &sysSocket{f: f, rc: sc}, pbe)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pc.noTimeouts = cfg.NoTimeouts
|
||||
pc.noCumulativeStats = cfg.NoCumulativeStats
|
||||
return pc, nil
|
||||
}
|
||||
|
@ -115,53 +126,12 @@ func newPacketConn(ifi *net.Interface, s socket, pbe uint16) (*packetConn, error
|
|||
|
||||
// ReadFrom implements the net.PacketConn.ReadFrom method.
|
||||
func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
||||
p.timeoutMu.Lock()
|
||||
deadline := p.rtimeout
|
||||
p.timeoutMu.Unlock()
|
||||
|
||||
var (
|
||||
// Information returned by unix.Recvfrom.
|
||||
n int
|
||||
addr unix.Sockaddr
|
||||
err error
|
||||
|
||||
// Timeout for a single loop iteration.
|
||||
timeout = readTimeout
|
||||
)
|
||||
|
||||
for {
|
||||
if !deadline.IsZero() {
|
||||
timeout = time.Until(deadline)
|
||||
if timeout > readTimeout {
|
||||
timeout = readTimeout
|
||||
}
|
||||
}
|
||||
|
||||
// Set a timeout for this iteration if configured to do so.
|
||||
if !p.noTimeouts {
|
||||
if err := p.s.SetTimeout(timeout); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to receive on socket
|
||||
// The recvfrom sycall will NOT be interrupted by closing of the socket
|
||||
n, addr, err = p.s.Recvfrom(b, 0)
|
||||
switch err {
|
||||
case nil:
|
||||
// Got data, break this loop shortly.
|
||||
case unix.EAGAIN:
|
||||
// Hit a timeout, keep looping.
|
||||
continue
|
||||
default:
|
||||
// Return on any other error.
|
||||
n, addr, err := p.s.Recvfrom(b, 0)
|
||||
if err != nil {
|
||||
return n, nil, err
|
||||
}
|
||||
|
||||
// Got data, exit the loop.
|
||||
break
|
||||
}
|
||||
|
||||
// Retrieve hardware address and other information from addr.
|
||||
sa, ok := addr.(*unix.SockaddrLinklayer)
|
||||
if !ok || sa.Halen < 6 {
|
||||
|
@ -223,20 +193,17 @@ func (p *packetConn) LocalAddr() net.Addr {
|
|||
|
||||
// SetDeadline implements the net.PacketConn.SetDeadline method.
|
||||
func (p *packetConn) SetDeadline(t time.Time) error {
|
||||
return p.SetReadDeadline(t)
|
||||
return p.s.SetDeadline(t)
|
||||
}
|
||||
|
||||
// SetReadDeadline implements the net.PacketConn.SetReadDeadline method.
|
||||
func (p *packetConn) SetReadDeadline(t time.Time) error {
|
||||
p.timeoutMu.Lock()
|
||||
p.rtimeout = t
|
||||
p.timeoutMu.Unlock()
|
||||
return nil
|
||||
return p.s.SetReadDeadline(t)
|
||||
}
|
||||
|
||||
// SetWriteDeadline implements the net.PacketConn.SetWriteDeadline method.
|
||||
func (p *packetConn) SetWriteDeadline(t time.Time) error {
|
||||
return nil
|
||||
return p.s.SetWriteDeadline(t)
|
||||
}
|
||||
|
||||
// SetBPF attaches an assembled BPF program to a raw net.PacketConn.
|
||||
|
@ -255,7 +222,6 @@ func (p *packetConn) SetBPF(filter []bpf.RawInstruction) error {
|
|||
if err != nil {
|
||||
return os.NewSyscallError("setsockopt", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -310,38 +276,91 @@ func (p *packetConn) handleStats(s unix.TpacketStats) *Stats {
|
|||
// sysSocket is the default socket implementation. It makes use of
|
||||
// Linux-specific system calls to handle raw socket functionality.
|
||||
type sysSocket struct {
|
||||
fd int
|
||||
f *os.File
|
||||
rc syscall.RawConn
|
||||
}
|
||||
|
||||
// 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 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 := unix.Syscall6(unix.SYS_GETSOCKOPT, uintptr(s.fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(&l)), 0)
|
||||
if err != 0 {
|
||||
return unix.Errno(err)
|
||||
func (s *sysSocket) SetDeadline(t time.Time) error {
|
||||
return s.f.SetDeadline(t)
|
||||
}
|
||||
return nil
|
||||
|
||||
func (s *sysSocket) SetReadDeadline(t time.Time) error {
|
||||
return s.f.SetReadDeadline(t)
|
||||
}
|
||||
func (s *sysSocket) Recvfrom(p []byte, flags int) (int, unix.Sockaddr, error) {
|
||||
return unix.Recvfrom(s.fd, p, flags)
|
||||
|
||||
func (s *sysSocket) SetWriteDeadline(t time.Time) error {
|
||||
return s.f.SetWriteDeadline(t)
|
||||
}
|
||||
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 := unix.Syscall6(unix.SYS_SETSOCKOPT, uintptr(s.fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0)
|
||||
if err != 0 {
|
||||
return unix.Errno(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *sysSocket) SetTimeout(timeout time.Duration) error {
|
||||
tv, err := newTimeval(timeout)
|
||||
|
||||
func (s *sysSocket) Bind(sa unix.Sockaddr) error {
|
||||
var err error
|
||||
cerr := s.rc.Control(func(fd uintptr) {
|
||||
err = unix.Bind(int(fd), sa)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return unix.SetsockoptTimeval(s.fd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, tv)
|
||||
return cerr
|
||||
}
|
||||
|
||||
func (s *sysSocket) Close() error {
|
||||
return s.f.Close()
|
||||
}
|
||||
|
||||
func (s *sysSocket) GetSockopt(level, name int, v unsafe.Pointer, l uintptr) error {
|
||||
var err error
|
||||
cerr := s.rc.Control(func(fd uintptr) {
|
||||
_, _, errno := unix.Syscall6(unix.SYS_GETSOCKOPT, fd, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(&l)), 0)
|
||||
if errno != 0 {
|
||||
err = os.NewSyscallError("getsockopt", errno)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cerr
|
||||
}
|
||||
|
||||
func (s *sysSocket) Recvfrom(p []byte, flags int) (n int, addr unix.Sockaddr, err error) {
|
||||
cerr := s.rc.Read(func(fd uintptr) bool {
|
||||
n, addr, err = unix.Recvfrom(int(fd), p, flags)
|
||||
// When the socket is in non-blocking mode, we might see EAGAIN
|
||||
// and end up here. In that case, return false to let the
|
||||
// poller wait for readiness. See the source code for
|
||||
// internal/poll.FD.RawRead for more details.
|
||||
//
|
||||
// If the socket is in blocking mode, EAGAIN should never occur.
|
||||
return err != unix.EAGAIN
|
||||
})
|
||||
if err != nil {
|
||||
return n, addr, err
|
||||
}
|
||||
return n, addr, cerr
|
||||
}
|
||||
|
||||
func (s *sysSocket) Sendto(p []byte, flags int, to unix.Sockaddr) error {
|
||||
var err error
|
||||
cerr := s.rc.Write(func(fd uintptr) bool {
|
||||
err = unix.Sendto(int(fd), p, flags, to)
|
||||
// See comment in Recvfrom.
|
||||
return err != unix.EAGAIN
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cerr
|
||||
}
|
||||
|
||||
func (s *sysSocket) SetSockopt(level, name int, v unsafe.Pointer, l uint32) error {
|
||||
var err error
|
||||
cerr := s.rc.Control(func(fd uintptr) {
|
||||
_, _, errno := unix.Syscall6(unix.SYS_SETSOCKOPT, fd, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0)
|
||||
if errno != 0 {
|
||||
err = os.NewSyscallError("setsockopt", errno)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cerr
|
||||
}
|
||||
|
|
26
vendor/github.com/mdlayher/raw/timeout_bsd.go
generated
vendored
Normal file
26
vendor/github.com/mdlayher/raw/timeout_bsd.go
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
package raw
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// Maximum read timeout per syscall.
|
||||
// It is required because read/recvfrom won't be interrupted on closing of the file descriptor.
|
||||
readTimeout = 200 * time.Millisecond
|
||||
)
|
||||
|
||||
// Copyright (c) 2012 The Go Authors. All rights reserved.
|
||||
// Source code in this file is based on src/net/interface_linux.go,
|
||||
// from the Go standard library. The Go license can be found here:
|
||||
// https://golang.org/LICENSE.
|
||||
|
||||
// Taken from:
|
||||
// https://github.com/golang/go/blob/master/src/net/net.go#L417-L421.
|
||||
type timeoutError struct{}
|
||||
|
||||
func (e *timeoutError) Error() string { return "i/o timeout" }
|
||||
func (e *timeoutError) Timeout() bool { return true }
|
||||
func (e *timeoutError) Temporary() bool { return true }
|
2
vendor/github.com/mdlayher/raw/timeval.go
generated
vendored
2
vendor/github.com/mdlayher/raw/timeval.go
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
// +build !darwin,!arm,!windows,!mipsle,!mips,!386
|
||||
// +build !darwin,!arm,!windows,!mipsle,!mips,!386,!linux
|
||||
|
||||
package raw
|
||||
|
||||
|
|
1
vendor/github.com/mdlayher/raw/timeval32.go
generated
vendored
1
vendor/github.com/mdlayher/raw/timeval32.go
generated
vendored
|
@ -1,4 +1,5 @@
|
|||
// +build arm mipsle mips 386
|
||||
// +build !linux
|
||||
|
||||
package raw
|
||||
|
||||
|
|
4
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
4
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
|
@ -25,8 +25,8 @@ func cmsgAlignOf(salen int) int {
|
|||
if SizeofPtr == 8 {
|
||||
salign = 4
|
||||
}
|
||||
case "openbsd":
|
||||
// OpenBSD armv7 requires 64-bit alignment.
|
||||
case "netbsd", "openbsd":
|
||||
// NetBSD and OpenBSD armv7 require 64-bit alignment.
|
||||
if runtime.GOARCH == "arm" {
|
||||
salign = 8
|
||||
}
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_386.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_386.go
generated
vendored
|
@ -575,6 +575,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -640,6 +641,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x8
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
generated
vendored
|
@ -576,6 +576,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -641,6 +642,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
generated
vendored
|
@ -579,6 +579,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -644,6 +645,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x8
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
generated
vendored
|
@ -577,6 +577,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -642,6 +643,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_mips.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_mips.go
generated
vendored
|
@ -578,6 +578,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -643,6 +644,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x8
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
generated
vendored
|
@ -577,6 +577,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -642,6 +643,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
generated
vendored
|
@ -577,6 +577,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -642,6 +643,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go
generated
vendored
|
@ -578,6 +578,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -643,6 +644,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x8
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
generated
vendored
|
@ -578,6 +578,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -643,6 +644,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
generated
vendored
|
@ -578,6 +578,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -643,6 +644,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go
generated
vendored
|
@ -577,6 +577,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -642,6 +643,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
generated
vendored
|
@ -576,6 +576,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -641,6 +642,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
12
vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
generated
vendored
12
vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
generated
vendored
|
@ -580,6 +580,7 @@ const (
|
|||
SizeofIfAddrmsg = 0x8
|
||||
SizeofRtMsg = 0xc
|
||||
SizeofRtNexthop = 0x8
|
||||
SizeofNdUseroptmsg = 0x10
|
||||
)
|
||||
|
||||
type NlMsghdr struct {
|
||||
|
@ -645,6 +646,17 @@ type RtNexthop struct {
|
|||
Ifindex int32
|
||||
}
|
||||
|
||||
type NdUseroptmsg struct {
|
||||
Family uint8
|
||||
Pad1 uint8
|
||||
Opts_len uint16
|
||||
Ifindex int32
|
||||
Icmp_type uint8
|
||||
Icmp_code uint8
|
||||
Pad2 uint16
|
||||
Pad3 uint32
|
||||
}
|
||||
|
||||
const (
|
||||
SizeofSockFilter = 0x8
|
||||
SizeofSockFprog = 0x10
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue