gemirro 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gemirro might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +39 -2
- data/bin/gemirro +2 -1
- data/lib/gemirro/server.rb +16 -9
- data/lib/gemirro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d800c2fcc4025d9b6c61b262de67bd7fabaa16b
|
4
|
+
data.tar.gz: 83b03d07f993704b6a944435cc0736f15cb691d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc903688bd26f284ecba57a374c2bbd21121fdb0c27b2a358780b5bb6126177428416277052049e7babb987bf2737e984a99d5ea91f1775da21346a3253c54b4
|
7
|
+
data.tar.gz: c4cfc5462bc6739b1857a5ff411dad6922fe69e8caeeff2605123bfea093377318d0afc6e0038ed93a52a4f6b271e5db8bcb55affbf6b8fdd054339e4b5ef534
|
data/README.md
CHANGED
@@ -54,7 +54,44 @@ If you want to use a custom configuration file not located in the current direct
|
|
54
54
|
|
55
55
|
|
56
56
|
##Apache configuration
|
57
|
-
|
57
|
+
|
58
|
+
You must active the apache `proxy` module.
|
59
|
+
|
60
|
+
```bash
|
61
|
+
$ sudo a2enmod proxy
|
62
|
+
$ sudo a2enmod proxy_http
|
63
|
+
```
|
64
|
+
|
65
|
+
Create your VirtualHost and replace following `http://localhost:2000` with your custom server configuration located in your `config.rb` file and restart Apache.
|
66
|
+
|
67
|
+
```
|
68
|
+
<VirtualHost *:80>
|
69
|
+
ServerName mirror.gemirro
|
70
|
+
ProxyPreserveHost On
|
71
|
+
ProxyRequests off
|
72
|
+
ProxyPass / http://localhost:2000
|
73
|
+
ProxyPassReverse / http://localhost:2000
|
74
|
+
</VirtualHost>
|
75
|
+
```
|
58
76
|
|
59
77
|
##Nginx configuration
|
60
|
-
|
78
|
+
|
79
|
+
Replace `localhost:2000` with your custom server configuration located in your `config.rb` file and restart Nginx.
|
80
|
+
|
81
|
+
```
|
82
|
+
upstream gemirro {
|
83
|
+
server localhost:2000;
|
84
|
+
}
|
85
|
+
|
86
|
+
server {
|
87
|
+
server_name rbgems;
|
88
|
+
|
89
|
+
location / {
|
90
|
+
proxy_pass http://gemirro;
|
91
|
+
proxy_set_header Host $host;
|
92
|
+
proxy_set_header X-Real-IP $remote_addr;
|
93
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
```
|
97
|
+
|
data/bin/gemirro
CHANGED
data/lib/gemirro/server.rb
CHANGED
@@ -39,10 +39,13 @@ module Gemirro
|
|
39
39
|
#
|
40
40
|
def run
|
41
41
|
while (session = server.accept)
|
42
|
-
request = session.gets
|
42
|
+
request = session.gets.chomp
|
43
43
|
logger.info(request)
|
44
44
|
|
45
|
-
trimmedrequest = request
|
45
|
+
trimmedrequest = request
|
46
|
+
.gsub(/(HEAD|GET)\ \//, '')
|
47
|
+
.gsub(/\ HTTP.*/, '')
|
48
|
+
.chomp
|
46
49
|
resource = "#{@destination}/#{trimmedrequest}"
|
47
50
|
|
48
51
|
# Try to download gem if file doesn't exists
|
@@ -56,13 +59,17 @@ module Gemirro
|
|
56
59
|
next
|
57
60
|
end
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
begin
|
63
|
+
if File.directory?(resource)
|
64
|
+
display_directory(session, resource)
|
65
|
+
else
|
66
|
+
mime_type = MIME::Types.type_for(resource)
|
67
|
+
session.print "HTTP/1.1 200/OK\r\nContent-type:#{mime_type}\r\n\r\n"
|
68
|
+
file = open(resource, 'rb')
|
69
|
+
session.puts(file.read)
|
70
|
+
end
|
71
|
+
rescue Errno::ECONNRESET, Errno::EPIPE => e
|
72
|
+
logger.info(e.message)
|
66
73
|
end
|
67
74
|
|
68
75
|
session.close
|
data/lib/gemirro/version.rb
CHANGED