Created
September 21, 2018 14:54
-
-
Save bryanp/888a01e66a1f56376cb3cd3aa96275ea to your computer and use it in GitHub Desktop.
Detect Platform Health Checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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