5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-23 00:51:35 +00:00

Fix TAP support again

This commit is contained in:
Neil Alexander 2019-04-23 11:46:16 +01:00
parent 2b44f5d2f6
commit 75130f7735
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
2 changed files with 5 additions and 5 deletions

View File

@ -236,7 +236,7 @@ func (tun *TunAdapter) connReader(conn *yggdrasil.Conn) error {
var dstAddr address.Address var dstAddr address.Address
if b[0]&0xf0 == 0x60 { if b[0]&0xf0 == 0x60 {
if len(b) < 40 { 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) util.PutBytes(b)
continue continue
} }
@ -301,8 +301,9 @@ func (tun *TunAdapter) connReader(conn *yggdrasil.Conn) error {
ethernet.NotTagged, // VLAN tagging ethernet.NotTagged, // VLAN tagging
proto, // Ethertype proto, // Ethertype
len(b)) // Payload length len(b)) // Payload length
copy(frame[tun_ETHER_HEADER_LENGTH:], b[:]) copy(frame[tun_ETHER_HEADER_LENGTH:], b[:n])
w, err = tun.iface.Write(b[:n]) n += tun_ETHER_HEADER_LENGTH
w, err = tun.iface.Write(frame[:n])
} }
} else { } else {
w, err = tun.iface.Write(b[:n]) w, err = tun.iface.Write(b[:n])

View File

@ -8,7 +8,6 @@ import (
"bytes" "bytes"
"encoding/hex" "encoding/hex"
"sync" "sync"
"sync/atomic"
"time" "time"
"github.com/yggdrasil-network/yggdrasil-go/src/address" "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. // 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. // Returns true if the session was updated, or false otherwise.
func (s *sessionInfo) update(p *sessionPing) bool { func (s *sessionInfo) update(p *sessionPing) bool {
if !(p.Tstamp > atomic.LoadInt64(&s.tstamp)) { if !(p.Tstamp > s.tstamp) {
// To protect against replay attacks // To protect against replay attacks
return false return false
} }