├── .gitignore
├── Gemfile
├── site
├── .DS_Store
├── review.jpg
├── complete.jpg
├── landing_page.jpg
└── paypal_login.jpg
├── public
├── images
│ ├── bbc.gif
│ ├── cantine.png
│ ├── church.jpg
│ ├── coffee.jpg
│ ├── football.jpg
│ └── ajax-loader.gif
├── javascript
│ └── donate.js
└── css
│ ├── main.css
│ ├── church.css
│ └── football.css
├── bin
├── configure.sh
├── stop_routing.sh
├── start_cleanpath.sh
├── rmtrack
└── start_routing.sh
├── Gemfile.lock
├── views
├── callback.erb
├── donate.erb
├── football.erb
└── church.erb
├── redirect.rb
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .rvmrc
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source :rubygems
2 | gem "thin"
3 |
4 | gem "sinatra"
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/site/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/site/.DS_Store
--------------------------------------------------------------------------------
/site/review.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/site/review.jpg
--------------------------------------------------------------------------------
/site/complete.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/site/complete.jpg
--------------------------------------------------------------------------------
/public/images/bbc.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/public/images/bbc.gif
--------------------------------------------------------------------------------
/site/landing_page.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/site/landing_page.jpg
--------------------------------------------------------------------------------
/site/paypal_login.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/site/paypal_login.jpg
--------------------------------------------------------------------------------
/public/images/cantine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/public/images/cantine.png
--------------------------------------------------------------------------------
/public/images/church.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/public/images/church.jpg
--------------------------------------------------------------------------------
/public/images/coffee.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/public/images/coffee.jpg
--------------------------------------------------------------------------------
/public/images/football.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/public/images/football.jpg
--------------------------------------------------------------------------------
/bin/configure.sh:
--------------------------------------------------------------------------------
1 | #/bin/sh
2 |
3 | dhclient eth0
4 |
5 | ifconfig eth1 172.16.254.1 netmask 255.255.255.0
6 |
7 |
8 |
--------------------------------------------------------------------------------
/public/images/ajax-loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomoconnor/captive-backend/HEAD/public/images/ajax-loader.gif
--------------------------------------------------------------------------------
/bin/stop_routing.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | sudo iptables -t nat --flush
3 | sudo iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
4 | sudo iptables --append FORWARD --in-interface eth1 -j ACCEPT
5 |
--------------------------------------------------------------------------------
/bin/start_cleanpath.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | sudo iptables -t nat --flush
4 | sudo iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
5 | sudo iptables --append FORWARD --in-interface eth1 -j ACCEPT
6 |
--------------------------------------------------------------------------------
/public/javascript/donate.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function(){
2 |
3 |
4 | $(".donate-buttons a").click(function(){
5 | $(".donate-buttons a").removeClass("active");
6 | $(this).addClass("active");
7 | $("form input[name=amount]").val($(this).data("amount"));
8 | });
9 | });
--------------------------------------------------------------------------------
/bin/rmtrack:
--------------------------------------------------------------------------------
1 | /usr/sbin/conntrack -L \
2 | |grep $1 \
3 | |grep ESTAB \
4 | |grep 'dport=80' \
5 | |awk \
6 | "{ system(\"conntrack -D --orig-src $1 --orig-dst \" \
7 | substr(\$6,5) \" -p tcp --orig-port-src \" substr(\$7,7) \" \
8 | --orig-port-dst 80\"); }"
9 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: http://rubygems.org/
3 | specs:
4 | daemons (1.1.9)
5 | eventmachine (1.0.0)
6 | rack (1.4.1)
7 | rack-protection (1.2.0)
8 | rack
9 | sinatra (1.3.3)
10 | rack (~> 1.3, >= 1.3.6)
11 | rack-protection (~> 1.2)
12 | tilt (~> 1.3, >= 1.3.3)
13 | thin (1.5.0)
14 | daemons (>= 1.0.9)
15 | eventmachine (>= 0.12.6)
16 | rack (>= 1.0.0)
17 | tilt (1.3.3)
18 |
19 | PLATFORMS
20 | ruby
21 |
22 | DEPENDENCIES
23 | sinatra
24 | thin
25 |
--------------------------------------------------------------------------------
/views/callback.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
12 | Simply Good Coffee Company
13 |
14 |
15 |
16 |
Enjoy our free WiFi
17 |
18 |
19 | Vestibulum id ligula porta felis euismod semper. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas faucibus mollis interdum. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
20 |
21 |
22 | Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
23 |
24 |
25 |
26 |
27 |
Donate
28 |
29 |
For every £ donated to our charity of the week, we will match the amount.
30 |
31 |
32 |
33 |
38 |
39 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/views/football.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Fast Scoring Rangers
13 |
14 |
15 |
16 |
Enjoy our free WiFi
17 |
18 |
19 | Vestibulum id ligula porta felis euismod semper. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas faucibus mollis interdum. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
20 |
21 |
22 | Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
23 |
24 |
25 |
26 |
27 |
We're renovating the cantina
28 |
29 |
We're trying to raise £10.000 to renovate the cantina. The last time the cantina was renovated was in 1982, and it's in real need of some TLC.
30 |
31 |
32 |
33 |
38 |
39 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/views/church.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Hubbard's Church of Sinful Mistakes
13 |
14 |
15 |
16 |
Enjoy our free WiFi
17 |
18 |
19 | Vestibulum id ligula porta felis euismod semper. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas faucibus mollis interdum. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
20 |
21 |
22 | Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
23 |
24 |
25 |
26 |
27 |
We're renovating the cantina
28 |
29 |
We're trying to raise £10.000 to renovate the cantina. The last time the cantina was renovated was in 1982, and it's in real need of some TLC.
30 |
31 |
32 |
33 |
38 |
39 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/public/css/main.css:
--------------------------------------------------------------------------------
1 | /* http://meyerweb.com/eric/tools/css/reset/
2 | v2.0 | 20110126
3 | License: none (public domain)
4 | */
5 |
6 | html, body, div, span, applet, object, iframe,
7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8 | a, abbr, acronym, address, big, cite, code,
9 | del, dfn, em, img, ins, kbd, q, s, samp,
10 | small, strike, strong, sub, sup, tt, var,
11 | b, u, i, center,
12 | dl, dt, dd, ol, ul, li,
13 | fieldset, form, label, legend,
14 | table, caption, tbody, tfoot, thead, tr, th, td,
15 | article, aside, canvas, details, embed,
16 | figure, figcaption, footer, header, hgroup,
17 | menu, nav, output, ruby, section, summary,
18 | time, mark, audio, video {
19 | margin: 0;
20 | padding: 0;
21 | border: 0;
22 | font-size: 100%;
23 | font: inherit;
24 | vertical-align: baseline;
25 | }
26 | /* HTML5 display-role reset for older browsers */
27 | article, aside, details, figcaption, figure,
28 | footer, header, hgroup, menu, nav, section {
29 | display: block;
30 | }
31 | body {
32 | line-height: 1;
33 | }
34 | ol, ul {
35 | list-style: none;
36 | }
37 | blockquote, q {
38 | quotes: none;
39 | }
40 | blockquote:before, blockquote:after,
41 | q:before, q:after {
42 | content: '';
43 | content: none;
44 | }
45 | table {
46 | border-collapse: collapse;
47 | border-spacing: 0;
48 | }
49 |
50 | body {
51 | background-color: #6F442A;
52 | background: url("/images/coffee.jpg");
53 | font-family: Arial, sans-serif;
54 | }
55 |
56 | .description {
57 | color: #ccc;
58 | width: 400px;
59 | float: left;
60 | padding-bottom: 20px;
61 | margin: 50px 25px 0px 100px;
62 | background-color: rgba(0,0,0, 0.5);
63 | }
64 |
65 | .description h1 {
66 | background-color: rgba(255, 255, 255, 0.9);
67 | padding: 20px;
68 | color: #333;
69 | font-weight: bold;
70 | font-size: 25px;
71 | line-height: 35px;
72 | /* font-family: 'Cinzel Decorative', cursive;*/
73 | }
74 |
75 | .description p {
76 | padding: 20px 20px 0px 20px;
77 | font-size: 16px;
78 | line-height: 22px;
79 | }
80 |
81 | .donate {
82 | color: white;
83 | width: 500px;
84 | float: left;
85 | margin: 50px 0px 0px 25px;
86 | background-color: rgba(0,0,0, 0.5);
87 | }
88 |
89 | .donate h1 {
90 | background-color: rgba(255, 255, 255, 0.9);
91 | padding: 20px;
92 | color: #333;
93 | font-weight: bold;
94 | font-size: 25px;
95 | line-height: 35px;
96 | /* font-family: 'Cinzel Decorative', cursive;*/
97 | }
98 |
99 | .title {
100 | background-color: rgba(255, 255, 255, 0.9);
101 | padding: 20px 100px;
102 | font-weight: bold;
103 | font-size: 30px;
104 | font-family: 'Cinzel Decorative', cursive;
105 | }
106 |
107 | .title img {
108 | height: 30px;
109 | }
110 |
111 | .donate center img {
112 | background-color: white;
113 | height: 60px;
114 | }
115 |
116 | .donate p {
117 | padding: 20px 20px 0px 20px;
118 | font-size: 16px;
119 | line-height: 22px;
120 | color: #ccc;
121 | }
122 |
123 | .donate-buttons {
124 | padding: 20px 95px;
125 | overflow: auto;
126 | }
127 |
128 | .donate-buttons a {
129 | float: left;
130 | background: #FFF9EE;
131 | width: 100px;
132 | text-align: center;
133 | text-decoration: none;
134 | padding: 10px 0px;
135 | border-right: 2px solid #aaa;
136 | color: #003366;
137 | font-weight: bold;
138 | }
139 |
140 | .donate-buttons a.first {
141 | border-radius: 5px 0px 0px 5px;
142 | }
143 |
144 | .donate-buttons a.last {
145 | border-radius: 0px 5px 5px 0px;
146 | border: none;
147 | }
148 |
149 | .donate-buttons a.active {
150 | background-color: #FFAC2D;
151 | }
152 |
153 | form {
154 | overflow: auto;
155 | padding: 20px 20px;
156 | }
157 |
158 | form a {
159 | float: right;
160 | color: #fff;
161 | margin-right: 20px;
162 | position: relative;
163 | top: 5px;
164 | }
165 |
166 | form input[type=image]{
167 | float: right;
168 | }
--------------------------------------------------------------------------------
/public/css/church.css:
--------------------------------------------------------------------------------
1 | /* http://meyerweb.com/eric/tools/css/reset/
2 | v2.0 | 20110126
3 | License: none (public domain)
4 | */
5 |
6 | html, body, div, span, applet, object, iframe,
7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8 | a, abbr, acronym, address, big, cite, code,
9 | del, dfn, em, img, ins, kbd, q, s, samp,
10 | small, strike, strong, sub, sup, tt, var,
11 | b, u, i, center,
12 | dl, dt, dd, ol, ul, li,
13 | fieldset, form, label, legend,
14 | table, caption, tbody, tfoot, thead, tr, th, td,
15 | article, aside, canvas, details, embed,
16 | figure, figcaption, footer, header, hgroup,
17 | menu, nav, output, ruby, section, summary,
18 | time, mark, audio, video {
19 | margin: 0;
20 | padding: 0;
21 | border: 0;
22 | font-size: 100%;
23 | font: inherit;
24 | vertical-align: baseline;
25 | }
26 | /* HTML5 display-role reset for older browsers */
27 | article, aside, details, figcaption, figure,
28 | footer, header, hgroup, menu, nav, section {
29 | display: block;
30 | }
31 | body {
32 | line-height: 1;
33 | }
34 | ol, ul {
35 | list-style: none;
36 | }
37 | blockquote, q {
38 | quotes: none;
39 | }
40 | blockquote:before, blockquote:after,
41 | q:before, q:after {
42 | content: '';
43 | content: none;
44 | }
45 | table {
46 | border-collapse: collapse;
47 | border-spacing: 0;
48 | }
49 |
50 | body {
51 | background-color: #6F442A;
52 | background: url("/images/church.jpg");
53 | font-family: Arial, sans-serif;
54 | }
55 |
56 | .description {
57 | color: #ccc;
58 | width: 400px;
59 | float: left;
60 | padding-bottom: 20px;
61 | margin: 50px 25px 0px 100px;
62 | background-color: rgba(0,0,0, 0.5);
63 | }
64 |
65 | .description h1 {
66 | background-color: rgba(255, 255, 255, 0.9);
67 | padding: 20px;
68 | color: #333;
69 | font-weight: bold;
70 | font-size: 25px;
71 | line-height: 35px;
72 | /* font-family: 'Cinzel Decorative', cursive;*/
73 | }
74 |
75 | .description p {
76 | padding: 20px 20px 0px 20px;
77 | font-size: 16px;
78 | line-height: 22px;
79 | }
80 |
81 | .donate {
82 | color: white;
83 | width: 500px;
84 | float: left;
85 | margin: 50px 0px 0px 25px;
86 | background-color: rgba(0,0,0, 0.5);
87 | }
88 |
89 | .donate h1 {
90 | background-color: rgba(255, 255, 255, 0.9);
91 | padding: 20px;
92 | color: #333;
93 | font-weight: bold;
94 | font-size: 25px;
95 | line-height: 35px;
96 | /* font-family: 'Cinzel Decorative', cursive;*/
97 | }
98 |
99 | .title {
100 | background-color: rgba(255, 255, 255, 0.9);
101 | padding: 20px 100px;
102 | font-weight: bold;
103 | font-size: 30px;
104 | font-family: 'Cinzel Decorative', cursive;
105 | }
106 |
107 | .title img {
108 | height: 30px;
109 | }
110 |
111 | .donate center img {
112 | background-color: white;
113 | width: 400px;
114 | margin: 20px 0px;
115 | }
116 |
117 | .donate p {
118 | padding: 20px 20px 0px 20px;
119 | font-size: 16px;
120 | line-height: 22px;
121 | color: #ccc;
122 | }
123 |
124 | .donate-buttons {
125 | padding: 20px 95px;
126 | overflow: auto;
127 | }
128 |
129 | .donate-buttons a {
130 | float: left;
131 | background: #FFF9EE;
132 | width: 100px;
133 | text-align: center;
134 | text-decoration: none;
135 | padding: 10px 0px;
136 | border-right: 2px solid #aaa;
137 | color: #003366;
138 | font-weight: bold;
139 | }
140 |
141 | .donate-buttons a.first {
142 | border-radius: 5px 0px 0px 5px;
143 | }
144 |
145 | .donate-buttons a.last {
146 | border-radius: 0px 5px 5px 0px;
147 | border: none;
148 | }
149 |
150 | .donate-buttons a.active {
151 | background-color: #FFAC2D;
152 | }
153 |
154 | form {
155 | overflow: auto;
156 | padding: 20px 20px;
157 | }
158 |
159 | form a {
160 | float: right;
161 | color: #fff;
162 | margin-right: 20px;
163 | position: relative;
164 | top: 5px;
165 | }
166 |
167 | form input[type=image]{
168 | float: right;
169 | }
--------------------------------------------------------------------------------
/public/css/football.css:
--------------------------------------------------------------------------------
1 | /* http://meyerweb.com/eric/tools/css/reset/
2 | v2.0 | 20110126
3 | License: none (public domain)
4 | */
5 |
6 | html, body, div, span, applet, object, iframe,
7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8 | a, abbr, acronym, address, big, cite, code,
9 | del, dfn, em, img, ins, kbd, q, s, samp,
10 | small, strike, strong, sub, sup, tt, var,
11 | b, u, i, center,
12 | dl, dt, dd, ol, ul, li,
13 | fieldset, form, label, legend,
14 | table, caption, tbody, tfoot, thead, tr, th, td,
15 | article, aside, canvas, details, embed,
16 | figure, figcaption, footer, header, hgroup,
17 | menu, nav, output, ruby, section, summary,
18 | time, mark, audio, video {
19 | margin: 0;
20 | padding: 0;
21 | border: 0;
22 | font-size: 100%;
23 | font: inherit;
24 | vertical-align: baseline;
25 | }
26 | /* HTML5 display-role reset for older browsers */
27 | article, aside, details, figcaption, figure,
28 | footer, header, hgroup, menu, nav, section {
29 | display: block;
30 | }
31 | body {
32 | line-height: 1;
33 | }
34 | ol, ul {
35 | list-style: none;
36 | }
37 | blockquote, q {
38 | quotes: none;
39 | }
40 | blockquote:before, blockquote:after,
41 | q:before, q:after {
42 | content: '';
43 | content: none;
44 | }
45 | table {
46 | border-collapse: collapse;
47 | border-spacing: 0;
48 | }
49 |
50 | body {
51 | background-color: #6F442A;
52 | background: url("/images/football.jpg");
53 | font-family: Arial, sans-serif;
54 | }
55 |
56 | .description {
57 | color: #ccc;
58 | width: 400px;
59 | float: left;
60 | padding-bottom: 20px;
61 | margin: 50px 25px 0px 100px;
62 | background-color: rgba(0,0,0, 0.5);
63 | }
64 |
65 | .description h1 {
66 | background-color: rgba(255, 255, 255, 0.9);
67 | padding: 20px;
68 | color: #333;
69 | font-weight: bold;
70 | font-size: 25px;
71 | line-height: 35px;
72 | /* font-family: 'Cinzel Decorative', cursive;*/
73 | }
74 |
75 | .description p {
76 | padding: 20px 20px 0px 20px;
77 | font-size: 16px;
78 | line-height: 22px;
79 | }
80 |
81 | .donate {
82 | color: white;
83 | width: 500px;
84 | float: left;
85 | margin: 50px 0px 0px 25px;
86 | background-color: rgba(0,0,0, 0.5);
87 | }
88 |
89 | .donate h1 {
90 | background-color: rgba(255, 255, 255, 0.9);
91 | padding: 20px;
92 | color: #333;
93 | font-weight: bold;
94 | font-size: 25px;
95 | line-height: 35px;
96 | /* font-family: 'Cinzel Decorative', cursive;*/
97 | }
98 |
99 | .title {
100 | background-color: rgba(255, 255, 255, 0.9);
101 | padding: 20px 100px;
102 | font-weight: bold;
103 | font-size: 30px;
104 | font-family: 'Cinzel Decorative', cursive;
105 | }
106 |
107 | .title img {
108 | height: 30px;
109 | }
110 |
111 | .donate center img {
112 | background-color: white;
113 | width: 400px;
114 | margin: 20px 0px;
115 | }
116 |
117 | .donate p {
118 | padding: 20px 20px 0px 20px;
119 | font-size: 16px;
120 | line-height: 22px;
121 | color: #ccc;
122 | }
123 |
124 | .donate-buttons {
125 | padding: 20px 95px;
126 | overflow: auto;
127 | }
128 |
129 | .donate-buttons a {
130 | float: left;
131 | background: #FFF9EE;
132 | width: 100px;
133 | text-align: center;
134 | text-decoration: none;
135 | padding: 10px 0px;
136 | border-right: 2px solid #aaa;
137 | color: #003366;
138 | font-weight: bold;
139 | }
140 |
141 | .donate-buttons a.first {
142 | border-radius: 5px 0px 0px 5px;
143 | }
144 |
145 | .donate-buttons a.last {
146 | border-radius: 0px 5px 5px 0px;
147 | border: none;
148 | }
149 |
150 | .donate-buttons a.active {
151 | background-color: #FFAC2D;
152 | }
153 |
154 | form {
155 | overflow: auto;
156 | padding: 20px 20px;
157 | }
158 |
159 | form a {
160 | float: right;
161 | color: #fff;
162 | margin-right: 20px;
163 | position: relative;
164 | top: 5px;
165 | }
166 |
167 | form input[type=image]{
168 | float: right;
169 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | CharityWifi
2 | ===============
3 |
4 | CharityWifi: Integrating a charitable donation into wireless hotspot captive portal.
5 | ------------------------------------------------------------------------------------
6 | For the [Paypal CharityHack 2012](http://charityhack.org/), [Cristiano Betta](https://github.com/cbetta/) and myself created a hardware hack using a free [Raspberry Pi](http://www.raspberrypi.org/) that were prizes for the first 40 people through the doors.
7 |
8 | So Cristiano’s original idea was lacking in the exact technical implementation, but we basically knew what the plan was.
9 |
10 | Once we’d got a 2GB SD card flashed with [Raspbian-wheezy](http://www.raspberrypi.org/downloads), which is basically just Debian for armv6, we had to go and find a TV with hdmi to do the initial setting.
11 |
12 | ### Basic Configuration Steps:
13 |
14 | 1. Connect the onboard port (eth0) to your router.
15 | 1. Connect a USB ethernet adapter to one of the USB ports. (eth1).
16 | 1. Connect the USB ethernet port to the relevant uplink port on your wireless access point.
17 | 1. Load the software from the github repository.
18 | 1. Run bundle install
19 | 1. Run bin/configure.sh (might not be required)
20 | 1. Run bin/start_routing.sh
21 | 1. Run ruby redirect.rb
22 |
23 | #### eth0 (onboard)
24 | IP address DHCP
25 |
26 | #### eth1 (USB NIC)
27 | IP address 172.16.254.1/24
28 |
29 | Then ssh in on the 172.16.254.1 address, and sudo up.
30 | And enable IP Forwarding in the kernel:
31 | echo 1 > /proc/sys/net/ipv4/ip_forward
32 |
33 | and then
34 | in `/etc/sysctl.conf`
35 | net.ipv4.ip_forward = 1
36 |
37 |
38 | So at this point, the next step is to configure NAT on the interface, so that the router is able to actually overload traffic onto the lone IP address.
39 |
40 | sudo iptables -t nat --flush
41 | sudo iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
42 | sudo iptables --append FORWARD --in-interface eth1 -j ACCEPT
43 |
44 | At this point, all traffic coming into the Pi on eth1 can be sent out to eth0 and out onto the internet.
45 |
46 | Let’s have a think about the code now. As Cristiano writes Ruby, and I’m learning Ruby, that was what we chose to write in.
47 |
48 | in bin/start_routing.sh there’s a bunch of iptables rules which set up the routing so that
49 | 1. All DHCP and DNS traffic is allowed out.
50 | 1. All traffic on port 80 gets redirected to the Pi’s IP onto port 4567 (the ruby port for the ruby app) initially
51 | 1. A new table called NET gets created, which is where we’ll dump the traffic from known clients into, and this’ll go straight to the internet.
52 |
53 | The next step is to start the ruby application, which will intercept HTTP requests to *anywhere*, and then redirect them to a Landing Page
54 |
55 | ,
56 |
57 | Which will then redirect to the Paypal payment gateway
58 |
59 | 
60 |
61 | Where the user will actually pay for their donation. All through this process, they don’t have to make one, they can cancel, and still surf for free.
62 |
63 | 
64 |
65 | The rest of the process just follows the traditional Paypal review/complete process.
66 |
67 | 
68 |
69 |
70 | The paypal return URL (when you click "Continue surfing") will mean that you’ll get redirected to where you expected to go to initially, after you hit our landing page.
71 |
72 |
73 |
74 | Things I found out:
75 | -------------------
76 | 1. Ruby isn’t installed by default on the ‘Pi (Python is, however).
77 | 1. “Building native extensions.. This may take a while.” No kidding.
78 | 3. Intercepting port 80 traffic and redirecting users is.. Cheeky. It doesn’t currently work with https, as that’s a whole bunch of SSL i didn’t have time to contemplate.
79 | 4. If you intercept a user’s traffic, make sure you forcibly close the connection with HTTP headers, or you’ll never get out of the loop.
80 | 5. Related to 4, You’ve gotta clear conntrack information for established connections, otherwise again, you’ll never break out.
81 | 6. Programming at 3AM is a bitch.
82 | 7. Serverfault *always* comes through.
83 | 8. Learning Ruby is insanely easy with StackOverflow with a guide. Seriously, there’s like 10 lines of code that I wrote and each line is the answer to a different SO question.
84 | 9. The only way to get a user’s mac address is to shell out to arp.
85 | 10. I *really* need sleep.
86 |
87 | CharityWifi won 2nd Place
88 | -------------------------
89 | 
90 |
91 | We won 2nd place, and apparently created "a very innovative hack" said one of the judges.
92 |
93 |
94 |
--------------------------------------------------------------------------------