aboutsummaryrefslogtreecommitdiffstats
path: root/tun
diff options
context:
space:
mode:
authorJordan Whited <jordan@tailscale.com>2023-02-08 10:42:07 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2023-02-09 12:35:58 -0300
commit1e2c3e5a3c1463cb8c7ec92d74aa739587b6642f (patch)
tree96be843d6d801bb65454abcfd8143283b009ad20 /tun
parentglobal: bump copyright year (diff)
downloadwireguard-go-1e2c3e5a3c1463cb8c7ec92d74aa739587b6642f.tar.xz
wireguard-go-1e2c3e5a3c1463cb8c7ec92d74aa739587b6642f.zip
tun: guard Device.Events() against chan writes
Signed-off-by: Jordan Whited <jordan@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun')
-rw-r--r--tun/netstack/tun.go2
-rw-r--r--tun/tun.go2
-rw-r--r--tun/tun_darwin.go2
-rw-r--r--tun/tun_freebsd.go2
-rw-r--r--tun/tun_linux.go2
-rw-r--r--tun/tun_openbsd.go2
-rw-r--r--tun/tun_windows.go2
-rw-r--r--tun/tuntest/tuntest.go8
8 files changed, 11 insertions, 11 deletions
diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go
index 25486a6..37c879d 100644
--- a/tun/netstack/tun.go
+++ b/tun/netstack/tun.go
@@ -109,7 +109,7 @@ func (tun *netTun) File() *os.File {
return nil
}
-func (tun *netTun) Events() chan tun.Event {
+func (tun *netTun) Events() <-chan tun.Event {
return tun.events
}
diff --git a/tun/tun.go b/tun/tun.go
index 7b26af0..01051b9 100644
--- a/tun/tun.go
+++ b/tun/tun.go
@@ -24,6 +24,6 @@ type Device interface {
Flush() error // flush all previous writes to the device
MTU() (int, error) // returns the MTU of the device
Name() (string, error) // fetches and returns the current name
- Events() chan Event // returns a constant channel of events related to the device
+ Events() <-chan Event // returns a constant channel of events related to the device
Close() error // stops the device and closes the event channel
}
diff --git a/tun/tun_darwin.go b/tun/tun_darwin.go
index a04bad4..7411a69 100644
--- a/tun/tun_darwin.go
+++ b/tun/tun_darwin.go
@@ -213,7 +213,7 @@ func (tun *NativeTun) File() *os.File {
return tun.tunFile
}
-func (tun *NativeTun) Events() chan Event {
+func (tun *NativeTun) Events() <-chan Event {
return tun.events
}
diff --git a/tun/tun_freebsd.go b/tun/tun_freebsd.go
index a8ebb34..42431aa 100644
--- a/tun/tun_freebsd.go
+++ b/tun/tun_freebsd.go
@@ -329,7 +329,7 @@ func (tun *NativeTun) File() *os.File {
return tun.tunFile
}
-func (tun *NativeTun) Events() chan Event {
+func (tun *NativeTun) Events() <-chan Event {
return tun.events
}
diff --git a/tun/tun_linux.go b/tun/tun_linux.go
index 6275399..25dbc07 100644
--- a/tun/tun_linux.go
+++ b/tun/tun_linux.go
@@ -376,7 +376,7 @@ func (tun *NativeTun) Read(buf []byte, offset int) (n int, err error) {
return
}
-func (tun *NativeTun) Events() chan Event {
+func (tun *NativeTun) Events() <-chan Event {
return tun.events
}
diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go
index ee8cf5a..e7fd79c 100644
--- a/tun/tun_openbsd.go
+++ b/tun/tun_openbsd.go
@@ -200,7 +200,7 @@ func (tun *NativeTun) File() *os.File {
return tun.tunFile
}
-func (tun *NativeTun) Events() chan Event {
+func (tun *NativeTun) Events() <-chan Event {
return tun.events
}
diff --git a/tun/tun_windows.go b/tun/tun_windows.go
index 751ad21..d5abb14 100644
--- a/tun/tun_windows.go
+++ b/tun/tun_windows.go
@@ -102,7 +102,7 @@ func (tun *NativeTun) File() *os.File {
return nil
}
-func (tun *NativeTun) Events() chan Event {
+func (tun *NativeTun) Events() <-chan Event {
return tun.events
}
diff --git a/tun/tuntest/tuntest.go b/tun/tuntest/tuntest.go
index 4e61df5..b143c76 100644
--- a/tun/tuntest/tuntest.go
+++ b/tun/tuntest/tuntest.go
@@ -138,10 +138,10 @@ func (t *chTun) Write(data []byte, offset int) (int, error) {
const DefaultMTU = 1420
-func (t *chTun) Flush() error { return nil }
-func (t *chTun) MTU() (int, error) { return DefaultMTU, nil }
-func (t *chTun) Name() (string, error) { return "loopbackTun1", nil }
-func (t *chTun) Events() chan tun.Event { return t.c.events }
+func (t *chTun) Flush() error { return nil }
+func (t *chTun) MTU() (int, error) { return DefaultMTU, nil }
+func (t *chTun) Name() (string, error) { return "loopbackTun1", nil }
+func (t *chTun) Events() <-chan tun.Event { return t.c.events }
func (t *chTun) Close() error {
t.Write(nil, -1)
return nil