trireme-lib: Index | Files | Directories

package rpcwrapper

import ""


Package Files

interfaces.go rpc_handle.go rpc_handlemock.go rpc_handletest.go rpc_testhelper.go types.go


const (
    SUCCESS = 0

exported consts from the package

func RegisterTypes Uses

func RegisterTypes()

RegisterTypes registers types that are exchanged between the controller and remoteenforcer

func TestNewRPCClient Uses

func TestNewRPCClient(t *testing.T)

TestNewRPCClient mocks an RPC client test

type CaptureType Uses

type CaptureType int

CaptureType identifies the type of iptables implementation that should be used

const (
    // IPTables forces an IPTables implementation
    IPTables CaptureType = iota
    // IPSets forces an IPSet implementation

type EnableDatapathPacketTracingPayLoad Uses

type EnableDatapathPacketTracingPayLoad struct {
    Direction packettracing.TracingDirection `json:",omitempty"`
    Interval  time.Duration                  `json:",omitempty"`
    ContextID string                         `json:",omitempty"`

EnableDatapathPacketTracingPayLoad is the payload to enable nfq packet tracing in the remote container

type EnableIPTablesPacketTracingPayLoad Uses

type EnableIPTablesPacketTracingPayLoad struct {
    IPTablesPacketTracing bool          `json:",omitempty"`
    Interval              time.Duration `json:",omitempty"`
    ContextID             string        `json:",omitempty"`

EnableIPTablesPacketTracingPayLoad is the payload message to enable iptable trace in remote containers

type EnforcePayload Uses

type EnforcePayload struct {
    ContextID string                 `json:",omitempty"`
    Policy    *policy.PUPolicyPublic `json:",omitempty"`
    Secrets   secrets.PublicSecrets  `json:",omitempty"`

EnforcePayload Payload for enforce request

type InitRequestPayload Uses

type InitRequestPayload struct {
    FqConfig               *fqconfig.FilterQueue  `json:",omitempty"`
    MutualAuth             bool                   `json:",omitempty"`
    PacketLogs             bool                   `json:",omitempty"`
    Validity               time.Duration          `json:",omitempty"`
    ServerID               string                 `json:",omitempty"`
    ExternalIPCacheTimeout time.Duration          `json:",omitempty"`
    Secrets                secrets.PublicSecrets  `json:",omitempty"`
    Configuration          *runtime.Configuration `json:",omitempty"`
    BinaryTokens           bool                   `json:",omitempty"`
    IsBPFEnabled           bool                   `json:",omitempty"`
    IPv6Enabled            bool                   `json:",omitempty"`

InitRequestPayload Payload for enforcer init request

type MockRPCHdl Uses

type MockRPCHdl struct {
    Client  *rpc.Client
    Channel string

MockRPCHdl is mock of rpchdl

type PayloadType Uses

type PayloadType int

PayloadType is the type of payload in the request.

const (
    PacketReport PayloadType = iota

Payload report types.

type PingPayload Uses

type PingPayload struct {
    ContextID  string
    PingConfig *policy.PingConfig

PingPayload represents the payload for ping config.

type RPCClient Uses

type RPCClient interface {
    NewRPCClient(contextID string, channel string, rpcSecret string) error
    GetRPCClient(contextID string) (*RPCHdl, error)
    RemoteCall(contextID string, methodName string, req *Request, resp *Response) error
    DestroyRPCClient(contextID string)
    ContextList() []string
    CheckValidity(req *Request, secret string) bool

RPCClient is the client interface

type RPCHdl Uses

type RPCHdl struct {
    Client  *rpc.Client
    Channel string
    Secret  string

RPCHdl is a per client handle

type RPCServer Uses

type RPCServer interface {
    StartServer(ctx context.Context, protocol string, path string, handler interface{}) error
    ProcessMessage(req *Request, secret string) bool
    CheckValidity(req *Request, secret string) bool

RPCServer is the server interface

func NewRPCServer Uses

func NewRPCServer() RPCServer

NewRPCServer returns an interface RPCServer

type RPCWrapper Uses

type RPCWrapper struct {
    // contains filtered or unexported fields

RPCWrapper is a struct which holds stats for all rpc sesions

func NewRPCWrapper Uses

func NewRPCWrapper() *RPCWrapper

NewRPCWrapper creates a new rpcwrapper

func (*RPCWrapper) CheckValidity Uses

func (r *RPCWrapper) CheckValidity(req *Request, secret string) bool

CheckValidity checks if the received message is valid

func (*RPCWrapper) ContextList Uses

func (r *RPCWrapper) ContextList() []string

ContextList returns the list of active context managed by the rpcwrapper

func (*RPCWrapper) DestroyRPCClient Uses

func (r *RPCWrapper) DestroyRPCClient(contextID string)

DestroyRPCClient calls close on the rpc and cleans up the connection

func (*RPCWrapper) GetRPCClient Uses

func (r *RPCWrapper) GetRPCClient(contextID string) (*RPCHdl, error)

GetRPCClient gets a handle to the rpc client for the contextID( enforcer in the container)

func (*RPCWrapper) NewRPCClient Uses

func (r *RPCWrapper) NewRPCClient(contextID string, channel string, sharedsecret string) error

NewRPCClient exported

func (*RPCWrapper) ProcessMessage Uses

func (r *RPCWrapper) ProcessMessage(req *Request, secret string) bool

ProcessMessage checks if the given request is valid

func (*RPCWrapper) RemoteCall Uses

func (r *RPCWrapper) RemoteCall(contextID string, methodName string, req *Request, resp *Response) error

RemoteCall is a wrapper around rpc.Call and also ensure message integrity by adding a hmac

func (*RPCWrapper) StartServer Uses

func (r *RPCWrapper) StartServer(ctx context.Context, protocol string, path string, handler interface{}) error

StartServer Starts a server and waits for new connections this function never returns

type ReportPayload Uses

type ReportPayload struct {
    Type    PayloadType
    Payload interface{}

ReportPayload is the generic report from remote enforcer

type Request Uses

type Request struct {
    HashAuth    []byte
    PayloadType PayloadType
    Payload     interface{}

Request exported

type Response Uses

type Response struct {
    Status  string
    Payload interface{} `json:",omitempty"`

Response is the response for every RPC call. This is used to carry the status of the actual function call made on the remote end

type SetLogLevelPayload Uses

type SetLogLevelPayload struct {
    Level constants.LogLevel `json:",omitempty"`

SetLogLevelPayload payload for set log level request

type SetTargetNetworksPayload Uses

type SetTargetNetworksPayload struct {
    Configuration *runtime.Configuration `json:",omitempty"`

SetTargetNetworksPayload carries the payload for target networks

type StatsPayload Uses

type StatsPayload struct {
    Flows map[string]*collector.FlowRecord `json:",omitempty"`
    Users map[string]*collector.UserRecord `json:",omitempty"`

StatsPayload is the payload carries by the stats reporting form the remote enforcer

type TestRPCClient Uses

type TestRPCClient interface {
    MockNewRPCClient(t *testing.T, impl func(contextID string, channel string, secret string) error)
    MockGetRPCClient(t *testing.T, impl func(contextID string) (*RPCHdl, error))
    MockRemoteCall(t *testing.T, impl func(contextID string, methodName string, req *Request, resp *Response) error)
    MockDestroyRPCClient(t *testing.T, impl func(contextID string))
    MockContextList(t *testing.T, impl func() []string)
    MockCheckValidity(t *testing.T, impl func(req *Request, secret string) bool)

TestRPCClient is a RPC Client used for test

func NewTestRPCClient Uses

func NewTestRPCClient() TestRPCClient

NewTestRPCClient is a Test RPC Client

type TestRPCServer Uses

type TestRPCServer interface {
    MockStartServer(t *testing.T, impl func(ctx context.Context, protocol string, path string, handler interface{}) error)
    MockProcessMessage(t *testing.T, impl func(req *Request, secret string) bool)
    MockCheckValidity(t *testing.T, impl func(req *Request, secret string) bool)

TestRPCServer is a RPC Server used for test

func NewTestRPCServer Uses

func NewTestRPCServer() TestRPCServer

NewTestRPCServer is a Test RPC Server

type TokenRequestPayload Uses

type TokenRequestPayload struct {
    ContextID        string                  `json:",omitempty"`
    Audience         string                  `json:",omitempty"`
    Validity         time.Duration           `json:",omitempty"`
    ServiceTokenType common.ServiceTokenType `json:",omitempty"`

TokenRequestPayload carries the payload for issuing tokens.

type TokenResponsePayload Uses

type TokenResponsePayload struct {
    Token string `json:",omitempty"`

TokenResponsePayload returns the issued token.

type UnEnforcePayload Uses

type UnEnforcePayload struct {
    ContextID string `json:",omitempty"`

UnEnforcePayload payload for unenforce request

type UpdateSecretsPayload Uses

type UpdateSecretsPayload struct {
    Secrets secrets.PublicSecrets `json:",omitempty"`

UpdateSecretsPayload payload for the update secrets to remote enforcers


mockrpcwrapperPackage mockrpcwrapper is a generated GoMock package.

Package rpcwrapper imports 27 packages (graph) and is imported by 19 packages. Updated 2020-04-03. Refresh now. Tools for package owners.