cloudflare 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +27 -61
- data/cloudflare.gemspec +1 -0
- data/lib/cloudflare/version.rb +1 -1
- data/lib/cloudflare/zones.rb +2 -0
- data/spec/spec_helper.rb +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93312512447e91ad4a4e49d249d0474ce69304fbaed539a49cee2277afdc35f7
|
4
|
+
data.tar.gz: 40c655960faf06672e9b0720cb9e24bfa2b47d09e87bc6e24f23b7def429f014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 212b1e7f5ec0c274676c6458a940eff14c9df4d2e43d990e1a03833bfa2ece184cb85e002a9eafe879ac6e8001e7750d23ebb07efb10bd8f1c02ae31686c5766
|
7
|
+
data.tar.gz: c8e62b92827dc64b0833f821f07b526164a1da58cd408dfbe9b597d5c64a38d51ab805359655049a4dc98ce3e2e520f330ddf58f98039cfcb6e04dfdbeea5c2a
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
It is a Ruby wrapper for the Cloudflare V4 API. It provides a light weight wrapper using `RestClient::Resource`. The wrapper functionality is limited to zones and DNS records at this time, *PRs welcome*.
|
4
4
|
|
5
5
|
[![Build Status](https://secure.travis-ci.org/socketry/cloudflare.svg)](http://travis-ci.org/socketry/cloudflare)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/socketry/cloudflare/badge.svg)](https://coveralls.io/r/socketry/cloudflare)
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -26,7 +27,7 @@ $ gem install cloudflare
|
|
26
27
|
|
27
28
|
## Usage
|
28
29
|
|
29
|
-
|
30
|
+
Here are some basic examples. For more details, refer to the code and specs.
|
30
31
|
|
31
32
|
```ruby
|
32
33
|
require 'cloudflare'
|
@@ -35,66 +36,31 @@ require 'cloudflare'
|
|
35
36
|
email = ENV['CLOUDFLARE_EMAIL']
|
36
37
|
key = ENV['CLOUDFLARE_KEY']
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
Get
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
```ruby
|
64
|
-
dns_record = records.first
|
65
|
-
puts records.first.record[:name]
|
66
|
-
puts records
|
67
|
-
```
|
68
|
-
|
69
|
-
Get firewall rules:
|
70
|
-
|
71
|
-
```ruby
|
72
|
-
all_rules = zones.first.firewall_rules
|
73
|
-
block_rules = zones.first.firewall_rules("block") # or "whitelist" or "challenge"
|
74
|
-
```
|
75
|
-
|
76
|
-
Get blocked ips:
|
77
|
-
|
78
|
-
```ruby
|
79
|
-
block_rules = zones.first.firewall_rules("block")
|
80
|
-
blocked_ips = zones.first.firewall_rules.firewalled_ips(block_rules)
|
81
|
-
```
|
82
|
-
|
83
|
-
Block an ip:
|
84
|
-
|
85
|
-
```ruby
|
86
|
-
# ip = "nnn.nnn.nnn.nnn"
|
87
|
-
# note: "some note about the block"
|
88
|
-
data = {"mode":"block","configuration":{"target":"ip","value":"#{ip}"},"notes":"#{note} #{Time.now.strftime("%m/%d/%y")} "}
|
89
|
-
response = zones.first.firewall_rules.post(data.to_json, content_type: 'application/json')
|
90
|
-
```
|
91
|
-
|
92
|
-
Add a DNS record dynamically. Here we add an A record for `batman.example.com`:
|
93
|
-
|
94
|
-
```ruby
|
95
|
-
client = Cloudflare.connect(key: CF_KEY, email: CF_EMAIL)
|
96
|
-
zone = client.zones.find_by_name("example.com")
|
97
|
-
zone.dns_records.post({"type":"A","name":"batman","content":"127.0.0.1","proxied":false}.to_json, :content_type => "application/json")
|
39
|
+
Cloudflare.connect(key: key, email: email) do
|
40
|
+
# Get all available zones:
|
41
|
+
zones = connection.zones
|
42
|
+
|
43
|
+
# Get a specific zone:
|
44
|
+
zone = connection.zones.find_by_id("...")
|
45
|
+
zone = connection.zones.find_by_name("example.com")
|
46
|
+
|
47
|
+
# Get DNS records for a given zone:
|
48
|
+
dns_records = zone.dns_records
|
49
|
+
|
50
|
+
# Show some details of the DNS record:
|
51
|
+
dns_record = dns_records.first
|
52
|
+
puts dns_record.name
|
53
|
+
|
54
|
+
# Add a DNS record. Here we add an A record for `batman.example.com`:
|
55
|
+
zone = zones.find_by_name("example.com")
|
56
|
+
zone.dns_records.create('A', 'batman', '1.2.3.4', proxied: false)
|
57
|
+
|
58
|
+
# Get firewall rules:
|
59
|
+
all_rules = zone.firewall_rules
|
60
|
+
|
61
|
+
# Block an ip:
|
62
|
+
rule = zone.firewall_rules.set('block', '1.2.3.4', notes: "ssh dictionary attack")
|
63
|
+
end
|
98
64
|
```
|
99
65
|
|
100
66
|
## Contributing
|
data/cloudflare.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_development_dependency 'async-rspec'
|
27
27
|
|
28
|
+
spec.add_development_dependency 'covered'
|
28
29
|
spec.add_development_dependency 'bundler'
|
29
30
|
spec.add_development_dependency 'rake'
|
30
31
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
data/lib/cloudflare/version.rb
CHANGED
data/lib/cloudflare/zones.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudflare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Prokop
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: async-rest
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: covered
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: bundler
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
145
|
- !ruby/object:Gem::Version
|
132
146
|
version: '0'
|
133
147
|
requirements: []
|
134
|
-
rubygems_version: 3.0.
|
148
|
+
rubygems_version: 3.0.2
|
135
149
|
signing_key:
|
136
150
|
specification_version: 4
|
137
151
|
summary: A Ruby wrapper for the Cloudflare API.
|