database

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeFileHash

func ComputeFileHash(path string) (string, error)

Types

type Client

type Client struct {
	IP     *IPClient
	Report *ReportClient
}

func NewClient

func NewClient(sqliteDBPath string) (*Client, error)

type IP

type IP struct {
	gorm.Model
	Value   string `gorm:"uniqueIndex"`
	CtiData string
	Reports []Report `gorm:"many2many:report_ips;"`
}

type IPClient

type IPClient struct {
	// contains filtered or unexported fields
}

func NewIPClient

func NewIPClient(db *gorm.DB) (*IPClient, error)

func (*IPClient) Create

func (i *IPClient) Create(ipAddr string, ctiData *cticlient.SmokeItem) (*IP, error)

func (*IPClient) CreateBatch

func (i *IPClient) CreateBatch(ips []*cticlient.SmokeItem) ([]IP, error)

func (*IPClient) Find

func (i *IPClient) Find(ipAddr string) (*cticlient.SmokeItem, error)

func (*IPClient) GetLastRefresh

func (i *IPClient) GetLastRefresh(value string) (time.Time, error)

type Report

type Report struct {
	gorm.Model
	Name        string
	FilePath    string
	IsFile      bool
	FileHash    string
	IsQuery     bool
	Query       string
	Since       string
	SinceTime   time.Time
	IPs         []IP        `gorm:"many2many:report_ips;"`
	StatsReport ReportStats `gorm:"constraint:OnDelete:CASCADE;"`
}

type ReportClient

type ReportClient struct {
	// contains filtered or unexported fields
}

func NewReportClient

func NewReportClient(db *gorm.DB) (*ReportClient, error)

func (*ReportClient) Create

func (r *ReportClient) Create(report *Report) error

func (*ReportClient) DeleteExpiredSince

func (r *ReportClient) DeleteExpiredSince(expirationDate time.Time) error

func (*ReportClient) FilePathExist

func (r *ReportClient) FilePathExist(filePath string) (*Report, bool, error)

func (*ReportClient) Find

func (r *ReportClient) Find(reportID string) (*Report, error)

func (*ReportClient) FindAll

func (r *ReportClient) FindAll() ([]*Report, error)

func (*ReportClient) FindByHash

func (r *ReportClient) FindByHash(filepath string) (*Report, error)

func (*ReportClient) FindById

func (r *ReportClient) FindById(reportID uint) (*Report, error)

func (*ReportClient) GetExpiredIPsFromReport

func (r *ReportClient) GetExpiredIPsFromReport(reportID uint) ([]*IP, error)

type ReportStats

type ReportStats struct {
	gorm.Model
	ReportID uint   `gorm:"uniqueIndex"` // ensure one-to-one
	Stats    string `gorm:"type:text"`   // store JSON as string
}

Jump to

Keyboard shortcuts

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