Skip to content

Instantly share code, notes, and snippets.

@bryanp
Created September 21, 2018 14:54
Show Gist options
  • Save bryanp/888a01e66a1f56376cb3cd3aa96275ea to your computer and use it in GitHub Desktop.
Save bryanp/888a01e66a1f56376cb3cd3aa96275ea to your computer and use it in GitHub Desktop.
Detect Platform Health Checks
# Platform health check ip addresses.
#
HEALTH_CHECK_ADDRS = [
IPAddr.new("209.85.152.0/22"),
IPAddr.new("209.85.204.0/22"),
IPAddr.new("35.191.0.0/16"),
IPAddr.new("130.211.0.0/22"),
IPAddr.new("35.191.0.0/16")
]
# This should be a helper method.
#
def health_check?
remote_ip = IPAddr.new(req.ip)
HEALTH_CHECK_ADDRS.any? { |addr|
addr === remote_ip
}
rescue IPAddr::InvalidAddressError
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment