Skip to content
Browse files

Enable unix sockets with paths as trusted proxies

 * Supersedes and closes #488
  • Loading branch information...
1 parent 03797e1 commit 9b8ab042a6b90249579415dd7a60e47269772e16 @raggi raggi committed
Showing with 5 additions and 1 deletion.
  1. +1 −1 lib/rack/request.rb
  2. +4 −0 test/spec_request.rb
View
2 lib/rack/request.rb
@@ -340,7 +340,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$|^unix$/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$|^unix:/i
end
def ip
View
4 test/spec_request.rb
@@ -999,6 +999,10 @@
'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
res.body.should.equal '3.4.5.6'
+ res = mock.get '/',
+ 'REMOTE_ADDR' => 'unix:/tmp/foo',
+ '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 9b8ab04

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