I was wondering if someone’s come across any existing package/s that are able to get a list of current active network connections on a host (Linux) and put those into a array of maps (I guess) or something like it?
The idea is to check in a configurable interval for current connections (incoming and outgoing) and log the IPs ideally trying to get the name, but IP will be a good start.
Any links / ideas ? Maybe there’s something in the standard lib that can do this?
If your wanting realtime on-the-wire connection tracking without the overhead of using conntrack you could build a simple tcp state machine on top of gopacket and capture the interface(s) using pcap/afpacket.
cool thanks! maybe i didn’t get far with google as I was thinking along the lines of netstat command, which thinking about it now, should also be available as a file somewhere (or many) in /proc - I’ll have a go at the above too - thanks a lot! alex