测试
This commit is contained in:
parent
26d8023cf1
commit
fb1b65184e
|
@ -7,6 +7,7 @@ import (
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
gen "slimming/proto/gen"
|
gen "slimming/proto/gen"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -131,7 +132,7 @@ func (nc *NetCard) Run() {
|
||||||
func NewNetCard() *NetCard {
|
func NewNetCard() *NetCard {
|
||||||
|
|
||||||
config := water.Config{
|
config := water.Config{
|
||||||
DeviceType: water.TAP,
|
DeviceType: water.TUN,
|
||||||
PlatformSpecificParams: water.PlatformSpecificParams{
|
PlatformSpecificParams: water.PlatformSpecificParams{
|
||||||
Name: "stun",
|
Name: "stun",
|
||||||
},
|
},
|
||||||
|
@ -179,7 +180,7 @@ func (nc *NetCard) runRead() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
rframe = rframe[:n]
|
rframe = rframe[:n]
|
||||||
if !waterutil.IsIPv4(rframe) {
|
if !waterutil.IsIPv4(rframe) || waterutil.IPv4Source(rframe).Equal(net.IPv4(0, 0, 0, 0)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,9 +196,8 @@ func (nc *NetCard) runRead() {
|
||||||
|
|
||||||
// log.Printf("Payload: % x\n", rframe.Payload())
|
// log.Printf("Payload: % x\n", rframe.Payload())
|
||||||
|
|
||||||
log.Printf("Dst: %s Src %s\n", waterutil.IPv4Destination(rframe), waterutil.IPv4Source(rframe))
|
|
||||||
|
|
||||||
log.Printf("Ethertype: % x %v\n", rframe.Ethertype(), waterutil.IsIPv4(rframe))
|
log.Printf("Ethertype: % x %v\n", rframe.Ethertype(), waterutil.IsIPv4(rframe))
|
||||||
|
log.Printf("Dst: %s Src %s\n", waterutil.IPv4Destination(rframe), waterutil.IPv4Source(rframe))
|
||||||
|
|
||||||
var buffer *ExchangeBuffer
|
var buffer *ExchangeBuffer
|
||||||
if buffer, ok = bytesMap[realAddr]; !ok {
|
if buffer, ok = bytesMap[realAddr]; !ok {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user