Skip to content

Commit 3885e44

Browse files
authored
feat: announce dns p2p addresses (#1196)
* feat: announce dns p2p addresses * fix: code review
1 parent de4b81b commit 3885e44

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/components/P2P/index.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,24 @@ export class OceanP2P extends EventEmitter {
242242
shouldAnnounce(addr: any) {
243243
try {
244244
const maddr = multiaddr(addr)
245-
// always filter loopback
245+
246+
const protos = maddr.getComponents()
246247
const addressString = maddr.nodeAddress().address
248+
if (
249+
protos.some(
250+
(entry) =>
251+
entry.name === 'dns' ||
252+
entry.name === 'dns4' ||
253+
entry.name === 'dns6' ||
254+
entry.name === 'dnsaddr'
255+
)
256+
) {
257+
if (addressString === 'localhost' || addressString === '127.0.0.1') {
258+
return false
259+
}
260+
261+
return true
262+
}
247263

248264
if (!ipaddr.isValid(addressString)) {
249265
return false

0 commit comments

Comments
 (0)