plugin

package
v0.0.0-...-0599406 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: GPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HelloWorldPluginInterfaceName = PluginInterfaceName("helloworld") // lower-case always
	SecurityPluginInterfaceName   = PluginInterfaceName("security")
	AccountPluginInterfaceName    = PluginInterfaceName("account")
)
View Source
const DefaultPublicKeyFile = "Central.pgp.pk"

Variables

This section is empty.

Functions

func ReadMultiFormatConfig

func ReadMultiFormatConfig(config interface{}) ([]byte, error)

Types

type CentralClient

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

Central https centralClient communicating with Plugin Central

func NewPluginCentralClient

func NewPluginCentralClient(config *PluginCentralConfiguration) *CentralClient

Create New Central Client

func (*CentralClient) PluginDistribution

func (cc *CentralClient) PluginDistribution(definition *PluginDefinition, outFilePath string) error

retrieve plugin distribution file

func (*CentralClient) PluginSignature

func (cc *CentralClient) PluginSignature(definition *PluginDefinition) ([]byte, error)

retrieve plugin signature

func (*CentralClient) PublicKey

func (cc *CentralClient) PublicKey() ([]byte, error)

Get the public key from central

type Dialer

type Dialer func(network, addr string) (net.Conn, error)

An adapter function for tls.Dial with CA verification & SSL Pinning support.

type Downloader

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

get plugin zip file from local or remote

func NewDownloader

func NewDownloader(pm *PluginManager) *Downloader

func (*Downloader) Download

func (d *Downloader) Download(definition *PluginDefinition) (string, error)

type EnvironmentAwaredValue

type EnvironmentAwaredValue string

support URI format with 'env' scheme during JSON/TOML/TEXT unmarshalling e.g.: env://FOO_VAR means read a string value from FOO_VAR environment variable

func (EnvironmentAwaredValue) String

func (d EnvironmentAwaredValue) String() string

func (*EnvironmentAwaredValue) UnmarshalJSON

func (d *EnvironmentAwaredValue) UnmarshalJSON(data []byte) error

func (*EnvironmentAwaredValue) UnmarshalTOML

func (d *EnvironmentAwaredValue) UnmarshalTOML(data []byte) error

func (*EnvironmentAwaredValue) UnmarshalText

func (d *EnvironmentAwaredValue) UnmarshalText(data []byte) error

type HelloWorldPluginTemplate

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

a template that returns the hello world plugin instance

func (HelloWorldPluginTemplate) Config

func (bp HelloWorldPluginTemplate) Config() *PluginDefinition

func (*HelloWorldPluginTemplate) Get

func (HelloWorldPluginTemplate) Info

func (bp HelloWorldPluginTemplate) Info() (PluginInterfaceName, interface{})

func (HelloWorldPluginTemplate) Start

func (bp HelloWorldPluginTemplate) Start() (err error)

func (HelloWorldPluginTemplate) Stop

func (bp HelloWorldPluginTemplate) Stop() error

type LocalVerifier

type LocalVerifier struct {
	PublicKeyPath    string // where to obtain PGP public key
	SignatureBaseDir string // where to obtain plugin signature file
}

Local Implementation of plugin.Verifier

func NewLocalVerifier

func NewLocalVerifier(publicKeyPath string, pluginSignatureBaseDir string) (*LocalVerifier, error)

Build a new LocalVerifier

func (*LocalVerifier) VerifySignature

func (v *LocalVerifier) VerifySignature(definition *PluginDefinition, checksum string) error

Verify a plugin giving its name from Central

type MetaData

type MetaData struct {
	Version    string   `json:"version"`
	Os         string   `json:"os"`
	Arch       string   `json:"arch"`
	EntryPoint string   `json:"entrypoint"`
	Parameters []string `json:"parameters,omitempty"`
}

Plugin-meta.json

type NonVerifier

type NonVerifier struct {
}

func NewNonVerifier

func NewNonVerifier() *NonVerifier

