Relay does not pick the right IP addr of local node
My laptop has two network interfaces: eth0, statically configured, in use when I'm wired in my office; and ppp0, dynamically configured, when I'm abroad and use a 3G wireless interface.
When I'm on eth0 (LAN), the tor relay works regularly. When I'm on the ppp0 (3G wireless), the tor relay works too but the ORPort and DirPort are not reachable from the outside, because the relay still picks the IP address associated to eth0 (unconnected actually) instead of ppp0 (the one in real use).
This problem probably affects all releases. One year ago I raised another bug ticket on this very same defect (see #5298 (moved))
The defect originates by the following two bugs:
src/or/config.c:resolve_my_address(), a rather messy (really badly written, to be honest) piece of code which mistakenly resolves via hostname rather than picking the IP address based on the network interface actually in use. I had to rewrite that function almost from scratch, and now it works.
src/common/address.c:get_interface_address6(): here a list of all net devices available is built, but then the first valid one is picked, regardless of it being the one actually in use or not (on my laptop it always chooses eth0, even if I'm using ppp0). Solved by disabling the list of net devices, thus falling back to the default "discovery" mechanism.
I have patches, if needed.