RuneHive-Game
Loading...
Searching...
No Matches
HAProxyMessageHandler.java
Go to the documentation of this file.
1package com.runehive.net;
2
3import com.runehive.Config;
4import io.netty.channel.ChannelHandlerContext;
5import io.netty.channel.SimpleChannelInboundHandler;
6import io.netty.handler.codec.haproxy.HAProxyMessage;
7
8/**
9 * @author Jire
10 */
11public final class HAProxyMessageHandler extends SimpleChannelInboundHandler<HAProxyMessage> {
12
13 @Override
14 protected void channelRead0(final ChannelHandlerContext ctx,
15 final HAProxyMessage msg) {
16 switch (msg.command()) {
17 case LOCAL -> ctx.close();
18 case PROXY -> {
19 final String sourceAddress = msg.sourceAddress();
20 if (sourceAddress != null) {
21 ctx.channel().attr(Config.SOURCE_ADDRESS).set(sourceAddress);
22 }
23 }
24 }
25 }
26
27}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final AttributeKey< String > SOURCE_ADDRESS
Definition Config.java:92
void channelRead0(final ChannelHandlerContext ctx, final HAProxyMessage msg)