mirror of
https://github.com/apache/rocketmq.git
synced 2026-09-17 17:17:55 +08:00
* fix parse ipv6 from address in haproxy * more
This commit is contained in:
+4
-4
@@ -171,7 +171,7 @@ public class DefaultAuthorizationContextBuilder implements AuthorizationContextB
|
||||
subject = User.of(fields.get(SessionCredentials.ACCESS_KEY));
|
||||
}
|
||||
String remoteAddr = RemotingHelper.parseChannelRemoteAddr(context.channel());
|
||||
String sourceIp = StringUtils.substringBefore(remoteAddr, CommonConstants.COLON);
|
||||
String sourceIp = StringUtils.substringBeforeLast(remoteAddr, CommonConstants.COLON);
|
||||
|
||||
Resource topic;
|
||||
Resource group;
|
||||
@@ -394,7 +394,7 @@ public class DefaultAuthorizationContextBuilder implements AuthorizationContextB
|
||||
subject = User.of(metadata.get(GrpcConstants.AUTHORIZATION_AK));
|
||||
}
|
||||
Resource resource = Resource.ofTopic(topic.getName());
|
||||
String sourceIp = StringUtils.substringBefore(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
|
||||
String sourceIp = StringUtils.substringBeforeLast(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
|
||||
DefaultAuthorizationContext context = DefaultAuthorizationContext.of(subject, resource, Arrays.asList(Action.PUB, Action.SUB), sourceIp);
|
||||
return Collections.singletonList(context);
|
||||
}
|
||||
@@ -437,7 +437,7 @@ public class DefaultAuthorizationContextBuilder implements AuthorizationContextB
|
||||
subject = User.of(metadata.get(GrpcConstants.AUTHORIZATION_AK));
|
||||
}
|
||||
Resource resource = Resource.ofTopic(topic.getName());
|
||||
String sourceIp = StringUtils.substringBefore(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
|
||||
String sourceIp = StringUtils.substringBeforeLast(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
|
||||
DefaultAuthorizationContext context = DefaultAuthorizationContext.of(subject, resource, Action.PUB, sourceIp);
|
||||
return Collections.singletonList(context);
|
||||
}
|
||||
@@ -483,7 +483,7 @@ public class DefaultAuthorizationContextBuilder implements AuthorizationContextB
|
||||
if (metadata.containsKey(GrpcConstants.AUTHORIZATION_AK)) {
|
||||
subject = User.of(metadata.get(GrpcConstants.AUTHORIZATION_AK));
|
||||
}
|
||||
String sourceIp = StringUtils.substringBefore(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
|
||||
String sourceIp = StringUtils.substringBeforeLast(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
|
||||
result.add(DefaultAuthorizationContext.of(subject, resource, Action.SUB, sourceIp));
|
||||
return result;
|
||||
}
|
||||
|
||||
+2
-2
@@ -118,11 +118,11 @@ public class HAProxyMessageForwarder extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
} else {
|
||||
String remoteAddr = RemotingHelper.parseChannelRemoteAddr(inboundChannel);
|
||||
sourceAddress = StringUtils.substringBefore(remoteAddr, CommonConstants.COLON);
|
||||
sourceAddress = StringUtils.substringBeforeLast(remoteAddr, CommonConstants.COLON);
|
||||
sourcePort = Integer.parseInt(StringUtils.substringAfterLast(remoteAddr, CommonConstants.COLON));
|
||||
|
||||
String localAddr = RemotingHelper.parseChannelLocalAddr(inboundChannel);
|
||||
destinationAddress = StringUtils.substringBefore(localAddr, CommonConstants.COLON);
|
||||
destinationAddress = StringUtils.substringBeforeLast(localAddr, CommonConstants.COLON);
|
||||
destinationPort = Integer.parseInt(StringUtils.substringAfterLast(localAddr, CommonConstants.COLON));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user