model

package
Version: v0.0.0-...-0bc30a8 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BearerTokenQueryTmpl       = `SELECT * FROM bearer_tokens %s;`
	BearerTokenNamedInsertTmpl = `` /* 158-byte string literal not displayed */

	BearerTokenDeleteTmpl = `DELETE FROM bearer_tokens %s;`
)
View Source
const (
	ConfigurationNamedInsertTmpl = `` /* 141-byte string literal not displayed */

	ConfigurationNamedUpdateTmpl = `
    UPDATE configuration
    SET updated_at=now(), value=:value
    WHERE key=:key OR id=:id;`

	ConfigurationQueryTmpl = `SELECT * FROM configuration %s;`
)
View Source
const (
	ConnectionResetCounterTmpl = `UPDATE connections SET count=0;`

	ConnectionNamedInsertTmpl = `` /* 280-byte string literal not displayed */

	ConnectionNamedUpdateTmpl = `` /* 239-byte string literal not displayed */

	ConnectionCountryQueryTmpl = `` /* 279-byte string literal not displayed */

	ConnectionQueryTmpl = `SELECT * FROM connections WHERE %s;`
)
View Source
const (
	DnsRecordNamedInsertTmpl = `` /* 237-byte string literal not displayed */

	DnsRecordNamedUpdateTmpl = `` /* 190-byte string literal not displayed */

	DnsRecordNamedDeleteTmpl = `DELETE FROM dns_records WHERE %s;`

	DnsRecordQueryTmpl = `SELECT * FROM dns_records %s;`
)
View Source
const (
	ExceptionQueryTmpl       = `SELECT * FROM exceptions %s;`
	ExceptionNamedInsertTmpl = `` /* 178-byte string literal not displayed */

	ExceptionNamedUpdateTmpl = `
    UPDATE exceptions
    SET updated_at=now(), alert=:alert, drop=:drop
    WHERE %s;`
)
View Source
const (
	IPInformationNamedInsertTmpl = `` /* 336-byte string literal not displayed */

	IPInformationNamedUpdateTmpl = `` /* 259-byte string literal not displayed */

	IPInformationQueryTmpl = `SELECT * FROM ip_information WHERE %s;`
)
View Source
const (
	IPProfileCleanUpTmpl = `DELETE FROM ip_profiles WHERE created_at < now() - interval '%d days';`

	IPProfileSelectGroupByIPIDTmpl = `
    SELECT ip_information_id
    FROM ip_profiles
    WHERE %s
    GROUP BY ip_information_id;`

	IPProfileNamedInsertTmpl = `` /* 177-byte string literal not displayed */

	IPProfileQueryTmpl = `` /* 926-byte string literal not displayed */

)
View Source
const (
	NetworkNamedInsertTmpl = `` /* 202-byte string literal not displayed */

	NetworkNamedUpdateTmpl = `` /* 159-byte string literal not displayed */

	NetworkNamedDeleteTmpl = `DELETE FROM networks WHERE %s;`

	NetworkQueryTmpl = `SELECT * FROM networks %s;`
)
View Source
const (
	NetworkInterfaceNamedInsertTmpl = `` /* 350-byte string literal not displayed */

	NetworkInterfaceNamedUpdateTmpl = `` /* 299-byte string literal not displayed */

	NetworkInterfaceNamedDeleteTmpl = `DELETE FROM network_interfaces WHERE %s;`

	NetworkInterfaceQueryTmpl = `SELECT * FROM network_interfaces %s;`
)
View Source
const (
	NotificationQueryTmpl = `SELECT a.* FROM notifications as a %s;`

	NotificationQuerySumCountTmpl = `` /* 144-byte string literal not displayed */

	NotificationNamedInsertTmpl = `` /* 192-byte string literal not displayed */

	NotificationNamedUpdateTmpl = `
    UPDATE notifications
    SET updated_at=now(), reviewed=:reviewed, trigger_count=:trigger_count
    WHERE %s;`
)
View Source
const (
	PatternQueryTmpl = `SELECT * FROM patterns %s;`

	PatternNamedUpdateTmpl = `
    UPDATE patterns
    SET updated_at=now()
    %s;`

	PatternNamedDeleteTmpl = `DELETE FROM patterns %s;`

	PatternNamedInsertTmpl = `` /* 143-byte string literal not displayed */

	PatternNamedBulkInsertTmpl = `` /* 1177-byte string literal not displayed */

	PatternCopyCSVQuery = `
    copy patterns
    from '/usr/share/fengg-pattern/patterns.csv'
    delimiter ',' csv header;`

	PatternCountTmpl = `select count(*) from patterns %s;`
)
View Source
const (
	PatternCategoryQueryTmpl = `
    SELECT * FROM pattern_categories %s;`

	PatternCategoryJoinedQueryTmpl = `` /* 205-byte string literal not displayed */

	PatternCategoryNamedUpdateTmpl = `
    UPDATE pattern_categories
    SET updated_at=now(), enabled=:enabled, count=:count, parent_id=:parent_id
    %s;`

	PatternCategoryNamedInsertTmpl = `` /* 171-byte string literal not displayed */

	PatternCategoryCopyCSVQuery = `
    copy pattern_categories
    from '/usr/share/fengg-pattern/pattern-categories.csv'
    delimiter ',' csv header;`

	PatternCategoryNamedFixCounterTmpl = `` /* 398-byte string literal not displayed */

)
View Source
const (
	PatternCategoryListQueryTmpl = `
    SELECT * FROM pattern_category_lists %s;`

	PatternCategoryListNamedInsertTmpl = `
    INSERT INTO pattern_category_lists (
      pattern_id, category_id
    ) VALUES (
      :pattern_id, :category_id
    );`

	PatternCategoryListCopyCSVQuery = `
    copy pattern_category_lists
    from '/usr/share/fengg-pattern/pattern-category-lists.csv'
    delimiter ',' csv header;`
)
View Source
const (
	PortalEventQueryTmpl       = `SELECT * FROM portal_events %s;`
	PortalEventNamedUpdateTmpl = `
    UPDATE portal_events
    SET updated_at=now(), ack=:ack
    %s;`
	PortalEventNamedInsertTmpl = `` /* 248-byte string literal not displayed */

	PortalEventDeleteTmpl = `DELETE FROM portal_events %s;`
)
View Source
const (
	PortalMigrationQueryTmpl       = `SELECT * FROM portal_migrations %s;`
	PortalMigrationNamedUpdateTmpl = `UPDATE portal_migrations SET version=:version WHERE %s;`
	PortalMigrationNamedInsertTmpl = `
    INSERT INTO portal_migrations (type, version) VALUES (:type, :version);`
)
View Source
const (
	ProfileNamedInsertTmpl = `` /* 188-byte string literal not displayed */

	ProfileNamedUpdateTmpl = `` /* 145-byte string literal not displayed */

	ProfileQueryTmpl = `SELECT * FROM profiles %s;`
)
View Source
const (
	R2ProfileCleanUpTmpl = `
    DELETE FROM r2_profiles
    WHERE created_at < now() - interval '%d days';`

	R2ProfileNamedInsertTmpl = `` /* 331-byte string literal not displayed */

	R2ProfileQueryTmpl = `` /* 706-byte string literal not displayed */

)
View Source
const (
	StatisticQueryTmpl       = `SELECT * FROM statistics %s;`
	StatisticNamedUpdateTmpl = `UPDATE statistics SET count=:count WHERE %s;`
	StatisticNamedInsertTmpl = `INSERT INTO statistics (key, count) VALUES (:key, :count);`
)
View Source
const (
	UserQueryTmpl = `SELECT * FROM users %s;`

	UserNamedUpdateTmpl = `
    UPDATE users
    SET updated_at=now(), name=:name, surname=:surname,
        bio=:bio, email=:email %s
    WHERE %s;`

	UserNamedInsertTmpl = `` /* 356-byte string literal not displayed */

)
View Source
const (
	WatcherResultNamedInsertTmpl = `` /* 193-byte string literal not displayed */

	WatcherResultNamedUpdateTmpl = `` /* 148-byte string literal not displayed */

	WatcherResultResetRetriesTmpl = `UPDATE watcher_results SET retries=0 WHERE retries > 0;`

	WatcherResultQueryTmpl = `SELECT * FROM watcher_results %s;`
)

