Class: ObjectStorage::CDN::GoogleIpCache
- Inherits:
-
Object
- Object
- ObjectStorage::CDN::GoogleIpCache
- Defined in:
- app/uploaders/object_storage/cdn/google_ip_cache.rb
Constant Summary collapse
- GOOGLE_CDN_LIST_KEY =
'google_cdn_ip_list'
- CACHE_EXPIRATION_TIME =
1.day
Class Method Summary collapse
- .async_refresh ⇒ Object
- .google_ip?(request_ip) ⇒ Boolean
- .ready? ⇒ Boolean
- .update!(subnets) ⇒ Object
Class Method Details
.async_refresh ⇒ Object
27 28 29 |
# File 'app/uploaders/object_storage/cdn/google_ip_cache.rb', line 27 def async_refresh ::GoogleCloud::FetchGoogleIpListWorker.perform_async end |
.google_ip?(request_ip) ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'app/uploaders/object_storage/cdn/google_ip_cache.rb', line 19 def google_ip?(request_ip) google_ip_ranges = cached_value(GOOGLE_CDN_LIST_KEY) return false unless google_ip_ranges google_ip_ranges.any? { |range| range.include?(request_ip) } end |
.ready? ⇒ Boolean
15 16 17 |
# File 'app/uploaders/object_storage/cdn/google_ip_cache.rb', line 15 def ready? caches.any? { |cache| cache.exist?(GOOGLE_CDN_LIST_KEY) } end |
.update!(subnets) ⇒ Object
11 12 13 |
# File 'app/uploaders/object_storage/cdn/google_ip_cache.rb', line 11 def update!(subnets) caches.each { |cache| cache.write(GOOGLE_CDN_LIST_KEY, subnets) } end |