Skip to content

Commit

Permalink
Add support for netty based socket addresses to fabric
Browse files Browse the repository at this point in the history
Affects issues:
- Possibly fixed #3065
  • Loading branch information
AuroraLS3 committed Jun 24, 2023
1 parent 439eb60 commit 4b33026
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package net.playeranalytics.plan.gathering.domain;

import com.djrapitops.plan.gathering.domain.PlatformPlayerData;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.unix.DomainSocketAddress;
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
import net.minecraft.server.network.ServerPlayerEntity;

Expand Down Expand Up @@ -76,9 +78,11 @@ private Optional<InetAddress> getIPFromSocketAddress() {
SocketAddress socketAddress = player.networkHandler.getConnectionAddress();
if (socketAddress instanceof InetSocketAddress inetSocketAddress) {
return Optional.of(inetSocketAddress.getAddress());
} else if (socketAddress instanceof UnixDomainSocketAddress) {
} else if (socketAddress instanceof UnixDomainSocketAddress || socketAddress instanceof LocalAddress) {
// These connections come from the same physical machine
return Optional.of(InetAddress.getLocalHost());
} else if (socketAddress instanceof DomainSocketAddress domainSocketAddress) {
return Optional.of(InetAddress.getByName(domainSocketAddress.path()));
}
} catch (NoSuchMethodError | UnknownHostException e) {
// Ignored
Expand Down

0 comments on commit 4b33026

Please sign in to comment.