mojira.dev

Simon McVittie

Assigned

No issues.

Reported

No issues.

Comments

The 1.4.5 prerelease seems to fix this in the way I suggested (part (3) only), and works for me (with two Linux machines, both upgraded). Please try again with that version.

Seems to work correctly in the 1.4.5 prerelease (Linux LAN server, Linux client). Thanks!

As I said on #MC-2549, it looks as though my suggestion (1) from https://mojang.atlassian.net/browse/MC-473?focusedCommentId=15647&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15647 has been done, but (2) and (3) have not. At least (3) is necessary to resolve this bug.

I suggested three changes in a comment on #MC-473; it appears that (1) has been done, but (2) and (3) have not.

The two remaining changes are:

2) when announcing our address to the network, if listening on 0.0.0.0, replace it with (an attempt to find) our IP address in the 'AD' packet (optional; only needed if you want to remain compatible with versions < 1.4.4)

and more importantly

3) when parsing an 'AD' packet, ignore the IP address in the packet, and replace it with the address from which the packet was received

If Minecraft was open source (or not obfuscated) I'd have given you a complete patch 🙂 but as it is, a patch relative to the de-obfuscated source in MCP is the best I can do:

http://www.pseudorandom.co.uk/~smcv/minecraft-1.3.2-lan-server-v4.diff

(I had this working correctly as a mod for 1.3.2 / MCP 7.2; I can update it to 1.4.2 / MCP 7.19 if that would be useful, just ask.)

The change in what MCP calls LanServerList.func_77551_a is the important bit. I doubt those names match what Mojang calls that class and function internally, though.

Further explanation of the changes I suggest:

1) listen on 0.0.0.0 or :: instead of specifying a particular listening address

2) when sending AD packets to the network, if they would contain 0.0.0.0, fill in something else, to be nice to unpatched versions (getLocalHost() is a reasonable fallback)

3) when receiving an AD packet from the network, ignore the IP address appearing before the ":", and use the IP address from which the packet was received (together with the port from after the ":" as usual)

According to Zorander on the wiki, this might be a problem on Mac too:

"This is actually an issue with any OS except Windows, due to the loopback interface."

Previously reported against 1.3.2 on the Minecraft wiki. Here's my more detailed report from there:

"""
On Debian, /etc/hosts usually maps the laptop's own hostname to 127.0.1.1, an alternative loopback address (e.g. "127.0.1.1 mylaptop.mydomain mylaptop" - all of 127.0.0.0/8 is loopback).

When a Minecraft-on-Debian user advertises their single-player game to the LAN, the multicast announcement comes from their LAN IP address (e.g. 192.168.0.2), but the server only listens on 127.0.1.1 and announces that address in the multicast packet, e.g. [AD]127.0.1.1:58388/AD, making other machines unable to join.
"""

(From other people's comments here, it seems other Linuxes end up with 127.0.0.1 or 127.0.0.2.)

The cause is that InetAddress.getLocalHost().getAddress() is pretty useless on Linux: it assumes that gethostname() returns a DNS name that resolves to the an address usable by other players, which isn't generally true.

Here is a patch relative to the MCP 7.2 semi-deobfuscated source, hopefully it'll be easy enough to make the corresponding change in the real Minecraft source code:

http://www.pseudorandom.co.uk/~smcv/minecraft-1.3.2-lan-server-v4.diff

Here is permission to do what you like with that patch, including incorporating it into Minecraft: copying and distribution of the patch, with or without modification, are permitted in any medium without royalty. The patch is offered as-is, without any warranty.