use of net.md_5.bungee.query.RemoteQuery in project BungeeCord by SpigotMC.
the class BungeeCord method startListeners.
public void startListeners() {
for (final ListenerInfo info : config.getListeners()) {
if (info.isProxyProtocol()) {
getLogger().log(Level.WARNING, "Using PROXY protocol for listener {0}, please ensure this listener is adequately firewalled.", info.getSocketAddress());
if (connectionThrottle != null) {
connectionThrottle = null;
getLogger().log(Level.WARNING, "Since PROXY protocol is in use, internal connection throttle has been disabled.");
}
}
ChannelFutureListener listener = new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
listeners.add(future.channel());
getLogger().log(Level.INFO, "Listening on {0}", info.getSocketAddress());
} else {
getLogger().log(Level.WARNING, "Could not bind to host " + info.getSocketAddress(), future.cause());
}
}
};
new ServerBootstrap().channel(PipelineUtils.getServerChannel(info.getSocketAddress())).option(ChannelOption.SO_REUSEADDR, // TODO: Move this elsewhere!
true).childAttr(PipelineUtils.LISTENER, info).childHandler(PipelineUtils.SERVER_CHILD).group(eventLoops).localAddress(info.getSocketAddress()).bind().addListener(listener);
if (info.isQueryEnabled()) {
Preconditions.checkArgument(info.getSocketAddress() instanceof InetSocketAddress, "Can only create query listener on UDP address");
ChannelFutureListener bindListener = new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
listeners.add(future.channel());
getLogger().log(Level.INFO, "Started query on {0}", future.channel().localAddress());
} else {
getLogger().log(Level.WARNING, "Could not bind to host " + info.getSocketAddress(), future.cause());
}
}
};
new RemoteQuery(this, info).start(PipelineUtils.getDatagramChannel(), new InetSocketAddress(info.getHost().getAddress(), info.getQueryPort()), eventLoops, bindListener);
}
}
}
Aggregations