• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang report.Networks类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: MapEndpoint2IP

// MapEndpoint2IP maps endpoint nodes to their IP address, for joining
// with container nodes.  We drop endpoint nodes with pids, as they
// will be joined to containers through the process topology, and we
// don't want to double count edges.
func MapEndpoint2IP(m RenderableNode, local report.Networks) RenderableNodes {
	// Don't include procspied connections, to prevent double counting
	_, ok := m.Latest.Lookup(endpoint.Procspied)
	if ok {
		return RenderableNodes{}
	}
	scope, addr, port, ok := report.ParseEndpointNodeID(m.ID)
	if !ok {
		return RenderableNodes{}
	}
	if ip := net.ParseIP(addr); ip != nil && !local.Contains(ip) {
		return RenderableNodes{TheInternetID: newDerivedPseudoNode(TheInternetID, TheInternetMajor, m)}
	}

	// We don't always know what port a container is listening on, and
	// container-to-container communications can be unambiguously identified
	// without ports. OTOH, connections to the host IPs which have been port
	// mapped to a container can only be unambiguously identified with the port.
	// So we need to emit two nodes, for two different cases.
	id := report.MakeScopedEndpointNodeID(scope, addr, "")
	idWithPort := report.MakeScopedEndpointNodeID(scope, addr, port)
	m = m.WithParents(report.EmptySets)
	return RenderableNodes{
		id:         NewRenderableNodeWith(id, "", "", "", m),
		idWithPort: NewRenderableNodeWith(idWithPort, "", "", "", m),
	}
}
开发者ID:pauloheck,项目名称:scope,代码行数:31,代码来源:mapping.go


示例2: MapAddressIdentity

// MapAddressIdentity maps an address topology node to an address renderable
// node. As it is only ever run on address topology nodes, we expect that
// certain keys are present.
func MapAddressIdentity(m RenderableNode, local report.Networks) RenderableNodes {
	addr, ok := m.Metadata[endpoint.Addr]
	if !ok {
		return RenderableNodes{}
	}

	// Nodes without a hostid are treated as psuedo nodes
	_, ok = m.Metadata[report.HostNodeID]
	if !ok {
		// If the addr is not in a network local to this report, we emit an
		// internet node
		if !local.Contains(net.ParseIP(addr)) {
			return RenderableNodes{TheInternetID: newDerivedPseudoNode(TheInternetID, TheInternetMajor, m)}
		}

		// Otherwise generate a pseudo node for every
		outputID := MakePseudoNodeID(addr, "")
		if len(m.Adjacency) > 0 {
			_, dstAddr, _ := report.ParseAddressNodeID(m.Adjacency[0])
			outputID = MakePseudoNodeID(addr, dstAddr)
		}
		return RenderableNodes{outputID: newDerivedPseudoNode(outputID, addr, m)}
	}

	var (
		id    = MakeAddressID(report.ExtractHostID(m.Node), addr)
		major = addr
		minor = report.ExtractHostID(m.Node)
		rank  = major
	)

	return RenderableNodes{id: NewRenderableNodeWith(id, major, minor, rank, m)}
}
开发者ID:philipz,项目名称:scope,代码行数:36,代码来源:mapping.go


示例3: MapEndpointIdentity

// MapEndpointIdentity maps an endpoint topology node to a single endpoint
// renderable node. As it is only ever run on endpoint topology nodes, we
// expect that certain keys are present.
func MapEndpointIdentity(m RenderableNode, local report.Networks) RenderableNodes {
	addr, ok := m.Metadata[endpoint.Addr]
	if !ok {
		return RenderableNodes{}
	}

	port, ok := m.Metadata[endpoint.Port]
	if !ok {
		return RenderableNodes{}
	}

	// We only show nodes found through procspy in this view.
	_, procspied := m.Metadata[endpoint.Procspied]
	if !procspied {
		return RenderableNodes{}
	}

	// Nodes without a hostid are treated as psuedo nodes
	if _, ok = m.Metadata[report.HostNodeID]; !ok {
		// If the dstNodeAddr is not in a network local to this report, we emit an
		// internet node
		if ip := net.ParseIP(addr); ip != nil && !local.Contains(ip) {
			return RenderableNodes{TheInternetID: newDerivedPseudoNode(TheInternetID, TheInternetMajor, m)}
		}

		// We are a 'client' pseudo node if the port is in the ephemeral port range.
		// Linux uses 32768 to 61000, IANA suggests 49152 to 65535.
		if p, err := strconv.Atoi(port); err == nil && len(m.Adjacency) > 0 && p >= 32768 && p < 65535 {
			// We only exist if there is something in our adjacency
			// Generate a single pseudo node for every (client ip, server ip, server port)
			dstNodeID := m.Adjacency[0]
			serverIP, serverPort := trySplitAddr(dstNodeID)
			outputID := MakePseudoNodeID(addr, serverIP, serverPort)
			return RenderableNodes{outputID: newDerivedPseudoNode(outputID, addr, m)}
		}

		// Otherwise (the server node is missing), generate a pseudo node for every (server ip, server port)
		outputID := MakePseudoNodeID(addr, port)
		if port != "" {
			return RenderableNodes{outputID: newDerivedPseudoNode(outputID, addr+":"+port, m)}
		}
		return RenderableNodes{outputID: newDerivedPseudoNode(outputID, addr, m)}
	}

	var (
		id    = MakeEndpointID(report.ExtractHostID(m.Node), addr, port)
		major = fmt.Sprintf("%s:%s", addr, port)
		minor = report.ExtractHostID(m.Node)
		rank  = major
	)

	pid, pidOK := m.Metadata[process.PID]
	if pidOK {
		minor = fmt.Sprintf("%s (%s)", minor, pid)
	}

	return RenderableNodes{id: NewRenderableNodeWith(id, major, minor, rank, m)}
}
开发者ID:webwurst,项目名称:scope,代码行数:61,代码来源:mapping.go


示例4: MapEndpoint2IP

// MapEndpoint2IP maps endpoint nodes to their IP address, for joining
// with container nodes.  We drop endpoint nodes with pids, as they
// will be joined to containers through the process topology, and we
// don't want to double count edges.
func MapEndpoint2IP(m RenderableNode, local report.Networks) RenderableNodes {
	_, ok := m.Metadata[process.PID]
	if ok {
		return RenderableNodes{}
	}
	addr, ok := m.Metadata[endpoint.Addr]
	if !ok {
		return RenderableNodes{}
	}
	if !local.Contains(net.ParseIP(addr)) {
		return RenderableNodes{TheInternetID: newDerivedPseudoNode(TheInternetID, TheInternetMajor, m)}
	}
	return RenderableNodes{addr: NewRenderableNodeWith(addr, "", "", "", m)}
}
开发者ID:webwurst,项目名称:scope,代码行数:18,代码来源:mapping.go


示例5: MapEndpoint2Pseudo

// MapEndpoint2Pseudo makes internet of host pesudo nodes from a endpoint node.
func MapEndpoint2Pseudo(n report.Node, local report.Networks) report.Nodes {
	var node report.Node

	addr, ok := n.Latest.Lookup(endpoint.Addr)
	if !ok {
		return report.Nodes{}
	}

	if ip := net.ParseIP(addr); ip != nil && !local.Contains(ip) {
		// If the dstNodeAddr is not in a network local to this report, we emit an
		// internet node
		node = theInternetNode(n)
	} else {
		// due to https://github.com/weaveworks/scope/issues/1323 we are dropping
		// all non-internet pseudo nodes for now.
		// node = NewDerivedPseudoNode(MakePseudoNodeID(addr), n)
		return report.Nodes{}
	}
	return report.Nodes{node.ID: node}
}
开发者ID:CNDonny,项目名称:scope,代码行数:21,代码来源:process.go


示例6: MapAddressIdentity

// MapAddressIdentity maps an address topology node to an address renderable
// node. As it is only ever run on address topology nodes, we expect that
// certain keys are present.
func MapAddressIdentity(m RenderableNode, local report.Networks) RenderableNodes {
	addr, ok := m.Metadata[endpoint.Addr]
	if !ok {
		return RenderableNodes{}
	}

	// Conntracked connections don't have a host id unless
	// they were merged with a procspied connection.  Filter
	// out those that weren't.
	_, hasHostID := m.Metadata[report.HostNodeID]
	_, conntracked := m.Metadata[endpoint.Conntracked]
	if !hasHostID && conntracked {
		return RenderableNodes{}
	}

	// Nodes without a hostid are treated as psuedo nodes
	if !hasHostID {
		// If the addr is not in a network local to this report, we emit an
		// internet node
		if !local.Contains(net.ParseIP(addr)) {
			return RenderableNodes{TheInternetID: newDerivedPseudoNode(TheInternetID, TheInternetMajor, m)}
		}

		// Otherwise generate a pseudo node for every
		outputID := MakePseudoNodeID(addr, "")
		if len(m.Adjacency) > 0 {
			_, dstAddr, _ := report.ParseAddressNodeID(m.Adjacency[0])
			outputID = MakePseudoNodeID(addr, dstAddr)
		}
		return RenderableNodes{outputID: newDerivedPseudoNode(outputID, addr, m)}
	}

	var (
		id    = MakeAddressID(report.ExtractHostID(m.Node), addr)
		major = addr
		minor = report.ExtractHostID(m.Node)
		rank  = major
	)

	return RenderableNodes{id: NewRenderableNodeWith(id, major, minor, rank, m)}
}
开发者ID:webwurst,项目名称:scope,代码行数:44,代码来源:mapping.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang report.Report类代码示例发布时间:2022-05-28
下一篇:
Golang report.EdgeMetadata类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap