Commit Graph

30 Commits

Author SHA1 Message Date
287af9dc81 fix: replace break with return in error handling for ws client
- pkg/protocol/ws/client.go
  - Changed `break` to `return` to ensure proper error handling flow in `client.go`.

  this bug was causing the CPU usage to go very high from fmt.Errorf statements. changed them to errorf.E so they printed and were visible.
2025-08-18 20:15:38 +01:00
a51e86f4c4 update: reorganize imports, add URL rewriting support, and minor refactoring
- cmd/lerproxy/reverse/proxy.go
  - Reorganized imports for logical grouping.

- cmd/lerproxy/main.go
  - Added URL rewriting capability and updated command-line usage documentation.
  - Reorganized imports for consistency.
  - Replaced `context.T` with `context.Context` for standardization.
  - Updated timeout handling logic to use `context.WithTimeout`.

- pkg/protocol/ws/connection.go
  - Replaced `fmt.Errorf` with `errorf.E` for error formatting.

- cmd/lerproxy/util/util.go
  - Renamed file for better clarity.
  - Removed unnecessary package documentation.

- cmd/lerproxy/hsts/proxy.go
  - Removed redundant package comments.

- cmd/lerproxy/tcpkeepalive/listener.go
  - Removed redundant package comments.
  - Adjusted import order.

- cmd/lerproxy/buf/bufpool.go
  - Removed unnecessary package comments.

- cmd/lerproxy/README.md
  - Updated package usage examples and installation instructions.
  - Removed outdated and unnecessary instructions.
2025-08-18 20:13:14 +01:00
d11f54228b remove deprecated and unused websocket tests
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
- pkg/protocol/ws/client_test.go
  - Commented out the `TestPublishBlocked` test as it is no longer in use.

- pkg/protocol/ws/subscription_test.go
  - Commented out `TestSubscribeBasic` and `TestNestedSubscriptions` tests.

- pkg/version/version
  - Updated version from `v0.8.3` to `v0.8.4`.
2025-08-17 20:12:40 +01:00
f1e8b52519 update: import utils, remove unused logs, and bump version
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
- pkg/crypto/p256k/btcec/btcec_test.go
  - Added `orly.dev/pkg/utils` import.

- pkg/protocol/ws/client.go
  - Commented out unused logging related to filter matching.

- pkg/version/version
  - Bumped version from `v0.8.1` to `v0.8.2`.
2025-08-17 18:17:21 +01:00
fd76013c10 refactor(tests): replace bytes imports with orly.dev/pkg/utils globally
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
- pkg/crypto/ec/ecdsa/signature_test.go
  - Removed `bytes`; added `orly.dev/pkg/utils`.

- pkg/encoders/filter/filter_test.go
  - Removed `bytes`; added `orly.dev/pkg/utils`.

- pkg/database/query-for-kinds-authors-tags_test.go
  - Added `orly.dev/pkg/utils`.
  - Changed `idTsPk` type from `[]store.IdPkTs` to `[]*store.IdPkTs`.

- pkg/version/version
  - Bumped version from `v0.8.0` to `v0.8.1`.

- pkg/database/fetch-event-by-serial_test.go
  - Added `orly.dev/pkg/utils`.

- pkg/encoders/filters/filters_test.go
  - Removed `bytes`; added `orly.dev/pkg/utils`.

- pkg/database/query-for-kinds_test.go
  - Added `orly.dev/pkg/utils`.
  - Changed `idTsPk` type from `[]store.IdPkTs` to `[]*store.IdPkTs`.

- pkg/database/get-serials-by-range_test.go
  - Added `orly.dev/pkg/utils`.

- pkg/crypto/ec/base58/base58_test.go
  - Removed `bytes`; added `orly.dev/pkg/utils`.

- pkg/database/query-events-multiple-param-replaceable_test.go
  - Removed `bytes`; added `orly.dev/pkg/utils`.

... and additional test files updated to address similar import changes or type adjustments.
2025-08-17 18:04:44 +01:00
02bf704e28 add fast bytes compare and start revising QueryForIds 2025-08-17 15:24:38 +01:00
7112930f73 add SimplePool implementation for managing relay connections
- pkg/protocol/ws/pool.go
  - Added `SimplePool` struct to manage connections to multiple relays.
  - Introduced associated methods for relay connection, publishing, and subscribing.
  - Added middleware support for events, duplicates, and queries.
  - Implemented penalty box for managing failed relay connections.
  - Provided various options for customizing behavior (e.g. relays, authentication, event handling).

- pkg/protocol/ws/subscription.go
  - Removed unnecessary `ReplaceableKey` struct.
  - Cleaned up redundant spaces and comments in subscription methods.
2025-08-17 11:40:41 +01:00
0187114918 fixed websocket client bugs 2025-08-17 09:48:01 +01:00
9832a8b28a refactor: cache event ID string conversion in OK handler 2025-08-16 22:23:44 -04:00
dda39de5a5 refactor logging to use closures for intensive tasks
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
2025-08-15 22:27:16 +01:00
bb8f070992 Add subscription feature and optimize logging
- pkg/protocol/ws/client.go
  - Added logging for received subscription events.
  - Optimized subscription ID assignment.

