|
15 | 15 | import org.checkerframework.checker.nullness.qual.NonNull; |
16 | 16 | import org.checkerframework.checker.nullness.qual.Nullable; |
17 | 17 | import org.geysermc.mcprotocollib.network.BuiltinFlags; |
| 18 | +import org.geysermc.mcprotocollib.network.NetworkConstants; |
18 | 19 | import org.geysermc.mcprotocollib.network.ProxyInfo; |
19 | 20 | import org.geysermc.mcprotocollib.network.Session; |
20 | 21 | import org.slf4j.Logger; |
@@ -128,8 +129,8 @@ public static void initializeHAProxySupport(Session session, Channel channel) { |
128 | 129 | return; |
129 | 130 | } |
130 | 131 |
|
131 | | - channel.pipeline().addLast("proxy-protocol-encoder", HAProxyMessageEncoder.INSTANCE); |
132 | | - channel.pipeline().addLast("proxy-protocol-packet-sender", new ChannelInboundHandlerAdapter() { |
| 132 | + channel.pipeline().addLast(NetworkConstants.PROXY_PROTOCOL_ENCODER_NAME, HAProxyMessageEncoder.INSTANCE); |
| 133 | + channel.pipeline().addLast(NetworkConstants.PROXY_PROTOCOL_PACKET_SENDER_NAME, new ChannelInboundHandlerAdapter() { |
133 | 134 | @Override |
134 | 135 | public void channelActive(ChannelHandlerContext ctx) throws Exception { |
135 | 136 | HAProxyProxiedProtocol proxiedProtocol = getProxiedProtocol(clientAddress); |
@@ -187,23 +188,23 @@ public static void addProxy(ProxyInfo proxy, ChannelPipeline pipeline) { |
187 | 188 | switch (proxy.type()) { |
188 | 189 | case HTTP -> { |
189 | 190 | if (proxy.username() != null && proxy.password() != null) { |
190 | | - pipeline.addLast("proxy", new HttpProxyHandler(proxy.address(), proxy.username(), proxy.password())); |
| 191 | + pipeline.addLast(NetworkConstants.PROXY_NAME, new HttpProxyHandler(proxy.address(), proxy.username(), proxy.password())); |
191 | 192 | } else { |
192 | | - pipeline.addLast("proxy", new HttpProxyHandler(proxy.address())); |
| 193 | + pipeline.addLast(NetworkConstants.PROXY_NAME, new HttpProxyHandler(proxy.address())); |
193 | 194 | } |
194 | 195 | } |
195 | 196 | case SOCKS4 -> { |
196 | 197 | if (proxy.username() != null) { |
197 | | - pipeline.addLast("proxy", new Socks4ProxyHandler(proxy.address(), proxy.username())); |
| 198 | + pipeline.addLast(NetworkConstants.PROXY_NAME, new Socks4ProxyHandler(proxy.address(), proxy.username())); |
198 | 199 | } else { |
199 | | - pipeline.addLast("proxy", new Socks4ProxyHandler(proxy.address())); |
| 200 | + pipeline.addLast(NetworkConstants.PROXY_NAME, new Socks4ProxyHandler(proxy.address())); |
200 | 201 | } |
201 | 202 | } |
202 | 203 | case SOCKS5 -> { |
203 | 204 | if (proxy.username() != null && proxy.password() != null) { |
204 | | - pipeline.addLast("proxy", new Socks5ProxyHandler(proxy.address(), proxy.username(), proxy.password())); |
| 205 | + pipeline.addLast(NetworkConstants.PROXY_NAME, new Socks5ProxyHandler(proxy.address(), proxy.username(), proxy.password())); |
205 | 206 | } else { |
206 | | - pipeline.addLast("proxy", new Socks5ProxyHandler(proxy.address())); |
| 207 | + pipeline.addLast(NetworkConstants.PROXY_NAME, new Socks5ProxyHandler(proxy.address())); |
207 | 208 | } |
208 | 209 | } |
209 | 210 | default -> throw new UnsupportedOperationException("Unsupported proxy type: " + proxy.type()); |
|
0 commit comments