use server ip address as default

This commit is contained in:
BetaSteward 2010-12-10 10:12:57 -05:00
parent 7aadc8ed9d
commit 681a030b8e

View file

@ -28,9 +28,11 @@
package mage.server; package mage.server;
import java.net.UnknownHostException;
import mage.server.util.PluginClassLoader; import mage.server.util.PluginClassLoader;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.net.InetAddress;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import mage.game.GameType; import mage.game.GameType;
@ -83,7 +85,16 @@ public class Main {
} }
} }
Copier.setLoader(classLoader); Copier.setLoader(classLoader);
System.setProperty("java.rmi.server.hostname", config.getServerAddress()); String ip = config.getServerAddress();
try {
if (ip.equals("localhost")) {
ip = InetAddress.getLocalHost().getHostAddress();
}
} catch (UnknownHostException ex) {
logger.log(Level.WARNING, "Could not get server address: ", ex);
}
System.setProperty("java.rmi.server.hostname", ip);
logger.info("MAGE server - using address " + ip);
server = new ServerImpl(config.getPort(), config.getServerName(), testMode); server = new ServerImpl(config.getPort(), config.getServerName(), testMode);
} }