rpc

package
v0.0.0-...-3d85bc3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPacketSize = 1200

Variables

This section is empty.

Functions

func ClientResponseFromError

func ClientResponseFromError(err error) *pb.ClientResponse

func ErrorFromClientResponse

func ErrorFromClientResponse(resp *pb.ClientResponse) error

func InjectFault

func InjectFault(from, to *net.UDPAddr) bool

InjectFault returns true iff a fault should be injected.

func RecvUDP

func RecvUDP(sec SecretsManager, conn *net.UDPConn) (*pb.Packet, *net.UDPAddr, uint32, error)

func SendUDP

func SendUDP(sec SecretsManager, secretNum uint32, conn *net.UDPConn, to *net.UDPAddr, packet *pb.Packet) error

func SetFaultInjectorFunction

func SetFaultInjectorFunction(fn func(from, to *net.UDPAddr) bool)

SetFaultInjectorFunction assigns a fault injector function. If the fault injector function is non-nil, then it is called with the source and destination UDP/IP addresses. If the function then returns true, a fault is injected and the packet is dropped.

Types

type AccessLevel

type AccessLevel uint8
const (
	NoAccess AccessLevel = iota
	ReadAccess
	WriteAccess
	AdminAccess
	PeerAccess
)

func (AccessLevel) Check

func (access AccessLevel) Check(category PacketCategory) bool

func (AccessLevel) String

func (access AccessLevel) String() string

type Error

type Error struct {
	Status       pb.ClientResponse_Status
	ErrorMessage string
	Redirect     string
}

func InvalidSessionError

func InvalidSessionError(sid uint32) Error

func NotLeaderError

func NotLeaderError(selfId, leaderId uint32, redirect string) Error

func TimedOutError

func TimedOutError() Error

func (Error) AsClientResponse

func (err Error) AsClientResponse() *pb.ClientResponse

func (Error) Error

func (err Error) Error() string

type FileSecretsManager

type FileSecretsManager string

func (FileSecretsManager) LookupSecret

func (path FileSecretsManager) LookupSecret(secretNum uint32) Secret

type PacketCategory

type PacketCategory uint8
const (
	UnknownCategory PacketCategory = iota
	ReadCategory
	WriteCategory
	AdminCategory
	PeerCategory
)

func Category

func Category(ptype pb.Packet_Type) PacketCategory

func (PacketCategory) String

func (category PacketCategory) String() string

type Secret

type Secret struct {
	Key    []byte
	Access AccessLevel
}

func (Secret) IsZero

func (s Secret) IsZero() bool

type SecretsManager

type SecretsManager interface {
	LookupSecret(secretNum uint32) Secret
}

type SimpleSecretsManager

type SimpleSecretsManager map[uint32]Secret

func (SimpleSecretsManager) LookupSecret

func (secrets SimpleSecretsManager) LookupSecret(secretNum uint32) Secret

type StoredSecret

type StoredSecret struct {
	Key    []byte `json:"key"`
	Access string `json:"access"`
}

func (*StoredSecret) Get

func (ss *StoredSecret) Get() Secret

func (*StoredSecret) Set

func (ss *StoredSecret) Set(s Secret)

Jump to

Keyboard shortcuts

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