remove getAllowedKinds function and related logic for handling allowed kinds
This commit is contained in:
parent
f2b1bd0a46
commit
d9c82c6eee
22
main.go
22
main.go
@ -4,8 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/fiatjaf/eventstore/postgresql"
|
"github.com/fiatjaf/eventstore/postgresql"
|
||||||
@ -20,23 +18,6 @@ func getEnv(key, fallback string) string {
|
|||||||
return fallback
|
return fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAllowedKinds() []uint16 {
|
|
||||||
allowedKindsStr := getEnv("ALLOWED_KINDS", "")
|
|
||||||
if allowedKindsStr == "" {
|
|
||||||
return nil // Allow all kinds
|
|
||||||
}
|
|
||||||
|
|
||||||
kindStrs := strings.Split(allowedKindsStr, ",")
|
|
||||||
kinds := make([]uint16, 0, len(kindStrs))
|
|
||||||
|
|
||||||
for _, k := range kindStrs {
|
|
||||||
if kind, err := strconv.ParseUint(strings.TrimSpace(k), 10, 16); err == nil {
|
|
||||||
kinds = append(kinds, uint16(kind))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return kinds
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Print ASCII art banner
|
// Print ASCII art banner
|
||||||
fmt.Print(`
|
fmt.Print(`
|
||||||
@ -66,8 +47,6 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
allowedKinds := getAllowedKinds()
|
|
||||||
|
|
||||||
relay.StoreEvent = append(relay.StoreEvent, db.SaveEvent)
|
relay.StoreEvent = append(relay.StoreEvent, db.SaveEvent)
|
||||||
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)
|
||||||
@ -78,7 +57,6 @@ func main() {
|
|||||||
policies.PreventLargeTags(120),
|
policies.PreventLargeTags(120),
|
||||||
policies.PreventTimestampsInThePast(time.Hour*2),
|
policies.PreventTimestampsInThePast(time.Hour*2),
|
||||||
policies.PreventTimestampsInTheFuture(time.Minute*30),
|
policies.PreventTimestampsInTheFuture(time.Minute*30),
|
||||||
policies.RestrictToSpecifiedKinds(true, allowedKinds...),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
fmt.Println("running on :3334")
|
fmt.Println("running on :3334")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user