Опиши проблемму..., если необходимо разделение сервера так сказать на 2 и более локальных сетей то я для сервака у себя в городе сдалал такой модик, т.е. ты подсети вписываеш сам...
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package net.sf.l2j.loginserver;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.l2j.Config;
/**
* This class ...
*
* @version $Revision: 1.9.4.4 $ $Date: 2005/03/27 15:30:09 $
*/
public class LoginServer
extends Thread
{
private static LoginServer _instance;
private LoginController loginController;
private Logins loginManager;
private int clientListeningPort;
private int clientGameServerPort;
private String _externalHostname
;
private String _internalHostname
;
private boolean _forwardLocalClient;
private String _InternalAdvHostEnabled
;
private String _internalHostname1
;
private String _internalHostname2
;
static Logger _log = Logger.getLogger(LoginServer.class.getName());
{
LoginServer server = new LoginServer("Stand Alone LoginServer.");
_log.config("Stand Alone LoginServer Listening on port " + Config.PORT_LOGIN);
server.start();
}
public void close()
{
this.interrupt();
try
{
clientServerSocket.close();
}
{
_log.log(Level.INFO, "", e);
}
}
/**
*
*/
public void run()
{
while (true)
{
try
{
if (Config.DEBUG)
_log.fine("waiting for client connection...");
Socket connection
= clientServerSocket.
accept();
if (Config.DEBUG)
_log.fine("connection from " + connection.getInetAddress());
// use local ip addess if no external hostname is set or if
// the the connection is requested from localhost (for router
// compatibility)
String connectedIp
= connection.
getInetAddress().
getHostAddress();
if ( _InternalAdvHostEnabled == null)
{
if (connectedIp.startsWith("192.168.") || connectedIp.startsWith("10.") || connectedIp.startsWith("172.16.") || connectedIp.startsWith("127.0.0.1"))
{
if (Config.DEBUG)
_log.fine("using internal ip as server ip " + _internalHostname);
new ClientThread(connection, loginManager, _internalHostname, clientGameServerPort);
}
else
{
if (Config.DEBUG)
_log.fine("using external ip as server ip " + _externalHostname);
new ClientThread(connection, loginManager, _externalHostname, clientGameServerPort);
}
}
else
{
for (int inet = 0; inet < 255; inet++)
{
if (_iternalNetwork1[inet] != null)
{
if (connectedIp.startsWith(_iternalNetwork1[inet]))
{
_log.config("Login Server : Connecting using ip " + _internalHostname1 + " on IP Network : " + _iternalNetwork1[inet] + " for IP: " + connectedIp);
if (Config.DEBUG)
_log.fine("Login Server : Connecting using internal ip as server ip " + _internalHostname1);
_log.fine("Login Server : user on :" + _iternalNetwork1[inet]);
new ClientThread(connection, loginManager, _internalHostname1, clientGameServerPort);
}
}
if (_iternalNetwork2[inet] != null)
{
if (connectedIp.startsWith( _iternalNetwork2[inet]))
{
_log.config("Login Server : Connecting using ip " + _internalHostname2 + " on IP Network : " + _iternalNetwork2[inet] + " for IP: " + connectedIp);
if (Config.DEBUG)
_log.fine("Login Server : Connected using internal ip as server ip " + _internalHostname2);
_log.fine("Login Server : user on :" + _iternalNetwork2[inet]);
new ClientThread(connection, loginManager, _internalHostname2, clientGameServerPort);
}
}
}
}
if (this.isInterrupted())
{
// shutdown?
try
{
clientServerSocket.close();
}
{
_log.log(Level.INFO, "", io);
}
break;
}
}
{
// not a real problem
if (this.isInterrupted())
{
// shutdown?
try
{
clientServerSocket.close();
}
{
_log.log(Level.INFO, "", io);
}
break;
}
}
}
}
public LoginServer
(String threadName
)
{
super(threadName);
clientListeningPort = Config.PORT_LOGIN;
new GameServerListener().start();
}
{
super("LoginServer");
InputStream is
= getClass
().
getResourceAsStream(Config.
CONFIGURATION_FILE);
serverSettings.load(is);
is.close();
String loginIp
= serverSettings.
getProperty("LoginserverHostname");
_externalHostname = serverSettings.getProperty("ExternalHostname");
if (_externalHostname == null)
{
_externalHostname = "localhost";
}
_internalHostname = serverSettings.getProperty("InternalHostname");
if (_internalHostname == null)
{
_internalHostname = "localhost";
}
String createAccounts
= serverSettings.
getProperty("AutoCreateAccounts");
_InternalAdvHostEnabled= serverSettings.getProperty("InternalAdvHostEnabled");
_internalHostname1 = serverSettings.getProperty("InternalHostname1");
_internalHostname2 = serverSettings.getProperty("InternalHostname2");
if (!"*".equals(loginIp))
{
_log.config("LoginServer listening on IP:" + clientListeningIP.getHostAddress() + " Port " + Config.PORT_LOGIN);
clientServerSocket
= new ServerSocket(Config.
PORT_LOGIN,
50, clientListeningIP
);
}
else
{
_log.config("LoginServer listening on all available IPs on Port " + Config.PORT_LOGIN);
}
_log.config("Hostname for external connections is: " + _externalHostname);
if ( _InternalAdvHostEnabled == null)
{
_log.config("Hostname for internal connections is: " + _internalHostname);
}
else
{
_log.config("Login Server : Advanted Internal Connections is Enabled ");
_log.config("Login Server : Internal Host #1: " + _internalHostname1);
_log.config("Login Server : Found IP Network #1: ");
for (int inet = 0; inet < 255; inet++)
{
if (serverSettings.getProperty("InternalNetwork1-"+inet) != null)
{
_log.config( "Login Server : "+ serverSettings.getProperty("InternalNetwork1-"+inet));
_iternalNetwork1[inet] = serverSettings.getProperty("InternalNetwork1-"+inet);
}
}
_log.config("Login Server : Internal Host #2: " + _internalHostname2);
_log.config("Login Server : Found IP Network #2: ");
for (int inet = 0; inet < 255; inet++)
{
if (serverSettings.getProperty("InternalNetwork2-"+inet) != null)
{
_log.config( "Login Server : "+ serverSettings.getProperty("InternalNetwork2-"+inet));
_iternalNetwork2[inet] = serverSettings.getProperty("InternalNetwork2-"+inet);
}
}
}
loginManager
= new Logins
(Boolean.
valueOf(createAccounts
).
booleanValue());
clientGameServerPort = Config.PORT_GAME;
/*
* ArrayList<String> bannedIpList = new ArrayList<String>();
* Properties bannedIpFile = new Properties(); try {
* bannedIpFile.loadFromXML(getClass().getResourceAsStream(Config.BANNED_IP_XML)); }
* catch (InvalidPropertiesFormatException e) { e.printStackTrace(); }
* catch (IOException e) { e.printStackTrace(); }
* bannedIpFile.setProperty(loginIp, createAccounts);
* bannedIpList.toString()
*/
try
{
InputStream bannedFile
= getClass
().
getResourceAsStream("/banned_ip.cfg");
if (bannedFile != null)
{
int count = 0;
while ((line = lnr.readLine()) != null)
{
line = line.trim();
if (line.length() > 0)
{
count++;
ClientThread.addBannedIP(line);
}
}
_log.info(count + " banned IPs defined");
}
else
{
_log.info("banned_ip.cfg not found");
}
}
{
_log.warning("error while reading banned file:" + e);
}
}
/**
*
*/
public static LoginServer getInstance()
{
// If no instances started before, try to start a new one
if (_instance == null)
&n