forked from DataDog/agent-payload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connections.go
39 lines (31 loc) · 1.54 KB
/
connections.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package process
func (m *CollectorConnections) GetHostTags(host *Host) []string {
return m.GetTags(int(host.TagIndex))
}
func (m *CollectorConnections) IterateHostTags(host *Host, cb func(i, total int, tag string) bool) {
iterateTags(m.EncodedTags, int(host.TagIndex), cb)
}
func (m *CollectorConnections) GetContainerTags(container *ContainerMetadata) []string {
return m.GetTags(int(container.TagIndex))
}
func (m *CollectorConnections) IterateContainerTags(container *ContainerMetadata, cb func(i, total int, tag string) bool) {
iterateTags(m.EncodedTags, int(container.TagIndex), cb)
}
func (m *CollectorConnections) GetTags(tagIndex int) []string {
return getTags(m.EncodedTags, tagIndex)
}
// GetDNS returns the DNS entries for the given addr.
// The first argument returned is the first DNS entry followed by any additional name resolutions. Most IPs will
// have a single resolution so this dual format allows us to avoid allocations for the common case. If there are
// multiple name resolutions, there is no implied priority between the dual values
func (m *CollectorConnections) GetDNS(addr *Addr) (string, []string) {
return GetDNS(m.EncodedDNS, addr.Ip)
}
// IterateDNS iterates over all of the DNS entries for the given addr, invoking the provided callback for each one
func (m *CollectorConnections) IterateDNS(addr *Addr, cb func(i, total int, entry string) bool) {
IterateDNS(m.EncodedDNS, addr.Ip, cb)
}
// GetDNSNames returns all the DNS entries
func (m *CollectorConnections) GetDNSNames() []string {
return getDNSNames(m.EncodedDNS)
}