MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / GetIP

Method GetIP

pkg/event/param.go:606–619  ·  view source on GitHub ↗

GetIP returns either the IPv4 or IPv6 address from the parameter.

(name string)

Source from the content-addressed store, hash-verified

604
605// GetIP returns either the IPv4 or IPv6 address from the parameter.
606func (pars Params) GetIP(name string) (net.IP, error) {
607 par, err := pars.findParam(name)
608 if err != nil {
609 return net.IP{}, err
610 }
611 if par.Type != params.IPv4 && par.Type != params.IPv6 {
612 return net.IP{}, fmt.Errorf("%q parameter is not an IP address", name)
613 }
614 v, ok := par.Value.(net.IP)
615 if !ok {
616 return net.IP{}, fmt.Errorf("unable to type cast %q parameter to net.IP value", name)
617 }
618 return v, nil
619}
620
621// MustGetIP returns the IP address parameter or panics if an error occurs.
622func (pars Params) MustGetIP(name string) net.IP {

Callers 5

MustGetIPMethod · 0.95
GetMethod · 0.80
newEventDictFunction · 0.80
PartialKeyMethod · 0.80
SummaryMethod · 0.80

Calls 1

findParamMethod · 0.95

Tested by

no test coverage detected