plugin

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2018 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KaetzchenPluginProtocolVersion is the version number
	// of this plugin system which we will iterate upon making
	// breaking changes so that we can invalidate old plugins.
	KaetzchenPluginProtocolVersion = 1
)

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  KaetzchenPluginProtocolVersion,
	MagicCookieKey:   "KAETZCHEN_PLUGIN",
	MagicCookieValue: "meow",
}

Handshake is a common handshake that is shared by plugin and host. Plugin usage of this is optional and is supported by the golang plugin implementations that use the go-plugin package.

View Source
var KaetzchenService = "kaetzchen"

KaetzchenService is the name of our Kaetzchen plugins which is used by the gRPC generated code.

View Source
var PluginMap = map[string]plugin.Plugin{
	KaetzchenService: &KaetzchenPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type GRPCClient

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

GRPCClient talks over gRPC to the external plugin.

func (*GRPCClient) OnRequest

func (m *GRPCClient) OnRequest(id uint64, request []byte, hasSURB bool) ([]byte, error)

OnRequest proxies the query over gRPC to the GRPCServer and returns a response payload if any.

func (*GRPCClient) Parameters

func (m *GRPCClient) Parameters() (map[string]string, error)

Parameters proxies the query over gRPC to the GRPCServer and returns a response map if any.

type GRPCServer

type GRPCServer struct {
	// Impl is the KaetzchenPluginInterface which golang
	// plugin implementations will use.
	Impl KaetzchenPluginInterface
}

GRPCServer is the gRPC server that GRPCClient talks to.

func (*GRPCServer) OnRequest

func (m *GRPCServer) OnRequest(ctx context.Context, request *proto.Request) (*proto.Response, error)

OnRequest proxies the gRPC query from the GRPCClient to the plugin implementation. A response payload if any is returned.

func (*GRPCServer) Parameters

func (m *GRPCServer) Parameters(ctx context.Context, empty *proto.Empty) (*proto.Params, error)

Parameters proxies the gRPC query from the GRPCClient to the plugin implementation. A response "Parameters" map if any is returned.

type KaetzchenPlugin

type KaetzchenPlugin struct {
	plugin.NetRPCUnsupportedPlugin

	// Impl is the concrete implementation, written in Go.
	// This is only used for plugins that are written in Go.
	Impl KaetzchenPluginInterface
}

KaetzchenPlugin is the implementation of plugin.Plugin so we can serve/consume this. We also implement GRPCPlugin so that this plugin can be served over gRPC.

func (*KaetzchenPlugin) GRPCClient

func (p *KaetzchenPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient returns the interface implementation for the plugin being served over gRPC. The provided context will be canceled by go-plugin in the event of the plugin process exiting.

func (*KaetzchenPlugin) GRPCServer

func (p *KaetzchenPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers this plugin for serving with the given gRPC server.

type KaetzchenPluginInterface

type KaetzchenPluginInterface interface {
	// OnRequest is the method that is called when the Provider receives
	// a request desgined for a particular agent. The caller will handle
	// extracting the payload component of the message
	OnRequest(id uint64, request []byte, hasSURB bool) ([]byte, error)

	// Parameters returns the agent's paramenters for publication in
	// the Provider's descriptor.
	Parameters() (map[string]string, error)
}

KaetzchenPluginInterface is the interface that we expose for external plugins to implement. This is similar to the internal Kaetzchen interface defined in: github.com/katzenpost/server/internal/provider/kaetzchen/kaetzchen.go

Directories

Path Synopsis
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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