Variables

This section is empty.

Functions

func Database

func Database() (*sqlx.DB, error)

Database returns the sqlx.DB pointer. Remember to close the connection if you are done!

func DatabaseAuth

func DatabaseAuth(driver string, connect string)

DatabaseAuth sets the authentication credentials for sqlx.

func IPProfileIPIDs

func IPProfileIPIDs() ([]uint, error)

IPProfileIPIDs returns from the last 30 minutes the active profile IDs

func Logger

func Logger(customLogger zerolog.Logger)

func NotificationCount

func NotificationCount(count *int) error

func PatternIPCount

func PatternIPCount(count *int) error

PatternIPCount will fetch the database count of the available IP pattern

func PatternImport

func PatternImport() error

PatternImport will bulk import all installed patterns and rules. WARNING: This is a very hardware expensive job!

func PatternURLCount

func PatternURLCount(count *int) error

PatternURLCount will fetch the database count of the available URL pattern

Types

type BearerLevel

type BearerLevel int
const (
	BearerRootLevel BearerLevel = 0
)

type BearerToken

type BearerToken struct {
	ID        uint      `db:"id" json:"id" binding:"-"`
	CreatedAt time.Time `db:"created_at" json:"createdAt" binding:"-"`

	UserID uint        `db:"user_id" json:"userId" binding:"-"`
	Token  string      `db:"token" json:"token" binding:"-"`
	Level  BearerLevel `db:"level" json:"level" binding:"-"`
	Note   *string     `db:"note" json:"note,omitempty" binding:"-"`
}

