rpcmessages

package
v0.0.0-...-e5c7075 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OpRPCCall is prepended to every rpc response messages, to indicate that the message is rpc response and not a notification.
	OpRPCCall = "r"
	// OpServiceInfoChanged notifies when the GetServiceInfo data changed.
	OpServiceInfoChanged = "s"
	// OpBaseUpdateProgressChanged notifies when the BaseUpdateProgress changes while performing a Base Update.
	OpBaseUpdateProgressChanged = "u"
	// OpBaseUpdateIsAvailable notifies when a image update is available for the Base.
	OpBaseUpdateIsAvailable = "x"
	// OpBaseUpdateSuccess notifies when the Base image update succeeded.
	OpBaseUpdateSuccess = "a"
	// OpBaseUpdateFailure notifies when the Base image update failed.
	OpBaseUpdateFailure = "b"
)

Put notification constants here. Notifications for new rpc data should have the format 'OpUCanHas' + 'RPC Method Name'.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthGenericRequest

type AuthGenericRequest struct {
	Token string
}

AuthGenericRequest is a struct that acts as a generic request struct

type BaseUpdateState

type BaseUpdateState int

BaseUpdateState is the used to hold the current state for a Base update.

const (
	UpdateNotInProgress BaseUpdateState = iota + 1
	UpdateDownloading
	UpdateFailed
	UpdateApplying
	UpdateRebooting
)

The possible values of BaseUpdateState. Representing the states that can be reached in a BaseUpdate RPC call.

type ErrorCode

type ErrorCode string

ErrorCode is a unique and short string code represeting an Error

