Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 17.78 KB | None | 0 0
  1. public class GameServerThread extends Thread
  2. {
  3.     private static final Logger _log = LogManager.getLogger(GameServerThread.class.getName());
  4.  
  5.     private Socket _connection;
  6.     private InputStream _in;
  7.     private OutputStream _out;
  8.     private RSAPublicKey _publicKey;
  9.     private RSAPrivateKey _privateKey;
  10.     private NewCrypt _blowfish;
  11.     private byte[] _blowfishKey;
  12.  
  13.     private String _connectionIp;
  14.  
  15.     private GameServerInfo _gsi;
  16.  
  17.     /** Authed Clients on a GameServer */
  18.     private Set<String> _accountsOnGameServer = new FastSet<String>();
  19.  
  20.     private String _connectionIPAddress;
  21.  
  22.     @Override
  23.     public void run()
  24.     {
  25.         boolean checkTime = true;
  26.         long time = System.currentTimeMillis();
  27.         _connectionIPAddress = _connection.getInetAddress().getHostAddress();
  28.  
  29.         if(GameServerThread.isBannedGameserverIP(_connectionIPAddress))
  30.         {
  31.             _log.info("IP Address " + _connectionIPAddress + " is on banned IP(s) list");
  32.             forceClose(LoginServerFail.REASON_IP_BANNED);
  33.             // ensure no further processing for this connection
  34.             return;
  35.         }
  36.  
  37.         InitLS startPacket = new InitLS(_publicKey.getModulus().toByteArray());
  38.         try
  39.         {
  40.             sendPacket(startPacket);
  41.  
  42.             int lengthHi = 0;
  43.             int lengthLo = 0;
  44.             int length = 0;
  45.             boolean checksumOk = false;
  46.  
  47.             while(true)
  48.             {
  49.                 if(time - System.currentTimeMillis() > 10000 && checkTime)
  50.                 {
  51.                     _connection.close();
  52.                     break;
  53.                 }
  54.                 try
  55.                 {
  56.                     lengthLo = _in.read();
  57.                     lengthHi = _in.read();
  58.                     length = lengthHi * 256 + lengthLo;
  59.                 }
  60.                 catch(IOException e)
  61.                 {
  62.                     lengthHi = -1;
  63.                     /*
  64.                     String serverName = getServerId() != -1 ? "[" + getServerId() + "] " + GameServerTable.getInstance().getServerNameById(getServerId()) : "(" + _connectionIPAddress + ")";
  65.                     String msg = "GameServer " + serverName + ": Connection lost: " + e.getMessage();
  66.                     _log.info(msg);
  67.                     serverName = null;
  68.                     msg = null;
  69.                     */
  70.                 }
  71.  
  72.                 if(lengthHi < 0 || _connection.isClosed())
  73.                 {
  74.                     if(Config.DEBUG)
  75.                         _log.debug("Login terminated the connection");
  76.                     break;
  77.                 }
  78.  
  79.                 byte[] data = new byte[length - 2];
  80.  
  81.                 int receivedBytes = 0;
  82.                 int newBytes = 0;
  83.  
  84.                 while(newBytes != -1 && receivedBytes < length - 2)
  85.                 {
  86.                     newBytes = _in.read(data, 0, length - 2);
  87.                     receivedBytes = receivedBytes + newBytes;
  88.                 }
  89.  
  90.                 if(receivedBytes != length - 2)
  91.                 {
  92.                     _log.warn("Incomplete Packet is sent to the server, closing connection ...");
  93.                     break;
  94.                 }
  95.  
  96.                 // decrypt if we have a key
  97.                 data = _blowfish.decrypt(data);
  98.                 checksumOk = NewCrypt.verifyChecksum(data);
  99.  
  100.                 if(!checksumOk)
  101.                 {
  102.                     _log.warn("Incorrect packet checksum, closing connection ...");
  103.                     return;
  104.                 }
  105.  
  106.                 if(Config.DEBUG){
  107.                     _log.warn("[C]\n" + Util.printData(data));
  108.                 }
  109.  
  110.                 int packetType = data[0] & 0xff;
  111.                 switch(packetType)
  112.                 {
  113.                     case 00:
  114.                         checkTime = false;
  115.                         onReceiveBlowfishKey(data);
  116.                         break;
  117.                     case 01:
  118.                         onGameServerAuth(data);
  119.                         break;
  120.                     case 02:
  121.                         onReceivePlayerInGame(data);
  122.                         break;
  123.                     case 03:
  124.                         onReceivePlayerLogOut(data);
  125.                         break;
  126.                     case 04:
  127.                         onReceiveChangeAccessLevel(data);
  128.                         break;
  129.                     case 05:
  130.                         onReceivePlayerAuthRequest(data);
  131.                         break;
  132.                     case 06:
  133.                         onReceiveServerStatus(data);
  134.                         break;
  135.                     case 0x1F:
  136.                         new ChangePassword(data);
  137.                         break;
  138.                     default:
  139.                         _log.warn("Unknown Opcode (" + Integer.toHexString(packetType).toUpperCase() + ") from GameServer, closing connection ...");
  140.                         forceClose(LoginServerFail.NOT_AUTHED);
  141.                 }
  142.             }
  143.         }
  144.         catch(IOException e)
  145.         {
  146.             if(Config.ENABLE_ALL_EXCEPTIONS)
  147.                 e.printStackTrace();
  148.  
  149.             String serverName = getServerId() != -1 ? "[" + getServerId() + "] " + GameServerTable.getInstance().getServerNameById(getServerId()) : "(" + _connectionIPAddress + ")";
  150.             String msg = "GameServer " + serverName + ": Connection lost: " + e.getMessage();
  151.             _log.info(msg);
  152.             serverName = null;
  153.             msg = null;
  154.         }
  155.         finally
  156.         {
  157.             if(isAuthed())
  158.             {
  159.                 _gsi.setDown();
  160.                 _log.info("Server [" + getServerId() + "] " + GameServerTable.getInstance().getServerNameById(getServerId()) + " is now set as disconnected");
  161.             }
  162.  
  163.             L2LoginServer.getInstance().getGameServerListener().removeGameServer(this);
  164.             L2LoginServer.getInstance().getGameServerListener().removeFloodProtection(_connectionIp);
  165.         }
  166.  
  167.         startPacket = null;
  168.     }
  169.  
  170.     private void onReceiveBlowfishKey(byte[] data)
  171.     {
  172.         /*if (_blowfish == null)
  173.         {*/
  174.         BlowFishKey bfk = new BlowFishKey(data, _privateKey);
  175.         _blowfishKey = bfk.getKey();
  176.         _blowfish = new NewCrypt(_blowfishKey);
  177.  
  178.         if(Config.DEBUG){
  179.             _log.debug("New BlowFish key received, Blowfih Engine initialized: ");
  180.         }
  181.         /*}
  182.         else
  183.         {
  184.             _log.warn("GameServer attempted to re-initialize the blowfish key.");
  185.             // TODO get a better reason
  186.             this.forceClose(LoginServerFail.NOT_AUTHED);
  187.         }*/
  188.  
  189.         bfk = null;
  190.     }
  191.  
  192.     private void onGameServerAuth(byte[] data) throws IOException
  193.     {
  194.         GameServerAuth gsa = new GameServerAuth(data);
  195.  
  196.         if(Config.DEBUG){
  197.             _log.debug("Auth request received");
  198.         }
  199.  
  200.         handleRegProcess(gsa);
  201.  
  202.         if(isAuthed())
  203.         {
  204.             AuthResponse ar = new AuthResponse(getGameServerInfo().getId());
  205.             sendPacket(ar);
  206.  
  207.             if(Config.DEBUG){
  208.                 _log.debug("Authed id: " + getGameServerInfo().getId());
  209.             }
  210.             ar = null;
  211.         }
  212.  
  213.         gsa = null;
  214.     }
  215.  
  216.     private void onReceivePlayerInGame(byte[] data)
  217.     {
  218.         if(isAuthed())
  219.         {
  220.             PlayerInGame pig = new PlayerInGame(data);
  221.             List<String> newAccounts = pig.getAccounts();
  222.  
  223.             for(String account : newAccounts)
  224.             {
  225.                 _accountsOnGameServer.add(account);
  226.  
  227.                 if(Config.DEBUG){
  228.                     _log.debug("Account " + account + " logged in GameServer: [" + getServerId() + "] " + GameServerTable.getInstance().getServerNameById(getServerId()));
  229.                 }
  230.             }
  231.  
  232.             pig = null;
  233.             newAccounts = null;
  234.         }
  235.         else{
  236.             forceClose(LoginServerFail.NOT_AUTHED);
  237.         }
  238.     }
  239.  
  240.     private void onReceivePlayerLogOut(byte[] data)
  241.     {
  242.         if(isAuthed())
  243.         {
  244.             PlayerLogout plo = new PlayerLogout(data);
  245.             _accountsOnGameServer.remove(plo.getAccount());
  246.  
  247.             if(Config.DEBUG){
  248.                 _log.debug("Player " + plo.getAccount() + " logged out from GameServer [" + getServerId() + "] " + GameServerTable.getInstance().getServerNameById(getServerId()));
  249.             }
  250.             plo = null;
  251.         }
  252.         else{
  253.             forceClose(LoginServerFail.NOT_AUTHED);
  254.         }
  255.     }
  256.  
  257.     private void onReceiveChangeAccessLevel(byte[] data)
  258.     {
  259.         if(isAuthed())
  260.         {
  261.             ChangeAccessLevel cal = new ChangeAccessLevel(data);
  262.             LoginController.getInstance().setAccountAccessLevel(cal.getAccount(), cal.getLevel());
  263.             cal = null;
  264.         }
  265.         else{
  266.             forceClose(LoginServerFail.NOT_AUTHED);
  267.         }
  268.     }
  269.  
  270.     private void onReceivePlayerAuthRequest(byte[] data) throws IOException
  271.     {
  272.         if(isAuthed())
  273.         {
  274.             PlayerAuthRequest par = new PlayerAuthRequest(data);
  275.             PlayerAuthResponse authResponse;
  276.  
  277.             if(Config.DEBUG){
  278.                 _log.debug("Auth request received for Player `" + par.getAccount() + "`");
  279.             }
  280.  
  281.             SessionKey key = LoginController.getInstance().getKeyForAccount(par.getAccount());
  282.  
  283.             if(key != null && key.equals(par.getKey()))
  284.             {
  285.                 if(Config.DEBUG){
  286.                     _log.debug("Auth request: OK");
  287.                 }
  288.  
  289.                 LoginController.getInstance().removeAuthedLoginClient(par.getAccount());
  290.                 authResponse = new PlayerAuthResponse(par.getAccount(), true);
  291.             }
  292.             else
  293.             {
  294.                 if(Config.DEBUG)
  295.                 {
  296.                     _log.debug("Auth request: NO");
  297.                     _log.debug("Session key from self: " + key);
  298.                     _log.debug("Session key sent: " + par.getKey());
  299.                 }
  300.                 authResponse = new PlayerAuthResponse(par.getAccount(), false);
  301.             }
  302.             sendPacket(authResponse);
  303.  
  304.             par = null;
  305.             authResponse = null;
  306.             key = null;
  307.         }
  308.         else
  309.         {
  310.             forceClose(LoginServerFail.NOT_AUTHED);
  311.         }
  312.     }
  313.  
  314.     private void onReceiveServerStatus(byte[] data)
  315.     {
  316.         if(isAuthed())
  317.         {
  318.             if(Config.DEBUG){
  319.                 _log.debug("ServerStatus received");
  320.             }
  321.             /*ServerStatus ss = */new ServerStatus(data, getServerId()); //server status
  322.         }
  323.         else{
  324.             forceClose(LoginServerFail.NOT_AUTHED);
  325.         }
  326.     }
  327.  
  328.     private void handleRegProcess(GameServerAuth gameServerAuth)
  329.     {
  330.         GameServerTable gameServerTable = GameServerTable.getInstance();
  331.  
  332.         int id = gameServerAuth.getDesiredID();
  333.         byte[] hexId = gameServerAuth.getHexID();
  334.  
  335.         GameServerInfo gsi = gameServerTable.getRegisteredGameServerById(id);
  336.         // is there a gameserver registered with this id?
  337.         if(gsi != null)
  338.         {
  339.             // does the hex id match?
  340.             if(Arrays.equals(gsi.getHexId(), hexId))
  341.             {
  342.                 // check to see if this GS is already connected
  343.                 synchronized(gsi)
  344.                 {
  345.                     if(gsi.isAuthed()){
  346.                         forceClose(LoginServerFail.REASON_ALREADY_LOGGED8IN);
  347.                     }else{
  348.                         attachGameServerInfo(gsi, gameServerAuth);
  349.                     }
  350.                 }
  351.             }
  352.             else
  353.             {
  354.                 // there is already a server registered with the desired id and different hex id
  355.                 // try to register this one with an alternative id
  356.                 if(Config.ACCEPT_NEW_GAMESERVER && gameServerAuth.acceptAlternateID())
  357.                 {
  358.                     gsi = new GameServerInfo(id, hexId, this);
  359.  
  360.                     if(gameServerTable.registerWithFirstAvaliableId(gsi))
  361.                     {
  362.                         attachGameServerInfo(gsi, gameServerAuth);
  363.                         gameServerTable.registerServerOnDB(gsi);
  364.                     }
  365.                     else
  366.                     {
  367.                         forceClose(LoginServerFail.REASON_NO_FREE_ID);
  368.                     }
  369.                 }
  370.                 else
  371.                 {
  372.                     // server id is already taken, and we cant get a new one for you
  373.                     forceClose(LoginServerFail.REASON_WRONG_HEXID);
  374.                 }
  375.             }
  376.         }
  377.         else
  378.         {
  379.             // can we register on this id?
  380.             if(Config.ACCEPT_NEW_GAMESERVER)
  381.             {
  382.                 gsi = new GameServerInfo(id, hexId, this);
  383.  
  384.                 if(gameServerTable.register(id, gsi))
  385.                 {
  386.                     attachGameServerInfo(gsi, gameServerAuth);
  387.                     gameServerTable.registerServerOnDB(gsi);
  388.                 }
  389.                 else
  390.                 {
  391.                     // some one took this ID meanwhile
  392.                     forceClose(LoginServerFail.REASON_ID_RESERVED);
  393.                 }
  394.             }
  395.             else
  396.             {
  397.                 forceClose(LoginServerFail.REASON_WRONG_HEXID);
  398.             }
  399.         }
  400.  
  401.         gameServerTable = null;
  402.         gsi = null;
  403.     }
  404.  
  405.     public boolean hasAccountOnGameServer(String account)
  406.     {
  407.         return _accountsOnGameServer.contains(account);
  408.     }
  409.  
  410.     public int getPlayerCount()
  411.     {
  412.         return _accountsOnGameServer.size();
  413.     }
  414.  
  415.     /**
  416.      * Attachs a GameServerInfo to this Thread <li>Updates the GameServerInfo values based on GameServerAuth packet</li>
  417.      * <li><b>Sets the GameServerInfo as Authed</b></li>
  418.      *
  419.      * @param gsi The GameServerInfo to be attached.
  420.      * @param gameServerAuth The server info.
  421.      */
  422.     private void attachGameServerInfo(GameServerInfo gsi, GameServerAuth gameServerAuth)
  423.     {
  424.         setGameServerInfo(gsi);
  425.         gsi.setGameServerThread(this);
  426.         gsi.setPort(gameServerAuth.getPort());
  427.         setGameHosts(gameServerAuth.getExternalHost(), gameServerAuth.getInternalHost());
  428.         gsi.setMaxPlayers(gameServerAuth.getMaxPlayers());
  429.         gsi.setAuthed(true);
  430.     }
  431.  
  432.     private void forceClose(int reason)
  433.     {
  434.         LoginServerFail lsf = new LoginServerFail(reason);
  435.  
  436.         try{
  437.             sendPacket(lsf);
  438.         }
  439.         catch(IOException e)
  440.         {
  441.             if(Config.ENABLE_ALL_EXCEPTIONS)
  442.                 e.printStackTrace();
  443.             _log.warn("Failed kicking banned server. Reason: " + e.getMessage());
  444.         }
  445.  
  446.         try{
  447.             _connection.close();
  448.         }
  449.         catch(IOException e)
  450.         {
  451.             if(Config.ENABLE_ALL_EXCEPTIONS)
  452.                 e.printStackTrace();
  453.             _log.warn("Failed disconnecting banned server, server already disconnected.");
  454.         }
  455.  
  456.         lsf = null;
  457.     }
  458.  
  459.     /*
  460.     private void handleRegisterationProcess(GameServerAuth gameServerauth)
  461.     {
  462.         try
  463.         {
  464.             GameServerTable gsTableInstance = GameServerTable.getInstance();
  465.             if (gsTableInstance.isARegisteredServer(gameServerauth.getHexID()))
  466.             {
  467.                 if (Config.DEBUG)
  468.                 {
  469.                     _log.info("Valid HexID");
  470.                 }
  471.                 _server_id = gsTableInstance.getServerIDforHex(gameServerauth.getHexID());
  472.                 if (gsTableInstance.isServerAuthed(_server_id))
  473.                 {
  474.                     LoginServerFail lsf = new LoginServerFail(LoginServerFail.REASON_ALREADY_LOGGED8IN);
  475.                     sendPacket(lsf);
  476.                     _connection.close();
  477.                     return;
  478.                 }
  479.                 _gamePort = gameServerauth.getPort();
  480.                 setGameHosts(gameServerauth.getExternalHost(), gameServerauth.getInternalHost());
  481.                 _max_players = gameServerauth.getMaxPlayers();
  482.                 _hexID = gameServerauth.getHexID();
  483.                 //gsTableInstance.addServer(this);
  484.             }
  485.             else if (Config.ACCEPT_NEW_GAMESERVER)
  486.             {
  487.                 if (Config.DEBUG)
  488.                 {
  489.                     _log.info("New HexID");
  490.                 }
  491.                 if(!gameServerauth.acceptAlternateID())
  492.                 {
  493.                     if(gsTableInstance.isIDfree(gameServerauth.getDesiredID()))
  494.                     {
  495.                         if (Config.DEBUG)_log.info("Desired ID is Valid");
  496.                         _server_id = gameServerauth.getDesiredID();
  497.                         _gamePort = gameServerauth.getPort();
  498.                         setGameHosts(gameServerauth.getExternalHost(), gameServerauth.getInternalHost());
  499.                         _max_players = gameServerauth.getMaxPlayers();
  500.                         _hexID = gameServerauth.getHexID();
  501.                         gsTableInstance.createServer(this);
  502.                         //gsTableInstance.addServer(this);
  503.                     }
  504.                     else
  505.                     {
  506.                         LoginServerFail lsf = new LoginServerFail(LoginServerFail.REASON_ID_RESERVED);
  507.                         sendPacket(lsf);
  508.                         _connection.close();
  509.                         return;
  510.                     }
  511.                 }
  512.                 else
  513.                 {
  514.                     int id;
  515.                     if(!gsTableInstance.isIDfree(gameServerauth.getDesiredID()))
  516.                     {
  517.                         id = gsTableInstance.findFreeID();
  518.                         if (Config.DEBUG)_log.info("Affected New ID:"+id);
  519.                         if(id < 0)
  520.                         {
  521.                             LoginServerFail lsf = new LoginServerFail(LoginServerFail.REASON_NO_FREE_ID);
  522.                             sendPacket(lsf);
  523.                             _connection.close();
  524.                             return;
  525.                         }
  526.                     }
  527.                     else
  528.                     {
  529.                         id = gameServerauth.getDesiredID();
  530.                         if (Config.DEBUG)_log.info("Desired ID is Valid");
  531.                     }
  532.                     _server_id = id;
  533.                     _gamePort = gameServerauth.getPort();
  534.                     setGameHosts(gameServerauth.getExternalHost(), gameServerauth.getInternalHost());
  535.                     _max_players = gameServerauth.getMaxPlayers();
  536.                     _hexID = gameServerauth.getHexID();
  537.                     gsTableInstance.createServer(this);
  538.                     //gsTableInstance.addServer(this);
  539.                 }
  540.             }
  541.             else
  542.             {
  543.                 _log.info("Wrong HexID");
  544.                 LoginServerFail lsf = new LoginServerFail(LoginServerFail.REASON_WRONG_HEXID);
  545.                 sendPacket(lsf);
  546.                 _connection.close();
  547.                 return;
  548.             }
  549.  
  550.         }
  551.         catch (IOException e)
  552.         {
  553.             _log.info("Error while registering GameServer "+GameServerTable.getInstance().serverNames.get(_server_id)+" (ID:"+_server_id+")");
  554.         }
  555.     }
  556.     */
  557.  
  558.     public static boolean isBannedGameserverIP(String ipAddress)
  559.     {
  560.         return false;
  561.     }
  562.  
  563.     public GameServerThread(Socket con)
  564.     {
  565.         _connection = con;
  566.         _connectionIp = con.getInetAddress().getHostAddress();
  567.  
  568.         try
  569.         {
  570.             _in = _connection.getInputStream();
  571.             _out = new BufferedOutputStream(_connection.getOutputStream());
  572.         }
  573.         catch(IOException e){
  574.             e.printStackTrace();
  575.         }
  576.  
  577.         KeyPair pair = GameServerTable.getInstance().getKeyPair();
  578.         _privateKey = (RSAPrivateKey) pair.getPrivate();
  579.         _publicKey = (RSAPublicKey) pair.getPublic();
  580.         _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
  581.     }
  582.  
  583.     private void sendPacket(ServerBasePacket sl) throws IOException
  584.     {
  585.         byte[] data = sl.getContent();
  586.         NewCrypt.appendChecksum(data);
  587.  
  588.         if(Config.DEBUG){
  589.             _log.debug("[S] " + sl.getClass().getSimpleName() + ":\n" + Util.printData(data));
  590.         }
  591.  
  592.         data = _blowfish.crypt(data);
  593.  
  594.         int len = data.length + 2;
  595.  
  596.         synchronized(_out)
  597.         {
  598.             _out.write(len & 0xff);
  599.             _out.write(len >> 8 & 0xff);
  600.             _out.write(data);
  601.             _out.flush();
  602.         }
  603.  
  604.         data = null;
  605.     }
  606.  
  607.     public void kickPlayer(String account)
  608.     {
  609.         KickPlayer kp = new KickPlayer(account);
  610.  
  611.         try{
  612.             sendPacket(kp);
  613.         }
  614.         catch(IOException e){
  615.             e.printStackTrace();
  616.         }
  617.  
  618.         kp = null;
  619.     }
  620.  
  621.     public void ChangePasswordResponse(byte successful, String characterName, String msgToSend)
  622.     {
  623.         ChangePasswordResponse cpr = new ChangePasswordResponse(successful, characterName, msgToSend);
  624.  
  625.         try{
  626.             sendPacket(cpr);
  627.         }
  628.         catch(IOException e){
  629.             e.printStackTrace();
  630.         }
  631.     }
  632.  
  633.     public void setGameHosts(String gameExternalHost, String gameInternalHost)
  634.     {
  635.         String oldInternal = _gsi.getInternalHost();
  636.         String oldExternal = _gsi.getExternalHost();
  637.  
  638.         _gsi.setExternalHost(gameExternalHost);
  639.         _gsi.setInternalIp(gameInternalHost);
  640.  
  641.         if(!gameExternalHost.equals("*"))
  642.         {
  643.             try{
  644.                 _gsi.setExternalIp(InetAddress.getByName(gameExternalHost).getHostAddress());
  645.             }
  646.             catch(UnknownHostException e)
  647.             {
  648.                 if(Config.ENABLE_ALL_EXCEPTIONS)
  649.                     e.printStackTrace();
  650.                 _log.warn("Could not resolve hostname \"" + gameExternalHost + "\"");
  651.             }
  652.         }
  653.         else{
  654.             _gsi.setExternalIp(_connectionIp);
  655.         }
  656.  
  657.         if(!gameInternalHost.equals("*"))
  658.         {
  659.             try{
  660.                 _gsi.setInternalIp(InetAddress.getByName(gameInternalHost).getHostAddress());
  661.             }
  662.             catch(UnknownHostException e)
  663.             {
  664.                 if(Config.ENABLE_ALL_EXCEPTIONS)
  665.                     e.printStackTrace();
  666.                 _log.warn("Could not resolve hostname \"" + gameInternalHost + "\"");
  667.             }
  668.         }
  669.         else{
  670.             _gsi.setInternalIp(_connectionIp);
  671.         }
  672.  
  673.         _log.info("Updated GameServer [" + getServerId() + "] " + GameServerTable.getInstance().getServerNameById(getServerId()) + " IP's: ");
  674.  
  675.         if(oldInternal == null || !oldInternal.equalsIgnoreCase(gameInternalHost))
  676.         {
  677.             _log.info("InternalIP: " + gameInternalHost);
  678.         }
  679.  
  680.         if(oldExternal == null || !oldExternal.equalsIgnoreCase(gameExternalHost))
  681.         {
  682.             _log.info("ExternalIP: " + gameExternalHost);
  683.         }
  684.  
  685.         oldInternal = null;
  686.         oldExternal = null;
  687.     }
  688.  
  689.     public boolean isAuthed()
  690.     {
  691.         if(getGameServerInfo() == null)
  692.             return false;
  693.         return getGameServerInfo().isAuthed();
  694.     }
  695.  
  696.     public void setGameServerInfo(GameServerInfo gsi)
  697.     {
  698.         _gsi = gsi;
  699.     }
  700.  
  701.     public GameServerInfo getGameServerInfo()
  702.     {
  703.         return _gsi;
  704.     }
  705.  
  706.     public String getConnectionIpAddress()
  707.     {
  708.         return _connectionIPAddress;
  709.     }
  710.  
  711.     private int getServerId()
  712.     {
  713.         if(getGameServerInfo() != null)
  714.             return getGameServerInfo().getId();
  715.  
  716.         return -1;
  717.     }
  718. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement