Skip to content
Browse files

Unix sockets are now correctly considered as local proxies.

  • Loading branch information...
1 parent 9ad30a2 commit 39432f9c717906cb6079725f3e92f83e5083ee7e @barttenbrinke barttenbrinke committed Mar 2, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −1 lib/rack/request.rb
  2. +7 −0 test/spec_request.rb
View
2 lib/rack/request.rb
@@ -309,7 +309,7 @@ def accept_encoding
end
def trusted_proxy?(ip)
- ip =~ /^127\.0\.0\.1$|^(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.|^::1$|^fd[0-9a-f]{2}:.+|^localhost$/i
+ ip =~ /^127\.0\.0\.1$|^(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.|^::1$|^fd[0-9a-f]{2}:.+|^localhost$|^unix$/i
end
def ip
View
7 test/spec_request.rb
@@ -892,6 +892,13 @@
res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '8.8.8.8, fe80::202:b3ff:fe1e:8329'
res.body.should.equal 'fe80::202:b3ff:fe1e:8329'
+
+ # Unix Sockets
+ res = mock.get '/',
+ 'REMOTE_ADDR' => 'unix',
+ 'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
+ res.body.should.equal '3.4.5.6'
+
end
class MyRequest < Rack::Request

0 comments on commit 39432f9

Please sign in to comment.
Something went wrong with that request. Please try again.