Add error code handling

This commit is contained in:
Zoltán Papp
2025-09-25 12:46:05 +02:00
parent 4d46adbb68
commit 71733dff3e
4 changed files with 35 additions and 3 deletions
+6 -1
View File
@@ -2,6 +2,7 @@ package peer
import (
"context"
"errors"
"fmt"
"math/rand"
"net"
@@ -209,7 +210,11 @@ func (conn *Conn) Open(engineCtx context.Context) error {
// both peer send offer
if err := conn.handshaker.SendOffer(); err != nil {
conn.Log.Errorf("failed to send offer: %v", err)
conn.guard.FailedToSendOffer()
// if remote peer is offline, no need to try to reconnect.
// The remote peer when online will send an offer to us
if !errors.Is(err, ErrPeerNotAvailable) {
conn.guard.FailedToSendOffer()
}
}
conn.opened = true