Exemple #1
0
func main() {
	ignoreIfaceNames := make(stringList)

	mflag.Var(&ignoreIfaceNames, []string{"-ignore-iface"}, "name of interface to ignore)")
	mflag.Parse()

	if len(mflag.Args()) < 1 {
		fmt.Fprintln(os.Stderr, "usage: netcheck [--ignore-iface <iface-name>] network-cidr")
		os.Exit(1)
	}

	cidrStr := mflag.Args()[0]
	addr, ipnet, err := net.ParseCIDR(cidrStr)
	if err != nil {
		fatal(err)
	}
	if ipnet.IP.Equal(addr) {
		err = weavenet.CheckNetworkFree(ipnet, ignoreIfaceNames)
	} else {
		err = weavenet.CheckAddressOverlap(addr, ignoreIfaceNames)
	}
	if err != nil {
		fatal(err)
	}
	os.Exit(0)
}
Exemple #2
0
func netcheck(args []string) error {
	if len(args) < 1 {
		cmdUsage("netcheck", "<cidr> [<interface-to-ignore> ...]")
	}
	addr, ipnet, err := net.ParseCIDR(args[0])
	if err != nil {
		return err
	}
	ignoreIfaceNames := make(map[string]struct{})
	for _, ifName := range args[1:] {
		ignoreIfaceNames[ifName] = struct{}{}
	}
	if ipnet.IP.Equal(addr) {
		err = weavenet.CheckNetworkFree(ipnet, ignoreIfaceNames)
	} else {
		err = weavenet.CheckAddressOverlap(addr, ignoreIfaceNames)
	}
	return err
}
Exemple #3
0
func main() {
	if len(os.Args) <= 1 {
		os.Exit(0)
	}

	cidrStr := os.Args[1]
	addr, ipnet, err := net.ParseCIDR(cidrStr)
	if err != nil {
		fatal(err)
	}
	if ipnet.IP.Equal(addr) {
		err = weavenet.CheckNetworkFree(ipnet)
	} else {
		err = weavenet.CheckAddressOverlap(addr)
	}
	if err != nil {
		fatal(err)
	}
	os.Exit(0)
}