Documentation
¶
Index ¶
- Constants
- Variables
- func AntiSyncBots(c context.T, f *filter.T) (rej bool, msg string)
- func DecryptDM(ev *event.T, meSec, youPub string) (decryptedStr string, err error)
- func EncryptDM(ev *event.T, meSec, youPub string) (evo *event.T, err error)
- func GetAuthed(c context.T) string
- func GetConnection(c context.T) *relayws.WebSocket
- func GetIP(c context.T) string
- func GetListeningFilters() (respFilters filters.T)
- func GetOpenSubscriptions(c context.T) filters.T
- func GetSubscriptionID(c context.T) string
- func MakeReply(ev *event.T, content string) (evo *event.T)
- func NoComplexFilters(c context.T, id subscriptionid.T, f *filter.T) (rej bool, msg string)
- func NoEmptyFilters(c context.T, id subscriptionid.T, f *filter.T) (reject bool, msg string)
- func NoSearchQueries(c context.T, id subscriptionid.T, f *filter.T) (reject bool, msg string)
- func PointerHasher[V any](_ maphash.Seed, k *V) uint64
- func RemoveListener(ws *relayws.WebSocket)
- func RemoveListenerId(ws *relayws.WebSocket, id string)
- func RemoveSearchQueries(c context.T, f *filter.T)
- func RequestAuth(c context.T, envType string)
- func SetListener(id string, ws *relayws.WebSocket, f filters.T, c context.C)
- func SprintHeader(hdr http.Header) func() (s string)
- type Command
- type CountEvents
- type Events
- type Headers
- type Hook
- type Listener
- type ListenerMap
- type OnEventSaved
- type OverrideDeletionOutcome
- type OverwriteFilter
- type OverwriteRelayInformation
- type OverwriteResponseEvent
- type QueryEvents
- type RejectEvent
- func PreventExcessTags(max int, ign kinds.T, only kinds.T) RejectEvent
- func PreventLargeTags(maxTagValueLen int) RejectEvent
- func PreventTimestampsInTheFuture(thresholdSeconds timestamp.T) RejectEvent
- func PreventTimestampsInThePast(thresholdSeconds timestamp.T) RejectEvent
- func RestrictToSpecifiedKinds(kinds ...kind.T) RejectEvent
- type RejectFilter
- type Relay
- func (rl *Relay) AddEvent(c context.T, ev *event.T) (err error)
- func (rl *Relay) AuthCheck(c context.T)
- func (rl *Relay) BroadcastEvent(ev *event.T)
- func (rl *Relay) Chat(c context.T, ev *event.T) (err error)
- func (rl *Relay) Export(db *badger.Backend, filename string, wg *sync.WaitGroup)
- func (rl *Relay) FilterPrivileged(c context.T, id subscriptionid.T, f *filter.T) (reject bool, msg string)
- func (rl *Relay) HandleNIP11(w http.ResponseWriter, r *http.Request)
- func (rl *Relay) HandleWebsocket(serviceURL string) func(w http.ResponseWriter, r *http.Request)
- func (rl *Relay) Import(db eventstore.Store, files []string, wg *sync.WaitGroup, start int)
- func (rl *Relay) Init()
- func (rl *Relay) IsAuthed(c context.T, envType string) bool
- func (rl *Relay) OverrideDelete(c context.T, tgt, del *event.T) (ok bool, msg string)
- func (rl *Relay) RescanAC(store *bdb.Backend) (err error)
- func (rl *Relay) Router() *http.ServeMux
- func (rl *Relay) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (rl *Relay) Shutdown(c context.T)
- func (rl *Relay) Start(host string, port int, started ...chan bool) (err error)
- func (rl *Relay) Wipe(store *bdb.Backend) (err error)
- type Spam
- type Spammer
Constants ¶
const ( WriteWait = 3 * time.Second PongWait = 6 * time.Second PingPeriod = 3 * time.Second ReadBufferSize = 4096 WriteBufferSize = 4096 MaxMessageSize int = 4 * units.Mb )
const IgnoreAfter = 16
Variables ¶
var Commands []*Command
var Software = "https://github.com/Hubmakerlabs/replicatr"
var Version = "v0.0.1"
Functions ¶
func AntiSyncBots ¶
AntiSyncBots tries to prevent people from syncing kind:1s from this relay to else by always requiring an author parameter at least.
func GetListeningFilters ¶
func GetSubscriptionID ¶
func MakeReply ¶
MakeReply creates an appropriate reply event from a provided event that is being replied to (not quoting, just the right tags, timestamps and kind).
func NoComplexFilters ¶
NoComplexFilters disallows filters with more than 3 tags or total of 6 of kinds and tags in sum..
func NoEmptyFilters ¶
NoEmptyFilters disallows filters that don't have at least a tag, a kind, an author or an id, or since or until.
func NoSearchQueries ¶
func RemoveListener ¶
RemoveListener removes WebSocket conn from listeners (no need to cancel contexts as they are all inherited from the main connection context)
func RemoveListenerId ¶
RemoveListenerId removes a specific subscription id from listeners for a given ws client and cancel its specific context
func RequestAuth ¶
func SetListener ¶
SetListener adds a filter to a connection.
func SprintHeader ¶
Types ¶
type CountEvents ¶
function types used in the relay state
type ListenerMap ¶
type OnEventSaved ¶
function types used in the relay state
type OverrideDeletionOutcome ¶
function types used in the relay state
type OverwriteFilter ¶
function types used in the relay state
func LimitAuthorsAndIDs ¶
func LimitAuthorsAndIDs(authors, ids int) OverwriteFilter
func RemoveAllButKinds ¶
func RemoveAllButKinds(k ...kind.T) OverwriteFilter
func RemoveAllButTags ¶
func RemoveAllButTags(tagNames ...string) OverwriteFilter
type OverwriteRelayInformation ¶
function types used in the relay state
type OverwriteResponseEvent ¶
function types used in the relay state
type QueryEvents ¶
function types used in the relay state
type RejectEvent ¶
function types used in the relay state
func PreventExcessTags ¶
PreventExcessTags returns a function that can be used as a RejectFilter that will reject events with more indexable (single-character) tags than the specified number.
If ignoreKinds is given this restriction will not apply to these kinds (useful for allowing a bigger). If onlyKinds is given then all other kinds will be ignored.
func PreventLargeTags ¶
func PreventLargeTags(maxTagValueLen int) RejectEvent
PreventLargeTags rejects events that have indexable tag values greater than maxTagValueLen.
func PreventTimestampsInTheFuture ¶
func PreventTimestampsInTheFuture(thresholdSeconds timestamp.T) RejectEvent
func PreventTimestampsInThePast ¶
func PreventTimestampsInThePast(thresholdSeconds timestamp.T) RejectEvent
func RestrictToSpecifiedKinds ¶
func RestrictToSpecifiedKinds(kinds ...kind.T) RejectEvent
RestrictToSpecifiedKinds returns a function that can be used as a RejectFilter that will reject any events with kinds different than the specified ones.
type RejectFilter ¶
function types used in the relay state
type Relay ¶
type Relay struct { Ctx context.T WG *sync.WaitGroup Cancel context.F RejectEvent []RejectEvent RejectFilter []RejectFilter RejectCountFilter []RejectFilter OverrideDeletion []OverrideDeletionOutcome OverwriteResponseEvent []OverwriteResponseEvent OverwriteFilter []OverwriteFilter OverwriteCountFilter []OverwriteFilter OverwriteRelayInfo []OverwriteRelayInformation StoreEvent []Events DeleteEvent []Events QueryEvents []QueryEvents CountEvents []CountEvents OnConnect []Hook OnDisconnect []Hook OnEventSaved []OnEventSaved Config *base.Config Info *relayinfo.T // in case you call Server.Start Addr string // websocket options // WriteWait is the time allowed to write a message to the peer. WriteWait time.Duration // PongWait is the time allowed to read the next pong message from the peer. PongWait time.Duration // PingPeriod is the tend pings to peer with this period. Must be less than // pongWait. PingPeriod time.Duration MaxMessageSize int64 // Maximum message size allowed from peer. Whitelist []string // whitelist of allowed IPs for access RelayPubHex string RelayNpub string // ACL is the list of users and privileges on this relay ACL *acl.T // contains filtered or unexported fields }
func (*Relay) AddEvent ¶
AddEvent sends an event through then normal add pipeline, as if it was received from a websocket.
func (*Relay) AuthCheck ¶
AuthCheck sends out a request if auth is required (this is an OnConnect method). It just asks for auth if enabled, saving the client time waiting until after sending a req.
func (*Relay) BroadcastEvent ¶
BroadcastEvent emits an event to all listeners whose filters' match, skipping all filters and actions it also doesn't attempt to store the event or trigger any reactions or callbacks
func (*Relay) Chat ¶
Chat implements the control interface, intercepting kind 4 encrypted direct messages and processing them if they are for the relay's pubkey
func (*Relay) FilterPrivileged ¶
func (rl *Relay) FilterPrivileged(c context.T, id subscriptionid.T, f *filter.T) (reject bool, msg string)
FilterPrivileged interacts between filters and the privileges of the users according to the access control settings of the relay, checking whether the request is authorised, if not, requesting authorisation.
If there is an ACL configured, it acts as a whitelist, no access without being on the ACL.
If the message is a private message, only authenticated users may get these events who also match one of the parties in the conversation.
func (*Relay) HandleNIP11 ¶
func (rl *Relay) HandleNIP11(w http.ResponseWriter, r *http.Request)
HandleNIP11 is a http handler for NIP-11 relayinfo.T requests
func (*Relay) HandleWebsocket ¶
HandleWebsocket is a http handler that accepts and manages websocket connections.
func (*Relay) Import ¶
Import a collection of JSON events from stdin or from one or more files, line structured JSON.
func (*Relay) OverrideDelete ¶
OverrideDelete decides whether to veto a delete event.
Temporarily removing delete functionality until a proper tombstone/indexing strategy is devised to filter out these events from database results.
func (*Relay) RescanAC ¶
RescanAC clears and regenerates access counter records. todo: implement this
func (*Relay) ServeHTTP ¶
func (rl *Relay) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler interface.
This is the main starting function of the relay. This launches HandleWebsocket which runs the message handling main loop.
Source Files
¶
- adding.go
- auth.go
- broadcasting.go
- chat.go
- chatcommands.go
- envelopes.go
- export.go
- filterpriv.go
- handlecount.go
- handledelete.go
- handlefilter.go
- handlerelayinfo.go
- helpers.go
- http.go
- import.go
- listener.go
- policiesevents.go
- policiesfilters.go
- relay.go
- rescan.go
- spam.go
- start.go
- wipe.go
- wshandler.go
- wsprocess.go
- wsread.go
- wswatcher.go