This commit is contained in:
黄思敏 2022-08-25 12:21:50 +08:00
parent dd933f1c8f
commit dc02f44e14
2 changed files with 3 additions and 1 deletions

1
rpc.go
View File

@ -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")
)

3
tap.go
View File

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