Improve documentation in backend.go.

Signed-off-by: David Anderson <dave@natulte.net>
pull/10/head
David Anderson 5 years ago committed by Dave Anderson
parent b0f5751a76
commit 73c0a2bee2

@ -72,9 +72,9 @@ type Notify struct {
type StateKey string type StateKey string
type Options struct { type Options struct {
// Public logtail id used by frontend. // FrontendLogID is the public logtail id used by the frontend.
FrontendLogID string FrontendLogID string
// Base URL for the tailcontrol server to talk to. // ServerURL is the base URL of the tailcontrol server to talk to.
ServerURL string ServerURL string
// StateKey and Prefs together define the state the backend should // StateKey and Prefs together define the state the backend should
// use: // use:
@ -86,27 +86,32 @@ type Options struct {
// an initial overwrite of backend state with Prefs. // an initial overwrite of backend state with Prefs.
StateKey StateKey StateKey StateKey
Prefs *Prefs Prefs *Prefs
// Callback for backend events. // Notify is called when backend events happen.
Notify func(Notify) `json:"-"` Notify func(Notify) `json:"-"`
} }
type Backend interface { type Backend interface {
// Start or restart the backend, because a new Handle has connected. // Start or restart the backend, because a new Handle has connected.
Start(opts Options) error Start(opts Options) error
// Start a new interactive login. This should trigger a new // StartLoginInteractive requests to start a new interactive login
// BrowseToURL notification eventually. // flow. This should trigger a new BrowseToURL notification
// eventually.
StartLoginInteractive() StartLoginInteractive()
// Terminate the current login session and stop the wireguard engine. // Logout terminates the current login session and stop the
// wireguard engine.
Logout() Logout()
// Install a new set of user preferences, including WantRunning. // SetPrefs install a new set of user preferences, including
// This may cause the wireguard engine to reconfigure or stop. // WantRunning. This may cause the wireguard engine to
// reconfigure or stop.
SetPrefs(new Prefs) SetPrefs(new Prefs)
// Poll for an update from the wireguard engine. Only needed if // RequestEngineStatus polls for an update from the wireguard
// you want to display byte counts. Connection events are emitted // engine. Only needed if you want to display byte
// automatically without polling. // counts. Connection events are emitted automatically without
// polling.
RequestEngineStatus() RequestEngineStatus()
// Pretend the current key is going to expire after duration x. // FakeExpireAfter pretends that the current key is going to
// This is useful for testing GUIs to make sure they react properly // expire after duration x. This is useful for testing GUIs to
// with keys that are going to expire. // make sure they react properly with keys that are going to
// expire.
FakeExpireAfter(x time.Duration) FakeExpireAfter(x time.Duration)
} }

Loading…
Cancel
Save