func NewBearerToken

func NewBearerToken() *BearerToken

func (*BearerToken) Create

func (token *BearerToken) Create() error

func (*BearerToken) DeleteByIDAndUserID

func (token *BearerToken) DeleteByIDAndUserID(id, uid uint) error

func (*BearerToken) FindByToken

func (token *BearerToken) FindByToken(fbToken string) error

type BearerTokens

type BearerTokens []BearerToken

func (*BearerTokens) FindByUserID

func (tokens *BearerTokens) FindByUserID(uid uint) error

type Configuration

type Configuration struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	Key   types.ConfigurationKey `db:"key" json:"key"`
	Value types.JsonString       `db:"value" json:"value"`
}

func NewConfiguration

func NewConfiguration(key types.ConfigurationKey) *Configuration

func (*Configuration) Create

func (configuration *Configuration) Create() error

func (*Configuration) Exists

func (configuration *Configuration) Exists() bool

Exists directly updates the struct with the findings

func (*Configuration) Map

func (configuration *Configuration) Map() (jsonMap map[string]interface{})

func (*Configuration) Marshal

func (configuration *Configuration) Marshal(data interface{}) error

func (*Configuration) MarshalAndCreate

func (configuration *Configuration) MarshalAndCreate(data interface{}) error

func (*Configuration) Slice

func (configuration *Configuration) Slice() (jsonSlice []string)

func (*Configuration) Update

func (configuration *Configuration) Update() error

type Connection

type Connection struct {
	ID        uint      `db:"id" json:"id"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	Count uint `db:"count" json:"count"`

	SourceID              uint `db:"source_id" json:"sourceId"`
	DestinationID         uint `db:"destination_id" json:"destinationId"`
	TransportProtocolID   uint `db:"transport_protocol_id" json:"transportProtocolId"`
	ApplicationProtocolID uint `db:"application_protocol_id" json:"applicationProtocolId"`

	Source              IPInformation `db:"-" json:"source"`
	Destination         IPInformation `db:"-" json:"destination"`
	TransportProtocol   Protocol      `db:"-" json:"transportProtocol"`
	ApplicationProtocol Protocol      `db:"-" json:"applicationProtocol"`
}

func NewConnection

func NewConnection() *Connection

func (*Connection) Create

func (a *Connection) Create() error

func (*Connection) Exists

func (a *Connection) Exists() bool

func (*Connection) LookupExtraInformation

func (a *Connection) LookupExtraInformation()

func (*Connection) PreLoad

func (a *Connection) PreLoad() error

PreLoad will fetch all extra information like e.g. IP information and write them to the connection struct

func (*Connection) Update

func (a *Connection) Update() error

func (*Connection) Valid

func (a *Connection) Valid() bool

type Connections

type Connections []Connection

func (*Connections) FindRecentConnections

func (a *Connections) FindRecentConnections() error

func (Connections) PreLoad

func (connections Connections) PreLoad() error

type DnsRecord

type DnsRecord struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	NetworkID uint      `db:"network_id" json:"networkId"`
	Type      int16     `db:"type" json:"type"`
	IPv4      *types.IP `db:"ipv4" json:"ipv4"`
	IPv6      *types.IP `db:"ipv6" json:"ipv6"`
	Name      string    `db:"name" json:"name"`
	Value     string    `db:"value" json:"value"`
	Priority  *int      `db:"priority" json:"priority"`
	TTL       *int      `db:"ttl" json:"ttl"`
}

func NewDnsRecord

func NewDnsRecord() *DnsRecord

func (*DnsRecord) Create

func (record *DnsRecord) Create() error

func (*DnsRecord) Delete

func (record *DnsRecord) Delete() error

func (*DnsRecord) Exists

func (record *DnsRecord) Exists() bool

Exists directly updates the struct with the findings

func (*DnsRecord) Update

func (record *DnsRecord) Update() error

type DnsRecords

type DnsRecords []DnsRecord

func (*DnsRecords) FindAll

func (records *DnsRecords) FindAll() error

func (*DnsRecords) FindByNetworkID

func (records *DnsRecords) FindByNetworkID(id uint) error

type Exception

type Exception struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	Type  types.NFQActionType `db:"type" json:"type"`
	Alert bool                `db:"alert" json:"alert"`
	Drop  bool                `db:"drop" json:"drop"`

	PatternID uint `db:"pattern_id" json:"patternId"`
	// can be loaded with PreLoad function
	Pattern *Pattern `db:"-" json:"-"`
}

func NewException

func NewException() *Exception

func (*Exception) Create

func (exception *Exception) Create() error

func (*Exception) Exists

func (exception *Exception) Exists() bool

Exists directly updates the struct with the findings

func (*Exception) FindByPattern

func (exception *Exception) FindByPattern(pattern Pattern) error

func (*Exception) PreLoad

func (exception *Exception) PreLoad() error

func (*Exception) Update

func (exception *Exception) Update() error

type Exceptions

type Exceptions []*Exception

func (*Exceptions) FindAll

func (exceptions *Exceptions) FindAll() error

func (*Exceptions) FindOutOfSync

func (exceptions *Exceptions) FindOutOfSync(migration PortalMigration) error

func (Exceptions) PreLoad

func (exceptions Exceptions) PreLoad() error

type IPInformation

type IPInformation struct {
	ID                uint      `db:"id" json:"id"`
	CreatedAt         time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt         time.Time `db:"updated_at" json:"updatedAt"`
	IP                types.IP  `db:"ip" json:"ip"`
	MacAddress        string    `db:"mac" json:"macAddress"`
	ReverseDNS        string    `db:"reverse_dns" json:"reverseDNS"`
	NetBIOS           string    `db:"net_bios" json:"netBIOS"`
	Country           string    `db:"country" json:"country"`
	EuropeanUnion     bool      `db:"european_union" json:"europeanUnion"`
	AnonymousProxy    bool      `db:"anonymous_proxy" json:"anonymousProxy"`
	SatelliteProvider bool      `db:"satellite_provider" json:"satelliteProvider"`
}

func NewIPInformation

func NewIPInformation() *IPInformation

func (*IPInformation) CreateOrUpdate

func (info *IPInformation) CreateOrUpdate() error

func (*IPInformation) Find

func (info *IPInformation) Find() error

func (*IPInformation) InternalNetwork

func (info *IPInformation) InternalNetwork() bool

func (*IPInformation) LookupMAC

func (info *IPInformation) LookupMAC() error

func (*IPInformation) LookupNetBios

func (info *IPInformation) LookupNetBios() error

func (*IPInformation) LookupRDNSAndGeoIP

func (info *IPInformation) LookupRDNSAndGeoIP()

func (*IPInformation) Valid

func (info *IPInformation) Valid() bool

type IPInformations

type IPInformations []IPInformation

type IPProfile

type IPProfile struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`

	IPInformationID uint `db:"ip_information_id" json:"ipInformationId"`
	ProtocolID      uint `db:"protocol_id" json:"protocolId"`

	IPInformation IPInformation `db:"-" json:"ipInformation"`
	Protocol      Protocol      `db:"-" json:"protocol"`

	Weight float64 `db:"weight" json:"weight"`
}