- pkg/protocol/nwc/client.go
  - Implemented `Subscribe` function to handle event subscriptions.

- cmd/walletcli/main.go
  - Added support for `subscribe` command to handle notifications.
  - Replaced `ctx` with `c` for context usage across all commands.

- pkg/crypto/p256k/helpers.go
  - Removed unnecessary logging from `HexToBin` function.
2025-08-08 13:22:36 +01:00
1535f10343 Add release process and bump version to v0.5.7
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
- .github/workflows/go.yml
  - Added a new `release` job with steps to set up Go, install `libsecp256k1`, and build release binaries.

- pkg/version/version
  - Updated version from v0.5.6 to v0.5.7.

- pkg/protocol/ws/pool_test.go
  - Commented out the `TestPoolContextCancellation` test function.
2025-08-08 09:37:28 +01:00
423270402b Comment out nested subscription test in subscription_test.go
- pkg/protocol/ws/subscription_test.go
  - Commented out the `TestNestedSubscriptions` test function.
  - Removed unused imports from the file.
2025-08-08 08:53:18 +01:00
b351d0fb78 fix bugs in tag comparison code
nwc walletcli now works!

bumped to v0.5.0 because NWC client now in and available
2025-08-07 09:32:53 +01:00
9c8ff2976d backporting relay client and pool from latest go-nostr 2025-08-06 22:18:26 +01:00
b74f4757e7 refactor: Simplify NWC protocol structures and update method handling
- cmd/lerproxy/app/bufpool.go
  - Removed bufferPool-related code and `Pool` struct

- cmd/nwcclient/main.go
  - Renamed `Method` to `Capability` for clarity in method handling

- pkg/utils/values/values.go
  - Added utility functions to return pointers for various types

- pkg/utils/pointers/pointers.go
  - Revised documentation to reference `utils/values` package for pointer utilities

- pkg/protocol/nwc/types.go
  - Replaced redundant types and structures with simplified versions
  - Introduced dedicated structs for `MakeInvoice`, `PayInvoice`, and related results
  - Refactored `Transaction` and its fields for consistent type usage

- pkg/protocol/nwc/uri.go
  - Added `ParseConnectionURI` function for URI parsing and validation

- pkg/protocol/nwc/client.go
  - Refactored `Client` struct to improve key management and relay handling
  - Introduced `Request` struct for generic method invocation payloads
2025-08-05 20:18:32 +01:00
1ffb7afb01 implement first draft of nwc client and cli 2025-08-04 14:54:15 +01:00
1223b1b20e implement nwc based on translation from js-sdk, refactor encryption to use bytes 2025-08-03 11:20:02 +01:00
0d7943be89 fixed bug with client message buffer causing overwriting of tag slices 2025-07-27 11:46:04 +01:00
c608e1075b Remove authed flag and use authed pubkey instead
- pkg/protocol/ws/listener.go
  - Removed `isAuthed` field from Listener struct
  - Modified `IsAuthed()` method to check if `authedPubkey` is non-empty
  - Removed `SetAuthed()` method
- pkg/encoders/event/readwriter.go
  - Created new file with implementation of `MarshalWrite` and `UnmarshalRead` methods for event encoding/decoding
- pkg/protocol/openapi/events.go
  - Created new file with implementation of the Events HTTP API method
- pkg/protocol/socketapi/handleReq.go
  - Modified logging to display authed pubkey
  - Updated comment regarding authentication status
- pkg/encoders/bytesbuf/pool.go
  - Created new package for concurrent-safe buffer pool
- pkg/protocol/openapi/event.go
  - Removed import of `lol` package
  - Removed tracing logic around `RegisterEvent` function
- pkg/encoders/bytesbuf/pool_test.go
  - Created new test file for buffer pool implementation
2025-07-25 13:36:49 +01:00
6901950059 Implement authentication handling in socket API event processing
- pkg/protocol/socketapi/handleAuth.go
  - Added comment block for handling pending events (currently commented out)
- pkg/protocol/ws/listener.go
  - Added import of "orly.dev/pkg/encoders/event"
  - Added `pendingEvent` field to Listener struct
  - Added `SetPendingEvent` and `GetPendingEvent` methods
- pkg/protocol/socketapi/socketapi.go
  - Added import of "orly.dev/pkg/encoders/envelopes/authenvelope"
  - Added authentication challenge logic including logging, RequestAuth call, and envelope writing
- pkg/protocol/socketapi/handleReq.go
  - Removed import of "orly.dev/pkg/encoders/envelopes/okenvelope"
  - Modified auth handling logic to send closed envelope with reason if auth is required and client is not authenticated
