1、服务端部分代码重构

2、流量报表字段调整
3、增加流量统计相关逻辑
This commit is contained in:
aoshiguchen
2022-10-26 22:00:13 +08:00
parent 540bedb809
commit df2ced99a0
16 changed files with 191 additions and 57 deletions
@@ -42,15 +42,15 @@ public class RealServerChannelHandler extends SimpleChannelInboundHandler<ByteBu
@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
Channel realServerChannel = ctx.channel();
Channel channel = realServerChannel.attr(Constants.NEXT_CHANNEL).get();
if (channel == null) {
Channel proxyChannel = realServerChannel.attr(Constants.NEXT_CHANNEL).get();
if (null == proxyChannel) {
// 代理客户端连接断开
ctx.channel().close();
} else {
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
String visitorId = ProxyUtil.getVisitorIdByRealServerChannel(realServerChannel);
channel.writeAndFlush(ProxyMessage.buildTransferMessage(visitorId, bytes));
proxyChannel.writeAndFlush(ProxyMessage.buildTransferMessage(visitorId, bytes));
}
}