测试
This commit is contained in:
parent
8b8f55d573
commit
b896363b34
|
@ -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
16
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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user