- pkg/protocol/socketapi/handleEvent.go
  - Removed import of "orly.dev/pkg/encoders/reason"
  - Added authentication challenge logic including logging, RequestAuth call, Ok.AuthRequired method, and envelope writing
- pkg/version/version
  - Bumped version from v0.2.17 to v0.2.18
2025-07-24 00:36:46 +01:00
bfa38822e0 add event to openapi, properly implement relay accept event policy and auth with owners set 2025-07-23 23:10:39 +01:00
eac5e05e77 Add noVerify flag to SaveEvent to prevent duplicate events and enhance test reliability
- pkg/database/save-event.go
  - Added `noVerify` parameter to `SaveEvent` function
  - Added check for existing event using `GetSerialById` when `noVerify` is false
  - Modified logic to handle event verification based on `noVerify` flag
- pkg/app/relay/server-publish.go
  - Added `false` as third argument to `SaveEvent` calls
- pkg/database/export_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/database/query-for-tags_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/database/query-for-kinds-authors_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/database/query-for-kinds-tags_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/database/query-for-serials_test.go
  - Added `false` as third argument to `SaveEvent` call
- main.go
  - Modified pprof handling to support different profiling types (cpu, memory, allocation)
  - Changed `Pprof` configuration from boolean to string with enum values
- pkg/app/config/config.go
  - Changed `Pprof` field type from `bool` to `string` with enum values
- pkg/database/query-for-kinds-authors-tags_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/version/version
  - Bumped version from v0.2.12 to v0.2.13
- pkg/database/fetch-event-by-serial_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/database/query-for-kinds_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/database/get-serials-by-range_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/database/query-events-multiple-param-replaceable_test.go
  - Added `false` as third argument to `SaveEvent` calls
- pkg/database/query-events_test.go
  - Added `false` as third argument to `SaveEvent` calls
- pkg/interfaces/store/store_interface.go
  - Updated `Saver` interface to include `noVerify` parameter in `SaveEvent` method
  - Added `SerialByIder` interface with `GetSerialById` method
- pkg/database/save-event_test.go
  - Added `false` as third argument to `SaveEvent` calls
  - Added new test case for saving existing event
- pkg/database/query-for-ids_test.go
  - Added `false` as third argument to `SaveEvent` call
- pkg/protocol/ws/client.go
  - Changed comment about context cancellation from "context is canceled" to "context is cancelled"
- pkg/app/relay/spider-fetch.go
  - Added signature checker for WebSocket connections
  - Modified logic to check for existing events before saving
  - Added logging and memory optimization improvements
2025-07-23 13:51:02 +01:00
651791aec1 Add export functionality and fix privilege checks
- Added `Export` method in `database/database.go` to export events to an io.Writer
- Implemented detailed logic for exporting all or specific pubkeys' events
- Removed placeholder `Export` function with TODO comment from `database/database.go`
- Updated error handling in `handleReq.go` and `publisher.go` by using `err != nil` instead of `chk.E(err)`
- Added more detailed logging in privilege check conditions in both `publisher.go` and `handleReq.go`
- Introduced new imports such as `"fmt"` in `connection.go` for improved error message formatting
- Created a new file `export.go` under the `database` package with complete implementation of export functionality
2025-07-22 11:34:57 +01:00
4bbbbb1bb6 Add DMRelaysList.K to kind.go and improve error messages with remote address in connection.go
- Added `DMRelaysList.K` constant to `pkg/encoders/kind/kind.go`
- Removed unused `"errors"` import from `pkg/protocol/ws/connection.go`
- Updated error messages in `WriteMessage`, `ReadMessage`, and related functions in `pkg/protocol/ws/connection.go` to include the remote address for better debugging
- Changed error handling from `chk.E(err)` to `chk.T(err)` in `pkg/encoders/envelopes/eventenvelope/eventenvelope.go`
- Updated ticker interval from 30 minutes to 1 hour in `pkg/app/relay/server.go`
2025-07-20 22:03:30 +01:00
56ab6eaa81 Remove redundant logging statements
- Removed log statement in `pkg/app/relay/spider-fetch.go` for batch processing
- Removed log level output in `main.go`
- Removed configuration logging in `pkg/app/config/config.go`
- Removed unused log import in `pkg/protocol/ws/subscription.go`
- Removed connection success log in `pkg/protocol/ws/client.go`
- Added early return condition for non-follow-list kind in `spider-fetch.go`
2025-07-20 21:52:04 +01:00
e3c931fcf9 Make spider fetch concurrent with mutex and waitgroup
- Added goroutines and sync primitives to handle concurrent relay connections in spider-fetch.go
- Added connection logging to client.go
2025-07-20 21:42:35 +01:00
65e1dd6183 fully implemented spider to fetch follows of owners, their follows, and the owner mute list 2025-07-20 09:42:06 +01:00
0e83a56025 completed first level of owners followed pubkeys 2025-07-19 19:37:30 +01:00
fc68bcf3cb moved everything into pkg/ 2025-07-17 13:18:55 +01:00