ipecache 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTBjYjQ0NmZiMWI1NTllNjdhYTNkM2YzN2JkNTBjNzc5MjliODE1NQ==
4
+ ZWYxNWE2YWQwNjExY2E0NWUzMzk3ZTAwMDJmYjEzYjk4Nzc2OWY4Nw==
5
5
  data.tar.gz: !binary |-
6
- OGFkY2RiMmZiOTcwZDA4OGJiZmQ3MDhhZDM0YzhhODA1ZDgyYTkwZg==
6
+ MzJiMTJiZGMxMWRjNzQxZGEzY2QxYWRjM2U5M2M2Y2RhOWI5ZGNmNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDZiMGM4NjA3ZGUyYzViNzJkNTc4YmZjOWU1OWYxNzEyMzcxNzYxZGU3YTQx
10
- NjljNzMxZGUyZWM4NjJmYzgwOGQ5MTMwNTdiMTFkYTE2Y2UwNmYwNzdjZTY1
11
- YWRlM2Q2MmU1NGE0MjM3NmQ3MGU4OGE5NTYzOGJhNjMxYTUwNjA=
9
+ OTdjZjdlMTdhMjVmZDZkOTNlZjBhNzdkY2JjY2UwYjgzY2MyY2I0MDk2ODZl
10
+ NTc5OTFhMDgwMmNiZjdhMzljZGMzOWQ0NDBhMjg3NzcyZDA3YWJjMTIxY2Q5
11
+ MTdlMmY3Zjc1NGQzNWVjYWNkMWNkNTFiM2JhNDRkZjU4M2NjMTc=
12
12
  data.tar.gz: !binary |-
