more anti-read policies, authorized kinds and khatru update.

This commit is contained in:
fiatjaf 2023-11-22 17:12:25 -03:00
parent bdc401c4aa
commit 93eb09a24f
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
3 changed files with 24 additions and 8 deletions

2
go.mod
View File

@ -6,7 +6,7 @@ toolchain go1.21.3
require ( require (
github.com/fiatjaf/eventstore v0.2.9 github.com/fiatjaf/eventstore v0.2.9
github.com/fiatjaf/khatru v0.0.12 github.com/fiatjaf/khatru v0.1.0
github.com/kelseyhightower/envconfig v1.4.0 github.com/kelseyhightower/envconfig v1.4.0
github.com/nbd-wtf/go-nostr v0.25.7 github.com/nbd-wtf/go-nostr v0.25.7
github.com/nbd-wtf/nostr-sdk v0.0.2 github.com/nbd-wtf/nostr-sdk v0.0.2

16
main.go
View File

@ -8,7 +8,7 @@ import (
"github.com/fiatjaf/eventstore/badger" "github.com/fiatjaf/eventstore/badger"
"github.com/fiatjaf/khatru" "github.com/fiatjaf/khatru"
"github.com/fiatjaf/khatru/plugins" "github.com/fiatjaf/khatru/policies"
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
"github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr"
"github.com/nbd-wtf/go-nostr/nip11" "github.com/nbd-wtf/go-nostr/nip11"
@ -63,19 +63,21 @@ func main() {
relay.QueryEvents = append(relay.QueryEvents, db.QueryEvents) relay.QueryEvents = append(relay.QueryEvents, db.QueryEvents)
relay.DeleteEvent = append(relay.DeleteEvent, db.DeleteEvent) relay.DeleteEvent = append(relay.DeleteEvent, db.DeleteEvent)
relay.RejectEvent = append(relay.RejectEvent, relay.RejectEvent = append(relay.RejectEvent,
plugins.PreventLargeTags(64), policies.PreventLargeTags(100),
plugins.PreventTooManyIndexableTags(8, []int{3, 10002}, nil), policies.PreventTooManyIndexableTags(8, []int{3, 10002}, nil),
plugins.PreventTooManyIndexableTags(1000, nil, []int{3, 10002}), policies.PreventTooManyIndexableTags(1000, nil, []int{3, 10002}),
plugins.RestrictToSpecifiedKinds(supportedKinds...), policies.RestrictToSpecifiedKinds(supportedKinds...),
rejectEventsFromUsersNotInWhitelist, rejectEventsFromUsersNotInWhitelist,
validateAndFilterReports, validateAndFilterReports,
) )
relay.OverwriteFilter = append(relay.OverwriteFilter, relay.OverwriteFilter = append(relay.OverwriteFilter,
plugins.RemoveAllButKinds(supportedKinds...), policies.RemoveAllButKinds(supportedKinds...),
removeAuthorsNotWhitelisted, removeAuthorsNotWhitelisted,
) )
relay.RejectFilter = append(relay.RejectFilter, relay.RejectFilter = append(relay.RejectFilter,
plugins.NoSearchQueries, policies.NoSearchQueries,
policies.NoEmptyFilters,
policies.AntiSyncBots,
) )
// load users registry // load users registry

View File

@ -31,8 +31,22 @@ var supportedKinds = []uint16{
10000, 10000,
10001, 10001,
10002, 10002,
10003,
10004,
10005,
10006,
10007,
10015,
10030,
30000,
30002,
30003,
30004,
30008, 30008,
30009, 30009,
30015,
30030,
30078,
30311, 30311,
31922, 31922,
31923, 31923,