func NewIPProfile

func NewIPProfile() *IPProfile

func (*IPProfile) Create

func (profile *IPProfile) Create() error

func (*IPProfile) Find

func (profile *IPProfile) Find() error

type IPProfiles

type IPProfiles []IPProfile

func (*IPProfiles) Get

func (profiles *IPProfiles) Get(ipInformationID, protocolID uint) *IPProfile

type Network

type Network struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	Name    string       `db:"name" json:"name" binding="alphanum,min=4"`
	Address *types.IP    `db:"address" json:"address,omitempty" binding="ip"`
	Network *types.IPNet `db:"network" json:"network,omitempty" binding="ipnet"`
	DHCP    bool         `db:"dhcp" json:"dhcp"`
	DNS     bool         `db:"dns" json:"dns"`
	Client  bool         `db:"client" json:"client"`
}

func NewNetwork

func NewNetwork() *Network

func (*Network) Create

func (network *Network) Create() error

func (*Network) Delete

func (network *Network) Delete() error

func (*Network) Exists

func (network *Network) Exists() bool

Exists directly updates the struct with the findings

func (*Network) Update

func (network *Network) Update() error

type NetworkInterface

type NetworkInterface struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	Name           string  `db:"name" json:"name"`
	DefaultGateway bool    `db:"default_gateway" json:"defaultGateway"`
	GatewayID      *uint   `db:"gateway_id" json:"gatewayId,omitempty"`
	NetworkID      uint    `db:"network_id" json:"networkId" binding="required"`
	WirelessCard   bool    `db:"wireless" json:"wirelessCard"`
	PhysicalCard   bool    `db:"physical" json:"physicalCard"`
	BridgeMaster   bool    `db:"bridge_master" json:"bridgeMaster"`
	BridgeID       *string `db:"bridge_id" json:"bridgeId"`
	TunTapDevice   bool    `db:"tun" json:"tunTapDevice"`
	Link           bool    `db:"link" json:"link"`
}

func NewNetworkInterface

func NewNetworkInterface() *NetworkInterface

func (*NetworkInterface) Create

func (intf *NetworkInterface) Create() error

func (*NetworkInterface) Delete

func (intf *NetworkInterface) Delete() error

func (*NetworkInterface) Exists

func (intf *NetworkInterface) Exists() bool

Exists directly updates the struct with the findings

func (*NetworkInterface) Network

func (intf *NetworkInterface) Network() (network *Network)

Network fetches the assigned ip network configuration for the interface

func (*NetworkInterface) ResetBridgeSetup

func (intf *NetworkInterface) ResetBridgeSetup() error

ResetBridgeSetup will remove all bridge related flags from the master and salve interfaces.

func (*NetworkInterface) Update

func (intf *NetworkInterface) Update() error

type NetworkInterfaces

type NetworkInterfaces []NetworkInterface

func (*NetworkInterfaces) FindAll

func (intfs *NetworkInterfaces) FindAll() error

func (*NetworkInterfaces) FindByNetworkID

func (intfs *NetworkInterfaces) FindByNetworkID(id uint) error

FindByNetworkID returns all interfaces related to the given network ID

func (*NetworkInterfaces) FindWirelessCards

func (intfs *NetworkInterfaces) FindWirelessCards() error

type Networks

type Networks []Network

func (*Networks) FindAll

func (networks *Networks) FindAll() error

func (*Networks) FindAllDHCP

func (networks *Networks) FindAllDHCP() error

type Notification

