From 9a0cf85ae1f5fb35255117790528d6f1a29c98fe Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Fri, 22 Sep 2023 10:45:23 -0400 Subject: [PATCH] fix: add ws to enr --- waku/v2/node/address_test.go | 6 +++--- waku/v2/node/localnode.go | 15 +++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/waku/v2/node/address_test.go b/waku/v2/node/address_test.go index 172f963d..862e2795 100644 --- a/waku/v2/node/address_test.go +++ b/waku/v2/node/address_test.go @@ -26,12 +26,12 @@ func TestExternalAddressSelection(t *testing.T) { w := &WakuNode{} extAddr, multiaddr, err := w.getENRAddresses([]ma.Multiaddr{a1, a2, a3, a4, a5, a6, a7, a8}) - a5NoP2P, _ := decapsulateP2P(a5) + a4NoP2P, _ := decapsulateP2P(a4) require.NoError(t, err) require.Equal(t, extAddr.IP, net.IPv4(192, 168, 0, 106)) require.Equal(t, extAddr.Port, 60000) - require.Equal(t, multiaddr[0].String(), a5NoP2P.String()) - require.Len(t, multiaddr, 1) // Should only have 1, without circuit relay + require.Equal(t, multiaddr[0].String(), a4NoP2P.String()) + require.Len(t, multiaddr, 4) // Should only have 4, without circuit relay a12, _ := ma.NewMultiaddr("/ip4/188.23.1.8/tcp/30303/p2p/16Uiu2HAmUVVrJo1KMw4QwUANYF7Ws4mfcRqf9xHaaGP87GbMuY2f") // VALID addrs = append(addrs, a12) diff --git a/waku/v2/node/localnode.go b/waku/v2/node/localnode.go index b9f92ead..1883881b 100644 --- a/waku/v2/node/localnode.go +++ b/waku/v2/node/localnode.go @@ -191,7 +191,7 @@ func decapsulateCircuitRelayAddr(addr ma.Multiaddr) (ma.Multiaddr, error) { return addr, nil } -func selectWSSListenAddresses(addresses []ma.Multiaddr) ([]ma.Multiaddr, error) { +func selectWSListenAddresses(addresses []ma.Multiaddr) ([]ma.Multiaddr, error) { var result []ma.Multiaddr for _, addr := range addresses { // It's a p2p-circuit address. We dont use these at this stage yet @@ -200,14 +200,9 @@ func selectWSSListenAddresses(addresses []ma.Multiaddr) ([]ma.Multiaddr, error) continue } - // Only WSS with a domain name are allowed - _, err = addr.ValueForProtocol(ma.P_DNS4) - if err != nil { - continue - } - - _, err = addr.ValueForProtocol(ma.P_WSS) - if err != nil { + _, noWS := addr.ValueForProtocol(ma.P_WSS) + _, noWSS := addr.ValueForProtocol(ma.P_WS) + if noWS != nil && noWSS != nil { // Neither WS or WSS found continue } @@ -240,7 +235,7 @@ func (w *WakuNode) getENRAddresses(addrs []ma.Multiaddr) (extAddr *net.TCPAddr, return nil, nil, err } - wssAddrs, err := selectWSSListenAddresses(addrs) + wssAddrs, err := selectWSListenAddresses(addrs) if err != nil { return nil, nil, err }