Skip to content

Commit

Permalink
close connection on dial error
Browse files Browse the repository at this point in the history
  • Loading branch information
asmogo committed Aug 27, 2024
1 parent 2f9dbca commit 701113a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/nws/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NOSTR_RELAYS = 'wss://localhost:7777'#NOSTR_RELAYS = 'ws://localhost:6666'
NOSTR_RELAYS = 'ws://0.0.0.0:7777'#NOSTR_RELAYS = 'ws://localhost:6666'
NOSTR_PRIVATE_KEY = ""
BACKEND_HOST = 'localhost:3338'
PUBLIC = true
Expand Down
5 changes: 4 additions & 1 deletion exit/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ func (e *Exit) processMessage(ctx context.Context, msg nostr.IncomingEvent) {
func (e *Exit) handleConnect(
ctx context.Context,
msg nostr.IncomingEvent,
protocolMessage *protocol.Message) {
protocolMessage *protocol.Message,
) {
e.mutexMap.Lock(protocolMessage.Key.String())
defer e.mutexMap.Unlock(protocolMessage.Key.String())
receiver, err := nip19.EncodeProfile(msg.PubKey, []string{msg.Relay.String()})
Expand All @@ -288,6 +289,7 @@ func (e *Exit) handleConnect(
dst, err = net.Dial("tcp", protocolMessage.Destination)
if err != nil {
slog.Error("could not connect to backend", "error", err)
connection.Close()
return
}

Expand Down Expand Up @@ -324,6 +326,7 @@ func (e *Exit) handleConnectReverse(protocolMessage *protocol.Message) {
dst, err = net.Dial("tcp", protocolMessage.Destination)
if err != nil {
slog.Error("could not connect to backend", "error", err)
connection.Close()
return
}
slog.Info("connected to entry", "key", protocolMessage.Key)
Expand Down

0 comments on commit 701113a

Please sign in to comment.