From dc02f44e141aabb96748a51dcb35813847fd87b1 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 12:21:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc.go | 1 + tap.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rpc.go b/rpc.go index 5ba8151..3a6bf5f 100644 --- a/rpc.go +++ b/rpc.go @@ -17,6 +17,7 @@ type RPCServer struct { var ( serverPort = flag.Int("port", 50051, "The server port") + cardIP = flag.String("card", "", "The card ip") othersAddr = flag.String("addr", "", "The other server addr") ) diff --git a/tap.go b/tap.go index 753ec30..f784e65 100644 --- a/tap.go +++ b/tap.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "log" "os/exec" gen "slimming/proto/gen" @@ -79,7 +80,7 @@ func (nc *NetCard) Run() { go nc.runWrite() // go nc.cli.run() time.Sleep(time.Second) - cmd := strings.Split("ip addr add 10.10.10.10/24 dev stap", " ") + cmd := strings.Split(fmt.Sprintf("ip addr add %s/24 dev stap", *cardIP), " ") err := exec.Command(cmd[0], cmd[1:]...).Run() if err != nil { log.Panic(err)