thanhbv200585 commented on code in PR #1824:
URL: https://github.com/apache/james-project/pull/1824#discussion_r1410335778


##########
server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java:
##########
@@ -173,6 +184,9 @@ public void channelActive(ChannelHandlerContext ctx) throws 
Exception {
         ImapSession imapsession = new NettyImapSession(ctx.channel(), secure, 
compress, authenticationConfiguration.isSSLRequired(),
             authenticationConfiguration.isPlainAuthEnabled(), sessionId,
             authenticationConfiguration.getOidcSASLConfiguration());
+
+        connectionCheckSet.forEach(connectionCheck -> 
Mono.from(connectionCheck.validate(imapsession.getRemoteAddress())).block());

Review Comment:
   This is `validate` method in `CrowdsecImapConnectionCheck`
   
   ```
       @Override
       public Publisher<Void> validate(InetSocketAddress remoteAddress) {
           String ip = remoteAddress..getAddress().getHostAddress();
           CrowdsecHttpClient client = new 
CrowdsecHttpClient(crowdsecClientConfiguration);
           return client.getCrowdsecDecisions()
               .filter(decisions -> decisions.stream().anyMatch(decision -> 
isBanned(decision, ip)))
               .map(decision -> {
                   throw new RuntimeException("Ip " + ip + " is not allowed to 
connect to IMAP server");
               });
       }
   ```
   
   Without blocking, client cannot get any crowdsec decisions. I know .block is 
forbidden in non-blocking stream, and I also try to find out other solutions 
but I cannot. I am not master reactive programming so hope that team can 
support me. 
   [Screencast from 30-11-2023 
15:39:47.webm](https://github.com/apache/james-project/assets/87489927/0105e0db-7b4e-4461-990b-88d4ad3b8d33)
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to