type Notification struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	TriggerCount uint                `db:"trigger_count" json:"triggerCount"`
	Type         types.NFQActionType `db:"type" json:"type"`
	Reviewed     bool                `db:"reviewed" json:"reviewed"`
	PatternID    uint                `db:"pattern_id" json:"patternId"`
	// can be loaded with PreLoad function
	Pattern *Pattern `db:"-" json:"-"`
}

func NewNotification

func NewNotification() *Notification

func (*Notification) Create

func (notification *Notification) Create() error

func (*Notification) Exists

func (notification *Notification) Exists() bool

Exists directly updates the struct with the findings

func (*Notification) FindByID

func (notification *Notification) FindByID() error

func (*Notification) PreLoad

func (notification *Notification) PreLoad() error

func (*Notification) Update

func (notification *Notification) Update() error

type Notifications

type Notifications []*Notification

func (*Notifications) FindOutOfSync

func (notifications *Notifications) FindOutOfSync(migration PortalMigration) error

func (Notifications) PreLoad

func (notifications Notifications) PreLoad() error

type Pattern

type Pattern struct {
	ID        uint      `db:"id" json:"id"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	Raw     string `db:"raw" json:"raw"`
	IP      bool   `db:"ip" json:"ip"`
	URL     bool   `db:"url" json:"url"`
	URLPath bool   `db:"url_path" json:"urlPath"`
}

func NewPattern

func NewPattern(address string) *Pattern

func (*Pattern) Create

func (pattern *Pattern) Create() error

func (*Pattern) Delete

func (pattern *Pattern) Delete() error

Delete will delete the pattern and all its relation e.g. category, category lists for more details see the postgres trigger function clean_up_after_pattern_delete

func (*Pattern) Exists

func (pattern *Pattern) Exists() bool

func (*Pattern) FindByID

func (pattern *Pattern) FindByID(id uint) error

func (*Pattern) Parse

func (pattern *Pattern) Parse(address string)

func (*Pattern) Update

func (pattern *Pattern) Update() error

func (Pattern) Valid

func (pattern Pattern) Valid() bool

type PatternCategories

type PatternCategories []*PatternCategory

func (*PatternCategories) FindAll

func (categories *PatternCategories) FindAll() error

func (*PatternCategories) FindByEnabled

func (categories *PatternCategories) FindByEnabled(enabled bool) error

func (PatternCategories) FindPatterns

func (categories PatternCategories) FindPatterns() (patterns Patterns, err error)

func (PatternCategories) FixCategoryCounter

func (categories PatternCategories) FixCategoryCounter() error

FixCategoryCounter will update the counter column. This happens normally after an update.

type PatternCategory

type PatternCategory struct {
	ID        uint      `db:"id" json:"id"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	Name     string `db:"name" json:"name"`
	ParentID *uint  `db:"parent_id" json:"-"`
	Enabled  bool   `db:"enabled" json:"enabled"`
	Count    int    `db:"count" json:"count"`
}

func NewPatternCategory

func NewPatternCategory() *PatternCategory

func (*PatternCategory) Create

func (category *PatternCategory) Create() error

func (*PatternCategory) Exists

func (category *PatternCategory) Exists() bool

func (PatternCategory) FindPatterns

func (category PatternCategory) FindPatterns() (patterns Patterns, err error)

func (*PatternCategory) Update

func (category *PatternCategory) Update() error

type PatternCategoryList

type PatternCategoryList struct {
	PatternID  uint `db:"pattern_id" json:"patternId"`
	CategoryID uint `db:"category_id" json:"categoryId"`
}

func NewPatternCategoryList

func NewPatternCategoryList() *PatternCategoryList

func (*PatternCategoryList) Create

func (list *PatternCategoryList) Create() error

func (*PatternCategoryList) Exists

func (list *PatternCategoryList) Exists() bool

type PatternCategoryLists

type PatternCategoryLists []PatternCategoryList

type Patterns

type Patterns []*Pattern

func (*Patterns) Delete

func (patterns *Patterns) Delete() error

Delete will delete the pattern and all its relation e.g. category, category lists for more details see the postgres trigger function clean_up_after_pattern_delete

func (*Patterns) FindByEnabled

