merge develop into master #21

Merged
JakeHillion merged 149 commits from develop into master 2021-05-12 00:22:59 +01:00
Showing only changes of commit 648aab7817 - Show all commits

View File

@ -10,7 +10,6 @@ import (
type SourceSink struct {
tun wgtun.Device
mtu int
}
func NewTun(name string, mtu int) (t wgtun.Device, err error) {
@ -26,7 +25,6 @@ func NewFromFile(fd uintptr, mtu int) (ss *SourceSink, err error) {
return
}
ss.mtu = mtu
return
}
@ -35,7 +33,12 @@ func (t *SourceSink) Close() error {
}
func (t *SourceSink) Source() (proxy.Packet, error) {
buf := make([]byte, t.mtu)
mtu, err := t.tun.MTU()
if err != nil {
return nil, err
}
buf := make([]byte, mtu+4)
read, err := t.tun.Read(buf, 4)
if err != nil {
@ -46,7 +49,7 @@ func (t *SourceSink) Source() (proxy.Packet, error) {
return nil, io.EOF
}
return proxy.SimplePacket(buf[4:read]), nil
return proxy.SimplePacket(buf[4:read+4]), nil
}
var good, bad float64