1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-11 10:18:08 +09:00

close quic connection on failed handshake

This commit is contained in:
Sergey Cherepanov 2024-04-25 12:23:22 +02:00
parent 7f2b2a5194
commit b00d992a54
No known key found for this signature in database
GPG key ID: 87F8EDE8FBDF637C

View file

@ -4,18 +4,20 @@ import (
"context"
"crypto/tls"
"fmt"
"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/app/logger"
"github.com/anyproto/any-sync/net/secureservice"
"github.com/anyproto/any-sync/net/transport"
"net"
"sync"
"time"
libp2crypto "github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
libp2ptls "github.com/libp2p/go-libp2p/p2p/security/tls"
"github.com/quic-go/quic-go"
"go.uber.org/zap"
"net"
"sync"
"time"
"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/app/logger"
"github.com/anyproto/any-sync/net/secureservice"
"github.com/anyproto/any-sync/net/transport"
)
const CName = "net.transport.quic"
@ -139,6 +141,9 @@ func (q *quicTransport) Dial(ctx context.Context, addr string) (mc transport.Mul
cctx, err := q.secure.HandshakeOutbound(ctx, stream, remotePeerId.String())
if err != nil {
defer func() {
_ = qConn.CloseWithError(3, "outbound handshake failed")
}()
return nil, err
}
@ -189,6 +194,9 @@ func (q *quicTransport) accept(conn quic.Connection) (err error) {
}()
cctx, err := q.secure.HandshakeInbound(ctx, stream, remotePeerId.String())
if err != nil {
defer func() {
_ = conn.CloseWithError(3, "inbound handshake failed")
}()
return
}
mc := newConn(cctx, conn)