const (

	// ExecutableNotFound is thrown when a executable is not found.
	// This can for example be a script (e.g. bbb-cmd.sh or bbb-config.sh) or a executable like `reboot`
	ExecutableNotFound ErrorCode = "EXECUTABLE_NOT_FOUND"

	// ErrorScriptNotSuperuser is thrown if a run scripts need to be run as superuser.
	ErrorScriptNotSuperuser ErrorCode = "SCRIPT_NOT_RUN_AS_SUPERUSER"

	// ErrorScriptIncludesNotFound is thrown when a script includes other bash functions, but the inclusion path (in the script) is invalid.
	ErrorScriptIncludesNotFound = "SCRIPT_INCLUDES_NOT_FOUND"

	// ErrorRedisError is a general Redis related error.
	// There is no differentiation of Redis errors because the front-end most likely handles them similar.
	ErrorRedisError ErrorCode = "REDIS_ERROR"

	// ErrorPrometheusError is a general Prometheus related error.
	// There is no differentiation of Prometheus errors because the front-end most likely handles them similar.
	ErrorPrometheusError ErrorCode = "PROMETHEUS_ERROR"

	// ErrorUnexpected is thrown when a a unknown/unhandled/unexpected error occurs.
	// It's a catch-all error.
	ErrorUnexpected ErrorCode = "UNEXPECTED_ERROR"
)
const (

	// ErrorCmdScriptInvalidArg is thrown if the argument for the bbb-cmd.sh script is not known.
	// Not to be confused with ErrorConfigScriptInvalidArg which is for the bbb-config.sh.
	ErrorCmdScriptInvalidArg ErrorCode = "CMD_SCRIPT_INVALID_ARG"

	// ErrorFlashdriveCheckMultiple is thrown if multiple USB flashdrives are found. Needs exactly one.
	ErrorFlashdriveCheckMultiple ErrorCode = "FLASHDRIVE_CHECK_MULTI"
	// ErrorFlashdriveCheckNone is thrown if no USB flashdrive is found.
	ErrorFlashdriveCheckNone ErrorCode = "FLASHDRIVE_CHECK_NONE"

	// ErrorFlashdriveMountNotFound is thrown if no flashdrive found on the passed <path>.
	ErrorFlashdriveMountNotFound ErrorCode = "FLASHDRIVE_MOUNT_NOT_FOUND"
	// ErrorFlashdriveMountNotUnique is thrown if the passed <path> does not uniquely identify a flashdrive.
	ErrorFlashdriveMountNotUnique ErrorCode = "FLASHDRIVE_MOUNT_NOT_UNIQUE"
	// ErrorFlashdriveMountNotSupported is thrown if the flashdrive is either bigger than 64GB or the filesystem is not supported.
	ErrorFlashdriveMountNotSupported ErrorCode = "FLASHDRIVE_MOUNT_NOT_SUPPORTED"

	// ErrorFlashdriveUnmountNotMounted is thrown if there is no flashdrive to unmount at /mnt/backup.
	ErrorFlashdriveUnmountNotMounted ErrorCode = "FLASHDRIVE_UNMOUNT_NOT_MOUNTED"

	// ErrorBackupSysconfigNotAMountpoint is thrown if /mnt/backup is no mountpoint. It's needed to backup the sysconfig.
	ErrorBackupSysconfigNotAMountpoint ErrorCode = "BACKUP_SYSCONFIG_NOT_A_MOUNTPOINT"

	// ErrorRestoreSysconfigBackupNotFound is thrown if the backup file /mnt/backup/bbb-backup.rdb is not found.
	ErrorRestoreSysconfigBackupNotFound ErrorCode = "RESTORE_SYSCONFIG_BACKUP_NOT_FOUND"

	// ErrorMenderUpdateImageNotMenderEnabled is thrown if the image is not mender enabled.
	ErrorMenderUpdateImageNotMenderEnabled ErrorCode = "MENDER_UPDATE_IMAGE_NOT_MENDER_ENABLED"

	// ErrorMenderUpdateInstallFailed is thrown if `mender -install` failed.
	ErrorMenderUpdateInstallFailed ErrorCode = "MENDER_UPDATE_INSTALL_FAILED"

	// ErrorMenderUpdateNoVersion thrown if no Base image version passed to the script.
	ErrorMenderUpdateNoVersion ErrorCode = "MENDER_UPDATE_NO_VERSION"

	// ErrorMenderUpdateInvalidVersion is thrown if an invalid Base image version passed to the script.
	ErrorMenderUpdateInvalidVersion ErrorCode = "MENDER_UPDATE_INVALID_VERSION"

	// ErrorMenderUpdateAlreadyInProgress is thrown by the middleware, if an update is already in progress.
	ErrorMenderUpdateAlreadyInProgress ErrorCode = "MENDER_UPDATE_ALREADY_IN_PROGRESS"

	// ErrorMenderUpdateCommitFailed is thrown if `mender -commit` failed.
	ErrorMenderUpdateCommitFailed ErrorCode = "MENDER_UPDATE_COMMIT_FAILED"
)
const (

	// ErrorConfigScriptInvalidArg is thrown if the argument for the bbb-config.sh script is not known.
	// Not to be confused with ErrorCmdScriptInvalidArg for the bbb-cmd script.
	ErrorConfigScriptInvalidArg ErrorCode = "CONFIG_SCRIPT_INVALID_ARG"

	// ErrorSetNeedsTwoArguments is thrown if `bbb-config.sh set <key> <value>` is thrown with not exactly two arguments.
	ErrorSetNeedsTwoArguments ErrorCode = "SET_NEEDS_TWO_ARGUMENTS"

	// ErrorSetBitcoinNetworkInvalidValue is thrown if the set <value> is not "testnet" or "mainnet".
	ErrorSetBitcoinNetworkInvalidValue ErrorCode = "SET_BITCOINETWORK_INVALID_VALUE"

	// ErrorSetBitcoinDBCacheInvalidValue is thrown if the <value> is not an integer in MB between 50 and 3000.
	ErrorSetBitcoinDBCacheInvalidValue ErrorCode = "SET_BITCOINDBCACHE_INVALID_VALUE"

	// ErrorSetHostnameInvalidValue is thrown if the <value> is an invalid hostname according to this regex '^[a-z][a-z0-9-]{0,22}[a-z0-9]$'.
	ErrorSetHostnameInvalidValue ErrorCode = "SET_HOSTNAME_INVALID_VALUE"
)
const (
	// ErrorInitialAuthenticationNotSuccessful is thrown if the initial authentication with default username and password is not successful.
	ErrorInitialAuthenticationNotSuccessful ErrorCode = "INITIAL_AUTHENTICATION_NOT_SUCCESSFUL"

	// ErrorAuthenticationPasswordIncorrect is thrown if the authentication is not successful.
	ErrorAuthenticationPasswordIncorrect ErrorCode = "AUTHENTICATION_PASSWORD_INCORRECT"

	// ErrorAuthenticationFailed is thrown if the authentication is not successful, because of a generic error
	ErrorAuthenticationFailed ErrorCode = "AUTHENTICATION_FAILED"

	// ErrorAuthenticationUsernameNotFound is thrown if the given username does not exist.
	ErrorAuthenticationUsernameNotFound ErrorCode = "AUTHENTICATION_USERNAME_NOEXIST"
)
const (
	// ErrorPasswordTooShort is thrown if the provided password is too short.
	ErrorPasswordTooShort ErrorCode = "CHANGEPASSWORD_TOO_SHORT"

	// ErrorPasswordChangeFailed is thrown if the there is an internal system error with e.g. redis or json parsing
	ErrorPasswordChangeFailed ErrorCode = "CHANGEPASSWORD_FAILED"

	// ErrorPasswordChangeUsernameNotExist is thrown if the given username does not exist
	ErrorPasswordChangeUsernameNotExist ErrorCode = "CHANGEPASSWORD_USERNAME_NOEXIST"

	// ErrorPasswordChangePasswordIncorrect is thrown is the given password does not match the bcrypted password from redis
	ErrorPasswordChangePasswordIncorrect ErrorCode = "CHANGEPASSWORD_PASSWORD_INCORRECT"
)
const (
	// ErrorSetLoginPasswordTooShort is thrown if the provided root password is too short.
	ErrorSetLoginPasswordTooShort ErrorCode = "SET_LOGINPASSWORD_PASSWORD_TOO_SHORT"
)
const (

	// ErrorSystemdServiceStartFailed is thrown when a systemd service cannot be
	// started.
	ErrorSystemdServiceStartFailed ErrorCode = "SYSTEMD_SERVICESTART_FAILED"
)
const JSONWebTokenInvalid ErrorCode = "JSONWEBTOKEN_INVALID"

