INNER CODE UNIT · TypeScript

isIPThrottled

keptn/keptn · bridge/server/app.ts:278

function isIPThrottled(ip: string, authConfig: AuthConfig): boolean {
  const ipBucket = throttleBucket[ip];
  return (
    ipBucket &&
    ipBucket.length >= authConfig.nRequestWithinTime &&
    new Date().getTime() - ipBucket[0] <= authConfig.requestTimeLimitMs
  );
}

/**
 * Delete an IP from the bucket if the last request is older than {requestTimeLimit}
 */
function cleanIpBuckets(authConfig: AuthConfig): void {
  for (const ip of Object.keys(throttleBucket)) {
    const ipBucket = throttleBucket[ip];
    if (ipBucket && new Date().getTime() - ipBucket[ipBucket.length - 1] > authConfig.requestTimeLimitMs) {
      delete throttleBucket[ip];
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…