當前位置: 首頁>>代碼示例>>Golang>>正文


Golang IPMask.String方法代碼示例

本文整理匯總了Golang中net.IPMask.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang IPMask.String方法的具體用法?Golang IPMask.String怎麽用?Golang IPMask.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.IPMask的用法示例。


在下文中一共展示了IPMask.String方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: MaskToInt

// MaskToInt converts net.IPMask to integer.
// TODO Not strictly firewall method, maybe put in different place.
func MaskToInt(mask net.IPMask) (uint64, error) {
	var imask uint64
	m, err := strconv.ParseInt(mask.String(), 16, 64)
	imask = uint64(m)
	if err != nil {
		return 0, err
	}
	return imask, nil
}
開發者ID:yangzhares,項目名稱:core,代碼行數:11,代碼來源:firewall.go

示例2: getHostOnlyNetwork

func getHostOnlyNetwork(nets map[string]*hostOnlyNetwork, hostIP net.IP, netmask net.IPMask) *hostOnlyNetwork {
	for _, n := range nets {
		// Second part of this conditional handles a race where
		// VirtualBox returns us the incorrect netmask value for the
		// newly created interface.
		if hostIP.Equal(n.IPv4.IP) &&
			(netmask.String() == n.IPv4.Mask.String() || n.IPv4.Mask.String() == buggyNetmask) {
			return n
		}
	}

	return nil
}
開發者ID:nlamirault,項目名稱:docker-machine-scaleway,代碼行數:13,代碼來源:network.go

示例3: getHostOnlyNetwork

func getHostOnlyNetwork(hostIP net.IP, netmask net.IPMask) (*hostOnlyNetwork, error) {
	nets, err := listHostOnlyNetworks()
	if err != nil {
		return nil, err
	}
	for _, n := range nets {
		if hostIP.Equal(n.IPv4.IP) &&
			netmask.String() == n.IPv4.Mask.String() {
			return n, nil
		}
	}
	return nil, nil
}
開發者ID:cdosso,項目名稱:machine,代碼行數:13,代碼來源:network.go

示例4: getHostOnlyAdapter

func getHostOnlyAdapter(nets map[string]*hostOnlyNetwork, hostIP net.IP, netmask net.IPMask) *hostOnlyNetwork {
	for _, n := range nets {
		// Second part of this conditional handles a race where
		// VirtualBox returns us the incorrect netmask value for the
		// newly created adapter.
		if hostIP.Equal(n.IPv4.IP) &&
			(netmask.String() == n.IPv4.Mask.String() || n.IPv4.Mask.String() == buggyNetmask) {
			log.Debugf("Found: %s", n.Name)
			return n
		}
	}

	log.Debug("Not found")
	return nil
}
開發者ID:webchip,項目名稱:machine,代碼行數:15,代碼來源:network.go

示例5: SetIP

// Sets the IP for the interface. Superuser authentication is required.
func (self IFConfig) SetIP(interfaceName string,
	ipAddress net.IP, netMask net.IPMask) error {
	logger.Debug("IFConfig: Setting the IP and Netmask")

	if !authorized() {
		return ErrAuthRequired
	}

	cmd := exec.Command("sudo", "ifconfig", interfaceName, ipAddress.String(),
		"netmask", netMask.String())
	logger.Debug("Command Start: %v", cmd.Args)
	out, err := cmd.CombinedOutput()
	if err != nil {
		logger.Error("Command Error: %v : %v", err, limitText(out))
		return err
	}
	logger.Debug("Command Return: %v", limitText(out))

	return nil
}
開發者ID:JmAbuDabi,項目名稱:skycoin,代碼行數:21,代碼來源:ifconfig.go


注:本文中的net.IPMask.String方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。