[fix] 添加namespace

This commit is contained in:
wujiawei
2025-06-11 16:45:17 +08:00
parent 3163987ef7
commit 229e273b7d
64 changed files with 177 additions and 180 deletions

View File

@ -15,7 +15,7 @@ import java.nio.charset.StandardCharsets;
@Setter
@Getter
public class NettyProxyMsg {
// body 长度 type 1 isSsl 1 appKey 4 appSecret 4 clientId 4 namespace 4 originalIp 4 clientTargetIp 4 clientTargetPort 4 visitorPort 4 visitorId 4 data 4
// body 长度 type 1 isSsl 1 appKey 4 appSecret 4 clientId 4 namespace 4 originalIp 4 targetIp 4 targetPort 4 visitorPort 4 visitorId 4 data 4
public static final int bodyLength = 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
@ -70,13 +70,13 @@ public class NettyProxyMsg {
* 客户端目标地址
* byte[] 长度 4
*/
private byte[] clientTargetIp;
private byte[] targetIp;
/**
* 客户端目标端口
* byte[] 长度 4
*/
private byte[] clientTargetPort;
private byte[] targetPort;
/**
* 客户端目使用的代理端口
* byte[] 长度 4
@ -98,8 +98,8 @@ public class NettyProxyMsg {
public String toString() {
return "NettyProxyMsg [type=" + type +
",clientId=" + (clientId == null ? null : new String(clientId)) +
",clientTargetIp=" + (clientTargetIp == null ? null : new String(clientTargetIp)) +
",clientTargetPort=" + (clientTargetPort == null ? null : new String(clientTargetPort)) +
",targetIp=" + (targetIp == null ? null : new String(targetIp)) +
",targetPort=" + (targetPort == null ? null : new String(targetPort)) +
",visitorPort=" + (visitorPort == null ? null : new String(visitorPort)) +
"]";
}
@ -208,10 +208,10 @@ public class NettyProxyMsg {
* @return 客户端目标地址
*/
public String targetIp() {
if (ObjectUtils.isEmpty(clientTargetIp)) {
if (ObjectUtils.isEmpty(targetIp)) {
return null;
}
return new String(clientTargetIp, StandardCharsets.UTF_8);
return new String(targetIp, StandardCharsets.UTF_8);
}
/**
* 客户端目标端口
@ -219,10 +219,10 @@ public class NettyProxyMsg {
* @return 客户端目标端口
*/
public String targetPort() {
if (ObjectUtils.isEmpty(clientTargetPort)) {
if (ObjectUtils.isEmpty(targetPort)) {
return null;
}
return new String(clientTargetPort, StandardCharsets.UTF_8);
return new String(targetPort, StandardCharsets.UTF_8);
}
/**
@ -243,20 +243,20 @@ public class NettyProxyMsg {
return Integer.valueOf(new String(visitorPort, StandardCharsets.UTF_8));
}
public void setClientTargetIp(byte[] clientTargetIp) {
this.clientTargetIp = clientTargetIp;
public void setTargetIp(byte[] targetIp) {
this.targetIp = targetIp;
}
public void setClientTargetIp(String clientTargetIp) {
this.clientTargetIp = clientTargetIp.getBytes(StandardCharsets.UTF_8);
public void setTargetIp(String clientTargetIp) {
this.targetIp = clientTargetIp.getBytes(StandardCharsets.UTF_8);
}
public void setClientTargetPort(Integer clientTargetPort) {
this.clientTargetPort = String.valueOf(clientTargetPort).getBytes(StandardCharsets.UTF_8);
public void setTargetPort(Integer targetPort) {
this.targetPort = String.valueOf(targetPort).getBytes(StandardCharsets.UTF_8);
}
public void setClientTargetPort(byte[] clientTargetPort) {
this.clientTargetPort = clientTargetPort;
public void setTargetPort(byte[] targetPort) {
this.targetPort = targetPort;
}
public void setVisitorPort(byte[] visitorPort) {

View File

@ -143,13 +143,13 @@ public class NettyProxyMsgDecoder extends LengthFieldBasedFrameDecoder {
int clientTargetIpLength = in.readInt();
byte[] clientTargetIpBytes = new byte[clientTargetIpLength];
in.readBytes(clientTargetIpBytes);
nettyProxyMsg.setClientTargetIp(clientTargetIpBytes);
nettyProxyMsg.setTargetIp(clientTargetIpBytes);
int clientTargetPortLength = in.readInt();
byte[] clientTargetPortBytes = new byte[clientTargetPortLength];
in.readBytes(clientTargetPortBytes);
nettyProxyMsg.setClientTargetPort(clientTargetPortBytes);
nettyProxyMsg.setTargetPort(clientTargetPortBytes);
int visitorPortLength = in.readInt();
byte[] visitorPortBytes = new byte[visitorPortLength];

View File

@ -30,8 +30,8 @@ public class NettyProxyMsgEncoder extends MessageToByteEncoder<NettyProxyMsg> {
byte[] originalIp = msg.getOriginalIp();
byte[] namespace = msg.getNamespace();
byte[] clientIdBytes = msg.getClientId();
byte[] clientTargetIpBytes = msg.getClientTargetIp();
byte[] clientTargetPortBytes = msg.getClientTargetPort();
byte[] clientTargetIpBytes = msg.getTargetIp();
byte[] clientTargetPortBytes = msg.getTargetPort();
byte[] visitorPortBytes = msg.getVisitorPort();
byte[] visitorIdBytes = msg.getVisitorId();
byte[] msgDataBytes = msg.getData();