netstat

package
v0.0.0-...-9e7e4f5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2019 License: MPL-2.0 Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasIPConnected

func HasIPConnected(val string) (found bool, elements []element, err error)

func HasListeningPort

func HasListeningPort(val string) (found bool, elements []element, err error)

func HasLocalIP

func HasLocalIP(ipStr string) (found bool, elements []element, err error)

HasLocalIP compares an input ip address with the ip addresses of the local interfaces, and returns found=true when found

func HasLocalMAC

func HasLocalMAC(macstr string) (found bool, elements []element, err error)

HasLocalMac returns the mac addresses that match an input MAC regex

func HasSeenIP

func HasSeenIP(val string) (found bool, elements []element, err error)

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

func HasSeenMac(val string) (found bool, elements []element, err error)

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  *:*

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL