common

package
v0.0.0-...-1361132 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: Apache-2.0 Imports: 12 Imported by: 20

Documentation

Index

Constants

View Source
const (
	OK_STATUS    = "OK"
	ERROR_STATUS = "Error"
)

standardized status values

View Source
const MaxIpPortTupleRawSize = 16 + 16 + 2 + 2
View Source
const MaxTcpTupleRawSize = 16 + 16 + 2 + 2 + 4
View Source
const TsLayout = "2006-01-02T15:04:05.000Z"

Layout to be used in the timestamp marshaling/unmarshaling everywhere. The timezone must always be UTC.

Variables

This section is empty.

Functions

func Bytes_Htohl

func Bytes_Htohl(b []byte) uint32

func Bytes_Ntohl

func Bytes_Ntohl(b []byte) uint32

func Bytes_Ntohll

func Bytes_Ntohll(b []byte) uint64

func Bytes_Ntohs

func Bytes_Ntohs(b []byte) uint16

func DumpInCSVFormat

func DumpInCSVFormat(fields []string, rows [][]string) string

Takes a set of fields and rows and returns a string representing the CSV representation for the fields and rows.

func Ipv4_Ntoa

func Ipv4_Ntoa(ip uint32) string

Ipv4_Ntoa transforms an IP4 address in it's dotted notation

func IsLoopback

func IsLoopback(ip_str string) (bool, error)

IsLoopback check if a particular IP notation corresponds to a loopback interface.

func LoadGeoIPData

func LoadGeoIPData(config Geoip) *libgeo.GeoIP

func LocalIpAddrs

func LocalIpAddrs() ([]net.IP, error)

LocalIpAddrs finds the IP addresses of the hosts on which the shipper currently runs on.

func LocalIpAddrsAsStrings

func LocalIpAddrsAsStrings(include_loopbacks bool) ([]string, error)

LocalIpAddrs finds the IP addresses of the hosts on which the shipper currently runs on and returns them as an array of strings.

func ReadString

func ReadString(s []byte) (string, error)

ReadString extracts the first null terminated string from a slice of bytes.

Types

type CmdlineTuple

type CmdlineTuple struct {
	Src, Dst []byte
}

Source and destination process names, as found by the proc module.

type Endpoint

type Endpoint struct {
	Ip      string
	Port    uint16
	Name    string
	Cmdline string
	Proc    string
}

Representing an endpoint in the communication.

type Geoip

type Geoip struct {
	Paths *[]string
}

type HashableIpPortTuple

type HashableIpPortTuple [MaxIpPortTupleRawSize]byte

type HashableTcpTuple

type HashableTcpTuple [MaxTcpTupleRawSize]byte

type IpPortTuple

type IpPortTuple struct {
	Ip_length          int
	Src_ip, Dst_ip     net.IP
	Src_port, Dst_port uint16
	// contains filtered or unexported fields
}

func NewIpPortTuple

func NewIpPortTuple(ip_length int, src_ip net.IP, src_port uint16,
	dst_ip net.IP, dst_port uint16) IpPortTuple

func (*IpPortTuple) ComputeHashebles

func (t *IpPortTuple) ComputeHashebles()

func (*IpPortTuple) Hashable

func (t *IpPortTuple) Hashable() HashableIpPortTuple

Hashable returns a hashable value that uniquely identifies the IP-port tuple.

func (*IpPortTuple) RevHashable

func (t *IpPortTuple) RevHashable() HashableIpPortTuple

Hashable returns a hashable value that uniquely identifies the IP-port tuple after swapping the source and destination.

func (*IpPortTuple) String

func (t *IpPortTuple) String() string

type MapStr

type MapStr map[string]interface{}

Commonly used map of things, used in JSON creation and the like.

func MapStrUnion

func MapStrUnion(dict1 MapStr, dict2 MapStr) MapStr

MapStrUnion creates a new MapStr containing the union of the key-value pairs of the two maps. If the same key is present in both, the key-value pairs from dict2 overwrite the ones from dict1.

func (MapStr) EnsureCountField

func (m MapStr) EnsureCountField() error

func (MapStr) EnsureTimestampField

func (m MapStr) EnsureTimestampField(now func() time.Time) error

Checks if a timestamp field exists and if it doesn't it adds one by using the injected now() function as a time source.

func (MapStr) String

func (m MapStr) String() string

Prints the dict as a json

func (MapStr) Update

func (m MapStr) Update(d MapStr)

Update copies all the key-value pairs from the d map overwriting any existing keys.

type TcpTuple

type TcpTuple struct {
	Ip_length          int
	Src_ip, Dst_ip     net.IP
	Src_port, Dst_port uint16
	Stream_id          uint32
	// contains filtered or unexported fields
}

func TcpTupleFromIpPort

func TcpTupleFromIpPort(t *IpPortTuple, tcp_id uint32) TcpTuple

func (*TcpTuple) ComputeHashebles

func (t *TcpTuple) ComputeHashebles()

func (*TcpTuple) Hashable

func (t *TcpTuple) Hashable() HashableTcpTuple

Hashable() returns a hashable value that uniquely identifies the TCP tuple.

func (TcpTuple) IpPort

func (t TcpTuple) IpPort() *IpPortTuple

Returns a pointer to the equivalent IpPortTuple.

func (TcpTuple) String

func (t TcpTuple) String() string

type Time

type Time time.Time

func MustParseTime

func MustParseTime(timespec string) Time

MustParseTime is a convenience equivalent of the ParseTime function that panics in case of errors.

func ParseTime

func ParseTime(timespec string) (Time, error)

ParseTime parses a time in the TsLayout format.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface. The time is a quoted string in the JsTsLayout format.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements js.Unmarshaler interface. The time is expected to be a quoted string in TsLayout format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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