Documentation
¶
Index ¶
- Variables
- type Option
- func WithAuthorizedKeys(keys []ed25519.PubKeyEd25519) Option
- func WithClientPrivKey(privKey ed25519.PrivKeyEd25519) Option
- func WithDialMaxRetries(maxRetries int) Option
- func WithDialRetryInterval(interval time.Duration) Option
- func WithDialTimeout(timeout time.Duration) Option
- func WithKeepAlivePeriod(period time.Duration) Option
- func WithRequestTimeout(timeout time.Duration) Option
- type RemoteSignerClient
- type RemoteSignerClientConfig
Constants ¶
This section is empty.
Variables ¶
var ( // Init. ErrInvalidAddressProtocol = errors.New("invalid client address protocol") ErrNilLogger = errors.New("nil logger") ErrFetchingPubKeyFailed = errors.New("failed to fetch public key") // Request. ErrSendingRequestFailed = errors.New("failed to send request") ErrInvalidResponseType = errors.New("invalid response type") ErrResponseContainsError = errors.New("response contains error") // Connection. ErrMaxRetriesExceeded = errors.New("maximum retries exceeded") // State. ErrClientAlreadyClosed = errors.New("client already closed") )
Errors returned by the remote signer client.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*RemoteSignerClient)
Option is a functional option type used for optional configuration.
func WithAuthorizedKeys ¶
func WithAuthorizedKeys(keys []ed25519.PubKeyEd25519) Option
WithAuthorizedKeys sets the list of authorized public keys that the client will accept. If empty (default), all keys are authorized.
func WithClientPrivKey ¶
func WithClientPrivKey(privKey ed25519.PrivKeyEd25519) Option
WithClientPrivKey sets the private key used by the client to authenticate with the server. The default is a random key.
func WithDialMaxRetries ¶
WithDialMaxRetries sets the maximum number of retries when dialing the server. If set to -1 (default), the client will retry indefinitely.
func WithDialRetryInterval ¶
WithDialRetryInterval sets the interval between dial retries when connecting to the server. The default is 5 seconds.
func WithDialTimeout ¶
WithDialTimeout sets the timeout for dialing the server. If set to 0, no timeout is set. The default is 5 seconds.
func WithKeepAlivePeriod ¶
WithKeepAlivePeriod sets the keep alive period for the TCP connection to the server. If set to 0, keep alive is disabled. The default is 2 seconds.
func WithRequestTimeout ¶
WithRequestTimeout sets the timeout for sending requests to the server. If set to 0, no timeout is set. The default is 5 seconds.
type RemoteSignerClient ¶
type RemoteSignerClient struct {
// contains filtered or unexported fields
}
RemoteSignerClient implements types.Signer by connecting to a RemoteSignerServer.
func NewRemoteSignerClient ¶
func NewRemoteSignerClient( serverAddress string, logger *slog.Logger, options ...Option, ) (*RemoteSignerClient, error)
NewRemoteSignerClient creates a new RemoteSignerClient with the required server address and logger. The client can be further configured using functional options.
func NewRemoteSignerClientFromConfig ¶
func NewRemoteSignerClientFromConfig( config *RemoteSignerClientConfig, clientPrivKey ed25519.PrivKeyEd25519, clientLogger *slog.Logger, ) (*RemoteSignerClient, error)
NewRemoteSignerClientFromConfig returns a new RemoteSignerClient instance based on the configuration. The clientPrivKey is only used if the client connects to the server using TCP.
func (*RemoteSignerClient) Close ¶
func (rsc *RemoteSignerClient) Close() error
Close implements type.Signer.
func (*RemoteSignerClient) Ping ¶
func (rsc *RemoteSignerClient) Ping() error
Ping sends a ping request to the server.
func (*RemoteSignerClient) PubKey ¶
func (rsc *RemoteSignerClient) PubKey() crypto.PubKey
PubKey implements types.Signer.
func (*RemoteSignerClient) Sign ¶
func (rsc *RemoteSignerClient) Sign(signBytes []byte) ([]byte, error)
Sign implements types.Signer.
func (*RemoteSignerClient) String ¶
func (rsc *RemoteSignerClient) String() string
String implements fmt.Stringer.
type RemoteSignerClientConfig ¶
type RemoteSignerClientConfig struct { // Address of the remote signer to dial (UNIX or TCP). ServerAddress string `` /* 142-byte string literal not displayed */ // Network dial and timeout options. DialMaxRetries int `` /* 148-byte string literal not displayed */ DialRetryInterval time.Duration `json:"dial_retry_interval" toml:"dial_retry_interval" comment:"Interval between retries to dial the remote signer"` DialTimeout time.Duration `json:"dial_timeout" toml:"dial_timeout" comment:"Timeout to dial the remote signer"` RequestTimeout time.Duration `json:"request_timeout" toml:"request_timeout" comment:"Timeout for requests to the remote signer"` // TCP specific options. AuthorizedKeys []string `` /* 166-byte string literal not displayed */ KeepAlivePeriod time.Duration `` /* 133-byte string literal not displayed */ }
RemoteSignerClientConfig defines the configuration options for a RemoteSignerClient. This is used to marshal/unmarshal the configuration to/from TOML and configure the client using the gnoland CLI tool.
func DefaultRemoteSignerClientConfig ¶
func DefaultRemoteSignerClientConfig() *RemoteSignerClientConfig
DefaultRemoteSignerClientConfig returns a default configuration for the RemoteSignerClient.
func TestRemoteSignerClientConfig ¶
func TestRemoteSignerClientConfig() *RemoteSignerClientConfig
TestRemoteSignerClientConfig returns a configuration for testing the RemoteSignerClient.
func (*RemoteSignerClientConfig) ValidateBasic ¶
func (cfg *RemoteSignerClientConfig) ValidateBasic() error
ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.