[PATCH 6/7] tun_darwin: adapt to TUNDevice interface change
Simon Ruderich
simon at ruderich.org
Sun Dec 31 17:16:53 CET 2017
Broken in 996c7c4 ("Removed IFF_NO_PI from TUN linux", 2017-12-04).
Untested!
---
src/tun_darwin.go | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/tun_darwin.go b/src/tun_darwin.go
index 87f6af6..a984e94 100644
--- a/src/tun_darwin.go
+++ b/src/tun_darwin.go
@@ -184,10 +184,14 @@ func (t *NativeTUN) Events() chan TUNEvent {
return t.events
}
-func (t *NativeTUN) Read(to []byte) (int, error) {
+func (t *NativeTUN) Read(to []byte, offset int) (int, error) {
+ to = to[offset:]
+
t.rMu.Lock()
defer t.rMu.Unlock()
+ // TODO: implement in-place read
+
if cap(t.rBuf) < len(to)+4 {
t.rBuf = make([]byte, len(to)+4)
}
@@ -198,15 +202,18 @@ func (t *NativeTUN) Read(to []byte) (int, error) {
return n - 4, err
}
-func (t *NativeTUN) Write(from []byte) (int, error) {
+func (t *NativeTUN) Write(from []byte, offset int) (int, error) {
- if len(from) == 0 {
+ if len(from) < offset {
return 0, unix.EIO
}
+ from := from[offset:]
t.wMu.Lock()
defer t.wMu.Unlock()
+ // TODO: implement in-place write
+
if cap(t.wBuf) < len(from)+4 {
t.wBuf = make([]byte, len(from)+4)
}
--
2.15.1
More information about the WireGuard
mailing list