waku-web-chat/patches/waku-hack-identify-peer-pro...

34 lines
1.5 KiB
Diff

--- node_modules/libp2p/src/identify/index.js 1985-10-26 16:15:00.000000000 +0800
+++ patches/waku-hack-libp2p-identify-index.js 2020-09-19 14:23:03.511349910 +0800
@@ -174,6 +174,8 @@
const id = await PeerId.createFromPubKey(publicKey)
+
+ log('identifier signed', signedPeerRecord)
if (connection.remotePeer.toB58String() !== id.toB58String()) {
throw errCode(new Error('identified peer does not match the expected peer'), codes.ERR_INVALID_PEER)
}
@@ -182,11 +184,16 @@
observedAddr = IdentifyService.getCleanMultiaddr(observedAddr)
try {
- const envelope = await Envelope.openAndCertify(signedPeerRecord, PeerRecord.DOMAIN)
- if (this.peerStore.addressBook.consumePeerRecord(envelope)) {
- this.peerStore.protoBook.set(id, protocols)
- return
- }
+ // HACK: Using hardcoded waku relay codec and no signing
+ log("WARNING: Using hacky hardcoded waku relay codec and no signing")
+ const codec = "/vac/waku/relay/2.0.0-beta1"
+ this.peerStore.protoBook.set(id, [codec])
+ // TODO: Fix this for nim-waku interop, currently this fails
+ // const envelope = await Envelope.openAndCertify(signedPeerRecord, PeerRecord.DOMAIN)
+ // if (this.peerStore.addressBook.consumePeerRecord(envelope)) {
+ // this.peerStore.protoBook.set(id, protocols)
+ // return
+ //}
} catch (err) {
log('received invalid envelope, discard it and fallback to listenAddrs is available', err)
}