db

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Handle defines the global database handle
	Handle *gorm.DB
)

Functions

func Cleanup

func Cleanup(timestamp time.Time)

Cleanup removes old events

func GetDefaultSession

func GetDefaultSession() (*gorm.DB, context.CancelFunc)

GetDefaultSession returns a database session with the default timeout. Don't forget to cancel the returned context

func Initialize

func Initialize(driver, dsn, customTLSConfig string, dbDebug bool, poolSize int) error

Initialize initializes the database engine

Types

type FsEvent

type FsEvent struct {
	ID                string `json:"id" gorm:"primaryKey"`
	Timestamp         int64  `json:"timestamp"`
	Action            string `json:"action"`
	Username          string `json:"username"`
	FsPath            string `json:"fs_path"`
	FsTargetPath      string `json:"fs_target_path,omitempty"`
	VirtualPath       string `json:"virtual_path"`
	VirtualTargetPath string `json:"virtual_target_path,omitempty"`
	SSHCmd            string `json:"ssh_cmd,omitempty"`
	FileSize          int64  `json:"file_size,omitempty"`
	Elapsed           int64  `json:"elapsed,omitempty"`
	Status            int    `json:"status"`
	Protocol          string `json:"protocol"`
	IP                string `json:"ip,omitempty"`
	SessionID         string `json:"session_id"`
	FsProvider        int    `json:"fs_provider"`
	Bucket            string `json:"bucket,omitempty"`
	Endpoint          string `json:"endpoint,omitempty"`
	OpenFlags         int    `json:"open_flags,omitempty"`
	Role              string `json:"role,omitempty"`
	InstanceID        string `json:"instance_id,omitempty"`
}

FsEvent defines a filesystem event

func (*FsEvent) BeforeCreate

func (ev *FsEvent) BeforeCreate(_ *gorm.DB) error

BeforeCreate implements gorm hook

func (*FsEvent) Create

func (ev *FsEvent) Create(tx *gorm.DB) error

Create persists the object

func (*FsEvent) TableName

func (ev *FsEvent) TableName() string

TableName defines the database table name

type LogEvent added in v1.0.7

type LogEvent struct {
	ID         string `json:"id" gorm:"primaryKey"`
	Timestamp  int64  `json:"timestamp"`
	Event      int    `json:"event"`
	Protocol   string `json:"protocol,omitempty"`
	Username   string `json:"username,omitempty"`
	IP         string `json:"ip,omitempty"`
	Message    string `json:"message,omitempty"`
	Role       string `json:"role,omitempty"`
	InstanceID string `json:"instance_id,omitempty"`
}

LogEvent defines a log event

func (*LogEvent) BeforeCreate added in v1.0.7

func (ev *LogEvent) BeforeCreate(_ *gorm.DB) (err error)

BeforeCreate implements gorm hook

func (*LogEvent) Create added in v1.0.7

func (ev *LogEvent) Create(tx *gorm.DB) error

Create persists the object

func (*LogEvent) TableName added in v1.0.7

func (ev *LogEvent) TableName() string

TableName defines the database table name

type Notifier

type Notifier struct {
	InstanceID string
}

func (*Notifier) NotifyFsEvent

func (n *Notifier) NotifyFsEvent(event *notifier.FsEvent) error

func (*Notifier) NotifyLogEvent added in v1.0.7

func (n *Notifier) NotifyLogEvent(event *notifier.LogEvent) error

func (*Notifier) NotifyProviderEvent

func (n *Notifier) NotifyProviderEvent(event *notifier.ProviderEvent) error

type ProviderEvent

type ProviderEvent struct {
	ID         string `json:"id" gorm:"primaryKey"`
	Timestamp  int64  `json:"timestamp"`
	Action     string `json:"action"`
	Username   string `json:"username"`
	IP         string `json:"ip,omitempty"`
	ObjectType string `json:"object_type"`
	ObjectName string `json:"object_name"`
	ObjectData []byte `json:"object_data"`
	Role       string `json:"role,omitempty"`
	InstanceID string `json:"instance_id,omitempty"`
}

ProviderEvent defines a provider event

func (*ProviderEvent) BeforeCreate

func (ev *ProviderEvent) BeforeCreate(_ *gorm.DB) (err error)

BeforeCreate implements gorm hook

func (*ProviderEvent) Create

func (ev *ProviderEvent) Create(tx *gorm.DB) error

Create persists the object

func (*ProviderEvent) TableName

func (ev *ProviderEvent) TableName() string

TableName defines the database table name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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