mirror of
https://github.com/yggdrasil-network/water.git
synced 2025-05-19 16:35:10 +03:00
Add test code for windows.
This commit is contained in:
parent
b090a0ff67
commit
dd56f4a2c6
4 changed files with 36 additions and 8 deletions
28
ipv4_windows_test.go
Normal file
28
ipv4_windows_test.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
// +build windows
|
||||
package water
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func startBroadcast(t *testing.T, dst net.IP) {
|
||||
if err := exec.Command("ping", "-n", "2", dst.String()).Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func setupIfce(t *testing.T, ipNet net.IPNet, dev string) {
|
||||
sargs := fmt.Sprintf("interface ip set address name=REPLACE_ME source=static addr=REPLACE_ME mask=REPLACE_ME gateway=none")
|
||||
args := strings.Split(sargs, " ")
|
||||
args[4] = fmt.Sprintf("name=%s", dev)
|
||||
args[6] = fmt.Sprintf("addr=%s", ipNet.IP)
|
||||
args[7] = fmt.Sprintf("mask=%d.%d.%d.%d", ipNet.Mask[0], ipNet.Mask[1], ipNet.Mask[2], ipNet.Mask[3])
|
||||
cmd := exec.Command("netsh", args...)
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue