mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Copy IP address if possible instead of localhost
This commit is contained in:
@@ -101,7 +101,7 @@ public class NetConnectUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void copyHostedServerUrl() {
|
public static void copyHostedServerUrl() {
|
||||||
String hostname = "localhost";
|
String hostname = FServerManager.getInstance().getLocalAddress();
|
||||||
String url = hostname + ":" + ForgeProfileProperties.getServerPort();
|
String url = hostname + ":" + ForgeProfileProperties.getServerPort();
|
||||||
GuiBase.getInterface().copyToClipboard(url);
|
GuiBase.getInterface().copyToClipboard(url);
|
||||||
SOptionPane.showMessageDialog("Share the following URL with anyone who wishes to join your server. It has been copied to your clipboard for convenience.\n\n" + url, "Server URL", SOptionPane.INFORMATION_ICON);
|
SOptionPane.showMessageDialog("Share the following URL with anyone who wishes to join your server. It has been copied to your clipboard for convenience.\n\n" + url, "Server URL", SOptionPane.INFORMATION_ICON);
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import io.netty.handler.logging.LogLevel;
|
|||||||
import io.netty.handler.logging.LoggingHandler;
|
import io.netty.handler.logging.LoggingHandler;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -196,14 +195,18 @@ public final class FServerManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mapNatPort(final int port) {
|
public String getLocalAddress() {
|
||||||
final String localAddress;
|
|
||||||
try {
|
try {
|
||||||
localAddress = InetAddress.getLocalHost().getHostAddress();
|
return InetAddress.getLocalHost().getHostAddress();
|
||||||
} catch (final UnknownHostException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
|
catch (final Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "localhost";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mapNatPort(final int port) {
|
||||||
|
final String localAddress = getLocalAddress();
|
||||||
final PortMapping portMapping = new PortMapping(port, localAddress, PortMapping.Protocol.TCP, "Forge");
|
final PortMapping portMapping = new PortMapping(port, localAddress, PortMapping.Protocol.TCP, "Forge");
|
||||||
if (upnpService != null) {
|
if (upnpService != null) {
|
||||||
// Safeguard shutdown call, to prevent lingering port mappings
|
// Safeguard shutdown call, to prevent lingering port mappings
|
||||||
|
|||||||
Reference in New Issue
Block a user