func (*NonVerifier) VerifySignature

func (*NonVerifier) VerifySignature(definition *PluginDefinition, checksum string) error

type OnlineVerifier

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

Implementation of plugin.Verifier that uses remote server to verify plugins.

func NewOnlineVerifier

func NewOnlineVerifier(centralClient *CentralClient) *OnlineVerifier

func (*OnlineVerifier) VerifySignature

func (v *OnlineVerifier) VerifySignature(definition *PluginDefinition, checksum string) error

Verify a plugin giving its name from Central

type PluginCentralConfiguration

type PluginCentralConfiguration struct {
	// To implement certificate pinning while communicating with PluginCentral
	// if it's empty, we skip cert pinning logic
	CertFingerprint       string `json:"certFingerprint" toml:""`
	BaseURL               string `json:"baseURL" toml:""`
	PublicKeyURI          string `json:"publicKeyURI" toml:""`
	InsecureSkipTLSVerify bool   `json:"insecureSkipTLSVerify" toml:""`
}

type PluginDefinition

type PluginDefinition struct {
	Name string `json:"name" toml:""`
	// the semver version of the plugin
	Version Version `json:"version" toml:""`
	// plugin configuration in a form of map/slice/string
	Config interface{} `json:"config,omitempty" toml:",omitempty"`
}

This is to describe a plugin

Information is used to discover the plugin binary and verify its integrity before forking a process running the plugin

func (*PluginDefinition) DistFileName

func (m *PluginDefinition) DistFileName() string

return plugin distribution file name

func (*PluginDefinition) FullName

func (m *PluginDefinition) FullName() string

return plugin name and version

func (*PluginDefinition) RemotePath

func (m *PluginDefinition) RemotePath() string

return remote folder storing the plugin distribution file and signature file

e.g.: my-plugin/v1.0.0/darwin-amd64

func (*PluginDefinition) SignatureFileName

func (m *PluginDefinition) SignatureFileName() string

return plugin distribution signature file name

type PluginInterfaceName

type PluginInterfaceName string

must be always be lowercase when define constants as when unmarshaling from config, value will be case-lowered

func (PluginInterfaceName) String

func (p PluginInterfaceName) String() string

func (*PluginInterfaceName) UnmarshalJSON

func (p *PluginInterfaceName) UnmarshalJSON(data []byte) error

When this is used as a key in map. This function is not invoked.

func (*PluginInterfaceName) UnmarshalTOML

func (p *PluginInterfaceName) UnmarshalTOML(data []byte) error

func (*PluginInterfaceName) UnmarshalText

func (p *PluginInterfaceName) UnmarshalText(data []byte) error

type PluginManager

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

this implements geth service

func NewEmptyPluginManager

func NewEmptyPluginManager() *PluginManager

func NewPluginManager

func NewPluginManager(nodeName string, settings *Settings, skipVerify bool, localVerify bool, publicKey string) (*PluginManager, error)

func (*PluginManager) APIs

func (s *PluginManager) APIs() []rpc.API

this is called after PluginManager service has been successfully started See node/node.go#Start()

func (*PluginManager) AddAccountPluginToBackend

func (s *PluginManager) AddAccountPluginToBackend(b *pluggable.Backend) error

AddAccountPluginToBackend adds the account plugin to the provided account backend

func (*PluginManager) GetPluginTemplate

func (s *PluginManager) GetPluginTemplate(name PluginInterfaceName, v managedPlugin) error

store the plugin instance to the value of the pointer v and cache it this function makes sure v value will never be nil

func (*PluginManager) IsEnabled

func (s *PluginManager) IsEnabled(name PluginInterfaceName) bool

Check if a plugin is enabled/setup

func (*PluginManager) PluginsInfo

func (s *PluginManager) PluginsInfo() interface{}

Provide details of current plugins being used

func (*PluginManager) Protocols

func (s *PluginManager) Protocols() []p2p.Protocol

func (*PluginManager) Reload

