当前位置: 首页>>代码示例>>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;未经允许,请勿转载。