| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add comprehensive rate limiting package that works seamlessly with
NIP-98 authentication.
Features:
- Token bucket algorithm (allows bursts, smooth average rate)
- Per-pubkey limits for authenticated users
- Per-IP limits for unauthenticated users (fallback)
- Method-specific overrides (e.g., stricter for PublishEvent)
- Per-user custom limits (VIP/admin tiers)
- Standard gRPC interceptors (chain after auth)
- Automatic cleanup of idle limiters
- Statistics tracking (allowed/denied/denial rate)
Configuration options:
- Default rate limits and burst sizes
- Method-specific overrides
- User-specific overrides (with method overrides)
- Skip methods (health checks, public endpoints)
- Skip users (admins, monitoring)
- Configurable cleanup intervals
Performance:
- In-memory (200 bytes per user)
- O(1) lookups with sync.RWMutex
- ~85ns per rate limit check
- Periodic cleanup to free memory
Returns gRPC ResourceExhausted (HTTP 429) when limits exceeded.
Includes comprehensive tests, benchmarks, and detailed README with
usage examples, configuration reference, and security considerations.
|
| |
|
|
|
|
| |
Update module path from northwest.io/nostr-grpc to northwest.io/muxstr.
This includes updating all Go imports, protobuf definitions, generated
files, and documentation.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Connect integration:
- Buf Connect codegen added to buf.gen.yaml
- Connect handler wraps gRPC server
- Serves on same port as WebSocket (:8080)
- HTTP/2 with h2c for cleartext HTTP/2
Now serving THREE protocols:
1. gRPC (native) on :50051 - binary, high performance
2. Connect on :8080/nostr.v1.NostrRelay/* - HTTP/JSON, browser compatible
3. WebSocket on :8080/ - Nostr standard protocol
All three protocols share:
- Same storage layer
- Same subscription manager
- Same validation logic
Browser-friendly! Call gRPC methods with fetch() or curl.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Storage implementation:
- Concrete type with constructor (consumer-side interfaces)
- Event storage: protobuf + zstd-compressed canonical JSON
- Schema: events, deletions, replaceable_events, auth_challenges, rate_limits
- WAL mode, STRICT typing, optimized indexes
- Methods: StoreEvent, GetEvent, GetEventWithCanonical, DeleteEvent
Dependencies:
- modernc.org/sqlite v1.45.0 (pure Go SQLite driver)
- github.com/klauspost/compress v1.18.4 (zstd compression)
366 lines, 10 tests passing
|
| |
|