aboutsummaryrefslogtreecommitdiffstats
path: root/main.go (follow)
Commit message (Collapse)AuthorAgeFilesLines
* conn, device, tun: implement vectorized I/O plumbingJordan Whited2023-03-101-7/+7
| | | | | | | | | | | | | | | | | | | | Accept packet vectors for reading and writing in the tun.Device and conn.Bind interfaces, so that the internal plumbing between these interfaces now passes a vector of packets. Vectors move untouched between these interfaces, i.e. if 128 packets are received from conn.Bind.Read(), 128 packets are passed to tun.Device.Write(). There is no internal buffering. Currently, existing implementations are only adjusted to have vectors of length one. Subsequent patches will improve that. Also, as a related fixup, use the unix and windows packages rather than the syscall package when possible. Co-authored-by: James Tucker <james@tailscale.com> Signed-off-by: James Tucker <james@tailscale.com> Signed-off-by: Jordan Whited <jordan@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: bump copyright yearJason A. Donenfeld2023-02-071-1/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: bump copyright yearJason A. Donenfeld2022-09-201-1/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: apply gofumptJason A. Donenfeld2021-12-091-1/+0
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: remove old-style build tagsJason A. Donenfeld2021-10-121-1/+0
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: add new go 1.17 build commentsJason A. Donenfeld2021-09-051-0/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* main: print kernel warning on OpenBSD and FreeBSD tooJason A. Donenfeld2021-04-151-13/+16
| | | | | | More kernels! Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: make binds replacableJason A. Donenfeld2021-02-231-1/+2
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: bump copyrightJason A. Donenfeld2021-01-281-1/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* device: remove version stringJason A. Donenfeld2021-01-281-2/+2
| | | | | | This is what modules are for, and Go binaries can introspect. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* device: combine debug and info log levels into 'verbose'Jason A. Donenfeld2021-01-261-10/+7
| | | | | | | | | | | | There are very few cases, if any, in which a user only wants one of these levels, so combine it into a single level. While we're at it, reduce indirection on the loggers by using an empty function rather than a nil function pointer. It's not like we have retpolines anyway, and we were always calling through a function with a branch prior, so this seems like a net gain. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* device: change logging interface to use functionsJosh Bleecher Snyder2021-01-261-11/+10
| | | | | | | | | | | | | | | | | | | | | This commit overhauls wireguard-go's logging. The primary, motivating change is to use a function instead of a *log.Logger as the basic unit of logging. Using functions provides a lot more flexibility for people to bring their own logging system. It also introduces logging helper methods on Device. These reduce line noise at the call site. They also allow for log functions to be nil; when nil, instead of generating a log line and throwing it away, we don't bother generating it at all. This spares allocation and pointless work. This is a breaking change, although the fix required of clients is fairly straightforward. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
* main: now that we're upstreamed, relax Linux warningJason A. Donenfeld2020-05-021-12/+10
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: update header comments and modulesJason A. Donenfeld2020-05-021-1/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* main: simplify warningsJason A. Donenfeld2019-09-081-15/+1
|
* tun: remove TUN prefix from types to reduce stutter elsewhereMatt Layher2019-06-141-1/+1
| | | | Signed-off-by: Matt Layher <mdlayher@gmail.com>
* global: regroup all importsJason A. Donenfeld2019-05-141-3/+4
|
* main: revise warningsJason A. Donenfeld2019-04-191-25/+15
|
* global: begin modularizationJason A. Donenfeld2019-03-031-15/+17
|
* tun: use netpoll instead of rwcancelJason A. Donenfeld2019-02-271-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new sysconn function of Go 1.12 makes this possible: package main import "log" import "os" import "unsafe" import "time" import "syscall" import "sync" import "golang.org/x/sys/unix" func main() { fd, err := os.OpenFile("/dev/net/tun", os.O_RDWR, 0) if err != nil { log.Fatal(err) } var ifr [unix.IFNAMSIZ + 64]byte copy(ifr[:], []byte("cheese")) *(*uint16)(unsafe.Pointer(&ifr[unix.IFNAMSIZ])) = unix.IFF_TUN var errno syscall.Errno s, _ := fd.SyscallConn() s.Control(func(fd uintptr) { _, _, errno = unix.Syscall( unix.SYS_IOCTL, fd, uintptr(unix.TUNSETIFF), uintptr(unsafe.Pointer(&ifr[0])), ) }) if errno != 0 { log.Fatal(errno) } b := [4]byte{} wait := sync.WaitGroup{} wait.Add(1) go func() { _, err := fd.Read(b[:]) log.Print("Read errored: ", err) wait.Done() }() time.Sleep(time.Second) log.Print("Closing") err = fd.Close() if err != nil { log.Print("Close errored: " , err) } wait.Wait() log.Print("Exiting") }
* Change package pathJason A. Donenfeld2019-02-181-1/+1
|
* Import windows scafoldingJason A. Donenfeld2019-02-051-0/+2
|
* Update copyrightJason A. Donenfeld2019-02-051-2/+2
|
* global: fix up copyright headersJason A. Donenfeld2018-09-161-2/+1
|
* Print version number in logJason A. Donenfeld2018-05-301-0/+2
|
* Catch EINTRJason A. Donenfeld2018-05-241-1/+1
|
* Add undocumented --version flagJason A. Donenfeld2018-05-241-0/+5
|
* Adopt GOPATHJason A. Donenfeld2018-05-231-1/+1
| | | | | GOPATH is annoying, but the Go community pushing me to adopt it is even more annoying.
* Move tun to subpackageJason A. Donenfeld2018-05-231-3/+4
|
* Minor main.go signal fixesFilippo Valsorda2018-05-211-2/+3
| | | | | | | | * Buffer the signal channel as it's non-blocking on the sender side * Notify on SIGTERM instead of the uncatchable SIGKILL License: MIT Signed-off-by: Filippo Valsorda <valsorda@google.com>
* Add copyright headersMathias Hall-Andersen2018-05-191-0/+1
|
* Use /dev/null as place holderJason A. Donenfeld2018-05-141-0/+5
|
* Ugly hack to suppress warning on backgrounded processJason A. Donenfeld2018-05-141-0/+4
|
* Netlink sockets can't be shutdownJason A. Donenfeld2018-05-141-4/+0
|
* Clean moreJason A. Donenfeld2018-05-141-1/+1
|
* Optional logging even in backgroundJason A. Donenfeld2018-05-141-3/+10
|
* Rewrite timers and related state machinesJason A. Donenfeld2018-05-101-0/+15
|
* Removed remaining signals from peerMathias Hall-Andersen2018-05-051-15/+0
| | | | | | 1. Removed remaining signals from peer struct 2. Made needAnotherKeepalive local 3. Removed environment check from warning text (annoying when debugging)
* Removed old signalsMathias Hall-Andersen2018-05-051-1/+0
|
* uapi: use kqueue for sock deletion on darwinJason A. Donenfeld2018-05-041-0/+4
|
* tun: allow darwin to auto assign namesJason A. Donenfeld2018-05-041-7/+15
|
* warning: put into mainJason A. Donenfeld2018-05-041-4/+41
|
* global: Add SPDX tags and copyright headerJason A. Donenfeld2018-05-031-0/+5
| | | | Mathias should probably add his copyright headers to each file too.
* Daemonize with environment variableJason A. Donenfeld2018-05-031-6/+19
|
* Start to dust off DarwinJason A. Donenfeld2018-05-031-0/+2
|
* We can determine the interface name ourselvesJason A. Donenfeld2018-04-191-1/+1
|
* Align with go library layoutMathias Hall-Andersen2018-02-041-0/+196