singleton

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(bootstrapToken, machineID string, ipStrategy string, trustedHeader string, trustedProxies []string) error

Initialize creates and starts the singleton manager

Types

type BootstrapClaims

type BootstrapClaims struct {
	ComponentType string `json:"component_type"`
	DeploymentID  string `json:"deployment_id"`
	Issuer        string `json:"iss"`
	jwt.RegisteredClaims
}

BootstrapClaims represents the JWT claims in the bootstrap token Note: We manually parse these due to Yaegi's issues with jwt/v5 struct tags See: https://github.com/traefik/yaegi/discussions/1548

type EDLUpdater

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

EDLUpdater manages EDL fetching and updating

func NewEDLUpdater

func NewEDLUpdater(url string, updateFrequency time.Duration, matcher *ipmatcher.Matcher, manager *Manager) *EDLUpdater

NewEDLUpdater creates a new EDL updater

func (*EDLUpdater) GetStatus

func (u *EDLUpdater) GetStatus() (time.Time, error, int64)

GetStatus returns the current status

func (*EDLUpdater) Reconfigure

func (u *EDLUpdater) Reconfigure(url string, updateFrequency time.Duration)

Reconfigure updates the EDL URL and update frequency

func (*EDLUpdater) Start

func (u *EDLUpdater) Start(ctx context.Context) error

Start performs initial EDL fetch

func (*EDLUpdater) StartUpdateLoop

func (u *EDLUpdater) StartUpdateLoop(ctx context.Context)

StartUpdateLoop starts the background update loop

func (*EDLUpdater) Stop

func (u *EDLUpdater) Stop()

Stop stops the updater

type Manager

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

func GetManager

func GetManager() *Manager

GetManager returns the singleton manager instance

func (*Manager) CheckConfigUpdates

func (m *Manager) CheckConfigUpdates(ctx context.Context)

CheckConfigUpdates fetches and applies any configuration changes

func (*Manager) GetDeviceID

func (m *Manager) GetDeviceID() string

GetDeviceID returns the device ID

func (*Manager) GetEDLMode

func (m *Manager) GetEDLMode() string

GetEDLMode returns the current EDL mode

func (*Manager) IsDeploymentEnabled

func (m *Manager) IsDeploymentEnabled() bool

IsDeploymentEnabled returns whether deployment is enabled

func (*Manager) IsIPAllowed

func (m *Manager) IsIPAllowed(clientIP string) (bool, error)

IsIPAllowed checks if an IP is allowed based on EDL

func (*Manager) IsIPAllowedWithStats

func (m *Manager) IsIPAllowedWithStats(clientIP string) (bool, bool, error)

IsIPAllowedWithStats checks if an IP is allowed and returns timing stats

func (*Manager) SendBlockEvent

func (m *Manager) SendBlockEvent(event *logs.BlockEvent)

SendBlockEvent sends a block event to the log shipper

func (*Manager) Stop

func (m *Manager) Stop()

Stop gracefully stops the manager

type TokenManager

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

TokenManager manages JWT tokens and refreshing

func NewTokenManager

func NewTokenManager(bootstrapToken string, machineID string) *TokenManager

NewTokenManager creates a new token manager

func (*TokenManager) GetConfigURL

func (tm *TokenManager) GetConfigURL() string

GetConfigURL returns the config API URL

func (*TokenManager) GetLogsURL

func (tm *TokenManager) GetLogsURL() string

GetLogsURL returns the logs URL

func (*TokenManager) GetToken

func (tm *TokenManager) GetToken() string

GetToken returns the current access token

func (*TokenManager) Initialize

func (tm *TokenManager) Initialize(ctx context.Context) error

Initialize performs initial bootstrap

func (*TokenManager) IsDeploymentActive

func (tm *TokenManager) IsDeploymentActive() bool

IsDeploymentActive returns whether the deployment is active

func (*TokenManager) ParseBootstrapToken

func (tm *TokenManager) ParseBootstrapToken() (*BootstrapClaims, error)

ParseBootstrapToken parses and validates the bootstrap token IMPORTANT: We use manual JWT parsing instead of jwt/v5's ParseUnverified because Yaegi (Traefik's Go interpreter) has issues with struct tags in jwt/v5, causing claims to be returned as empty. This is a known Yaegi limitation. See: https://github.com/traefik/yaegi/discussions/1548

func (*TokenManager) StartRefreshLoop

func (tm *TokenManager) StartRefreshLoop(ctx context.Context)

StartRefreshLoop starts the background token refresh loop

func (*TokenManager) Stop

func (tm *TokenManager) Stop()

Stop stops the token manager

Jump to

Keyboard shortcuts

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