func (s *PluginManager) Reload(name PluginInterfaceName) (bool, error)

func (*PluginManager) Start

func (s *PluginManager) Start(_ *p2p.Server) (err error)

func (*PluginManager) Stop

func (s *PluginManager) Stop() error

type PluginManagerAPI

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

func NewPluginManagerAPI

func NewPluginManagerAPI(pm *PluginManager) *PluginManagerAPI

func (*PluginManagerAPI) ReloadPlugin

func (pmapi *PluginManagerAPI) ReloadPlugin(name PluginInterfaceName) (bool, error)

type ReloadableAccountServiceFactory

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

func (ReloadableAccountServiceFactory) Config

func (bp ReloadableAccountServiceFactory) Config() *PluginDefinition

func (*ReloadableAccountServiceFactory) Create

func (ReloadableAccountServiceFactory) Info

func (bp ReloadableAccountServiceFactory) Info() (PluginInterfaceName, interface{})

func (ReloadableAccountServiceFactory) Start

func (bp ReloadableAccountServiceFactory) Start() (err error)

func (ReloadableAccountServiceFactory) Stop

func (bp ReloadableAccountServiceFactory) Stop() error

type SecurityPluginTemplate

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

func (*SecurityPluginTemplate) AuthenticationManager

func (sp *SecurityPluginTemplate) AuthenticationManager() (security.AuthenticationManager, error)

AuthenticationManager returns an implementation of security.AuthenticationManager which could be a deferred implemenation or a disabled implementation.

The deferred implementation delegates to the actual implemenation (which is the plugin client).

The disabled implementation allows no authentication verification.

func (SecurityPluginTemplate) Config

func (bp SecurityPluginTemplate) Config() *PluginDefinition

func (SecurityPluginTemplate) Info

func (bp SecurityPluginTemplate) Info() (PluginInterfaceName, interface{})

func (SecurityPluginTemplate) Start

func (bp SecurityPluginTemplate) Start() (err error)

func (SecurityPluginTemplate) Stop

func (bp SecurityPluginTemplate) Stop() error

func (*SecurityPluginTemplate) TLSConfigurationSource

func (sp *SecurityPluginTemplate) TLSConfigurationSource() (security.TLSConfigurationSource, error)

TLSConfigurationSource returns an implementation of security.TLSConfigurationSource which could be nil in case the plugin doesn't implement the corresponding service. In order to verify that, it attempts to make a call and inspect the error.

type Settings

type Settings struct {
	BaseDir       EnvironmentAwaredValue                   `json:"baseDir" toml:""`
	CentralConfig *PluginCentralConfiguration              `json:"central" toml:"Central"`
	Providers     map[PluginInterfaceName]PluginDefinition `json:"providers" toml:""`
}

this defines plugins used in the geth node

func (*Settings) CheckSettingsAreSupported

func (s *Settings) CheckSettingsAreSupported(supportedPlugins []PluginInterfaceName) error

CheckSettingsAreSupported validates Settings by ensuring that only supportedPlugins are defined. It is not required for all supportedPlugins to be defined. An error containing plugin details is returned if one or more unsupported plugins are defined.

func (*Settings) GetPluginDefinition

func (s *Settings) GetPluginDefinition(name PluginInterfaceName) (*PluginDefinition, bool)

func (*Settings) SetDefaults

func (s *Settings) SetDefaults()

type Verifier

type Verifier interface {
	// verify plugin signature using checksum & pgp public key
	VerifySignature(definition *PluginDefinition, checksum string) error
}

Plugin Integrity Verifier. Verifier works on the assumption an attacker can not compromise the integrity of geth running process.

func NewVerifier

func NewVerifier(pm *PluginManager, localVerify bool, publicKey string) (Verifier, error)

type Version

type Version string

Directories

Path Synopsis
gen
proto_common
Package proto_common is a generated GoMock package.
Package proto_common is a generated GoMock package.

Jump to

Keyboard shortcuts

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