transport

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: MPL-2.0, MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContactCodeTopic

func ContactCodeTopic(publicKey *ecdsa.PublicKey) string

func DefaultMessage

func DefaultMessage() types.NewMessage

func DiscoveryTopic

func DiscoveryTopic() string

func NegotiatedTopic

func NegotiatedTopic(publicKey *ecdsa.PublicKey) string

func PartitionedTopic

func PartitionedTopic(publicKey *ecdsa.PublicKey) string

PartitionedTopic returns the associated partitioned topic string with the given public key.

func PersonalDiscoveryTopic

func PersonalDiscoveryTopic(publicKey *ecdsa.PublicKey) string

func PublicKeyToStr

func PublicKeyToStr(publicKey *ecdsa.PublicKey) string

func StrToPublicKey

func StrToPublicKey(str string) (*ecdsa.PublicKey, error)

func ToTopic

func ToTopic(s string) []byte

ToTopic converts a string to a whisper topic.

Types

type EnvelopeEventsHandler

type EnvelopeEventsHandler interface {
	EnvelopeSent([][]byte)
	EnvelopeExpired([][]byte, error)
	MailServerRequestCompleted(types.Hash, types.Hash, []byte, error)
	MailServerRequestExpired(types.Hash)
}

EnvelopeEventsHandler used for two different event types.

type EnvelopesMonitorConfig

type EnvelopesMonitorConfig struct {
	EnvelopeEventsHandler          EnvelopeEventsHandler
	MaxAttempts                    int
	MailserverConfirmationsEnabled bool
	IsMailserver                   func(types.EnodeID) bool
	Logger                         *zap.Logger
}

type Filter

type Filter struct {
	// ChatID is the identifier of the chat
	ChatID string `json:"chatId"`
	// FilterID the whisper filter id generated
	FilterID string `json:"filterId"`
	// SymKeyID is the symmetric key id used for symmetric filters
	SymKeyID string `json:"symKeyId"`
	// OneToOne tells us if we need to use asymmetric encryption for this chat
	OneToOne bool `json:"oneToOne"`
	// Identity is the public key of the other recipient for non-public filters.
	// It's encoded using encoding/hex.
	Identity string `json:"identity"`
	// Topic is the whisper topic
	Topic types.TopicType `json:"topic"`
	// Discovery is whether this is a discovery topic
	Discovery bool `json:"discovery"`
	// Negotiated tells us whether is a negotiated topic
	Negotiated bool `json:"negotiated"`
	// Listen is whether we are actually listening for messages on this chat, or the filter is only created in order to be able to post on the topic
	Listen bool `json:"listen"`
}

TODO: revise fields encoding/decoding. Some are encoded using hexutil and some using encoding/hex.

func (*Filter) IsPublic

func (c *Filter) IsPublic() bool

type FiltersManager

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

func NewFiltersManager

func NewFiltersManager(persistence KeysPersistence, service FiltersService, privateKey *ecdsa.PrivateKey, logger *zap.Logger) (*FiltersManager, error)

NewFiltersManager returns a new filtersManager.

func (*FiltersManager) Filter

func (s *FiltersManager) Filter(chatID string) *Filter

func (*FiltersManager) FilterByFilterID

func (s *FiltersManager) FilterByFilterID(filterID string) *Filter

FilterByFilterID returns a Filter with a given Whisper filter ID.

func (*FiltersManager) Filters

func (s *FiltersManager) Filters() (result []*Filter)

func (*FiltersManager) FiltersByPublicKey

func (s *FiltersManager) FiltersByPublicKey(publicKey *ecdsa.PublicKey) (result []*Filter)

func (*FiltersManager) GetNegotiated

func (s *FiltersManager) GetNegotiated(identity *ecdsa.PublicKey) *Filter

GetNegotiated returns a negotiated chat given an identity

func (*FiltersManager) Init

func (s *FiltersManager) Init(
	chatIDs []string,
	publicKeys []*ecdsa.PublicKey,
) ([]*Filter, error)

func (*FiltersManager) InitWithFilters

func (s *FiltersManager) InitWithFilters(filters []*Filter) ([]*Filter, error)

DEPRECATED

func (*FiltersManager) LoadContactCode

func (s *FiltersManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Filter, error)

LoadContactCode creates a filter for the advertise topic for a given public key.

func (*FiltersManager) LoadDiscovery

func (s *FiltersManager) LoadDiscovery() ([]*Filter, error)

LoadDiscovery adds 1 discovery filter for the personal discovery topic.

func (*FiltersManager) LoadNegotiated

func (s *FiltersManager) LoadNegotiated(secret types.NegotiatedSecret) (*Filter, error)

LoadNegotiated loads a negotiated secret as a filter.

func (*FiltersManager) LoadPartitioned

func (s *FiltersManager) LoadPartitioned(publicKey *ecdsa.PublicKey) (*Filter, error)

LoadPartitioned creates a filter for a partitioned topic.

func (*FiltersManager) LoadPublic

func (s *FiltersManager) LoadPublic(chatID string) (*Filter, error)

LoadPublic adds a filter for a public chat.

func (*FiltersManager) Remove

func (s *FiltersManager) Remove(filters ...*Filter) error

Remove remove all the filters associated with a chat/identity

func (*FiltersManager) Reset

func (s *FiltersManager) Reset() error

type FiltersService

type FiltersService interface {
	AddKeyPair(key *ecdsa.PrivateKey) (string, error)
	DeleteKeyPair(keyID string) bool

	AddSymKeyDirect(key []byte) (string, error)
	AddSymKeyFromPassword(password string) (string, error)
	GetSymKey(id string) ([]byte, error)
	DeleteSymKey(id string) bool

	Subscribe(opts *types.SubscriptionOptions) (string, error)
	Unsubscribe(id string) error
}

type KeysPersistence

type KeysPersistence interface {
	All() (map[string][]byte, error)
	Add(chatID string, key []byte) error
}

type RawFilter

type RawFilter struct {
	FilterID string
	Topic    types.TopicType
	SymKeyID string
}

type Transport

type Transport interface {
	Stop() error

	JoinPrivate(publicKey *ecdsa.PublicKey) error
	LeavePrivate(publicKey *ecdsa.PublicKey) error
	JoinGroup(publicKeys []*ecdsa.PublicKey) error
	LeaveGroup(publicKeys []*ecdsa.PublicKey) error
	JoinPublic(chatID string) error
	LeavePublic(chatID string) error
	GetCurrentTime() uint64

	SendPublic(ctx context.Context, newMessage *types.NewMessage, chatName string) ([]byte, error)
	SendPrivateWithSharedSecret(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey, secret []byte) ([]byte, error)
	SendPrivateWithPartitioned(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
	SendMessagesRequest(
		ctx context.Context,
		peerID []byte,
		from, to uint32,
		previousCursor []byte,
	) (cursor []byte, err error)

	Track(identifiers [][]byte, hash []byte, newMessage *types.NewMessage)

	InitFilters(chatIDs []string, publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
	LoadFilters(filters []*Filter) ([]*Filter, error)
	RemoveFilters(filters []*Filter) error
	ResetFilters() error
	Filters() []*Filter
	ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*Filter, error)
	RetrieveRawAll() (map[Filter][]*types.Message, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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