func (patterns *Patterns) FindByEnabled(enabled bool) error

type PortalEvent

type PortalEvent struct {
	ID        uint      `db:"id" json:"id" binding:"gt=0"`
	PID       uint      `db:"pid" json:"pid"`
	CreatedAt time.Time `db:"created_at" json:"createdAt" binding:"-"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt" binding:"-"`

	Ack       *bool                 `db:"ack" json:"ack,omitempty"`
	Type      types.PortalEventType `db:"type" json:"type" binding:"gt=0"`
	Message   *types.JsonString     `db:"message" json:"message,omitempty"`
	MessageID uint                  `db:"message_id" json:"messageId" binding:"gt=0"`
	UuidID    uint                  `db:"uuid_id" json:"uuidId" binding:"gt=0"`
	ClientID  uint                  `db:"client_id" json:"clientId,omitempty"`
}

func NewPortalEvent

func NewPortalEvent() *PortalEvent

func (*PortalEvent) Create

func (event *PortalEvent) Create() error

func (*PortalEvent) Exists

func (event *PortalEvent) Exists(pid uint) bool

func (*PortalEvent) Update

func (event *PortalEvent) Update() error

type PortalEvents

type PortalEvents []PortalEvent

func (*PortalEvents) FindAll

func (events *PortalEvents) FindAll() error

type PortalMigration

type PortalMigration struct {
	Type    types.PortalEventType `db:"type" json:"type"`
	Version time.Time             `db:"version" json:"version"`
}

func NewPortalMigration

func NewPortalMigration() *PortalMigration

func (*PortalMigration) CreateOrUpdate

func (migration *PortalMigration) CreateOrUpdate() error

func (*PortalMigration) FindByType

func (migration *PortalMigration) FindByType(id types.PortalEventType) error

type PortalMigrations

type PortalMigrations []PortalMigration

type Profile

type Profile struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	IPInformationID uint          `db:"ip_information_id" json:"ipInformationId"`
	IPInformation   IPInformation `db:"-" json:"ipInformation"`

	AnomalyDetection float64 `db:"anomaly_detection" json:"anomalyDetection"`
}

func NewProfile

func NewProfile() *Profile

func (*Profile) Create

func (profile *Profile) Create() error

func (*Profile) Exists

func (profile *Profile) Exists() bool

func (*Profile) PreLoad

func (profile *Profile) PreLoad() error

PreLoad will fetch all extra information like e.g. IP information and write them to the profile struct

func (*Profile) Update

func (profile *Profile) Update() error

type Profiles

type Profiles []Profile

func (*Profiles) FindAll

func (profiles *Profiles) FindAll() error

func (Profiles) PreLoad

func (profiles Profiles) PreLoad() error

type Protocol

type Protocol struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	Name      string    `db:"name" json:"name"`
}

func NewProtocol

func NewProtocol() *Protocol

func (*Protocol) CreateIfNotExists

func (protocol *Protocol) CreateIfNotExists() error

func (*Protocol) Find

func (protocol *Protocol) Find() error

func (*Protocol) ParseIPHeader

func (protocol *Protocol) ParseIPHeader(num int)

String will print the string representation of the network protocol layer (see https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)

func (Protocol) Valid

func (protocol Protocol) Valid() bool

type R2Profile

