当前位置: 首页>>代码示例>>Golang>>正文


Golang netutils.ReverseIP函数代码示例

本文整理汇总了Golang中github.com/docker/libnetwork/netutils.ReverseIP函数的典型用法代码示例。如果您正苦于以下问题:Golang ReverseIP函数的具体用法?Golang ReverseIP怎么用?Golang ReverseIP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ReverseIP函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: deleteSvcRecords

func (n *network) deleteSvcRecords(name string, epIP net.IP, ipMapUpdate bool) {
	c := n.getController()
	c.Lock()
	defer c.Unlock()
	sr, ok := c.svcDb[n.ID()]
	if !ok {
		return
	}

	if ipMapUpdate {
		delete(sr.ipMap, netutils.ReverseIP(epIP.String()))
	}

	ipList := sr.svcMap[name]
	for i, ip := range ipList {
		if ip.Equal(epIP) {
			ipList = append(ipList[:i], ipList[i+1:]...)
			break
		}
	}
	sr.svcMap[name] = ipList

	if len(ipList) == 0 {
		delete(sr.svcMap, name)
	}
}
开发者ID:hoonmin,项目名称:libnetwork,代码行数:26,代码来源:network.go

示例2: deleteSvcRecords

func (n *network) deleteSvcRecords(name string, epIP net.IP, epIPv6 net.IP, ipMapUpdate bool) {
	// Do not delete service names from ingress network as this is a
	// routing only network
	if n.ingress {
		return
	}

	c := n.getController()
	c.Lock()
	defer c.Unlock()
	sr, ok := c.svcRecords[n.ID()]
	if !ok {
		return
	}

	if ipMapUpdate {
		delete(sr.ipMap, netutils.ReverseIP(epIP.String()))

		if epIPv6 != nil {
			delete(sr.ipMap, netutils.ReverseIP(epIPv6.String()))
		}
	}

	delNameToIP(sr.svcMap, name, epIP)

	if epIPv6 != nil {
		delNameToIP(sr.svcIPv6Map, name, epIPv6)
	}
}
开发者ID:msabansal,项目名称:libnetwork,代码行数:29,代码来源:network.go

示例3: addSvcRecords

func (n *network) addSvcRecords(name string, epIP net.IP, ipMapUpdate bool) {
	c := n.getController()
	c.Lock()
	defer c.Unlock()
	sr, ok := c.svcDb[n.ID()]
	if !ok {
		sr = svcInfo{
			svcMap: make(map[string][]net.IP),
			ipMap:  make(map[string]string),
		}
		c.svcDb[n.ID()] = sr
	}

	if ipMapUpdate {
		reverseIP := netutils.ReverseIP(epIP.String())
		if _, ok := sr.ipMap[reverseIP]; !ok {
			sr.ipMap[reverseIP] = name
		}
	}

	ipList := sr.svcMap[name]
	for _, ip := range ipList {
		if ip.Equal(epIP) {
			return
		}
	}
	sr.svcMap[name] = append(sr.svcMap[name], epIP)
}
开发者ID:hoonmin,项目名称:libnetwork,代码行数:28,代码来源:network.go

示例4: addIPToName

func addIPToName(ipMap map[string]*ipInfo, name string, ip net.IP) {
	reverseIP := netutils.ReverseIP(ip.String())
	if _, ok := ipMap[reverseIP]; !ok {
		ipMap[reverseIP] = &ipInfo{
			name: name,
		}
	}
}
开发者ID:jfrazelle,项目名称:docker,代码行数:8,代码来源:network.go

示例5: deleteSvcRecords

func (n *network) deleteSvcRecords(name string, epIP net.IP, epIPv6 net.IP, ipMapUpdate bool) {
	c := n.getController()
	c.Lock()
	defer c.Unlock()
	sr, ok := c.svcRecords[n.ID()]
	if !ok {
		return
	}

	if ipMapUpdate {
		delete(sr.ipMap, netutils.ReverseIP(epIP.String()))

		if epIPv6 != nil {
			delete(sr.ipMap, netutils.ReverseIP(epIPv6.String()))
		}
	}

	delNameToIP(sr.svcMap, name, epIP)

	if epIPv6 != nil {
		delNameToIP(sr.svcIPv6Map, name, epIPv6)
	}
}
开发者ID:amitshukla,项目名称:docker,代码行数:23,代码来源:network.go

示例6: HandleQueryResp

func (n *network) HandleQueryResp(name string, ip net.IP) {
	c := n.getController()
	c.Lock()
	defer c.Unlock()
	sr, ok := c.svcRecords[n.ID()]

	if !ok {
		return
	}

	ipStr := netutils.ReverseIP(ip.String())

	if ipInfo, ok := sr.ipMap[ipStr]; ok {
		ipInfo.extResolver = true
	}
}
开发者ID:jfrazelle,项目名称:docker,代码行数:16,代码来源:network.go

示例7: updateSvcRecord

func (n *network) updateSvcRecord(ep *endpoint, localEps []*endpoint, isAdd bool) {
	if ep.isAnonymous() {
		return
	}

	c := n.getController()
	sr, ok := c.svcDb[n.ID()]
	if !ok {
		c.svcDb[n.ID()] = svcInfo{
			svcMap: make(map[string]net.IP),
			ipMap:  make(map[string]string),
		}
		sr = c.svcDb[n.ID()]
	}

	epName := ep.Name()
	n.Lock()
	if iface := ep.Iface(); iface.Address() != nil {

		reverseIP := netutils.ReverseIP(iface.Address().IP.String())
		if isAdd {
			// If we already have this endpoint in service db just return
			if _, ok := sr.svcMap[epName]; ok {
				n.Unlock()
				return
			}

			sr.svcMap[epName] = iface.Address().IP
			sr.ipMap[reverseIP] = epName
		} else {
			delete(sr.svcMap, epName)
			delete(sr.ipMap, reverseIP)
		}
	}
	n.Unlock()
}
开发者ID:martijnboekhorst,项目名称:libnetwork,代码行数:36,代码来源:network.go

示例8: addIPToName

func addIPToName(ipMap map[string]string, name string, ip net.IP) {
	reverseIP := netutils.ReverseIP(ip.String())
	if _, ok := ipMap[reverseIP]; !ok {
		ipMap[reverseIP] = name
	}
}
开发者ID:amitshukla,项目名称:docker,代码行数:6,代码来源:network.go


注:本文中的github.com/docker/libnetwork/netutils.ReverseIP函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。