测试
This commit is contained in:
parent
bca066e547
commit
806173ff92
16
main.go
16
main.go
|
@ -18,8 +18,8 @@ func init() {
|
|||
|
||||
//go:generate bash -c "protoc --go_out=plugins=grpc:. proto/*.proto"
|
||||
func main() {
|
||||
// testmain()
|
||||
NewNetCard().Run()
|
||||
testmain()
|
||||
// NewNetCard().Run()
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -47,7 +47,7 @@ func testmain() {
|
|||
flag.Parse()
|
||||
|
||||
config := water.Config{
|
||||
DeviceType: water.TAP,
|
||||
DeviceType: water.TUN,
|
||||
}
|
||||
config.Name = "stun"
|
||||
|
||||
|
@ -68,9 +68,13 @@ func testmain() {
|
|||
}
|
||||
frame = frame[:n]
|
||||
|
||||
log.Printf("DstMac: %s SrcMac: %s\n", waterutil.MACDestination(frame), waterutil.MACSource(frame))
|
||||
log.Printf("DstIP: %s SrcIP: %s\n", waterutil.IPv4Destination(frame), waterutil.IPv4Source(frame))
|
||||
log.Printf("Ethertype: % x\n", frame.Ethertype())
|
||||
if frame.Ethertype() != ethernet.ARP {
|
||||
log.Printf("Ethertype: % x\n", frame.Ethertype())
|
||||
|
||||
log.Printf("DstMac: %s SrcMac: %s\n", waterutil.IPv4Destination(frame), waterutil.IPv4Source(frame))
|
||||
log.Printf("DstPort: %d SrcPort: %d\n", waterutil.IPv4DestinationPort(frame), waterutil.IPv4SourcePort(frame))
|
||||
}
|
||||
|
||||
// log.Printf("Payload: % x\n", frame.Payload())
|
||||
|
||||
ifce.Write(frame)
|
||||
|
|
|
@ -272,8 +272,11 @@ func (nc *NetCard) runWrite() {
|
|||
for _, buf := range bufs {
|
||||
|
||||
log.Printf("get wframes decode len: %d", len(buf))
|
||||
var wbuf []byte
|
||||
wbuf = append(wbuf, buf[0:20]...)
|
||||
wbuf = append(wbuf, waterutil.IPv4Payload(buf)...)
|
||||
log.Printf("get decode frames decode source: %s dst: %s", waterutil.IPv4Source(buf), waterutil.IPv4Destination(buf))
|
||||
_, err := ifce.Write(buf)
|
||||
_, err := ifce.Write(wbuf)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user