Documentation
¶
Overview ¶
Package blocklist is the hub's identity denylist: the peer ids refused at attach time, durable across restarts.
Blocking bans an id, not one token: any token with that subject is refused while the entry exists, so a leaked token is stopped without rotating the signing secret on everyone else.
The denylist is stored behind the Store interface — SQLite for a single hub, PostgreSQL for a fleet (see the sqlite and postgres subpackages), mirroring the presence directory's backends. Reads go to the store, so a block issued by another hub on a shared store takes effect everywhere; an in-memory snapshot answers when the store is unreachable.
Index ¶
- type BlockedPeer
- type Dialect
- type List
- type SQLOption
- type SQLStore
- func (s *SQLStore) Block(ctx context.Context, peer string, atUnix int64) error
- func (s *SQLStore) IsBlocked(ctx context.Context, peer string) (bool, error)
- func (s *SQLStore) Load(ctx context.Context) (map[string]int64, error)
- func (s *SQLStore) Migrate(ctx context.Context) error
- func (s *SQLStore) Unblock(ctx context.Context, peer string) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockedPeer ¶
BlockedPeer is one entry in the denylist.
type Dialect ¶
type Dialect int
Dialect selects SQL syntax that differs between engines (parameter placeholders, mainly).
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is the denylist over a pluggable Store. It satisfies both the admin service's Blocker (Block/Unblock/Blocked) and the attach guard's Blocker (IsBlocked).
func (*List) Blocked ¶
func (l *List) Blocked() []BlockedPeer
Blocked returns the blocked peers, ordered by peer id. Served from the store — fleet-wide on a shared one — with the snapshot as the fallback.
type SQLStore ¶
type SQLStore struct {
// contains filtered or unexported fields
}
SQLStore is the SQL-backed Store. It imports only database/sql — the consumer brings the driver and hands in an opened *sql.DB.
func (*SQLStore) Block ¶
Block records a blocked peer (unix seconds), keeping the original block time if the peer is already blocked.
func (*SQLStore) Load ¶
Load returns the currently-blocked peers keyed by peer id, valued by the unix time they were blocked.
type Store ¶
type Store interface {
// Load returns every blocked peer, keyed by peer id, valued by the
// unix time it was blocked.
Load(ctx context.Context) (map[string]int64, error)
// IsBlocked reports whether peer is currently blocked.
IsBlocked(ctx context.Context, peer string) (bool, error)
// Block records a block (unix seconds), keeping the original time
// if the peer is already blocked.
Block(ctx context.Context, peer string, atUnix int64) error
// Unblock removes a peer from the denylist.
Unblock(ctx context.Context, peer string) error
}
Store persists the denylist. NewSQL provides the SQL implementation for both supported dialects.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package postgres is the PostgreSQL flavour of the SQL-backed denylist.
|
Package postgres is the PostgreSQL flavour of the SQL-backed denylist. |
|
Package sqlite is the SQLite flavour of the SQL-backed denylist.
|
Package sqlite is the SQLite flavour of the SQL-backed denylist. |