Documentation ¶
Overview ¶
netstat is a module that retrieves network information about the endpoint, such as mac addresses, local and connected IPs, listening TCP and UDP sockets and peers
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Contributor: Rob Murtha robmurtha@gmail.com [:robmurtha]
Index ¶
- func HasIPConnected(val string) (found bool, elements []element, err error)
- func HasListeningPort(val string) (found bool, elements []element, err error)
- func HasLocalIP(ipStr string) (found bool, elements []element, err error)
- func HasLocalMAC(macstr string) (found bool, elements []element, err error)
- func HasSeenIP(val string) (found bool, elements []element, err error)
- func HasSeenMac(val string) (found bool, elements []element, err error)
- type NetstatWinOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasIPConnected ¶
func HasListeningPort ¶
func HasLocalIP ¶
HasLocalIP compares an input ip address with the ip addresses of the local interfaces, and returns found=true when found
func HasLocalMAC ¶
HasLocalMac returns the mac addresses that match an input MAC regex
func HasSeenIP ¶
HasSeenIP on linux looks for a matching IP address in /proc/net/arp or in individual processes <pid>/net/arp, and returns its MAC and IP address if found
func HasSeenMac ¶
HasSeenMac on linux looks for a matching mac address in /proc/net/arp or in individual processes <pid>/net/arp, and returns its MAC and IP address if found
Types ¶
type NetstatWinOutput ¶
type NetstatWinOutput struct {
Entries []netstatWinEntry
}
NetstatWinOutput supports functions for parsing and responding to queries based on the output of the windows netstat -na command.
func (*NetstatWinOutput) HasIPConnected ¶
func (n *NetstatWinOutput) HasIPConnected(ipnet *net.IPNet) []element
HasIPConnected searches the parsed Entries for matches based on ipnet. This function also increments stats.Examined for each entry that is processed.
func (*NetstatWinOutput) HasListeningPort ¶
func (n *NetstatWinOutput) HasListeningPort(port int) []element
HasListeningPort returns elements with matching host listeners for the given port.
func (*NetstatWinOutput) UnmarshalText ¶
func (n *NetstatWinOutput) UnmarshalText(text []byte) error
UnmarshalText parses the output of windows netstat -na containing IPv4 and IPv6 addresses into the NetstatWinOutput struct.
Sample windows netstat -na output: Active Connections Proto Local Address Foreign Address State TCP 0.0.0.0:135 0.0.0.0:0 LISTENING TCP 0.0.0.0:445 0.0.0.0:0 LISTENING UDP [fe80::1c5a:2c75:6ce3:9f0%3]:1900 *:* UDP [fe80::1c5a:2c75:6ce3:9f0%3]:54109 *:*