diff --git a/device.go b/device.go index 3ba3255..337cd5b 100644 --- a/device.go +++ b/device.go @@ -131,9 +131,11 @@ func (nc *NetCard) Run() { func NewNetCard() *NetCard { config := water.Config{ - DeviceType: water.TUN, + DeviceType: water.TAP, + PlatformSpecificParams: water.PlatformSpecificParams{ + Name: "stun", + }, } - config.Name = "stun" ifce, err := water.New(config) if err != nil { diff --git a/main.go b/main.go index bef35ea..ba1d5eb 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "log" "os/exec" @@ -17,15 +18,22 @@ func init() { //go:generate bash -c "protoc --go_out=plugins=grpc:. proto/*.proto" func main() { - // testmain() - NewNetCard().Run() + testmain() + // NewNetCard().Run() } +var ( + flagAddr = flag.String("addr", "", "addr set") +) + func testmain() { + + flag.Parse() + var a chan bool = make(chan bool) go func() { <-a - cmdstr := fmt.Sprintf("ip addr add %s dev stun", "10.10.10.111") + cmdstr := fmt.Sprintf("ip addr add %s dev stun", *flagAddr) log.Println(cmdstr) cmd := strings.Split(cmdstr, " ") err := exec.Command(cmd[0], cmd[1:]...).Run() @@ -42,7 +50,7 @@ func testmain() { }() config := water.Config{ - DeviceType: water.TUN, + DeviceType: water.TAP, } config.Name = "stun"