13
- YTQ3OGFiNDJkZmE2YWM0YzNmZTNmNmExOTRlODA3MzNjOTQ3N2VjOTFjNmVj
14
- ZTAwMjljN2EwYjdlN2UyYmQ3ZGRmMDIxNWJiOGJiMzU0ZWEzZmFiMzMxNTRi
15
- NzY5MTRhYWY5ZWUyODQ4NTA1ZDk2YzYyYjIyYzNlMmU1NzZmYTk=
13
+ ZjFkODA2YTRjZjMwNDk2NTRhN2E1NDA3YWM4ZGEyNTAxZTg5YWRhZjJiZmM0
14
+ YzMzOTgxZWNhYmQ0MGZiYWE2MzE2ZGE5ZjY1YzM3MzNlNmJiMzgyMmRkOGNi
15
+ NTkxYTEwNGRmZGQxN2Q4ZWQ4ZWM5MTBjNTVkYzNmZTAyMGUxZTI=
@@ -1,7 +1,23 @@
1
+ ## 0.0.6 (April 28, 2014)
2
+
3
+ Features:
4
+
5
+ - Cloudflare plugin (Thanks to https://github.com/adedommelin)
6
+ - Add quiet mode (Thanks to https://github.com/nespresso)
7
+ - Add -n short option to --nofail (Thanks to https://github.com/nespresso)
8
+
9
+ Bugfixes:
10
+
11
+ - Fix plugin_puts_error to print URL (Thanks to https://github.com/nespresso)
12
+
1
13
  ## 0.0.5 (April 25, 2014)
2
14
 
3
- Switched Akamai plugin to use new CCUAPI (Thanks to https://github.com/adedommelin)
15
+ Features:
16
+
17
+ - Switched Akamai plugin to use new CCUAPI (Thanks to https://github.com/adedommelin)
4
18
 
5
19
  ## 0.0.1 (March 20, 2013)
6
20
 
7
- Initial version.
21
+ Features:
22
+
23
+ - Initial version.
@@ -1,21 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ipecache (0.0.5)
4
+ ipecache (0.0.4)
5
5
  app_conf (>= 0.4.0)
6
6
  choice (>= 0.1.6)
7
7
  faraday_middleware (>= 0.9.0)
8
+ savon (>= 2.1.0)
8
9
 
9
10
  GEM
10
11
  remote: http://rubygems.org/
11
12
  specs:
12
- app_conf (0.4.1)
13
+ akami (1.2.0)
14
+ gyoku (>= 0.4.0)
15
+ nokogiri (>= 1.4.0)
16
+ app_conf (0.4.0)
17
+ builder (3.0.0)
13
18
  choice (0.1.6)
14
- faraday (0.8.8)
15
- multipart-post (~> 1.2.0)
19
+ faraday (0.8.6)
20
+ multipart-post (~> 1.1)
16
21
  faraday_middleware (0.9.0)
17
22
  faraday (>= 0.7.4, < 0.9)
23
+ gyoku (1.0.0)
24
+ builder (>= 2.1.2)
25
+ httpi (2.0.2)
26
+ rack
18
27
  multipart-post (1.2.0)
28
+ nokogiri (1.5.9)
29
+ nori (2.0.4)
30
+ rack (1.4.1)
31
+ savon (2.1.0)
32
+ akami (~> 1.2.0)
33
+ builder (>= 2.1.2)
34
+ gyoku (~> 1.0.0)
35
+ httpi (~> 2.0.2)
36
+ nokogiri (>= 1.4.0)
37
+ nori (~> 2.0.3)
38
+ wasabi (~> 3.0.0)
39
+ wasabi (3.0.0)
40
+ httpi (~> 2.0)
41
+ nokogiri (>= 1.4.0)
19
42
 
20
43
  PLATFORMS
21
44
  ruby
data/README.md CHANGED
@@ -45,6 +45,9 @@ plugins:
45
45
  akamai:
46
46
  username: myusername
47
47
  password: mypassword
48
+ cloudflare:
49
+ login: foo@bar.com
50
+ api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
48
51
  ```
49
52
 
50
53
  #### atschef
@@ -59,6 +62,9 @@ For more information on how to configure the Edgecast CDN plugin, please read th
59
62
  #### Akamai
60
63
  For more information on how to configure the Akamai plugin, please read the [plugins/Akamai.md](plugins/Akamai.md) file.
61
64
 
65
+ #### CloudFlare
66
+ For more information on how to configure the CloudFlare plugin, please read the [plugins/CloudFlare.md](plugins/CloudFlare.md) file.
67
+
62
68
 
63
69
 
64
70
  Ipecache Usage
@@ -67,7 +73,7 @@ The main component of Ipecache, and the program which initialises and calls all
67
73
 
68
74
  #### Usage
69
75
  ```bash
70
- ipecache [-f -u -c -p -l --status]
76
+ ipecache [-f -u -c -p -l -q --status]
71
77
  ```
72
78
 
73
79
  * Mandatory Parameters (you must specify one or the other)
@@ -79,7 +85,8 @@ ipecache [-f -u -c -p -l --status]
79
85
  * -c: Indicates that only CDN plugins should be run
80
86
  * -p: Indicates that only local proxy plugins should be run.
81
87
  * -l: Specify a file to log errors to
82
- * --nofail: Do not quit on error, continue purging
88
+ * -n, --nofail: Do not quit on error, continue purging
89
+ * -q, --quiet: Suppress all console output
83
90
 
84
91
 
85
92
  #### Example (Checking plugin status)
@@ -179,4 +186,4 @@ $> ipecache -f ~/urlfile
179
186
  Ipecache::Plugins::Fastly: Purge successful!
180
187
 
181
188
  All done!
182
- ```
189
+ ```
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # ipecache - A command line memcached traffic analyzer
3
+ # ipecache - Extensible tool for purging URLs from Caches and CDNs.
4
4
  #
5
5
  # Author:: Jon Cowie (<jcowie@etsy.com>)
6
6
 
@@ -48,9 +48,20 @@ Choice.options do
48
48
  end
49
49
 
50
50
  option :continue_on_error, :required => false do
51
+ short '-n'
51
52
  long '--nofail'
52
53
  desc 'Continue on errors instead of exiting'
53
54
  end
55
+
56
+ option :quiet_mode, :required => false do
57
+ short '-q'
58
+ long '--quiet'
59
+ desc 'Suppress all console output'
60
+ end
61
+ end
62
+
63
+ if Choice.choices[:quiet_mode]
64
+ @quiet_mode = Choice.choices[:quiet_mode]
54
65
  end
55
66
 
56
67
  if Choice.choices[:status]
@@ -70,7 +81,9 @@ elsif Choice.choices[:urlfile]
70
81
  if File.exists?(urlfile)
71
82
  @urls = File.open(urlfile, 'r').readlines
72
83
  else
73
- puts "Error: #{urlfile} doesn't exist."
84
+ if !@quiet_mode
85
+ puts "Error: #{urlfile} doesn't exist."
86
+ end
74
87
  exit 1
75
88
  end
76
89
  else
@@ -86,18 +99,24 @@ if Choice.choices[:continue_on_error]
86
99
  end
87
100
 
88
101
  if !Choice.choices[:cdnonly]
89
- puts ""
90
- puts "Running plugins registered for Proxy Purge..."
91
- puts ""
102
+ if !@quiet_mode
103
+ puts ""
104
+ puts "Running plugins registered for Proxy Purge..."
105
+ puts ""
106
+ end
92
107
  run_plugins(:proxy_purge)
93
108
  end
94
109
 
95
110
  if !Choice.choices[:proxyonly]
96
- puts ""
97
- puts "Running plugins registered for CDN Purge..."
98
- puts ""
111
+ if !@quiet_mode
112
+ puts ""
113
+ puts "Running plugins registered for CDN Purge..."
114
+ puts ""
115
+ end
99
116
  run_plugins(:cdn_purge)
100
117
  end
101
118
 
102
- puts ""
103
- puts "All done!"
119
+ if !@quiet_mode
120
+ puts ""
121
+ puts "All done!"
122
+ end
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'ipecache'
5
- gem.version = '0.0.5'
5
+ gem.version = '0.0.6'
6
6
  gem.authors = ["Jon Cowie"]
7
7
  gem.email = 'jonlives@gmail.com'
8
8
  gem.homepage = 'https://github.com/jonlives/ipecache'
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.add_runtime_dependency 'app_conf', '>= 0.4.0'
19
19
  gem.add_runtime_dependency 'choice', '>= 0.1.6'
20
20
  gem.add_runtime_dependency 'faraday_middleware', '>= 0.9.0'
21
+ gem.add_runtime_dependency 'public_suffix', '>= 1.4.2'
21
22
  end
@@ -23,7 +23,6 @@ module Ipecache
23
23
  exit 1
24
24
  end
25
25
 
26
- puts ""
27
26
  plugin_puts "Beginning URL Purge from Akamai..."
28
27
 
29
28
  urls.each do |u|
@@ -29,7 +29,6 @@ module Ipecache
29
29
  exit 1
30
30
  end
31
31
 
32
- puts ""
33
32
  plugin_puts "Beginning URL Purge from ATS..."
34
33
  plugin_puts "Finding ATS Servers..."
35
34
  nodes_ats_fqdns = []
@@ -58,4 +57,4 @@ module Ipecache
58
57
  end
59
58
  end
60
59
  end
61
- end
60
+ end
@@ -0,0 +1,70 @@
1
+ require 'ipecache/plugins/plugin'
2
+
3
+ module Ipecache
4
+ module Plugins
5
+ class CloudFlare < Plugin
6
+ name :cloudflare
7
+ hooks :cdn_purge
8
+
9
+ def perform
10
+ safe_require 'uri'
11
+ safe_require 'faraday_middleware'
12
+ safe_require 'json'
13
+ safe_require 'public_suffix'
14
+
15
+ login = config.login
16
+ api_key = config.api_key
17
+
18
+ if login.nil?
19
+ plugin_puts "CloudFlare login not specified, Exiting..."
20
+ exit 1
21
+ end
22
+
23
+ if api_key.nil?
24
+ plugin_puts "CloudFlare API key not specified, Exiting..."
25
+ exit 1
26
+ end
27
+
28
+ plugin_puts "Beginning URL Purge from CloudFlare..."
29
+
30
+ urls.each do |u|
31
+ url = u.chomp
32
+ plugin_puts "Purging #{url}"
33
+
34
+ uri = URI.parse(url)
35
+ zone = PublicSuffix.parse(uri.host).domain
36
+
37
+ connection = Faraday::Connection.new(
38
+ {:url => "https://www.cloudflare.com",
39
+ :headers => { :accept => 'application/json',
40
+ :user_agent => 'Ipecache'
41
+ },
42
+ :ssl => { :verify => true }
43
+ }) do |builder|
44
+ builder.request :url_encoded
45
+ builder.adapter Faraday.default_adapter
46
+ end
47
+
48
+ response = connection.get("/api_json.html",
49
+ { :act => 'zone_file_purge',
50
+ :tkn => api_key,
51
+ :email => login,
52
+ :z => zone,
53
+ :url => url
54
+ })
55
+
56
+ response_json = JSON.parse(response.body)
57
+ response_result = response_json['result']
58
+
59
+ if response_result != 'success'
60
+ plugin_puts_error(url,"Purge failed!")
61
+ plugin_puts response.body
62
+ exit 1 unless continue_on_error
63
+ else
64
+ plugin_puts "Purge successful!"
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -24,7 +24,6 @@ module Ipecache
24
24
  exit 1
25
25
  end
26
26
 
27
- puts ""
28
27
  plugin_puts "Beginning URL Purge from Edgecast..."
29
28
 
30
29
  urls.each do |u|
@@ -56,4 +55,4 @@ module Ipecache
56
55
  end
57
56
  end
58
57
  end
59
- end
58
+ end
@@ -17,7 +17,6 @@ module Ipecache
17
17
  exit 1
18
18
  end
19
19
 
20
- puts ""
21
20
  plugin_puts "Beginning URL Purge from Fastly..."
22
21
 
23
22
  urls.each do |u|
@@ -57,4 +56,4 @@ class Net::HTTP::Purge < Net::HTTPRequest
57
56
  METHOD = 'PURGE'
58
57
  REQUEST_HAS_BODY = false
59
58
  RESPONSE_HAS_BODY = true
60
- end
59
+ end
@@ -21,6 +21,9 @@ module Ipecache
21
21
  # hook. That will be fired when the hook is fired.
22
22
  def self.hook(the_hook)
23
23
  self.send(:define_method, the_hook.to_sym) do
24
+ if !quiet_mode
25
+ puts ""
26
+ end
24
27
  perform
25
28
  end
26
29
  end
@@ -47,19 +50,28 @@ module Ipecache
47
50
  @options[:continue_on_error]
48
51
  end
49
52
 
53
+ def quiet_mode
54
+ @options[:quiet_mode]
55
+ end
56
+
50
57
  def name
51
58
  self.class.to_s
52
59
  end
53
60
 
54
61
  def plugin_puts(message)
55
- puts "#{name}: #{message}"
62
+ if !quiet_mode
63
+ puts "#{name}: #{message}"
64
+ end
56
65
  end
57
66
 
58
67
  def plugin_puts_error(url,message)
59
68
  if log_file
60
69
  File.open(log_file, 'a') { |file| file.write("#{Time.now.getutc} #{url} #{name}: #{message}\n") }
61
70
  end
62
- puts "#{name}: #{message}"
71
+
72
+ if !quiet_mode
73
+ puts "#{url} #{name}: #{message}"
74
+ end
63
75
  end
64
76
 
65
77
  private
@@ -26,12 +26,14 @@ module Ipecache
26
26
  urls = @urls
27
27
  log_file = @log_file
28
28
  continue_on_error = @continue_on_error
29
+ quiet_mode = @quiet_mode
29
30
  Ipecache::Plugins.run(
30
31
  :config => ipecache_config,
31
32
  :hook => hook.to_sym,
32
33
  :urls => urls,
33
34
  :log_file => log_file,
34
- :continue_on_error => continue_on_error
35
+ :continue_on_error => continue_on_error,
36
+ :quiet_mode => quiet_mode
35
37
  )
36
38
  end
37
39
 
@@ -0,0 +1,26 @@
1
+ CloudFlare
2
+ ==========
3
+ Purge URLs from the CloudFlare CDN.
4
+
5
+ Hooks
6
+ -----
7
+ - `cdn_purge`
8
+
9
+ Configuration
10
+ -------------
11
+ ```yaml
12
+ plugins:
13
+ cloudflare:
14
+ login: foo@bar.com
15
+ api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
16
+ ```
17
+
18
+ #### login
19
+ This is your standard CloudFlare login.
20
+
21
+ - Type: `String`
22
+
23
+ #### api_key
24
+ Associated API Key, available on the "Account" page.
25
+
26
+ - Type: `String`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipecache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Cowie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: app_conf
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: public_suffix
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.4.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.4.2
55
69
  description: An extensible tool for purging urls from caches and CDNs
56
70
  email: jonlives@gmail.com
57
71
  executables:
@@ -71,12 +85,14 @@ files:
71
85
  - lib/ipecache/plugins.rb
72
86
  - lib/ipecache/plugins/akamai.rb
73
87
  - lib/ipecache/plugins/ats_chef.rb
88
+ - lib/ipecache/plugins/cloudflare.rb
74
89
  - lib/ipecache/plugins/edgecast.rb
75
90
  - lib/ipecache/plugins/fastly.rb
76
91
  - lib/ipecache/plugins/plugin.rb
77
92
  - lib/ipecache/runner.rb
78
93
  - plugins/ATSChef.md
79
94
  - plugins/Akamai.md
95
+ - plugins/CloudFlare.md
80
96
  - plugins/Edgecast.md
81
97
  - plugins/Fastly.md
82
98
  - plugins/README.md