diff --git a/exit/exit.go b/exit/exit.go index 0591169..039e7be 100644 --- a/exit/exit.go +++ b/exit/exit.go @@ -195,7 +195,8 @@ func (e *Exit) setSubscriptions(ctx context.Context) error { // It returns an error if there is any issue with the subscription. func (e *Exit) handleSubscription(ctx context.Context, pubKey string, since nostr.Timestamp) error { incomingEventChannel := e.pool.SubMany(ctx, e.config.NostrRelays, nostr.Filters{ - {Kinds: []int{protocol.KindEphemeralEvent}, + { + Kinds: []int{protocol.KindEphemeralEvent}, Since: &since, Tags: nostr.TagMap{ "p": []string{pubKey}, diff --git a/netstr/conn.go b/netstr/conn.go index dc14ca0..9245b92 100644 --- a/netstr/conn.go +++ b/netstr/conn.go @@ -163,6 +163,9 @@ func (nc *NostrConnection) Write(b []byte) (int, error) { // Go lang func (nc *NostrConnection) handleNostrWrite(buffer []byte) (int, error) { + if nc.ctx.Err() != nil { + return 0, fmt.Errorf("context canceled: %w", nc.ctx.Err()) + } publicKey, relays, err := nc.parseDestination() if err != nil { return 0, fmt.Errorf("could not parse destination: %w", err) diff --git a/netstr/dial.go b/netstr/dial.go index 44dd96c..bee4cb6 100644 --- a/netstr/dial.go +++ b/netstr/dial.go @@ -44,7 +44,7 @@ func DialSocks(options DialOptions, config *config.EntryConfig) func(ctx context } else { publicKey, relays, err = connection.parseDestination() if err != nil { - slog.Error("error parsing host", err) + slog.Error("error parsing host", "error", err) return nil, fmt.Errorf("error parsing host: %w", err) } } diff --git a/socks5/request.go b/socks5/request.go index 5e8f3c9..7d60e65 100644 --- a/socks5/request.go +++ b/socks5/request.go @@ -3,13 +3,15 @@ package socks5 import ( "context" "fmt" - "github.com/asmogo/nws/netstr" - "github.com/asmogo/nws/protocol" - "github.com/google/uuid" "io" "net" "strconv" "strings" + "time" + + "github.com/asmogo/nws/netstr" + "github.com/asmogo/nws/protocol" + "github.com/google/uuid" ) const ( @@ -193,7 +195,7 @@ func (s *Server) handleConnect(ctx context.Context, conn net.Conn, req *Request, dial = netstr.DialSocks(options, s.config.entryConfig) } - + ctx, _ = context.WithTimeout(context.Background(), time.Second*10) target, err := dial(ctx, "tcp", req.realDestAddr.Address()) if err != nil { msg := err.Error()