rpc

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Unlicense Imports: 27 Imported by: 0

Documentation

Overview

Package rpc provides an RPC server for use in remote control and external application integration.

Index

Constants

View Source
const (
	PrivateKeySize = 32
	PublicKeySize  = 32
)
View Source
const NullPort = 0

Variables

View Source
var (
	UnixPathFlag  = "rpc-unix-listen"
	TunEnableFlag = "rpc-tun-enable"
	TunPortFlag   = "rpc-tun-port"
	TunPeersFlag  = "rpc-tun-peer"
)
View Source
var (
	ErrKeyNotExists error = errors.New("key not found")
)

Functions

func Dial

func Dial(target string, opts ...DialOption) (conn *grpc.ClientConn, err error)

func DialContext

func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *grpc.ClientConn, err error)

func InitFlags

func InitFlags(cmd *cobra.Command)

func IsConfigured

func IsConfigured() chan bool

func IsReady

func IsReady() chan bool

func RunWith

func RunWith(r func(srv *grpc.Server), opts ...ServerOption)

func Shutdown

func Shutdown()

func WhenStartFailed

func WhenStartFailed() chan error

Types

type BadgerStore

type BadgerStore struct {
	*badger.DB
}

func (*BadgerStore) GetKey

func (s *BadgerStore) GetKey() (*PrivateKey, error)

func (*BadgerStore) Reset

func (s *BadgerStore) Reset()

func (*BadgerStore) SetKey

func (s *BadgerStore) SetKey(key *PrivateKey) error

type DialOption

type DialOption interface {
	// contains filtered or unexported methods
}

DialOption configures how we set up the connection.

func WithKeepAliveInterval

func WithKeepAliveInterval(seconds int) DialOption

func WithPeer

func WithPeer(pubKey string) DialOption

func WithPrivateKey

func WithPrivateKey(key string) DialOption

type Endpoint

type Endpoint string

func EndpointString

func EndpointString(endpoint string) (ep Endpoint)

func (Endpoint) Address

func (e Endpoint) Address() string

func (Endpoint) Port

func (e Endpoint) Port() string

func (Endpoint) String

func (e Endpoint) String() string

type MacaroonCredential

type MacaroonCredential struct{ macaroons.MacaroonCredential }

func NewMacaroonCredential

func NewMacaroonCredential(m *macaroon.Macaroon) (MacaroonCredential, error)

NewMacaroonCredential returns a copy of the passed macaroon wrapped in a MacaroonCredential struct which implements PerRPCCredentials.

func (MacaroonCredential) RequireTransportSecurity

func (m MacaroonCredential) RequireTransportSecurity() bool

RequireTransportSecurity implements the PerRPCCredentials interface.

type PrivateKey

type PrivateKey [PrivateKeySize]byte

func DecodePrivateKey

func DecodePrivateKey(key string) PrivateKey

func NewPrivateKey

func NewPrivateKey() (*PrivateKey, error)

func (*PrivateKey) AsDeviceKey

func (sk *PrivateKey) AsDeviceKey() device.NoisePrivateKey

func (PrivateKey) Bytes

func (sk PrivateKey) Bytes() []byte

func (*PrivateKey) Decode

func (sk *PrivateKey) Decode(key string)

func (*PrivateKey) DecodeBytes

func (sk *PrivateKey) DecodeBytes(key []byte)

func (PrivateKey) Encode

func (sk PrivateKey) Encode() (key string)

func (PrivateKey) Equals

func (key PrivateKey) Equals(tar PrivateKey) bool

func (PrivateKey) HexString

func (sk PrivateKey) HexString() string

func (PrivateKey) IsZero

func (sk PrivateKey) IsZero() bool

func (*PrivateKey) PubKey

func (sk *PrivateKey) PubKey() (pk PublicKey)

type PublicKey

type PublicKey [PublicKeySize]byte

func DecodePublicKey

func DecodePublicKey(key string) PublicKey

func (PublicKey) AsDeviceKey

func (sk PublicKey) AsDeviceKey() device.NoisePublicKey

func (*PublicKey) Decode

func (sk *PublicKey) Decode(key string)

func (PublicKey) Encode

func (sk PublicKey) Encode() (key string)

func (PublicKey) HexString

func (sk PublicKey) HexString() string

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

func WithDisableTunnel

func WithDisableTunnel() ServerOption

func WithStore

func WithStore(store Store) ServerOption

func WithTunOptions

func WithTunOptions(port uint16, peers []string) ServerOption

func WithUnixPath

func WithUnixPath(path string) ServerOption

type ServerOptions

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

func Options

func Options() *ServerOptions

func (*ServerOptions) GetTunPort

func (s *ServerOptions) GetTunPort() uint16

type Store

type Store interface {
	Reset()

	SetKey(key *PrivateKey) error

	GetKey() (*PrivateKey, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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