This commit is contained in:
黄思敏 2022-08-29 09:37:00 +08:00
parent 26d8023cf1
commit fb1b65184e
2 changed files with 6 additions and 6 deletions

View File

@ -7,6 +7,7 @@ import (
"encoding/gob"
"fmt"
"log"
"net"
"os/exec"
gen "slimming/proto/gen"
"strings"
@ -131,7 +132,7 @@ func (nc *NetCard) Run() {
func NewNetCard() *NetCard {
config := water.Config{
DeviceType: water.TAP,
DeviceType: water.TUN,
PlatformSpecificParams: water.PlatformSpecificParams{
Name: "stun",
},
@ -179,7 +180,7 @@ func (nc *NetCard) runRead() {
log.Fatal(err)
}
rframe = rframe[:n]
if !waterutil.IsIPv4(rframe) {
if !waterutil.IsIPv4(rframe) || waterutil.IPv4Source(rframe).Equal(net.IPv4(0, 0, 0, 0)) {
continue
}
@ -195,9 +196,8 @@ func (nc *NetCard) runRead() {
// 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("Dst: %s Src %s\n", waterutil.IPv4Destination(rframe), waterutil.IPv4Source(rframe))
var buffer *ExchangeBuffer
if buffer, ok = bytesMap[realAddr]; !ok {

View File

@ -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 (