Documentation
¶
Index ¶
- Variables
- func AntiSyncBots(ctx context.Context, filter nostr.Filter) (reject bool, msg string)
- func ConnectionRateLimiter(tokensPerInterval int, interval time.Duration, maxTokens int) func(r *http.Request) bool
- func EventIPRateLimiter(tokensPerInterval int, interval time.Duration, maxTokens int) func(ctx context.Context, _ nostr.Event) (reject bool, msg string)
- func EventPubKeyRateLimiter(tokensPerInterval int, interval time.Duration, maxTokens int) func(ctx context.Context, _ nostr.Event) (reject bool, msg string)
- func FilterIPRateLimiter(tokensPerInterval int, interval time.Duration, maxTokens int) func(ctx context.Context, _ nostr.Filter) (reject bool, msg string)
- func MustAuth(ctx context.Context, filter nostr.Filter) (reject bool, msg string)
- func NoComplexFilters(ctx context.Context, filter nostr.Filter) (reject bool, msg string)
- func NoEmptyFilters(ctx context.Context, filter nostr.Filter) (reject bool, msg string)
- func NoSearchQueries(ctx context.Context, filter nostr.Filter) (reject bool, msg string)
- func OnlyAllowNIP70ProtectedEvents(ctx context.Context, event nostr.Event) (reject bool, msg string)
- func PreventLargeContent(maxContent int) func(context.Context, nostr.Event) (bool, string)
- func PreventLargeTags(maxTagValueLen int) func(context.Context, nostr.Event) (bool, string)
- func PreventTimestampsInTheFuture(threshold time.Duration) func(context.Context, nostr.Event) (bool, string)
- func PreventTimestampsInThePast(threshold time.Duration) func(context.Context, nostr.Event) (bool, string)
- func PreventTooManyIndexableTags(max int, ignoreKinds []nostr.Kind, onlyKinds []nostr.Kind) func(context.Context, nostr.Event) (bool, string)
- func RejectEventsWithBase64Media(ctx context.Context, evt nostr.Event) (bool, string)
- func RemoveAllButKinds(kinds ...nostr.Kind) func(context.Context, *nostr.Filter)
- func RemoveAllButTags(tagNames ...string) func(context.Context, *nostr.Filter)
- func RemoveSearchQueries(ctx context.Context, filter *nostr.Filter)
- func RestrictToSpecifiedKinds(allowEphemeral bool, kinds ...nostr.Kind) func(context.Context, nostr.Event) (bool, string)
- func SeqEvent(funcs ...func(ctx context.Context, evt nostr.Event) (bool, string)) func(context.Context, nostr.Event) (reject bool, reason string)
- func SeqRequest(funcs ...func(ctx context.Context, evt nostr.Filter) (bool, string)) func(context.Context, nostr.Filter) (reject bool, reason string)
- func SeqStore(funcs ...func(ctx context.Context, evt nostr.Event) error) func(context.Context, nostr.Event) error
- func ValidateKind(ctx context.Context, evt nostr.Event) (bool, string)
Constants ¶
This section is empty.
Variables ¶
var ConnectionRejectionStrictDefaults = ConnectionRateLimiter(1, time.Minute*5, 100)
var EventRejectionStrictDefaults = SeqEvent( RejectEventsWithBase64Media, PreventLargeTags(100), PreventTooManyIndexableTags(12, []nostr.Kind{3}, nil), PreventTooManyIndexableTags(1200, nil, []nostr.Kind{3}), PreventLargeContent(5000), EventIPRateLimiter(2, time.Minute*3, 10), )
var RequestRejectionStrictDefaults = SeqRequest( NoComplexFilters, NoSearchQueries, FilterIPRateLimiter(20, time.Minute, 100), )
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 ConnectionRateLimiter ¶
func EventIPRateLimiter ¶
func EventPubKeyRateLimiter ¶
func FilterIPRateLimiter ¶
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 NoSearchQueries ¶
func PreventLargeContent ¶
PreventLargeContent rejects events with content too large
func PreventLargeTags ¶
PreventLargeTags rejects events that have indexable tag values greater than maxTagValueLen.
func PreventTooManyIndexableTags ¶
func PreventTooManyIndexableTags(max int, ignoreKinds []nostr.Kind, onlyKinds []nostr.Kind) func(context.Context, nostr.Event) (bool, string)
PreventTooManyIndexableTags 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 RemoveAllButKinds ¶
func RemoveAllButTags ¶
func RestrictToSpecifiedKinds ¶
func RestrictToSpecifiedKinds(allowEphemeral bool, kinds ...nostr.Kind) func(context.Context, nostr.Event) (bool, string)
RestrictToSpecifiedKinds returns a function that can be used as a RejectFilter that will reject any events with kinds different than the specified ones.
func SeqRequest ¶
Types ¶
This section is empty.