@Test public void testIPGetRemoved() { long sleepTime = 100; POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler(); setupMockedSMTPSession(); POP3BeforeSMTPHelper.addIPAddress("192.168.200.1"); assertThat(mockedSession.isRelayingAllowed()).isFalse(); try { Thread.sleep(sleepTime); POP3BeforeSMTPHelper.removeExpiredIP(Duration.ofMillis(10)); handler.onConnect(mockedSession); assertThat(mockedSession.isRelayingAllowed()).isFalse(); } catch (InterruptedException e) { } }
@Override public Response onConnect(SMTPSession session) { if (Math.random() > 0.99) { POP3BeforeSMTPHelper.removeExpiredIP(expireTime); } if (!session.isRelayingAllowed() && POP3BeforeSMTPHelper.isAuthorized(session.getRemoteAddress().getAddress().getHostAddress())) { session.setRelayingAllowed(true); } return null; }
POP3BeforeSMTPHandler implements ConnectHandler<SMTPSession>, Configurable { @Override public Response onConnect(SMTPSession session) { if (Math.random() > 0.99) { POP3BeforeSMTPHelper.removeExpiredIP(expireTime); } if (!session.isRelayingAllowed() && POP3BeforeSMTPHelper.isAuthorized(session.getRemoteAddress().getAddress().getHostAddress())) { session.setRelayingAllowed(true); } return null; } }
POP3BeforeSMTPHandler implements ConnectHandler<SMTPSession>, Configurable { @Override public Response onConnect(SMTPSession session) { if (Math.random() > 0.99) { POP3BeforeSMTPHelper.removeExpiredIP(expireTime); } if (!session.isRelayingAllowed() && POP3BeforeSMTPHelper.isAuthorized(session.getRemoteAddress().getAddress().getHostAddress())) { session.setRelayingAllowed(true); } return null; }  }
POP3BeforeSMTPHandler implements ConnectHandler<SMTPSession>, Configurable { @Override public Response onConnect(SMTPSession session) { if (Math.random() > 0.99) { POP3BeforeSMTPHelper.removeExpiredIP(expireTime); } if (!session.isRelayingAllowed() && POP3BeforeSMTPHelper.isAuthorized(session.getRemoteAddress().getAddress().getHostAddress())) { session.setRelayingAllowed(true); } return null; }  @Override void configure(HierarchicalConfiguration<ImmutableNode> config); void setExpireTime(String rawExpireTime); @Override Response onConnect(SMTPSession session); }
POP3BeforeSMTPHandler implements ConnectHandler<SMTPSession>, Configurable { @Override public Response onConnect(SMTPSession session) { if (Math.random() > 0.99) { POP3BeforeSMTPHelper.removeExpiredIP(expireTime); } if (!session.isRelayingAllowed() && POP3BeforeSMTPHelper.isAuthorized(session.getRemoteAddress().getAddress().getHostAddress())) { session.setRelayingAllowed(true); } return null; }  @Override void configure(HierarchicalConfiguration<ImmutableNode> config); void setExpireTime(String rawExpireTime); @Override Response onConnect(SMTPSession session);  }