30 lines
904 B
Diff
30 lines
904 B
Diff
# UNDF: UNDF-2026-000001014
|
|
--- a/p2p/security/noise/transport.go
|
|
+++ b/p2p/security/noise/transport.go
|
|
@@ -3,7 +3,6 @@ package noise
|
|
import (
|
|
"context"
|
|
"net"
|
|
- "slices"
|
|
|
|
"github.com/libp2p/go-libp2p/core/crypto"
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
@@ -88,10 +87,13 @@ func (i *transportEarlyDataHandler) Received(_ context.Context, _ net.Conn, ext
|
|
|
|
func matchMuxers(initiatorMuxers, responderMuxers []protocol.ID) protocol.ID {
|
|
- for _, initMuxer := range initiatorMuxers {
|
|
- if slices.Contains(responderMuxers, initMuxer) {
|
|
- return initMuxer
|
|
+ if len(initiatorMuxers) == 0 || len(responderMuxers) == 0 {
|
|
+ return ""
|
|
+ }
|
|
+ respSet := make(map[protocol.ID]struct{}, len(responderMuxers))
|
|
+ for _, m := range responderMuxers {
|
|
+ respSet[m] = struct{}{}
|
|
+ }
|
|
+ for _, initMuxer := range initiatorMuxers {
|
|
+ if _, ok := respSet[initMuxer]; ok {
|
|
+ return initMuxer
|
|
}
|
|
}
|
|
return ""
|