JSONWebTokenInvalid is thrown when the authentication with the provided token has failed. This can happen for both an expired token and if the token is invalid.

type ErrorResponse

type ErrorResponse struct {
	Success bool
	Code    ErrorCode
	Message string
}

ErrorResponse is a generic RPC response indicating if a RPC call was successful or not. It can be embedded into other RPC responses that return values. In any case the ErrorResponse should be checked first, so that, if an error is returned, we ignore everything else in the response.

func (*ErrorResponse) Error

func (err *ErrorResponse) Error() string

Error formats the ErrorResponse in the following two formats: If no error occurred:

ErrorResponse: Success: true

If an error occurred:

ErrorResponse:
	Success: false
	Code: <ERROR_CODE>
	Message: <message>

type GetBaseInfoResponse

type GetBaseInfoResponse struct {
	ErrorResponse             *ErrorResponse
	MiddlewareLocalIP         string `json:"middlewareLocalIP"`
	MiddlewarePort            string `json:"middlewarePort"`
	MiddlewareTorOnion        string `json:"middlewareTorOnion"`
	IsSSHPasswordLoginEnabled bool   `json:"isSSHPasswordLoginEnabled"`
	FreeDiskspace             int64  `json:"freeDiskspace"`  // in Byte
	TotalDiskspace            int64  `json:"totalDiskspace"` // in Byte
	BaseVersion               string `json:"baseVersion"`
	BitcoindVersion           string `json:"bitcoindVersion"`
	LightningdVersion         string `json:"lightningdVersion"`
	ElectrsVersion            string `json:"electrsVersion"`
}

GetBaseInfoResponse is the struct that gets sent by the RPC server during a GetBaseInfo RPC call

type GetBaseUpdateProgressResponse

type GetBaseUpdateProgressResponse struct {
	ErrorResponse         *ErrorResponse
	State                 BaseUpdateState `json:"updateState"`
	ProgressPercentage    int             `json:"updatePercentage"`
	ProgressDownloadedKiB int             `json:"updateKBDownloaded"`
}

