當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。