mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-03-17 13:22:56 +01:00
return blank IP and do not rate-limit when calling AddEvent().
This commit is contained in:
parent
b8bb58f77c
commit
6d827ac89a
@ -13,7 +13,11 @@ func EventIPRateLimiter(tokensPerInterval int, interval time.Duration, maxTokens
|
||||
rl := startRateLimitSystem[string](tokensPerInterval, interval, maxTokens)
|
||||
|
||||
return func(ctx context.Context, _ *nostr.Event) (reject bool, msg string) {
|
||||
return rl(khatru.GetIP(ctx)), "rate-limited: slow down, please"
|
||||
ip := khatru.GetIP(ctx)
|
||||
if ip == "" {
|
||||
return false, ""
|
||||
}
|
||||
return rl(ip), "rate-limited: slow down, please"
|
||||
}
|
||||
}
|
||||
|
||||
|
7
utils.go
7
utils.go
@ -41,7 +41,12 @@ func GetAuthed(ctx context.Context) string {
|
||||
}
|
||||
|
||||
func GetIP(ctx context.Context) string {
|
||||
return GetIPFromRequest(GetConnection(ctx).Request)
|
||||
conn := GetConnection(ctx)
|
||||
if conn == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return GetIPFromRequest(conn.Request)
|
||||
}
|
||||
|
||||
func GetSubscriptionID(ctx context.Context) string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user