type R2Profile struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`

	IPInformationID uint          `db:"ip_information_id" json:"ipInformationId"`
	IPInformation   IPInformation `db:"-" json:"ipInformation"`

	R2Daily          float64 `db:"r2_daily" json:"r2Daily"`
	R2Weekly         float64 `db:"r2_weekly" json:"r2Weekly"`
	R2Monthly        float64 `db:"r2_monthly" json:"r2Monthly"`
	R2DailyNetwork   float64 `db:"r2_daily_network" json:"r2DailyNetwork"`
	R2WeeklyNetwork  float64 `db:"r2_weekly_network" json:"r2WeeklyNetwork"`
	R2MonthlyNetwork float64 `db:"r2_monthly_network" json:"r2MonthlyNetwork"`
}

func NewR2Profile

func NewR2Profile() *R2Profile

func (*R2Profile) Create

func (profile *R2Profile) Create() error

func (*R2Profile) Exists

func (profile *R2Profile) Exists() bool

type R2Profiles

type R2Profiles []R2Profile

func (*R2Profiles) CleanUp

func (profiles *R2Profiles) CleanUp(days int) error

CleanUp will purge all profiles older then X days

func (*R2Profiles) FindAll

func (profiles *R2Profiles) FindAll() error

func (*R2Profiles) FindTodaysProfiles

func (profiles *R2Profiles) FindTodaysProfiles() error

FindTodaysProfiles selects all profiles with a creation time of now()::date

func (R2Profiles) Len

func (profiles R2Profiles) Len() int

make R2Profiles sortable

func (R2Profiles) Less

func (profiles R2Profiles) Less(i, j int) bool

func (R2Profiles) Swap

func (profiles R2Profiles) Swap(i, j int)

type Statistic

type Statistic struct {
	ID    uint               `db:"id" json:"id"`
	Key   types.StatisticKey `db:"key" json:"key"`
	Count float64            `db:"count" json:"count"`
}

func NewStatistic

func NewStatistic() *Statistic

func (*Statistic) CreateOrUpdate

func (statistic *Statistic) CreateOrUpdate() error

func (*Statistic) Find

func (statistic *Statistic) Find() error

func (Statistic) Valid

func (statistic Statistic) Valid() bool

type Statistics

type Statistics []Statistic

func (Statistics) CreateOrUpdate

func (statistics Statistics) CreateOrUpdate() (errs []error)

func (*Statistics) Find

func (statistics *Statistics) Find() error

func (*Statistics) FindAll

func (statistics *Statistics) FindAll() error

type User

type User struct {
	ID        uint      `db:"id" json:"id" binding:"-"`
	CreatedAt time.Time `db:"created_at" json:"createdAt" binding:"-"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt" binding:"-"`

	Name    *string `db:"name" json:"name,omitempty"`
	Surname *string `db:"surname" json:"surname,omitempty"`
	Bio     *string `db:"bio" json:"bio,omitempty"`
	Email   *string `db:"email" json:"email,omitempty" binding="email,omitempty"`

	Nickname string  `db:"nickname" json:"nickname" binding:"alphanum,min=4"`
	Password *string `db:"-" json:"password,omitempty" binding:"min=4,required"`
	// XXX Repassword must be validated manually
	Repassword     *string `db:"-" json:"repassword,omitempty" binding:"-"`
	HashedPassword string  `db:"hashed_password" json:"-" binding:"-"`

	Fingerprint          string `db:"fingerprint" json:"fingerprint" binding:"fingerprint"`
	SerializedPublicKey  string `db:"serialized_public_key" json:"serializedPublicKey" binding:"publickey"`
	SerializedPrivateKey string `db:"serialized_private_key" json:"-" binding:"privatekey"`
}

func NewUser

func NewUser() *User

func (*User) Create

func (user *User) Create() error

func (*User) FindByFingerprint

func (user *User) FindByFingerprint(fingerprint string) error

func (*User) FindByID

func (user *User) FindByID(id uint) error

func (*User) FindByNickname

func (user *User) FindByNickname(nickname string) error

func (*User) Update

func (user *User) Update() error

type Users

type Users []User

func (*Users) FindAll

func (users *Users) FindAll() error

type WatcherResult

type WatcherResult struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`

	WorkerName string  `db:"worker_name" json:"workerName"`
	Alive      bool    `db:"alive" json:"alive"`
	Retries    int     `db:"retries" json:"retries"`
	Error      *string `db:"error" json:"error,omitempty"`
}

func NewWatcherResult

func NewWatcherResult() *WatcherResult

func (*WatcherResult) Create

func (result *WatcherResult) Create() error

func (*WatcherResult) Exists

func (result *WatcherResult) Exists() bool

func (*WatcherResult) Update

func (result *WatcherResult) Update() error

type WatcherResults

type WatcherResults []WatcherResult

func (*WatcherResults) FindAll

func (results *WatcherResults) FindAll() error

func (*WatcherResults) ResetRetries

func (results *WatcherResults) ResetRetries() error

Jump to

Keyboard shortcuts

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