Skip to content
This repository
Browse code

Unix sockets are now correctly considered as local proxies.

  • Loading branch information...
commit 39432f9c717906cb6079725f3e92f83e5083ee7e 1 parent 9ad30a2
Bart ten Brinke barttenbrinke authored

Showing 2 changed files with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  lib/rack/request.rb
  2. +7 0 test/spec_request.rb
2  lib/rack/request.rb
@@ -309,7 +309,7 @@ def accept_encoding
309 309 end
310 310
311 311 def trusted_proxy?(ip)
312   - 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
  312 + 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
313 313 end
314 314
315 315 def ip
7 test/spec_request.rb
@@ -892,6 +892,13 @@
892 892
893 893 res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '8.8.8.8, fe80::202:b3ff:fe1e:8329'
894 894 res.body.should.equal 'fe80::202:b3ff:fe1e:8329'
  895 +
  896 + # Unix Sockets
  897 + res = mock.get '/',
  898 + 'REMOTE_ADDR' => 'unix',
  899 + 'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
  900 + res.body.should.equal '3.4.5.6'
  901 +
895 902 end
896 903
897 904 class MyRequest < Rack::Request

0 comments on commit 39432f9

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