fix: ignore ws from circuit relay addresses, and allow non multiaddresses in `multiaddrs` ENR key (#1141)

This commit is contained in:
richΛrd 2024-07-01 09:03:34 -04:00 committed by GitHub
parent 8d7c2f7bfa
commit 201d434d50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -234,18 +234,25 @@ func selectWSListenAddresses(addresses []ma.Multiaddr) ([]ma.Multiaddr, error) {
func selectCircuitRelayListenAddresses(ctx context.Context, addresses []ma.Multiaddr) ([]ma.Multiaddr, error) {
var result []ma.Multiaddr
for _, addr := range addresses {
addr, err := decapsulateCircuitRelayAddr(ctx, addr)
if err != nil {
continue
}
_, noWS := addr.ValueForProtocol(ma.P_WSS)
_, noWSS := addr.ValueForProtocol(ma.P_WS)
if noWS == nil || noWSS == nil { // WS or WSS found
continue
}
result = append(result, addr)
}
return result, nil
}
func filter0Port(addresses []ma.Multiaddr) ([]ma.Multiaddr, error) {
var result []ma.Multiaddr
for _, addr := range addresses {

View File

@ -120,7 +120,8 @@ func Multiaddress(node *enode.Node) (peer.ID, []multiaddr.Multiaddr, error) {
maRaw := multiaddrRaw[offset+2 : offset+2+int(maSize)]
addr, err := multiaddr.NewMultiaddrBytes(maRaw)
if err != nil {
return "", nil, fmt.Errorf("invalid multiaddress field length")
// The value is not a multiaddress. Ignoring...
continue
}
hostInfoStr := fmt.Sprintf("/p2p/%s", peerID.String())