repproto

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2015 License: BSD-2-Clause Imports: 14 Imported by: 4

Documentation

Overview

Package repproto implements the repbin protocol wrappers.

Index

Constants

View Source
const Version = "0.0.2 very alpha"

Version of this release

Variables

View Source
var (
	// ErrNoServers is returned if no servers are known
	ErrNoServers = errors.New("rep: No servers")
	// ErrNoResponse is returned if no response could be gotten
	ErrNoResponse = errors.New("rep: No response")
	// ErrBadProto is returned if the protocol is not adhered to
	ErrBadProto = errors.New("rep: Bad proto")
	// ErrNoMoreServers is returned if no more servers are available
	ErrNoMoreServers = errors.New("rep: Servers exhausted")
	// ErrPrivKey is returned if authentication is required but the private key was not given
	ErrPrivKey = errors.New("rep: Private key required but missing")
)

Functions

This section is empty.

Types

type Proto

type Proto struct {
	SocksServer string   // the socks server
	Servers     []string // Repbin servers
	// ServerSelector replaces server selection. first string is messageID, remaining are available servers.
	// ServerSelector MUST return ErrNoMoreServers when servers are exhausted or an infinite loop will result
	ServerSelector func([]byte, ...string) (string, error)
	// SelectorReset resets server selection
	SelectorReset func()
	// contains filtered or unexported fields
}

Proto implements the protocol wrappers

func New

func New(socksserver string, firstServer string, servers ...string) *Proto

New creates a proto wrapper

func (*Proto) Auth

func (proto *Proto) Auth(server string, privKey []byte) (string, error)

Auth creates an authentication for server and privKey

func (*Proto) Get

func (proto *Proto) Get(messageID []byte) (string, []byte, error)

Get a message

func (*Proto) GetGlobalIndex

func (proto *Proto) GetGlobalIndex(server, auth string, start, count int) (messages []*structs.MessageStruct, more bool, err error)

GetGlobalIndex returns the global index of a server

func (*Proto) GetSpecific

func (proto *Proto) GetSpecific(server string, messageID []byte) ([]byte, error)

GetSpecific fetches a message from a specific server

func (*Proto) GetSpecificAuth

func (proto *Proto) GetSpecificAuth(server, auth string, messageID []byte) ([]byte, error)

GetSpecificAuth fetches a message from a specific server using authentication

func (*Proto) ID

func (proto *Proto) ID(server string) (*ServerInfo, error)

ID returns the ID of a specific server

func (*Proto) List

func (proto *Proto) List(pubKey, privKey []byte, start, count int) (server string, messages []*structs.MessageStruct, more bool, err error)

List messages for pubKey

func (*Proto) ListSpecific

func (proto *Proto) ListSpecific(server string, pubKey, privKey []byte, start, count int) (messages []*structs.MessageStruct, more bool, err error)

ListSpecific lists the messages for pubKey from a specific server

func (*Proto) Notify

func (proto *Proto) Notify(server, auth string) error

Notify a server

func (*Proto) Post

func (proto *Proto) Post(messageID []byte, message []byte) (string, error)

Post a message

func (*Proto) PostSpecific

func (proto *Proto) PostSpecific(server string, message []byte) error

PostSpecific posts a message to a specific server

type ServerInfo

type ServerInfo struct {
	Time            int64
	AuthPubKey      string
	AuthChallenge   string
	MaxPostSize     int64    // Maximum post size
	MinPostSize     int      // Minimum post size
	MinHashCashBits byte     // Minimum hashcash bits required
	Peers           []string // Peers of the server, if any
}

ServerInfo public server info

Directories

Path Synopsis
Package structs implements types used in list exchange and storage on the server.
Package structs implements types used in list exchange and storage on the server.

Jump to

Keyboard shortcuts

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