GetBaseUpdateProgressResponse is the response to a GetBaseUpdateProgress RPC call. The app is notified over a changed middleware state calls the GetBaseUpdateProgress RPC which returns GetBaseUpdateProgressResponse.

type GetEnvResponse

type GetEnvResponse struct {
	Network        string
	ElectrsRPCPort string
}

GetEnvResponse is the struct that gets sent by the rpc server during a GetSystemEnv call

type GetServiceInfoResponse

type GetServiceInfoResponse struct {
	ErrorResponse                *ErrorResponse `json:"errorResponse"`
	BitcoindBlocks               int64          `json:"bitcoindBlocks"`
	BitcoindHeaders              int64          `json:"bitcoindHeaders"`
	BitcoindVerificationProgress float64        `json:"bitcoindVerificationProgress"`
	BitcoindPeers                int64          `json:"bitcoindPeers"`
	BitcoindIBD                  bool           `json:"bitcoindIBD"`
	LightningdBlocks             int64          `json:"lightningdBlocks"`
	LightningActiveChannels      int64          `json:"lightningActiveChannels"`
	ElectrsBlocks                int64          `json:"electrsBlocks"`
}

GetServiceInfoResponse is the struct that gets sent by the RPC server during a GetServiceInfo RPC call

type GetServiceStatusResponse

type GetServiceStatusResponse struct {
	ErrorResponse    *ErrorResponse `json:"errorResponse"`
	Hostname         string         `json:"hostname"`
	Status           string         `json:"status"`
	IsTorEnabled     bool           `json:"isTorEnabled"`
	BitcoindStatus   bool           `json:"isBitcoindListening"`
	LightningdStatus bool           `json:"lightningdStatus"`
	ElectrsStatus    bool           `json:"electrsStatus"`
}

GetServiceStatusResponse is the struct that gets sent by the RPC server during a GetServiceStatus RPC call

type IsBaseUpdateAvailableResponse

type IsBaseUpdateAvailableResponse struct {
	ErrorResponse   *ErrorResponse
	UpdateAvailable bool       `json:"available"`
	UpdateInfo      UpdateInfo `json:"info"`
}

IsBaseUpdateAvailableResponse is returned as an response for an IsBaseUpdateAvailable RPC call.

type SetHostnameArgs

type SetHostnameArgs struct {
	Hostname string
	Token    string
}

SetHostnameArgs is a struct that holds the to be set hostname

type SetLoginPasswordArgs

type SetLoginPasswordArgs struct {
	LoginPassword string
	Token         string
}

SetLoginPasswordArgs is a struct that holds the to be set login password

type SetupStatusResponse

type SetupStatusResponse struct {
	MiddlewarePasswordSet bool
	BaseSetup             bool
}

SetupStatusResponse is the struct that gets sent by the rpc server during a SetupStatus rpc call. This call is not authenticated and serves as indicator for what to show during the base setup wizzard.

type ToggleSettingArgs

type ToggleSettingArgs struct {
	ToggleSetting bool
	Token         string
}

ToggleSettingArgs is a generic message for settings that can be enabled or disabled

type UpdateBaseArgs

type UpdateBaseArgs struct {
	Version string
	Token   string
}

UpdateBaseArgs is a struct that holds the Base version that should be updated to

type UpdateInfo

type UpdateInfo struct {
	Description string `json:"description"`
	Version     string `json:"version"`
	Severity    string `json:"severity"`
}

UpdateInfo holds information about a available Base image update

type UserAuthenticateArgs

type UserAuthenticateArgs struct {
	Username string
	Password string
}

UserAuthenticateArgs is an struct that holds the arguments for the UserAuthenticate RPC call

type UserAuthenticateResponse

type UserAuthenticateResponse struct {
	ErrorResponse *ErrorResponse
	Token         string
}

UserAuthenticateResponse is the struct that gets sent by the rpc server during a UserAuthenticate call. It contains the session's jwt token.

type UserChangePasswordArgs

type UserChangePasswordArgs struct {
	Username    string
	Password    string
	NewPassword string
	Token       string
}

UserChangePasswordArgs is an struct that holds the arguments for the UserChangePassword RPC call

Jump to

Keyboard shortcuts

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