Documentation
¶
Index ¶
- Constants
- func FilterEqual(a Filter, b Filter) bool
- func GeneratePrivateKey() string
- func GetPublicKey(sk string) (string, error)
- func NormalizeURL(u string) string
- type Connection
- type Event
- type EventMessage
- type Filter
- type Filters
- type IntList
- type NoticeMessage
- type PublishStatus
- type RelayPool
- type RelayPoolPolicy
- type SimplePolicy
- type Status
- type StringList
- type Subscription
- type TagMap
- type Tags
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func FilterEqual ¶ added in v0.4.2
func GeneratePrivateKey ¶ added in v0.5.0
func GeneratePrivateKey() string
func GetPublicKey ¶ added in v0.5.0
func NormalizeURL ¶
Types ¶
type Connection ¶ added in v0.5.1
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶ added in v0.5.1
func NewConnection(socket *websocket.Conn) *Connection
func (*Connection) Close ¶ added in v0.5.1
func (c *Connection) Close() error
func (*Connection) WriteJSON ¶ added in v0.5.1
func (c *Connection) WriteJSON(v interface{}) error
func (*Connection) WriteMessage ¶ added in v0.5.1
func (c *Connection) WriteMessage(messageType int, data []byte) error
type Event ¶
type Event struct {
ID string
PubKey string
CreatedAt time.Time
Kind int
Tags Tags
Content string
Sig string
}
func (Event) CheckSignature ¶
CheckSignature checks if the signature is valid for the id (which is a hash of the serialized event content). returns an error if the signature itself is invalid.
func (Event) MarshalJSON ¶ added in v0.6.1
func (*Event) Serialize ¶
Serialize outputs a byte array that can be hashed/signed to identify/authenticate
func (*Event) UnmarshalJSON ¶ added in v0.6.1
type EventMessage ¶
type Filter ¶ added in v0.6.1
type Filter struct {
IDs StringList
Kinds IntList
Authors StringList
Tags TagMap
Since *time.Time
Until *time.Time
Limit int
}
func (Filter) MarshalJSON ¶ added in v0.6.1
func (*Filter) UnmarshalJSON ¶ added in v0.6.1
type NoticeMessage ¶
type PublishStatus ¶
type RelayPool ¶
type RelayPool struct {
SecretKey *string
Relays s.MapOf[string, RelayPoolPolicy]
Notices chan *NoticeMessage
// contains filtered or unexported fields
}
func (*RelayPool) Add ¶
func (r *RelayPool) Add(url string, policy RelayPoolPolicy) error
Add adds a new relay to the pool, if policy is nil, it will be a simple read+write policy.
func (*RelayPool) PublishEvent ¶
func (r *RelayPool) PublishEvent(evt *Event) (*Event, chan PublishStatus, error)
func (*RelayPool) Sub ¶
func (r *RelayPool) Sub(filters Filters) *Subscription
type RelayPoolPolicy ¶
type SimplePolicy ¶
func (SimplePolicy) ShouldRead ¶ added in v0.4.1
func (s SimplePolicy) ShouldRead(_ Filters) bool
func (SimplePolicy) ShouldWrite ¶ added in v0.4.1
func (s SimplePolicy) ShouldWrite(_ *Event) bool
type StringList ¶
type StringList []string
func (StringList) Contains ¶
func (haystack StringList) Contains(needle string) bool
func (StringList) ContainsPrefixOf ¶ added in v0.6.1
func (haystack StringList) ContainsPrefixOf(needle string) bool
func (StringList) Equals ¶
func (as StringList) Equals(bs StringList) bool
type Subscription ¶
type Subscription struct {
Events chan EventMessage
UniqueEvents chan Event
// contains filtered or unexported fields
}
func (*Subscription) Sub ¶
func (subscription *Subscription) Sub(filters Filters)
func (Subscription) Unsub ¶
func (subscription Subscription) Unsub()
type TagMap ¶ added in v0.6.1
type TagMap map[string]StringList
type Tags ¶
type Tags []StringList
func (Tags) ContainsAny ¶
func (tags Tags) ContainsAny(tagName string, values StringList) bool
Source Files
¶
Click to show internal directories.
Click to hide internal directories.