Documentation
¶
Index ¶
- type AccessLogCountryStat
- type AccessLogQuery
- type AccessLogView
- type AddressView
- type DeviceView
- type HTTPHandler
- func (h *HTTPHandler) GetAccessLog(ctx context.Context, request httpapi.GetAccessLogRequestObject) (httpapi.GetAccessLogResponseObject, error)
- func (h *HTTPHandler) GetAccessLogByCountry(ctx context.Context, request httpapi.GetAccessLogByCountryRequestObject) (httpapi.GetAccessLogByCountryResponseObject, error)
- func (h *HTTPHandler) GetDeviceAddresses(ctx context.Context, request httpapi.GetDeviceAddressesRequestObject) (httpapi.GetDeviceAddressesResponseObject, error)
- func (h *HTTPHandler) GetDevices(ctx context.Context, _ httpapi.GetDevicesRequestObject) (httpapi.GetDevicesResponseObject, error)
- type Repository
- func (r *Repository) DeviceExists(ctx context.Context, deviceID device.DeviceID) (bool, error)
- func (r *Repository) GetDeviceAddresses(ctx context.Context, deviceID device.DeviceID) ([]AddressView, error)
- func (r *Repository) GetDevices(ctx context.Context) ([]DeviceView, error)
- func (r *Repository) ListAccessLog(ctx context.Context, q AccessLogQuery) ([]AccessLogView, int, error)
- func (r *Repository) ListAccessLogStatsByCountry(ctx context.Context, from, to time.Time) ([]AccessLogCountryStat, error)
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 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 ¶
func (h *HTTPHandler) GetAccessLog( ctx context.Context, request httpapi.GetAccessLogRequestObject, ) (httpapi.GetAccessLogResponseObject, error)
func (*HTTPHandler) GetAccessLogByCountry ¶
func (h *HTTPHandler) GetAccessLogByCountry( ctx context.Context, request httpapi.GetAccessLogByCountryRequestObject, ) (httpapi.GetAccessLogByCountryResponseObject, error)
func (*HTTPHandler) GetDeviceAddresses ¶
func (h *HTTPHandler) GetDeviceAddresses( ctx context.Context, request httpapi.GetDeviceAddressesRequestObject, ) (httpapi.GetDeviceAddressesResponseObject, error)
func (*HTTPHandler) GetDevices ¶
func (h *HTTPHandler) GetDevices( ctx context.Context, _ httpapi.GetDevicesRequestObject, ) (httpapi.GetDevicesResponseObject, error)
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *sqlx.DB) *Repository
func (*Repository) DeviceExists ¶
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.
Click to show internal directories.
Click to hide internal directories.