telegram

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

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

Authorizer is the admission authorizer of the operator's phone. Per new node identity — an enrollment's or a vote's boundary, claim, and presented keys' fingerprints keyed together — it prompts the configured chat over the Bot API with the facts and an approve and a deny button, and answers on the long-polled callbacks, one prompt per identity inside a decision window — a decided prompt rewritten to its verdict with its buttons gone. A host never prompts: the operator asks the bot for an auth key in the configured chat, naming the node its host lands on, and hands it to the headless client; a registration presenting a key the plugin minted and has not spent approves on the plugin's own records onto that node and spends it, the approval standing for the presenting machine for a window, and any other registration is denied — a host comes with a key or not at all. It speaks the API directly over net/http — no SDK, for a vendored tree prices every dependency, and the handful of calls this needs are plain HTTPS and JSON. The prompts' decisions live in memory: a restart forgets pending and denied entries and a join still in flight asks again, while the unspent auth keys persist in the state directory.

func New

func New(cfg Config) (*Authorizer, error)

New builds the authorizer; Run launches its poll loop. Unspent auth keys load from the state directory when its file exists.

func (*Authorizer) Authorize

Authorize answers one admission exchange. A registration is answered by admitHostLocked, on the plugin's own records alone, and never prompts. For an enrollment or a vote, a standing decision returns for its window's remainder, and the first ask — or the first past the window — sends the chat one prompt and pends. A prompt that cannot be sent denies: with the API unreachable admission fails closed, safe, but unavailable until it returns.

func (*Authorizer) Run

func (t *Authorizer) Run(ctx context.Context)

Run receives the operator's chat until the context is canceled: it offers the console's commands once, then one getUpdates long poll after another, under the caller's supervision, each pass sweeping the decisions whose window has passed and answering the buttons pressed and the messages sent.

type Config

type Config struct {
	// API is the Bot API's base URL; empty is the public one.
	API string
	// Chat is the chat the prompts go to and the only one whose answers
	// count — and the only one the operator can mint or retire auth keys
	// from.
	Chat int64
	// Token is the bot's token. It rides the run argument and so the
	// process list — an accepted consequence of argument-driven
	// configuration, the file indirection deliberately not built.
	Token string
	// State is the core's state directory: the unspent auth keys'
	// persistent home, so an auth key survives a restart while the
	// transient asks stay in memory.
	State string
	// Window overrides how long one prompt's verdict stands; zero uses the
	// default.
	Window time.Duration
}

Config configures the Telegram authorizer.

Jump to

Keyboard shortcuts

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