From 75130f7735c961e33db05246c63cb1c048507345 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 23 Apr 2019 11:46:16 +0100 Subject: [PATCH] Fix TAP support again --- src/tuntap/tun.go | 7 ++++--- src/yggdrasil/session.go | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index fed6563..01cafaa 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -236,7 +236,7 @@ func (tun *TunAdapter) connReader(conn *yggdrasil.Conn) error { var dstAddr address.Address if b[0]&0xf0 == 0x60 { if len(b) < 40 { - //panic("Tried to sendb a packet shorter than an IPv6 header...") + //panic("Tried to send a packet shorter than an IPv6 header...") util.PutBytes(b) continue } @@ -301,8 +301,9 @@ func (tun *TunAdapter) connReader(conn *yggdrasil.Conn) error { ethernet.NotTagged, // VLAN tagging proto, // Ethertype len(b)) // Payload length - copy(frame[tun_ETHER_HEADER_LENGTH:], b[:]) - w, err = tun.iface.Write(b[:n]) + copy(frame[tun_ETHER_HEADER_LENGTH:], b[:n]) + n += tun_ETHER_HEADER_LENGTH + w, err = tun.iface.Write(frame[:n]) } } else { w, err = tun.iface.Write(b[:n]) diff --git a/src/yggdrasil/session.go b/src/yggdrasil/session.go index 44c8387..bf35e8c 100644 --- a/src/yggdrasil/session.go +++ b/src/yggdrasil/session.go @@ -8,7 +8,6 @@ import ( "bytes" "encoding/hex" "sync" - "sync/atomic" "time" "github.com/yggdrasil-network/yggdrasil-go/src/address" @@ -78,7 +77,7 @@ type sessionPing struct { // Updates session info in response to a ping, after checking that the ping is OK. // Returns true if the session was updated, or false otherwise. func (s *sessionInfo) update(p *sessionPing) bool { - if !(p.Tstamp > atomic.LoadInt64(&s.tstamp)) { + if !(p.Tstamp > s.tstamp) { // To protect against replay attacks return false }