cloudflare-ips 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d0f532395dd7fc445e792dbb324041f746fdc44092ad286873faca044c74d8c9
4
+ data.tar.gz: 0325b4e55c9eb39b3c15afa5c99775b1370dd7bee6556aff99acc7592043b29b
5
+ SHA512:
6
+ metadata.gz: 9492f3bbe86e0f9d6cce97e23c731ac2c9bac91d969a01b9b470de02b510892e0c120ca3e027bf7b6fb3893d0464d64cb263cd21a27d028ffe4be0fa9da59ae4
7
+ data.tar.gz: 6adfb4a0e55e0034bf9b1fea5d6430a5a020d16e1b84f0b6e9fd1f46ee730fffd710c549eccaac0d2ddeb9a19fb3e9487a7254de0376ffd2498d7f1dc5360f6c
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kevin Sylvestre
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # OmniAI
2
+
3
+ [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ksylvest/cloudflare_ips/blob/main/LICENSE)
4
+ [![RubyGems](https://img.shields.io/gem/v/cloudflare_ips)](https://rubygems.org/gems/cloudflare_ips)
5
+ [![GitHub](https://img.shields.io/badge/github-repo-blue.svg)](https://github.com/ksylvest/cloudflare_ips)
6
+ [![Yard](https://img.shields.io/badge/docs-site-blue.svg)](https://cloudflare_ips.ksylvest.com)
7
+ [![CircleCI](https://img.shields.io/circleci/build/github/ksylvest/cloudflare_ips)](https://circleci.com/gh/ksylvest/cloudflare_ips)
8
+
9
+ ## Installation
10
+
11
+ ```ruby
12
+ group :production do
13
+ gem "cloudflare_ips"
14
+ end
15
+ ```
16
+
17
+ ```bash
18
+ $ bundle
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ request.remote_ip # avoid request.ip
25
+ ```
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+
5
+ require 'bundler/gem_tasks'
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudflareIPs
4
+ # Configure trusted_proxies with Cloudflare IPv4 and IPv6 addresses.
5
+ class Railtie < ::Rails::Railtie
6
+ initializer 'cloudflare_ips.configure_rails_initialization' do |app|
7
+ app.config.action_dispatch.trusted_proxies += CloudflareIPs::IPS_V4 + CloudflareIPs::IPS_V6
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudflareIps
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cloudflare_ips/version'
4
+ require 'cloudflare_ips/railtie'
5
+
6
+ module CloudflareIPs
7
+ # https://www.cloudflare.com/ips-v4/
8
+ IPS_V4 = %w[
9
+ 173.245.48.0/20
10
+ 103.21.244.0/22
11
+ 103.22.200.0/22
12
+ 103.31.4.0/22
13
+ 141.101.64.0/18
14
+ 108.162.192.0/18
15
+ 190.93.240.0/20
16
+ 188.114.96.0/20
17
+ 197.234.240.0/22
18
+ 198.41.128.0/17
19
+ 162.158.0.0/15
20
+ 104.16.0.0/13
21
+ 104.24.0.0/14
22
+ 172.64.0.0/13
23
+ 131.0.72.0/22
24
+ ].map { |proxy| IPAddr.new(proxy) }
25
+
26
+ # https://www.cloudflare.com/ips-v6/
27
+ IPS_V6 = %w[
28
+ 2400:cb00::/32
29
+ 2606:4700::/32
30
+ 2803:f800::/32
31
+ 2405:b500::/32
32
+ 2405:8100::/32
33
+ 2a06:98c0::/29
34
+ 2c0f:f248::/32
35
+ ].map { |proxy| IPAddr.new(proxy) }
36
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloudflare-ips
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Sylvestre
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 7.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 7.0.0
27
+ description: This library ensures Cloudflare IPs are used with rails.
28
+ email:
29
+ - kevin@ksylvest.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - lib/cloudflare_ips.rb
38
+ - lib/cloudflare_ips/railtie.rb
39
+ - lib/cloudflare_ips/version.rb
40
+ homepage: https://github.com/ksylvest/cloudflare_ips
41
+ licenses:
42
+ - MIT
43
+ metadata:
44
+ homepage_uri: https://github.com/ksylvest/cloudflare_ips
45
+ changelog_uri: https://github.com/ksylvest/cloudflare_ips/releases
46
+ rubygems_mfa_required: 'true'
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '3.2'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.5.22
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: A library to configure Cloudflare trusted IPs.
66
+ test_files: []