From ed1df53a6d58439fabeaf109ffb2f129aae784e7 Mon Sep 17 00:00:00 2001 From: Monica Sarbu Date: Sun, 16 Mar 2014 19:11:09 +0100 Subject: [PATCH] - keep a topology map in elasticsearch with all public IPs that each agent has - at startup, each agent adds its IPs to the topology map (in elasticsearch under packetbeat-topology index) - determine src_server and dst_server for each transaction - ignore duplicated transactions --- net.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 net.go diff --git a/net.go b/net.go new file mode 100644 index 000000000000..8a2251cb4a70 --- /dev/null +++ b/net.go @@ -0,0 +1,22 @@ +package main + +import ( + "net" +) + + +func LocalAddrs() ([]string, error) { + var localAddrs = []string{} + addrs, err := net.InterfaceAddrs() + if err != nil { + return nil, err + } + for _, addr := range addrs { + // a bit wtf'ish.. Don't know how to do this otherwise + ip, _, err := net.ParseCIDR(addr.String()) + if err == nil && ip != nil { + localAddrs = append(localAddrs, ip.String()) + } + } + return localAddrs, nil +}