have the core wrap and export the underlying PacketConn, move IPv6 ReadWriteCloser wrapper logic to a separate package

This commit is contained in:
Arceliar 2021-07-05 13:14:12 -05:00
parent 35e8ff7c9d
commit f990a56046
11 changed files with 170 additions and 110 deletions

View file

@ -17,7 +17,7 @@ func (tun *TunAdapter) read() {
begin := TUN_OFFSET_BYTES
end := begin + n
bs := buf[begin:end]
if _, err := tun.core.Write(bs); err != nil {
if _, err := tun.rwc.Write(bs); err != nil {
tun.log.Debugln("Unable to send packet:", err)
}
}
@ -27,7 +27,7 @@ func (tun *TunAdapter) write() {
var buf [TUN_OFFSET_BYTES + 65535]byte
for {
bs := buf[TUN_OFFSET_BYTES:]
n, err := tun.core.Read(bs)
n, err := tun.rwc.Read(bs)
if err != nil {
tun.log.Errorln("Exiting tun writer due to core read error:", err)
return