@ -32,8 +32,8 @@ import org.pmw.tinylog.policies.StartupPolicy;
@@ -32,8 +32,8 @@ import org.pmw.tinylog.policies.StartupPolicy;
import org.pmw.tinylog.writers.RollingFileWriter ;
import java.io.* ;
import java.net.DatagramSocket ;
import java.net.InetAddress ;
import java.net.URL ;
import java.nio.file.Files ;
import java.nio.file.Paths ;
import java.sql.Connection ;
@ -268,19 +268,16 @@ public class LoginServer {
@@ -268,19 +268,16 @@ public class LoginServer {
String name = ConfigManager . MB_WORLD_NAME . getValue ( ) ;
if ( ConfigManager . MB_PUBLIC _ADDR . getValue ( ) . equals ( "0.0.0.0" ) ) {
if ( ConfigManager . MB_BIND _ADDR . getValue ( ) . equals ( "0.0.0.0" ) ) {
// Autoconfigure IP address for use in worldserver response
// .
Logger . info ( "AUTOCONFIG PUBLIC IP ADDRESS" ) ;
URL whatismyip = new URL ( "http://checkip.amazonaws.com" ) ;
BufferedReader in = new BufferedReader ( new InputStreamReader (
whatismyip . openStream ( ) ) ) ;
ConfigManager . MB_PUBLIC_ADDR . setValue ( in . readLine ( ) ) ;
try ( final DatagramSocket socket = new DatagramSocket ( ) ) {
socket . connect ( InetAddress . getByName ( "8.8.8.8" ) , 10002 ) ;
ConfigManager . MB_BIND_ADDR . setValue ( socket . getLocalAddress ( ) . getHostAddress ( ) ) ;
}
Logger . info ( "Public address: " + ConfigManager . MB_PUBLIC_ADDR . getValue ( ) ) ;
Logger . info ( "Magicbane bind config: " + ConfigManager . MB_BIND_ADDR . getValue ( ) + ":" + ConfigManager . MB_LOGIN_PORT . getValue ( ) ) ;
}
Logger . info ( "Magicbane binding to: " + ConfigManager . MB_BIND_ADDR . getValue ( ) + ":" + ConfigManager . MB_LOGIN_PORT . getValue ( ) ) ;
InetAddress addy = InetAddress . getByName ( ConfigManager . MB_BIND_ADDR . getValue ( ) ) ;
int port = Integer . parseInt ( ConfigManager . MB_LOGIN_PORT . getValue ( ) ) ;