queries

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLogCountryStat

type AccessLogCountryStat struct {
	CountryCode   string
	CountryName   string
	ContinentCode string
	Total         int64
	Allowed       int64
	Denied        int64
}

AccessLogCountryStat holds aggregated request counts for a single country.

type AccessLogQuery

type AccessLogQuery struct {
	From          time.Time
	To            time.Time
	BeforeID      *int64 // cursor: return rows with id < BeforeID; nil for first page
	ClientIP      *string
	Outcome       *bool
	DenyReason    *string
	DeviceID      *device.DeviceID
	TargetHost    *string
	CountryCode   *string
	ContinentCode *string
	Limit         int
}

func NewAccessLogQuery

func NewAccessLogQuery(params httpapi.GetAccessLogParams) AccessLogQuery

type AccessLogView

type AccessLogView struct {
	ID            int64
	ClientIP      string
	Outcome       bool
	DenyReason    *string
	DeviceID      *device.DeviceID
	DeviceName    *string
	AddressID     *device.AddressID
	CreatedAt     time.Time
	DurationUs    int64
	XFFChain      *string
	TargetHost    *string
	TargetURI     *string
	HTTPMethod    *string
	Headers       map[string][]string
	CountryCode   *string
	CountryName   *string
	ContinentCode *string
	ASN           *int64
	ASNOrg        *string
}

type AddressView

type AddressView struct {
	ID        device.AddressID `db:"id"`
	DeviceID  device.DeviceID  `db:"device_id"`
	IP        string           `db:"ip"`
	IsEnabled bool             `db:"is_enabled"`
	Source    string           `db:"source"`
	UpdatedAt time.Time        `db:"updated_at"`
	CreatedAt time.Time        `db:"created_at"`
	ExpiresAt *time.Time       `db:"expires_at"`
}

type DeviceView

type DeviceView struct {
	ID           device.DeviceID   `db:"id"`
	Name         string            `db:"name"`
	DeviceType   device.DeviceType `db:"device_type"`
	Description  *string           `db:"description"`
	Icon         *string           `db:"icon"`
	CreatedAt    time.Time         `db:"created_at"`
	UpdatedAt    time.Time         `db:"updated_at"`
	KeyPrefix    string            `db:"key_prefix"`
	AddressCount int               `db:"address_count"`
	LastSeenAt   *database.DBTime  `db:"last_seen_at"`
}

type HTTPHandler

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

func NewHTTPHandler

func NewHTTPHandler(repo *Repository, logger *slog.Logger) *HTTPHandler

func (*HTTPHandler) GetAccessLog

type Repository

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

func NewRepository

func NewRepository(db *sqlx.DB) *Repository

func (*Repository) DeviceExists

func (r *Repository) DeviceExists(ctx context.Context, deviceID device.DeviceID) (bool, error)

func (*Repository) GetDeviceAddresses

func (r *Repository) GetDeviceAddresses(ctx context.Context, deviceID device.DeviceID) ([]AddressView, error)

func (*Repository) GetDevices

func (r *Repository) GetDevices(ctx context.Context) ([]DeviceView, error)

func (*Repository) ListAccessLog

func (r *Repository) ListAccessLog(ctx context.Context, q AccessLogQuery) ([]AccessLogView, int, error)

func (*Repository) ListAccessLogStatsByCountry

func (r *Repository) ListAccessLogStatsByCountry(ctx context.Context, from, to time.Time) ([]AccessLogCountryStat, error)

ListAccessLogStatsByCountry returns request counts grouped by country for all rows within the [from, to] time window. Only rows with GeoIP data are included.

Jump to

Keyboard shortcuts

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