1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Several improvements

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-21 20:19:13 -03:00
parent 6efce6615f
commit ab38e7d5ba
125 changed files with 969 additions and 205 deletions

View File

@@ -27,16 +27,18 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.logging.Slf4JLoggerFactory;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2PipelineFactory;
import com.l2jserver.game.net.packet.ServerPacket;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.configuration.ConfigurationService;
import com.l2jserver.service.core.LoggingService;
import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.service.logging.LoggingService;
import com.l2jserver.service.network.keygen.BlowfishKeygenService;
import com.l2jserver.util.factory.CollectionFactory;
@@ -97,6 +99,7 @@ public class NettyNetworkService extends AbstractService implements
@Override
public void register(final Lineage2Connection client) {
Preconditions.checkNotNull(client, "client");
clients.add(client);
client.getChannel().getCloseFuture()
.addListener(new ChannelFutureListener() {
@@ -110,11 +113,13 @@ public class NettyNetworkService extends AbstractService implements
@Override
public void unregister(Lineage2Connection client) {
Preconditions.checkNotNull(client, "client");
clients.remove(client);
}
@Override
public Lineage2Connection discover(CharacterID character) {
Preconditions.checkNotNull(character, "character");
for (final Lineage2Connection client : clients) {
if (character.equals(client.getCharacterID()))
return client;
@@ -122,6 +127,12 @@ public class NettyNetworkService extends AbstractService implements
return null;
}
@Override
public void broadcast(ServerPacket packet) {
Preconditions.checkNotNull(packet, "packet");
channel.write(packet);
}
@Override
public void cleanup() {
// TODO

View File

@@ -17,6 +17,7 @@
package com.l2jserver.service.network;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.ServerPacket;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.service.Service;
@@ -52,6 +53,14 @@ public interface NetworkService extends Service {
*/
Lineage2Connection discover(CharacterID character);
/**
* Broadcast an given <tt>packet</tt> to all clients connected
*
* @param packet
* the packet
*/
void broadcast(ServerPacket packet);
/**
* Searches for idle connection and removes them
*/

View File

@@ -18,6 +18,20 @@ package com.l2jserver.service.network.keygen;
import com.l2jserver.service.Service;
/**
* This service generated cryptography keys used to encrypt and decrypt client
* or server packets. Implementations can use an fixed set of keys or generate a
* random one. Note that the generated key might not be cryptographically safe,
* and this is implementation specific.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface BlowfishKeygenService extends Service {
/**
* Creates a new 128 bits key. Note that the key is not necessarily random
* and can be a fixed key.
*
* @return the 128 bits key
*/
byte[] generate();
}

View File

@@ -22,8 +22,17 @@ import com.l2jserver.service.AbstractService;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
/**
* Generates a new random key using JDK {@link Random}. Keys generated by this
* implementation are not completely secure but are very fast to generate.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class PseudoRandomBlowfishKeygenService extends AbstractService
implements BlowfishKeygenService {
/**
* The random number generator
*/
private Random random;
@Override