This commit is contained in:
黄思敏 2022-08-29 09:11:46 +08:00
parent 8b8f55d573
commit b896363b34
2 changed files with 16 additions and 6 deletions

View File

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

16
main.go
View File

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