Documentation ¶
Overview ¶
Package middleware emits events with data from services running on the base.
Index ¶
- type Middleware
- func (middleware *Middleware) BackupHSMSecret() rpcmessages.ErrorResponse
- func (middleware *Middleware) BackupSysconfig() (response rpcmessages.ErrorResponse)
- func (middleware *Middleware) EnableClearnetIBD(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) EnableRootLogin(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) EnableSSHPasswordLogin(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) EnableTor(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) EnableTorElectrs(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) EnableTorMiddleware(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) EnableTorSSH(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) FinalizeSetupWizard() rpcmessages.ErrorResponse
- func (middleware *Middleware) GetBaseInfo() rpcmessages.GetBaseInfoResponse
- func (middleware *Middleware) GetBaseUpdateProgress() rpcmessages.GetBaseUpdateProgressResponse
- func (middleware *Middleware) GetMiddlewareVersion() string
- func (middleware *Middleware) GetServiceInfo() rpcmessages.GetServiceInfoResponse
- func (middleware *Middleware) GetServiceStatus() rpcmessages.GetServiceStatusResponse
- func (middleware *Middleware) InitialAdminPassword() string
- func (middleware *Middleware) IsBaseUpdateAvailable() rpcmessages.IsBaseUpdateAvailableResponse
- func (middleware *Middleware) RebootBase() rpcmessages.ErrorResponse
- func (middleware *Middleware) ReindexBitcoin() rpcmessages.ErrorResponse
- func (middleware *Middleware) RestoreHSMSecret() rpcmessages.ErrorResponse
- func (middleware *Middleware) RestoreSysconfig() (response rpcmessages.ErrorResponse)
- func (middleware *Middleware) ResyncBitcoin() rpcmessages.ErrorResponse
- func (middleware *Middleware) SetHostname(args rpcmessages.SetHostnameArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) SetLoginPassword(args rpcmessages.SetLoginPasswordArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) SetupStatus() rpcmessages.SetupStatusResponse
- func (middleware *Middleware) ShutdownBase() rpcmessages.ErrorResponse
- func (middleware *Middleware) Start() <-chan handlers.Event
- func (middleware *Middleware) SystemEnv() rpcmessages.GetEnvResponse
- func (middleware *Middleware) UpdateBase(args rpcmessages.UpdateBaseArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) UserAuthenticate(args rpcmessages.UserAuthenticateArgs) rpcmessages.UserAuthenticateResponse
- func (middleware *Middleware) UserChangePassword(args rpcmessages.UserChangePasswordArgs) rpcmessages.ErrorResponse
- func (middleware *Middleware) ValidateToken(token string) error
- func (middleware *Middleware) VerifyAppMiddlewarePairing(channelHash []byte) (bool, error)
- type UserAuthStruct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware connects to services on the base with provided parameters and emits events for the handler.
func NewMiddleware ¶
func NewMiddleware(config configuration.Configuration, hsmFirmware *firmware.Device) (*Middleware, error)
NewMiddleware returns a new instance of the middleware.
hsmFirmware let's you talk to the HSM. NOTE: it the HSM could not be connected, this is nil. The middleware must be able to run and serve RPC calls without the HSM present.
func (*Middleware) BackupHSMSecret ¶
func (middleware *Middleware) BackupHSMSecret() rpcmessages.ErrorResponse
BackupHSMSecret returns a ErrorResponse struct in response to a rpcserver request
func (*Middleware) BackupSysconfig ¶
func (middleware *Middleware) BackupSysconfig() (response rpcmessages.ErrorResponse)
BackupSysconfig creates a backup of the system configuration onto a flashdrive. 1. Check if one and only one valid flashdrive is plugged in 2. Mount the flashdrive 3. Backup the system configuration 4. Unmount the flashdrive
func (*Middleware) EnableClearnetIBD ¶
func (middleware *Middleware) EnableClearnetIBD(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
EnableClearnetIBD enables/disables the initial block download over clearnet based on the passed ToggleSettingArgsEnable/Disable argument
func (*Middleware) EnableRootLogin ¶
func (middleware *Middleware) EnableRootLogin(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
EnableRootLogin enables/disables the ssh login of the root user and returns a ErrorResponse indicating if the call was successful.
func (*Middleware) EnableSSHPasswordLogin ¶
func (middleware *Middleware) EnableSSHPasswordLogin(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
EnableSSHPasswordLogin enables/disables the ssh login with a password (in addition to ssh keys) and returns a ErrorResponse indicating if the call was successful.
func (*Middleware) EnableTor ¶
func (middleware *Middleware) EnableTor(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
EnableTor enables/disables the tor.service and configures bitcoind and lightningd based on the passed ToggleSettingArgsEnable/Disable argument and returns a ErrorResponse indicating if the call was successful.
func (*Middleware) EnableTorElectrs ¶
func (middleware *Middleware) EnableTorElectrs(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
EnableTorElectrs enables/disables the tor hidden service for electrs based on the passed ToggleSettingArgsEnable/Disable argument and returns a ErrorResponse indicating if the call was successful.
func (*Middleware) EnableTorMiddleware ¶
func (middleware *Middleware) EnableTorMiddleware(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
EnableTorMiddleware enables/disables the tor hidden service for the middleware based on the passed ToggleSettingArgsEnable/Disable argument and returns a ErrorResponse indicating if the call was successful.
func (*Middleware) EnableTorSSH ¶
func (middleware *Middleware) EnableTorSSH(toggleAction rpcmessages.ToggleSettingArgs) rpcmessages.ErrorResponse
EnableTorSSH enables/disables the tor hidden service for ssh based on the passed ToggleSettingArgsEnable/Disable argument and returns a ErrorResponse indicating if the call was successful.
func (*Middleware) FinalizeSetupWizard ¶
func (middleware *Middleware) FinalizeSetupWizard() rpcmessages.ErrorResponse
FinalizeSetupWizard finalizes the setup wizard by setting a redis key, enabling Bitcoin Core and related services and starting Bitcoin Core and related services.
func (*Middleware) GetBaseInfo ¶
func (middleware *Middleware) GetBaseInfo() rpcmessages.GetBaseInfoResponse
GetBaseInfo returns information about the Base in a GetBaseInfoResponse
func (*Middleware) GetBaseUpdateProgress ¶
func (middleware *Middleware) GetBaseUpdateProgress() rpcmessages.GetBaseUpdateProgressResponse
GetBaseUpdateProgress returns the Base update progress. This RPC should only be called by the app after receiving an OpBaseUpdateProgressChanged notification.
func (*Middleware) GetMiddlewareVersion ¶
func (middleware *Middleware) GetMiddlewareVersion() string
GetMiddlewareVersion returns the Middleware Version for the `GET /version` endpoint.
func (*Middleware) GetServiceInfo ¶
func (middleware *Middleware) GetServiceInfo() rpcmessages.GetServiceInfoResponse
GetServiceInfo returns the most recent information about services running on the Base such as for example bitcoind, electrs or lightningd.
func (*Middleware) GetServiceStatus ¶
func (middleware *Middleware) GetServiceStatus() rpcmessages.GetServiceStatusResponse
GetServiceStatus returns the most recent status information of the base and a few of its services
func (*Middleware) InitialAdminPassword ¶
func (middleware *Middleware) InitialAdminPassword() string
InitialAdminPassword is a getter that returns the constant initialAdminPassword string This password is only valid for authentication until the admin user changes it.
func (*Middleware) IsBaseUpdateAvailable ¶
func (middleware *Middleware) IsBaseUpdateAvailable() rpcmessages.IsBaseUpdateAvailableResponse
IsBaseUpdateAvailable indicates if a Base firmeware is available and returns information about the update
func (*Middleware) RebootBase ¶
func (middleware *Middleware) RebootBase() rpcmessages.ErrorResponse
RebootBase reboots the Base. The reboot is executed in a goroutine with a delay of a few seconds. Prior to starting the goroutine the path for the `reboot` executable is checked. If the executable is found, a ErrorResponse indicating success is returned. Otherwise a ExecutableNotFound Code is returned.
func (*Middleware) ReindexBitcoin ¶
func (middleware *Middleware) ReindexBitcoin() rpcmessages.ErrorResponse
ReindexBitcoin returns a ErrorResponse struct in response to a rpcserver request
func (*Middleware) RestoreHSMSecret ¶
func (middleware *Middleware) RestoreHSMSecret() rpcmessages.ErrorResponse
RestoreHSMSecret returns a ErrorResponse struct in response to a rpcserver request
func (*Middleware) RestoreSysconfig ¶
func (middleware *Middleware) RestoreSysconfig() (response rpcmessages.ErrorResponse)
RestoreSysconfig restores a backup of the system configuration from the flashdrive. 1. Check if one and only one valid flashdrive is plugged in 2. Mount the flashdrive 3. Restore the system configuration (currently not choosable) 4. Unmount the flashdrive
func (*Middleware) ResyncBitcoin ¶
func (middleware *Middleware) ResyncBitcoin() rpcmessages.ErrorResponse
ResyncBitcoin returns a ErrorResponse struct in response to a rpcserver request
func (*Middleware) SetHostname ¶
func (middleware *Middleware) SetHostname(args rpcmessages.SetHostnameArgs) rpcmessages.ErrorResponse
SetHostname sets the systems hostname
func (*Middleware) SetLoginPassword ¶
func (middleware *Middleware) SetLoginPassword(args rpcmessages.SetLoginPasswordArgs) rpcmessages.ErrorResponse
SetLoginPassword sets the system main ssh/login password
func (*Middleware) SetupStatus ¶
func (middleware *Middleware) SetupStatus() rpcmessages.SetupStatusResponse
SetupStatus returns the current status in the setup process as a SetupStatusResponse struct. This includes the middleware password set boolean and the base setup boolean.
func (*Middleware) ShutdownBase ¶
func (middleware *Middleware) ShutdownBase() rpcmessages.ErrorResponse
ShutdownBase shuts the Base down. The shutdown is executed in a goroutine with a delay of a few seconds. Prior to starting the goroutine the path for the `shutdown` executable is checked. If the executable is found, a ErrorResponse indicating success is returned. Otherwise a ExecutableNotFound Code is returned.
func (*Middleware) Start ¶
func (middleware *Middleware) Start() <-chan handlers.Event
Start gives a trigger for the handler to start the rpc event loop
func (*Middleware) SystemEnv ¶
func (middleware *Middleware) SystemEnv() rpcmessages.GetEnvResponse
SystemEnv returns a new GetEnvResponse struct with the values as read from the environment
func (*Middleware) UpdateBase ¶
func (middleware *Middleware) UpdateBase(args rpcmessages.UpdateBaseArgs) rpcmessages.ErrorResponse
UpdateBase executes a over-the-air Base update. The version is to be passed as an argument. This is archived by running the `bbb-cmd.sh mender-update install <version>` command. The current update download progress is read from stdout, parsed and saved as the current state (BaseUpdateState). Every time the `BaseUpdateState` of the middleware changes a websocket notification is emitted to the App backend. Once the download is complete and the update is applied without errors a Base reboot is scheduled to be executed in 5 seconds. The call returns ErrorResponse.Success when a reboot has been scheduled.
func (*Middleware) UserAuthenticate ¶
func (middleware *Middleware) UserAuthenticate(args rpcmessages.UserAuthenticateArgs) rpcmessages.UserAuthenticateResponse
UserAuthenticate returns an ErrorResponse struct in response to a rpcserver request. To check if the user should be authenticated from default values, the bool 'isMiddlewarePasswordSet' is read from redis
func (*Middleware) UserChangePassword ¶
func (middleware *Middleware) UserChangePassword(args rpcmessages.UserChangePasswordArgs) rpcmessages.ErrorResponse
UserChangePassword returns an ErrorResponse struct in response to a rpcserver request The function first validates the current password with redis, then replaces it with the new password. Passwords need to be longer than or equal to 8 chars.
func (*Middleware) ValidateToken ¶
func (middleware *Middleware) ValidateToken(token string) error
ValidateToken validates a jwt token string and returns an error if not valid and nil otherwise.
func (*Middleware) VerifyAppMiddlewarePairing ¶
func (middleware *Middleware) VerifyAppMiddlewarePairing(channelHash []byte) (bool, error)
VerifyAppMiddlewarePairing is a blocking call to confirm the noise pairing (BitBoxApp<->Middleware) with the user. The pairing is shown on the screen via the HSM.
type UserAuthStruct ¶
UserAuthStruct holds the structure that is written into the redis middleware:auth key's value.
Directories ¶
Path | Synopsis |
---|---|
Package configuration provides the functionality to provide configuration values to the Middleware.
|
Package configuration provides the functionality to provide configuration values to the Middleware. |
Package handlers implements an api for the bitbox-wallet-app to talk to.
|
Package handlers implements an api for the bitbox-wallet-app to talk to. |
Package hsm contains the API to talk to the BitBoxBase HSM.
|
Package hsm contains the API to talk to the BitBoxBase HSM. |
Package ipcnotification reads notifications from a named pipe and passes them into a channel.
|
Package ipcnotification reads notifications from a named pipe and passes them into a channel. |
Package noisemanager gives some useful functions to interact with the noise encryption and decryption, provides verification of the noise channel hash and writes the noise keys to a file
|
Package noisemanager gives some useful functions to interact with the noise encryption and decryption, provides verification of the noise channel hash and writes the noise keys to a file |
Package redis implements a communication interface with the redis server running on the BitBoxBase.
|
Package redis implements a communication interface with the redis server running on the BitBoxBase. |