Documentation ¶
Index ¶
- Constants
- Variables
- func AntiSyncBots(c context.T, f *filter.T) (rej bool, msg string)
- func GetAuthed(c context.T) string
- 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 NoComplexFilters(c context.T, f *filter.T) (rej bool, msg string)
- func NoEmptyFilters(c context.T, f *filter.T) (reject bool, msg string)
- func NoSearchQueries(c context.T, f *filter.T) (reject bool, msg string)
- func PointerHasher[V any](_ maphash.Seed, k *V) uint64
- func RejectKind4Snoopers(c context.T, f *filter.T) (bool, string)
- func RemoveListener(ws *WebSocket)
- func RemoveListenerId(ws *WebSocket, id string)
- func RemoveSearchQueries(c context.T, f *filter.T)
- func RequestAuth(c context.T)
- func SetListener(id string, ws *WebSocket, f filters.T, c context.C)
- type CountEvents
- type Events
- type Hook
- type Listener
- type ListenerMap
- type OnEventSaved
- type OverwriteDeletionOutcome
- 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) BroadcastEvent(evt *event.T)
- func (rl *Relay) HandleNIP11(w http.ResponseWriter, r *http.Request)
- func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request)
- 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)
- type WebSocket
Constants ¶
Variables ¶
var Software = "https://github.com/Hubmakerlabs/replicatr/cmd/replicatrd"
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 NoComplexFilters ¶
NoComplexFilters disallows filters with more than 2 tags.
func NoEmptyFilters ¶
NoEmptyFilters disallows filters that don't have at least a tag, a kind, an author or an id.
func RejectKind4Snoopers ¶
RejectKind4Snoopers prevents reading NIP-04 messages from people not involved in the conversation.
func RemoveListener ¶
func RemoveListener(ws *WebSocket)
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 ¶
Types ¶
type CountEvents ¶
function types used in the relay state
type ListenerMap ¶
type OnEventSaved ¶
function types used in the relay state
type OverwriteDeletionOutcome ¶
function types used in the relay state
type OverwriteFilter ¶
function types used in the relay state
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 ¶ added in v1.0.11
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 { ServiceURL string RejectEvent []RejectEvent RejectFilter []RejectFilter RejectCountFilter []RejectFilter OverwriteDeletionOutcome []OverwriteDeletionOutcome OverwriteResponseEvent []OverwriteResponseEvent OverwriteFilter []OverwriteFilter OverwriteCountFilter []OverwriteFilter OverwriteRelayInfo []OverwriteRelayInformation StoreEvent []Events DeleteEvent []Events QueryEvents []QueryEvents CountEvents []CountEvents OnConnect []Hook OnDisconnect []Hook OnEventSaved []OnEventSaved // editing info will affect Info *nip11.Info *slog.Log // in case you call Server.Start Addr string // websocket options WriteWait time.Duration // Time allowed to write a message to the peer. PongWait time.Duration // Time allowed to read the next pong message from the peer. PingPeriod time.Duration // Send pings to peer with this period. Must be less than pongWait. MaxMessageSize int64 // Maximum message size allowed from peer. // 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) 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) HandleNIP11 ¶
func (rl *Relay) HandleNIP11(w http.ResponseWriter, r *http.Request)
func (*Relay) HandleWebsocket ¶
func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request)
func (*Relay) ServeHTTP ¶
func (rl *Relay) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler interface.
type WebSocket ¶
type WebSocket struct { Request *http.Request // original request Challenge string // nip42 AuthedPublicKey string Authed chan struct{} // contains filtered or unexported fields }
WebSocket is a wrapper around a fasthttp/websocket with mutex locking and NIP-42 Auth support