Documentation
¶
Index ¶
- Variables
- func ContactCodeTopic(publicKey *ecdsa.PublicKey) string
- func DiscoveryTopic() string
- func NegotiatedTopic(publicKey *ecdsa.PublicKey) string
- func PartitionedTopic(publicKey *ecdsa.PublicKey) string
- func PersonalDiscoveryTopic(publicKey *ecdsa.PublicKey) string
- func PubkeyToHex(key *ecdsa.PublicKey) string
- func PublicKeyToStr(publicKey *ecdsa.PublicKey) string
- func StrToPublicKey(str string) (*ecdsa.PublicKey, error)
- func ToTopic(s string) []byte
- type EnvelopeEventsHandler
- type EnvelopeState
- type EnvelopesMonitor
- type EnvelopesMonitorConfig
- type Filter
- type FiltersManager
- func (f *FiltersManager) Filter(chatID string) *Filter
- func (f *FiltersManager) FilterByChatID(chatID string) *Filter
- func (f *FiltersManager) FilterByFilterID(filterID string) *Filter
- func (f *FiltersManager) Filters() (result []*Filter)
- func (f *FiltersManager) FiltersByPublicKey(publicKey *ecdsa.PublicKey) (result []*Filter)
- func (f *FiltersManager) GetNegotiated(identity *ecdsa.PublicKey) *Filter
- func (f *FiltersManager) Init(chatIDs []string, publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
- func (f *FiltersManager) InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
- func (f *FiltersManager) InitPublicFilters(chatIDs []string) ([]*Filter, error)
- func (f *FiltersManager) InitWithFilters(filters []*Filter) ([]*Filter, error)
- func (f *FiltersManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Filter, error)
- func (f *FiltersManager) LoadDiscovery() ([]*Filter, error)
- func (f *FiltersManager) LoadEphemeral(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
- func (f *FiltersManager) LoadNegotiated(secret types.NegotiatedSecret) (*Filter, error)
- func (f *FiltersManager) LoadPartitioned(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
- func (f *FiltersManager) LoadPersonal(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
- func (f *FiltersManager) LoadPublic(chatID string) (*Filter, error)
- func (f *FiltersManager) Remove(filters ...*Filter) error
- func (f *FiltersManager) RemoveFilterByChatID(chatID string) (*Filter, error)
- func (f *FiltersManager) RemoveNoListenFilters() error
- func (f *FiltersManager) Reset() error
- type FiltersService
- type KeysPersistence
- type Option
- type ProcessedMessageIDsCache
- type RawFilter
- type Transport
- func (t *Transport) CleanMessagesProcessed(timestamp uint64) error
- func (t *Transport) ConfirmMessagesProcessed(ids []string, timestamp uint64) error
- func (t *Transport) FilterByChatID(chatID string) *Filter
- func (t *Transport) Filters() []*Filter
- func (t *Transport) GetCurrentTime() uint64
- func (t *Transport) InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
- func (t *Transport) InitFilters(chatIDs []string, publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
- func (t *Transport) InitPublicFilters(chatIDs []string) ([]*Filter, error)
- func (t *Transport) JoinGroup(publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
- func (t *Transport) JoinPrivate(publicKey *ecdsa.PublicKey) (*Filter, error)
- func (t *Transport) JoinPublic(chatID string) (*Filter, error)
- func (t *Transport) LeaveGroup(publicKeys []*ecdsa.PublicKey) error
- func (t *Transport) LeavePrivate(publicKey *ecdsa.PublicKey) error
- func (t *Transport) LeavePublic(chatID string) error
- func (t *Transport) LoadFilters(filters []*Filter) ([]*Filter, error)
- func (t *Transport) LoadKeyFilters(key *ecdsa.PrivateKey) (*Filter, error)
- func (t *Transport) MaxMessageSize() uint32
- func (t *Transport) ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*Filter, error)
- func (t *Transport) RemoveFilterByChatID(chatID string) (*Filter, error)
- func (t *Transport) RemoveFilters(filters []*Filter) error
- func (t *Transport) ResetFilters() error
- func (t *Transport) RetrieveRawAll() (map[Filter][]*types.Message, error)
- func (t *Transport) SendCommunityMessage(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
- func (t *Transport) SendMessagesRequest(ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte, ...) (cursor []byte, err error)
- func (t *Transport) SendMessagesRequestForFilter(ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte, ...) (cursor []byte, err error)
- func (t *Transport) SendPrivateOnPersonalTopic(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
- func (t *Transport) SendPrivateWithPartitioned(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
- func (t *Transport) SendPrivateWithSharedSecret(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey, ...) ([]byte, error)
- func (t *Transport) SendPublic(ctx context.Context, newMessage *types.NewMessage, chatName string) ([]byte, error)
- func (t *Transport) SetEnvelopeEventsHandler(handler EnvelopeEventsHandler) error
- func (t *Transport) Stop() error
- func (t *Transport) Track(identifiers [][]byte, hash []byte, newMessage *types.NewMessage)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoMailservers returned if there is no configured mailservers that can be used. ErrNoMailservers = errors.New("no configured mailservers") )
Functions ¶
func ContactCodeTopic ¶
func DiscoveryTopic ¶
func DiscoveryTopic() string
func NegotiatedTopic ¶
func PartitionedTopic ¶
PartitionedTopic returns the associated partitioned topic string with the given public key.
func PersonalDiscoveryTopic ¶
func PubkeyToHex ¶ added in v0.72.0
func PublicKeyToStr ¶
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 EnvelopeState ¶ added in v0.76.6
type EnvelopeState int
EnvelopeState in local tracker
const ( // NotRegistered returned if asked hash wasn't registered in the tracker. NotRegistered EnvelopeState = -1 // EnvelopePosted is set when envelope was added to a local waku queue. EnvelopePosted EnvelopeState = iota + 1 // EnvelopeSent is set when envelope is sent to at least one peer. EnvelopeSent )
type EnvelopesMonitor ¶ added in v0.76.6
type EnvelopesMonitor struct {
// contains filtered or unexported fields
}
EnvelopesMonitor is responsible for monitoring waku envelopes state.
func NewEnvelopesMonitor ¶ added in v0.76.6
func NewEnvelopesMonitor(w types.Waku, config EnvelopesMonitorConfig) *EnvelopesMonitor
NewEnvelopesMonitor returns a pointer to an instance of the EnvelopesMonitor.
func (*EnvelopesMonitor) Add ¶ added in v0.76.6
func (m *EnvelopesMonitor) Add(identifiers [][]byte, envelopeHash types.Hash, message types.NewMessage)
Add hash to a tracker.
func (*EnvelopesMonitor) GetState ¶ added in v0.76.6
func (m *EnvelopesMonitor) GetState(hash types.Hash) EnvelopeState
func (*EnvelopesMonitor) Start ¶ added in v0.76.6
func (m *EnvelopesMonitor) Start()
Start processing events.
func (*EnvelopesMonitor) Stop ¶ added in v0.76.6
func (m *EnvelopesMonitor) Stop()
Stop process events.
type EnvelopesMonitorConfig ¶
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"` // Ephemeral indicates that this is an ephemeral filter Ephemeral bool `json:"ephemeral"` }
TODO: revise fields encoding/decoding. Some are encoded using hexutil and some using encoding/hex.
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 (f *FiltersManager) Filter(chatID string) *Filter
func (*FiltersManager) FilterByChatID ¶ added in v0.76.3
func (f *FiltersManager) FilterByChatID(chatID string) *Filter
FilterByChatID returns a Filter for given chat id
func (*FiltersManager) FilterByFilterID ¶
func (f *FiltersManager) FilterByFilterID(filterID string) *Filter
FilterByFilterID returns a Filter with a given Whisper filter ID.
func (*FiltersManager) Filters ¶
func (f *FiltersManager) Filters() (result []*Filter)
func (*FiltersManager) FiltersByPublicKey ¶
func (f *FiltersManager) FiltersByPublicKey(publicKey *ecdsa.PublicKey) (result []*Filter)
func (*FiltersManager) GetNegotiated ¶
func (f *FiltersManager) GetNegotiated(identity *ecdsa.PublicKey) *Filter
GetNegotiated returns a negotiated chat given an identity
func (*FiltersManager) InitCommunityFilters ¶ added in v0.72.0
func (f *FiltersManager) InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
func (*FiltersManager) InitPublicFilters ¶ added in v0.67.0
func (f *FiltersManager) InitPublicFilters(chatIDs []string) ([]*Filter, error)
func (*FiltersManager) InitWithFilters ¶
func (f *FiltersManager) InitWithFilters(filters []*Filter) ([]*Filter, error)
DEPRECATED
func (*FiltersManager) LoadContactCode ¶
func (f *FiltersManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Filter, error)
LoadContactCode creates a filter for the advertise topic for a given public key.
func (*FiltersManager) LoadDiscovery ¶
func (f *FiltersManager) LoadDiscovery() ([]*Filter, error)
LoadDiscovery adds 1 discovery filter for the personal discovery topic.
func (*FiltersManager) LoadEphemeral ¶ added in v0.69.0
func (f *FiltersManager) LoadEphemeral(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
LoadEphemeral creates a filter for a partitioned/personal topic.
func (*FiltersManager) LoadNegotiated ¶
func (f *FiltersManager) LoadNegotiated(secret types.NegotiatedSecret) (*Filter, error)
LoadNegotiated loads a negotiated secret as a filter.
func (*FiltersManager) LoadPartitioned ¶
func (f *FiltersManager) LoadPartitioned(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
LoadPartitioned creates a filter for a partitioned topic.
func (*FiltersManager) LoadPersonal ¶ added in v0.69.0
func (f *FiltersManager) LoadPersonal(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
LoadPersonal creates a filter for a personal topic.
func (*FiltersManager) LoadPublic ¶
func (f *FiltersManager) LoadPublic(chatID string) (*Filter, error)
LoadPublic adds a filter for a public chat.
func (*FiltersManager) Remove ¶
func (f *FiltersManager) Remove(filters ...*Filter) error
Remove remove all the filters associated with a chat/identity
func (*FiltersManager) RemoveFilterByChatID ¶ added in v0.67.0
func (f *FiltersManager) RemoveFilterByChatID(chatID string) (*Filter, error)
Remove remove all the filters associated with a chat/identity
func (*FiltersManager) RemoveNoListenFilters ¶ added in v0.69.0
func (f *FiltersManager) RemoveNoListenFilters() error
Remove remove all the filters associated with a chat/identity
func (*FiltersManager) Reset ¶
func (f *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 UnsubscribeMany(ids []string) error }
type KeysPersistence ¶
type ProcessedMessageIDsCache ¶ added in v0.68.6
type ProcessedMessageIDsCache struct {
// contains filtered or unexported fields
}
func NewProcessedMessageIDsCache ¶ added in v0.68.6
func NewProcessedMessageIDsCache(db *sql.DB) *ProcessedMessageIDsCache
func (*ProcessedMessageIDsCache) Add ¶ added in v0.68.6
func (c *ProcessedMessageIDsCache) Add(ids []string, timestamp uint64) (err error)
func (*ProcessedMessageIDsCache) Clean ¶ added in v0.68.6
func (c *ProcessedMessageIDsCache) Clean(timestamp uint64) error
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is a transport based on Whisper service.
func NewTransport ¶ added in v0.76.6
func NewTransport( waku types.Waku, privateKey *ecdsa.PrivateKey, db *sql.DB, mailservers []string, envelopesMonitorConfig *EnvelopesMonitorConfig, logger *zap.Logger, opts ...Option, ) (*Transport, error)
NewTransport returns a new Transport. TODO: leaving a chat should verify that for a given public key
there are no other chats. It may happen that we leave a private chat but still have a public chat for a given public key.
func (*Transport) CleanMessagesProcessed ¶ added in v0.68.6
CleanMessagesProcessed clears the messages that are older than timestamp
func (*Transport) ConfirmMessagesProcessed ¶ added in v0.68.6
ConfirmMessagesProcessed marks the messages as processed in the cache so they won't be passed to the next layer anymore
func (*Transport) FilterByChatID ¶ added in v0.76.3
func (*Transport) GetCurrentTime ¶
GetCurrentTime returns the current unix timestamp in milliseconds
func (*Transport) InitCommunityFilters ¶ added in v0.72.0
func (t *Transport) InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
func (*Transport) InitFilters ¶
func (*Transport) InitPublicFilters ¶ added in v0.67.0
func (*Transport) JoinPrivate ¶
func (*Transport) LeavePublic ¶
func (*Transport) LoadFilters ¶
func (*Transport) LoadKeyFilters ¶ added in v0.56.1
func (t *Transport) LoadKeyFilters(key *ecdsa.PrivateKey) (*Filter, error)
func (*Transport) MaxMessageSize ¶ added in v0.63.2
func (*Transport) ProcessNegotiatedSecret ¶
func (t *Transport) ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*Filter, error)
func (*Transport) RemoveFilterByChatID ¶ added in v0.67.0
func (*Transport) RemoveFilters ¶
func (*Transport) ResetFilters ¶
func (*Transport) RetrieveRawAll ¶
func (*Transport) SendCommunityMessage ¶ added in v0.72.0
func (*Transport) SendMessagesRequest ¶
func (t *Transport) SendMessagesRequest( ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte, waitForResponse bool, ) (cursor []byte, err error)
RequestHistoricMessages requests historic messages for all registered filters.
func (*Transport) SendMessagesRequestForFilter ¶ added in v0.76.3
func (*Transport) SendPrivateOnPersonalTopic ¶ added in v0.69.0
func (*Transport) SendPrivateWithPartitioned ¶
func (*Transport) SendPrivateWithSharedSecret ¶
func (*Transport) SendPublic ¶
func (t *Transport) SendPublic(ctx context.Context, newMessage *types.NewMessage, chatName string) ([]byte, error)
SendPublic sends a new message using the Whisper service. For public filters, chat name is used as an ID as well as a topic.
func (*Transport) SetEnvelopeEventsHandler ¶ added in v0.64.7
func (t *Transport) SetEnvelopeEventsHandler(handler EnvelopeEventsHandler) error