本文整理汇总了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)
}
}
示例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)
}
}
示例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)
}
示例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,
}
}
}
示例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)
}
}
示例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
}
}
示例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()
}
示例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
}
}