Archived
0

MCSM: указание парольной фразы в конфиге

This commit is contained in:
2017-04-29 15:14:46 +03:00
parent c9af162ff5
commit e815af6e41
4 changed files with 7 additions and 5 deletions

View File

@@ -39,9 +39,10 @@ public class Activator implements BundleActivator, ServiceListener {
String host = config.getString("asys.mcsmanager.host", "127.0.0.1");
int port = config.getInt("asys.mcsmanager.port", 8779);
String passcode = config.getString("asys.mcsmanager.passcode", "testpasscode");
logger.debug("Start server manager: {}:{}", host, port);
serverManager = new Server();
serverManager.start(host, port);
serverManager.start(host, port, passcode);
serviceConfigTracker.close();
}

View File

@@ -23,8 +23,10 @@ public class Server {
1, CS_Ping.class
);
private EventLoopGroup bossGroup, workerGroup;
static String passcode;
public void start(String host, int port) {
public void start(String host, int port, String passcode) {
Server.passcode = passcode;
bossGroup = new NioEventLoopGroup(1);
workerGroup = new NioEventLoopGroup();

View File

@@ -23,7 +23,6 @@ class ServerPacketHandler extends ChannelInboundHandlerAdapter implements IPacke
2, SC_HandshakeResult.class
);
private static Map<Class<? extends Packet>, IPacketHandler> handshakeHandlers;
private static final String PASSCODE = "testpassphrase";
ServerPacketHandler() {
if (handshakeHandlers == null) {
@@ -46,7 +45,7 @@ class ServerPacketHandler extends ChannelInboundHandlerAdapter implements IPacke
}
private void handleCSHandshake(CS_Handshake packet, ChannelHandlerContext context) {
if (!packet.getPasscode().equalsIgnoreCase(PASSCODE)) {
if (!packet.getPasscode().equalsIgnoreCase(Server.passcode)) {
try {
context.channel().writeAndFlush(HandshakeResult.INVALID_PASSCODE).sync().channel().close();
} catch (InterruptedException ignore) {