mirror of https://github.com/status-im/go-waku.git
fix: add ws to enr
This commit is contained in:
parent
6955d01498
commit
9a0cf85ae1
|
@ -26,12 +26,12 @@ func TestExternalAddressSelection(t *testing.T) {
|
||||||
w := &WakuNode{}
|
w := &WakuNode{}
|
||||||
extAddr, multiaddr, err := w.getENRAddresses([]ma.Multiaddr{a1, a2, a3, a4, a5, a6, a7, a8})
|
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.NoError(t, err)
|
||||||
require.Equal(t, extAddr.IP, net.IPv4(192, 168, 0, 106))
|
require.Equal(t, extAddr.IP, net.IPv4(192, 168, 0, 106))
|
||||||
require.Equal(t, extAddr.Port, 60000)
|
require.Equal(t, extAddr.Port, 60000)
|
||||||
require.Equal(t, multiaddr[0].String(), a5NoP2P.String())
|
require.Equal(t, multiaddr[0].String(), a4NoP2P.String())
|
||||||
require.Len(t, multiaddr, 1) // Should only have 1, without circuit relay
|
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
|
a12, _ := ma.NewMultiaddr("/ip4/188.23.1.8/tcp/30303/p2p/16Uiu2HAmUVVrJo1KMw4QwUANYF7Ws4mfcRqf9xHaaGP87GbMuY2f") // VALID
|
||||||
addrs = append(addrs, a12)
|
addrs = append(addrs, a12)
|
||||||
|
|
|
@ -191,7 +191,7 @@ func decapsulateCircuitRelayAddr(addr ma.Multiaddr) (ma.Multiaddr, error) {
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectWSSListenAddresses(addresses []ma.Multiaddr) ([]ma.Multiaddr, error) {
|
func selectWSListenAddresses(addresses []ma.Multiaddr) ([]ma.Multiaddr, error) {
|
||||||
var result []ma.Multiaddr
|
var result []ma.Multiaddr
|
||||||
for _, addr := range addresses {
|
for _, addr := range addresses {
|
||||||
// It's a p2p-circuit address. We dont use these at this stage yet
|
// 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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only WSS with a domain name are allowed
|
_, noWS := addr.ValueForProtocol(ma.P_WSS)
|
||||||
_, err = addr.ValueForProtocol(ma.P_DNS4)
|
_, noWSS := addr.ValueForProtocol(ma.P_WS)
|
||||||
if err != nil {
|
if noWS != nil && noWSS != nil { // Neither WS or WSS found
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = addr.ValueForProtocol(ma.P_WSS)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +235,7 @@ func (w *WakuNode) getENRAddresses(addrs []ma.Multiaddr) (extAddr *net.TCPAddr,
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
wssAddrs, err := selectWSSListenAddresses(addrs)
|
wssAddrs, err := selectWSListenAddresses(addrs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue