Documentation
¶
Overview ¶
Package sqlite implements the expose data store backed by a SQLite database. It manages API keys, domains, tunnels, connect tokens, and server settings.
Index ¶
- Variables
- type OpenOptions
- type Store
- func (s *Store) ActiveTunnelCountByKey(ctx context.Context, keyID string) (int, error)
- func (s *Store) AllocateDomainAndTunnel(ctx context.Context, keyID, mode, subdomain, baseDomain string) (domain.Domain, domain.Tunnel, error)
- func (s *Store) AllocateDomainAndTunnelWithClientMeta(ctx context.Context, keyID, mode, subdomain, baseDomain, clientMeta string) (domain.Domain, domain.Tunnel, error)
- func (s *Store) Close() error
- func (s *Store) CloseTemporaryTunnel(ctx context.Context, tunnelID string) (string, bool, error)
- func (s *Store) ConsumeConnectToken(ctx context.Context, token string) (string, error)
- func (s *Store) CreateAPIKey(ctx context.Context, name, keyHash string) (domain.APIKey, error)
- func (s *Store) CreateAPIKeyWithLimit(ctx context.Context, name, keyHash string, tunnelLimit int) (domain.APIKey, error)
- func (s *Store) CreateConnectToken(ctx context.Context, tunnelID string, ttl time.Duration) (string, error)
- func (s *Store) FindRouteByHost(ctx context.Context, host string) (domain.TunnelRoute, error)
- func (s *Store) GetAPIKeyTunnelLimit(ctx context.Context, keyID string) (int, error)
- func (s *Store) GetServerPepper(ctx context.Context) (string, bool, error)
- func (s *Store) IsHostnameActive(ctx context.Context, host string) (bool, error)
- func (s *Store) ListAPIKeys(ctx context.Context) ([]domain.APIKey, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) PurgeInactiveTemporaryDomains(ctx context.Context, olderThan time.Time, limit int) ([]string, error)
- func (s *Store) PurgeStaleConnectTokens(ctx context.Context, now, usedOlderThan time.Time, limit int) (int64, error)
- func (s *Store) ResetConnectedTunnels(ctx context.Context) (int64, error)
- func (s *Store) ResolveAPIKeyID(ctx context.Context, keyHash string) (string, error)
- func (s *Store) ResolveServerPepper(ctx context.Context, suggested string) (string, error)
- func (s *Store) RevokeAPIKey(ctx context.Context, id string) error
- func (s *Store) SetAPIKeyTunnelLimit(ctx context.Context, keyID string, limit int) error
- func (s *Store) SetTunnelAccessCredentials(ctx context.Context, tunnelID, user, mode, hash string) error
- func (s *Store) SetTunnelAccessPasswordHash(ctx context.Context, tunnelID, hash string) error
- func (s *Store) SetTunnelConnected(ctx context.Context, tunnelID string) error
- func (s *Store) SetTunnelDisconnected(ctx context.Context, tunnelID string) error
- func (s *Store) SwapTunnelSession(ctx context.Context, domainID, keyID, clientMeta string) (domain.Tunnel, error)
- func (s *Store) TouchDomain(ctx context.Context, domainID string) error
- func (s *Store) TrySetTunnelConnected(ctx context.Context, tunnelID string) error
Constants ¶
This section is empty.
Variables ¶
var ErrHostnameInUse = errors.New("hostname already in use")
ErrHostnameInUse is returned when the requested hostname is already allocated by another key or tunnel type and cannot be claimed by the caller.
Functions ¶
This section is empty.
Types ¶
type OpenOptions ¶ added in v0.4.0
OpenOptions controls SQLite connection pool sizing.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps a SQLite database connection for all expose persistence operations.
func Open ¶
Open creates or opens the SQLite database at path, runs migrations, and enables WAL mode for improved concurrent read performance.
func OpenWithOptions ¶ added in v0.4.0
func OpenWithOptions(path string, opts OpenOptions) (*Store, error)
OpenWithOptions creates or opens the SQLite database at path with tunable connection pool settings, runs migrations, and enables WAL mode.
func (*Store) ActiveTunnelCountByKey ¶
func (*Store) AllocateDomainAndTunnel ¶
func (*Store) AllocateDomainAndTunnelWithClientMeta ¶
func (*Store) CloseTemporaryTunnel ¶
func (*Store) ConsumeConnectToken ¶
func (*Store) CreateAPIKey ¶
func (*Store) CreateAPIKeyWithLimit ¶ added in v0.12.0
func (*Store) CreateConnectToken ¶
func (*Store) FindRouteByHost ¶
func (*Store) GetAPIKeyTunnelLimit ¶ added in v0.12.0
GetAPIKeyTunnelLimit returns the per-key tunnel limit for the given key ID. A value of -1 means unlimited.
func (*Store) GetServerPepper ¶
func (*Store) IsHostnameActive ¶
func (*Store) ListAPIKeys ¶
func (*Store) Migrate ¶
Migrate creates all required tables and indexes if they do not already exist.
func (*Store) PurgeInactiveTemporaryDomains ¶
func (*Store) PurgeStaleConnectTokens ¶ added in v0.4.0
func (s *Store) PurgeStaleConnectTokens(ctx context.Context, now, usedOlderThan time.Time, limit int) (int64, error)
PurgeStaleConnectTokens removes expired tokens and used tokens older than the provided cutoff. It limits each run to avoid long write transactions.
func (*Store) ResetConnectedTunnels ¶
func (*Store) ResolveAPIKeyID ¶
func (*Store) ResolveServerPepper ¶
func (*Store) SetAPIKeyTunnelLimit ¶ added in v0.12.0
SetAPIKeyTunnelLimit updates the per-key tunnel limit. Use -1 for unlimited.