plugin

package
v2.5.5+incompatible Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

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) ReadConfig

func (m *PluginDefinition) ReadConfig() ([]byte, error)

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) 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) 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 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) 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