fix: add ws to enr

This commit is contained in:
Richard Ramos 2023-09-22 10:45:23 -04:00 committed by richΛrd
parent 6955d01498
commit 9a0cf85ae1
2 changed files with 8 additions and 13 deletions

View File

@ -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)

View File

@ -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
}