Documentation ¶
Index ¶
- Variables
- func CacheDelete(key string)
- func CacheReplace(key string, value interface{}, duration time.Duration) error
- func CacheSet(key string, value interface{}, duration time.Duration)
- func CurrentUser(ctx *gin.Context) (*model.User, error)
- func DefaultLikelihood(ipid, intervalFrom, intervalTo uint, unit string) *regression.Regression
- func HandlerJsonError(msg string, err error, ctx *gin.Context)
- func Likelihood(ipid, intervalFrom, intervalTo uint, unit string) *regression.Regression
- func Logger(customLogger zerolog.Logger)
- func ParseRSAPrivateKey(decodedKey []byte) (*rsa.PrivateKey, error)
- func ParseRSAPublicKey(decodedKey []byte) (*rsa.PublicKey, error)
- func PreparePortalWebRequest(path string, body io.Reader) (*http.Request, error)
- func RandomMac(unicast bool) (string, error)
- func RawFlagsByInterface(intf *net.Interface) (net.Flags, error)
- func ScanWifiNetworks(intfName string) (ssid map[string]float64, err error)
- func Token() (string, error)
Constants ¶
This section is empty.
Variables ¶
var FingerprintValidator validator.Func = func(fieldLevel validator.FieldLevel) bool { if field, ok := fieldLevel.Field().Interface().(string); ok { if field == "" { return true } _, err := base64.RawURLEncoding.DecodeString(strings.TrimLeft(field, "SHA256:")) return err == nil && strings.HasPrefix(field, "SHA256:") } return false }
see https://github.com/torvalds/linux/blob/master/include/uapi/linux/if.h#L103
var IpValidator validator.Func = func(fieldLevel validator.FieldLevel) bool { if parent, ok := fieldLevel.Parent().Interface().(model.Network); ok { if parent.Client { return true } } if field, ok := fieldLevel.Field().Interface().(*types.IP); ok { return len(field.Raw) > 0 } return false }
var IpnetValidator validator.Func = func(fieldLevel validator.FieldLevel) bool { if parent, ok := fieldLevel.Parent().Interface().(model.Network); ok { if parent.Client { return true } } if field, ok := fieldLevel.Field().Interface().(*types.IPNet); ok { return len(field.Raw.IP) > 0 && len(field.Raw.Mask) > 0 } return false }
var IporcidrValidator validator.Func = func(fieldLevel validator.FieldLevel) bool { if field, ok := fieldLevel.Field().Interface().([]string); ok { for _, entry := range field { ip := net.ParseIP(entry) _, _, errCIDR := net.ParseCIDR(entry) if errCIDR != nil && ip == nil { return false } } } return true }
Functions ¶
func DefaultLikelihood ¶
func DefaultLikelihood(ipid, intervalFrom, intervalTo uint, unit string) *regression.Regression
defaultLikelihood will generate an R^2 for the specified IP address against all known network profiles including the specified IP address
The interval and unit variables delimiting the data as following: * expected between from and to (unit e.g. days) * observed between from and now() (unit e.g days)
If intervalTo is smaller then one it will use all known data
func HandlerJsonError ¶
HandlerJsonError is a generic way of printing and returning JSON error messages via the frontend
func Likelihood ¶
func Likelihood(ipid, intervalFrom, intervalTo uint, unit string) *regression.Regression
likelihood will generate an R^2 for the specified IP address against traffic found for the specified IP address
The interval and unit variables delimiting the data as following: * expected between from and to (unit e.g. days) * observed between from and now() (unit e.g days)
If intervalTo is smaller then one it will use all known data
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(decodedKey []byte) (*rsa.PrivateKey, error)
ParseRSAPublicKey transforms a serialized private key into a rsa.PrivateKey
func ParseRSAPublicKey ¶
ParseRSAPublicKey transforms a serialized public key into a rsa.PublicKey
func PreparePortalWebRequest ¶
PreparePortalWebRequest sets the portal endpoint and generates the signed header
func RawFlagsByInterface ¶
RawFlagsByInterface returns the raw interface flags since linkFlags in https://golang.org/src/net/interface_linux.go returns only a couple of supported flags. This could change in future (see https://github.com/golang/go/issues/42488). In our case we want to detect LOWER_UP (1<<16).
XXX This function only supports linux distributions!!
Types ¶
This section is empty.