accesslogs

package
v0.81.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package accesslogs is a generated GoMock package.

Index

Constants

View Source
const (
	// DefaultPageSize is the default number of records per page
	DefaultPageSize = 50
	// MaxPageSize is the maximum number of records allowed per page
	MaxPageSize = 100

	// Default sorting
	DefaultSortBy    = "timestamp"
	DefaultSortOrder = "desc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLogEntry

type AccessLogEntry struct {
	ID              string        `gorm:"primaryKey"`
	AccountID       string        `gorm:"index"`
	ServiceID       string        `gorm:"index"`
	Timestamp       time.Time     `gorm:"index"`
	GeoLocation     peer.Location `gorm:"embedded;embeddedPrefix:location_"`
	SubdivisionCode string
	Method          string        `gorm:"index"`
	Host            string        `gorm:"index"`
	Path            string        `gorm:"index"`
	Duration        time.Duration `gorm:"index"`
	StatusCode      int           `gorm:"index"`
	Reason          string
	UserId          string            `gorm:"index"`
	AuthMethodUsed  string            `gorm:"index"`
	BytesUpload     int64             `gorm:"index"`
	BytesDownload   int64             `gorm:"index"`
	Protocol        AccessLogProtocol `gorm:"index"`
	Metadata        map[string]string `gorm:"serializer:json"`
	// AgentNetwork marks the entry as emitted by a synthesised agent-network
	// service. Sourced from proto.AccessLog.AgentNetwork the proxy stamps
	// before shipping. Indexed so the agent-network log surface filters cheaply.
	AgentNetwork bool `gorm:"index"`
}

func (*AccessLogEntry) FromProto

func (a *AccessLogEntry) FromProto(serviceLog *proto.AccessLog)

FromProto creates an AccessLogEntry from a proto.AccessLog

func (*AccessLogEntry) ToAPIResponse

func (a *AccessLogEntry) ToAPIResponse() *api.ProxyAccessLog

ToAPIResponse converts an AccessLogEntry to the API ProxyAccessLog type

type AccessLogFilter

type AccessLogFilter struct {
	// Page is the current page number (1-indexed)
	Page int
	// PageSize is the number of records per page
	PageSize int

	// Sorting parameters
	SortBy    string // Field to sort by: timestamp, url, host, path, method, status_code, duration, source_ip, user_id, auth_method, reason
	SortOrder string // Sort order: asc or desc (default: desc)

	// Filtering parameters
	Search     *string    // General search across log ID, host, path, source IP, and user fields
	SourceIP   *string    // Filter by source IP address
	Host       *string    // Filter by host header
	Path       *string    // Filter by request path (supports LIKE pattern)
	UserID     *string    // Filter by authenticated user ID
	UserEmail  *string    // Filter by user email (requires user lookup)
	UserName   *string    // Filter by user name (requires user lookup)
	Method     *string    // Filter by HTTP method
	Status     *string    // Filter by status: "success" (2xx/3xx) or "failed" (1xx/4xx/5xx)
	StatusCode *int       // Filter by HTTP status code
	StartDate  *time.Time // Filter by timestamp >= start_date
	EndDate    *time.Time // Filter by timestamp <= end_date
}

AccessLogFilter holds pagination, filtering, and sorting parameters for access logs

func (*AccessLogFilter) GetLimit

func (f *AccessLogFilter) GetLimit() int

GetLimit returns the page size for database queries

func (*AccessLogFilter) GetOffset

func (f *AccessLogFilter) GetOffset() int

GetOffset calculates the database offset for pagination

func (*AccessLogFilter) GetSortColumn added in v0.66.0

func (f *AccessLogFilter) GetSortColumn() string

GetSortColumn returns the validated database column name for sorting

func (*AccessLogFilter) GetSortOrder added in v0.66.0

func (f *AccessLogFilter) GetSortOrder() string

GetSortOrder returns the validated sort order (ASC or DESC)

func (*AccessLogFilter) ParseFromRequest

func (f *AccessLogFilter) ParseFromRequest(r *http.Request)

ParseFromRequest parses pagination, sorting, and filter parameters from HTTP request query parameters

type AccessLogProtocol added in v0.67.0

type AccessLogProtocol string

AccessLogProtocol identifies the transport protocol of an access log entry.

const (
	AccessLogProtocolHTTP AccessLogProtocol = "http"
	AccessLogProtocolTCP  AccessLogProtocol = "tcp"
	AccessLogProtocolUDP  AccessLogProtocol = "udp"
)

type Manager

type Manager interface {
	SaveAccessLog(ctx context.Context, proxyLog *AccessLogEntry) error
	GetAllAccessLogs(ctx context.Context, accountID, userID string, filter *AccessLogFilter) ([]*AccessLogEntry, int64, error)
	CleanupOldAccessLogs(ctx context.Context, retentionDays int) (int64, error)
	StartPeriodicCleanup(ctx context.Context, retentionDays, cleanupIntervalHours int)
	StopPeriodicCleanup()
}

type MockRepository added in v0.81.0

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

MockRepository is a mock of Repository interface.

func NewMockRepository added in v0.81.0

func NewMockRepository(ctrl *gomock.Controller) *MockRepository

NewMockRepository creates a new mock instance.

func (*MockRepository) Create added in v0.81.0

func (m *MockRepository) Create(ctx context.Context, entry *AccessLogEntry) error

Create mocks base method.

func (*MockRepository) DeleteOlderThan added in v0.81.0

func (m *MockRepository) DeleteOlderThan(ctx context.Context, olderThan time.Time) (int64, error)

DeleteOlderThan mocks base method.

func (*MockRepository) EXPECT added in v0.81.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRepository) ListByAccount added in v0.81.0

func (m *MockRepository) ListByAccount(ctx context.Context, lockStrength db.LockingStrength, accountID string, filter AccessLogFilter) ([]*AccessLogEntry, int64, error)

ListByAccount mocks base method.

func (*MockRepository) WithTx added in v0.81.0

func (m *MockRepository) WithTx(tx *db.Tx) Repository

WithTx mocks base method.

type MockRepositoryMockRecorder added in v0.81.0

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

MockRepositoryMockRecorder is the mock recorder for MockRepository.

func (*MockRepositoryMockRecorder) Create added in v0.81.0

func (mr *MockRepositoryMockRecorder) Create(ctx, entry any) *gomock.Call

Create indicates an expected call of Create.

func (*MockRepositoryMockRecorder) DeleteOlderThan added in v0.81.0

func (mr *MockRepositoryMockRecorder) DeleteOlderThan(ctx, olderThan any) *gomock.Call

DeleteOlderThan indicates an expected call of DeleteOlderThan.

func (*MockRepositoryMockRecorder) ListByAccount added in v0.81.0

func (mr *MockRepositoryMockRecorder) ListByAccount(ctx, lockStrength, accountID, filter any) *gomock.Call

ListByAccount indicates an expected call of ListByAccount.

func (*MockRepositoryMockRecorder) WithTx added in v0.81.0

func (mr *MockRepositoryMockRecorder) WithTx(tx any) *gomock.Call

WithTx indicates an expected call of WithTx.

type Repository added in v0.81.0

type Repository interface {
	WithTx(tx *db.Tx) Repository
	Create(ctx context.Context, entry *AccessLogEntry) error
	ListByAccount(ctx context.Context, lockStrength db.LockingStrength, accountID string, filter AccessLogFilter) ([]*AccessLogEntry, int64, error)
	DeleteOlderThan(ctx context.Context, olderThan time.Time) (int64, error)
}

Repository persists reverse proxy access log entries.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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