From f8d4727c2b6a45fa53d73c5752c2de7e5e384b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=80=9D=E6=95=8F?= Date: Thu, 25 Aug 2022 10:24:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tap.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tap.go b/tap.go index 59d039c..b698270 100644 --- a/tap.go +++ b/tap.go @@ -3,7 +3,9 @@ package main import ( "context" "log" + "os/exec" gen "slimming/proto/gen" + "strings" "time" "github.com/songgao/packets/ethernet" @@ -67,6 +69,17 @@ func (nc *NetCard) Run() { go nc.runRead() go nc.runWrite() // go nc.cli.run() + time.Sleep(time.Second) + cmd := strings.Split("addr add 10.10.10.10/24 dev stap", " ") + err := exec.Command(cmd[0], cmd[1:]...).Run() + if err != nil { + panic(err) + } + cmd = strings.Split("ip link set dev stap up", " ") + err = exec.Command(cmd[0], cmd[1:]...).Run() + if err != nil { + panic(err) + } nc.server.run() } @@ -109,6 +122,7 @@ func (nc *NetCard) runRead() { framesBytes = append(framesBytes, []byte(rframe)) } + println(len(framesBytes)) if len(framesBytes) > 0 { if nc.cli.conn == nil { nc.cli.connect()