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


Golang sets.IPNet類代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/util/net/sets.IPNet的典型用法代碼示例。如果您正苦於以下問題:Golang IPNet類的具體用法?Golang IPNet怎麽用?Golang IPNet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: UpdateFirewall

func (f *fakeFirewallRules) UpdateFirewall(name, msgTag string, srcRange netset.IPNet, ports []int64, hosts []string) error {
	var exists bool
	strPorts := []string{}
	for _, p := range ports {
		strPorts = append(strPorts, fmt.Sprintf("%v", p))
	}

	// To accurately mimic the cloudprovider we need to add the k8s-fw
	// prefix to the given rule name.
	name = f.namer.FrName(name)
	for i := range f.fw {
		if f.fw[i].Name == name {
			exists = true
			f.fw[i] = &compute.Firewall{
				Name:         name,
				SourceRanges: srcRange.StringSlice(),
				Allowed:      []*compute.FirewallAllowed{{Ports: strPorts}},
			}
		}
	}
	if exists {
		return nil
	}
	return fmt.Errorf("Update failed for rule %v, srcRange %v ports %v, rule not found", name, srcRange, ports)
}
開發者ID:spxtr,項目名稱:contrib,代碼行數:25,代碼來源:fakes.go

示例2: IsAllowAll

// IsAllowAll checks whether the netsets.IPNet allows traffic from 0.0.0.0/0
func IsAllowAll(ipnets netsets.IPNet) bool {
	for _, s := range ipnets.StringSlice() {
		if s == "0.0.0.0/0" {
			return true
		}
	}
	return false
}
開發者ID:CNDonny,項目名稱:scope,代碼行數:9,代碼來源:util.go

示例3: CreateFirewall

func (f *fakeFirewallRules) CreateFirewall(name, msgTag string, srcRange netset.IPNet, ports []int64, hosts []string) error {
	strPorts := []string{}
	for _, p := range ports {
		strPorts = append(strPorts, fmt.Sprintf("%v", p))
	}
	f.fw = append(f.fw, &compute.Firewall{
		// To accurately mimic the cloudprovider we need to add the k8s-fw
		// prefix to the given rule name.
		Name:         f.namer.FrName(name),
		SourceRanges: srcRange.StringSlice(),
		Allowed:      []*compute.FirewallAllowed{{Ports: strPorts}},
	})
	return nil
}
開發者ID:spxtr,項目名稱:contrib,代碼行數:14,代碼來源:fakes.go


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