Source:
<code>private boolean isClientInControlOfSourceIpAddress(ClientHello clientHello, Record record, Connection connection) { try { byte[] expectedCookie = null; byte[] providedCookie = clientHello.getCookie(); if (providedCookie != null && providedCookie.length > 0) { expectedCookie = cookieGenerator.generateCookie(clientHello); if (Arrays.equals(expectedCookie, providedCookie)) { return true; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("provided cookie must match {}. Send verify request to {}", StringUtil.byteArray2HexString(providedCookie, StringUtil.NO_SEPARATOR, 6), StringUtil.byteArray2HexString(expectedCookie, StringUtil.NO_SEPARATOR, 6), record.getPeerAddress()); } } else if (!config.isVerifyRequestOnResumptionEnabled()) { Connection sessionConnection = connectionStore.find(clientHello.getSessionId()); if (sessionConnection != null) { if (record.getPeerAddress().equals(sessionConnection.getPeerAddress())) { return true; } if (connection == null || !connection.hasEstablishedSession()) { int pending = pendingShortResumptionHandshakes.get(); int remainingCapacity = connectionStore.remainingCapacity(); <START> if (pending < (remainingCapacity / 8)) { <END> return true; } } } } if (expectedCookie == null) { expectedCookie = cookieGenerator.generateCookie(clientHello); } sendHelloVerify(clientHello, record, expectedCookie); return false; } catch (GeneralSecurityException e) { throw new DtlsHandshakeException("Cannot compute cookie for peer", AlertDescription.INTERNAL_ERROR, AlertLevel.FATAL, clientHello.getPeer(), e); } }</code><technical_language>remaining capacity count staled connection</technical_language>

Target:
private boolean isClientInControlOfSourceIpAddress(ClientHello clientHello, Record record, Connection connection) { try { byte[] expectedCookie = null; byte[] providedCookie = clientHello.getCookie(); if (providedCookie != null && providedCookie.length > 0) { expectedCookie = cookieGenerator.generateCookie(clientHello); if (Arrays.equals(expectedCookie, providedCookie)) { return true; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("provided cookie must match {}. Send verify request to {}", StringUtil.byteArray2HexString(providedCookie, StringUtil.NO_SEPARATOR, 6), StringUtil.byteArray2HexString(expectedCookie, StringUtil.NO_SEPARATOR, 6), record.getPeerAddress()); } } else { if (0 < thresholdHandshakesWithoutVerifiedPeer) { Connection sessionConnection = connectionStore.find(clientHello.getSessionId()); if (sessionConnection != null) { if (record.getPeerAddress().equals(sessionConnection.getPeerAddress())) { LOGGER.trace("resuming peer's session", record.getPeerAddress()); return true; } if (connection == null || !connection.hasEstablishedSession()) { int pending = pendingHandshakesWithoutVerifiedPeer.get(); LOGGER.trace("pending fast resumptions [{}], threshold [{}]", pending, thresholdHandshakesWithoutVerifiedPeer); if (pending < thresholdHandshakesWithoutVerifiedPeer) { LOGGER.trace("fast resume for peer [{}]", record.getPeerAddress(), pending); return true; } } } } } if (expectedCookie == null) { expectedCookie = cookieGenerator.generateCookie(clientHello); } sendHelloVerify(clientHello, record, expectedCookie); return false; } catch (GeneralSecurityException e) { throw new DtlsHandshakeException("Cannot compute cookie for peer", AlertDescription.INTERNAL_ERROR, AlertLevel.FATAL, clientHello.getPeer(), e); } }