Skip to content

Loopback addresses published by mDNS lead to dial failures #5995

Open
@MatthiasvB

Description

@MatthiasvB

Summary

For simplicity, I like to have my nodes listen on all network interfaces. Also, I'm building a local file sharing app that relies on mDNS and request_response.

request_response automatically initiates dialling, without any intervention from the user's side (possible, afaik)

Since mDNS wildly publishes all listening addresses on all interfaces as already mentioned here, there are loopback addresses among the dialing candidates that request_response ends up using.

This means that the node ends up dialing itself.

It does not ignore contacting itself silently, instead, the entire dial fails with a libp2p::swarm::DialError::WrongPeerId

In order to make my node work nonetheless I had to fork the repository and add this hotfix

I see it as non-negotiable that mDNS should, on each interface, only broadcast its listening address on that interface to avoid bugs like this.

As a side note, finding the cause of this has been an ordeal. I'm trying to make this work on Android (and weirdly I encounter this issue only there), and changing the log level and inspecting the logs is not very straightforward there. I added up modifying the libp2p code to add print statements and had to discover that the very very useless request_response::OutboundFailure::DialFailure could easily be enhanced by wrapping the aforementioned libp2p::swarm::DialError here.

Error handling via trace-logging should not be a thing, particularly in Rust

Expected behavior

mDNS should only publish addresses that make sense

Actual behavior

it publishes all addresses on all interfaces

Relevant log output

Possible Solution

No response

Version

0.55.1

Would you like to work on fixing this bug?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions