fight-for-net-neutrality 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Bruno Michel <bruno.michel@af83.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ FightForNetNeutrality
2
+ =====================
3
+
4
+ This package is a Rack middleware which allow to block some IP Address.
5
+ By default the french parlement is denied.
6
+
7
+ See http://reflets.info/wp-neutalityfr-la-neutralite-du-net-expliquee-de-maniere-optimalisee-a-muriel/
8
+
9
+
10
+ Usage
11
+ -----
12
+
13
+ Install FightForNetNeutrality:
14
+
15
+ $ gem install fight-for-net-neutrality
16
+
17
+ Then use this middleware in your `config.ru`:
18
+
19
+ require "fight_for_net_neutrality"
20
+ use FightForNetNeutrality
21
+
22
+ If you are using Ruby on Rails, see the [Rails on Rack](http://guides.rubyonrails.org/rails_on_rack.html) guide.
23
+
24
+ You can also define your own IP range:
25
+
26
+ use FightForNetNeutrality, ["62.160.71.0/24"]
27
+
28
+ That's it.
29
+
30
+
31
+ Credits
32
+ -------
33
+
34
+ It's a port to Ruby world of a WSGI middleware:
35
+ https://github.com/gawel/FightForNetNeutrality
36
+
37
+ Copyright (c) 2011 Bruno Michel <bmichel@menfin.info>
38
+ Released under the MIT license
@@ -0,0 +1,63 @@
1
+ # Encoding: utf-8
2
+
3
+ require "rack"
4
+ require "ipaddr"
5
+
6
+
7
+ class FightForNetNeutrality
8
+ def initialize(app, ips=nil)
9
+ ips ||= ["62.160.71.0/24", "84.233.174.48/28", "80.118.39.160/27"]
10
+ @app = app
11
+ @ips_banned = ips.map {|ip| IPAddr.new(ip) }
12
+ @html = HTML % ips.map {|ip| "<li>#{ip}</li>" }.join
13
+ end
14
+
15
+ def call(env)
16
+ req = Rack::Request.new(env)
17
+ if @ips_banned.any? {|ips| ips.include? req.ip }
18
+ [403, {"Content-Type" => "text/html; charset=utf8"}, [@html]]
19
+ else
20
+ @app.call(env)
21
+ end
22
+ end
23
+ end
24
+
25
+
26
+ HTML = <<-EOS
27
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
28
+ <html>
29
+ <head>
30
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
31
+ <title>Ressource inaccessible</title>
32
+ <style>
33
+ h1{font-size:14px; padding-top:5px}
34
+ h2{font-size:12px}
35
+ </style>
36
+ </head>
37
+ <body>
38
+ <div style="width:800px; margin:0 auto;">
39
+ <img src="http://www.paulds.fr/p4ul/blocked/france.jpg" alt="liberté, égalité, fraternité ET Neutralité" style="float:left; margin-right:20px" />
40
+
41
+ <h1>Le serveur (son propriétaire en fait) n'a pas envie de vous laisser accéder à cette ressource...</h1>
42
+ <h2>Et en même temps, vous l'avez bien cherché...</h2>
43
+
44
+ <p style="clear:both; text-align:justify; padding-top:50px">Ce nom de
45
+ domaine, ainsi que beaucoup d'autres, ont été saisis par les
46
+ internautes à la suite d'attaques répétées à l'encontre de la
47
+ Neutralité du Net par les pouvoirs publics.</p>
48
+ <p style="text-align:justify;">Conduire, financer, gêrer, superviser,
49
+ diriger ou proposer une atteinte à la Neutralité du Net revient
50
+ basiquement à s'attaquer à la liberté d'expression du peuple et devrait
51
+ être considéré comme une atteinte manifeste aux droits de l'Homme.</p>
52
+ <p style="text-align:justify;">Il n'y aura aucune suite à cette saisie citoyenne.</p>
53
+ <p style="text-align:justify;">Les plages d'adresses IP filtrées sont les suivantes : </p>
54
+
55
+ <ul>
56
+ %s
57
+ </ul>
58
+ <p>Plus d'informations ici : <a href="http://reflets.info/optimiser-son-internet-a-la-sauce-marland-militello/">Optimiser son Internet à la sauce Marland-Militello</a></p>
59
+
60
+ </div>
61
+ </body>
62
+ </html>
63
+ EOS
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fight-for-net-neutrality
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Bruno Michel
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-23 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rack
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 11
30
+ segments:
31
+ - 1
32
+ - 2
33
+ version: "1.2"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: minitest
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 2
47
+ - 0
48
+ version: "2.0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ description: This package is a Rack middleware which allow to block some IP Address. By default the french parlement is denied.
52
+ email: bruno.michel@af83.com
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - README.md
59
+ files:
60
+ - MIT-LICENSE
61
+ - README.md
62
+ - Gemfile
63
+ - lib/fight_for_net_neutrality.rb
64
+ has_rdoc: true
65
+ homepage: http://github.com/nono/FightForNetNeutrality
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options: []
70
+
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ requirements: []
92
+
93
+ rubyforge_project:
94
+ rubygems_version: 1.5.2
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: This package is a Rack middleware which allow to block some IP Address. By default the french parlement is denied.
98
+ test_files: []
99
+