新TAP测试

This commit is contained in:
黄思敏 2022-08-31 18:10:27 +08:00
parent 23e8da5467
commit e8e66b6143

View File

@ -9,6 +9,7 @@ import (
gen "slimming/proto/gen" gen "slimming/proto/gen"
"strings" "strings"
"sync" "sync"
"time"
"github.com/474420502/check" "github.com/474420502/check"
"github.com/474420502/perfectshutdown" "github.com/474420502/perfectshutdown"
@ -40,6 +41,8 @@ func NewNetTunnel() *NetTunnel {
} }
nt.shutdown.OnClose(func() { nt.shutdown.OnClose(func() {
time.Sleep(time.Second * 2)
log.Println("OnClose")
os.Exit(0) os.Exit(0)
}) })
@ -82,7 +85,7 @@ func NewNetTunnel() *NetTunnel {
switch frame.Ethertype() { switch frame.Ethertype() {
case ethernet.ARP: case ethernet.ARP:
log.Printf("bytes len: %d type: % x", len(rbuf), frame) // 数据长度 log.Printf("bytes len: %d type: % x", len(rbuf), frame.Ethertype()) // 数据长度
nt.clients.Range(func(key, value any) bool { nt.clients.Range(func(key, value any) bool {
if key == nt.ipv4key { if key == nt.ipv4key {
return true return true