sbsm 1.5.5 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2eda12c46b1116c92dfe97027a53565f71715cd3
4
- data.tar.gz: 709c375fec68690bbabffebe91886f34f1b61503
3
+ metadata.gz: b2938a44d2cbad70bde08139096f8578c00cb635
4
+ data.tar.gz: ffef6523d8bcdae0ea1d9b1b553c704c1da2de66
5
5
  SHA512:
6
- metadata.gz: 5086f2d5dc29a833ecc655695deac70c6373aa0363a5fc82ae9b7e9fe1dbaa9a121f700d36d5bb152a217cf6a949c6844114fb18cb7fe2fe0a3afc2f4221cf6d
7
- data.tar.gz: 3be17e83ef6c00f6a1b192000848fdeae6d95ce294aa13ab28df53ba223208fcf073484b696ea5dca320d8697408b3ac14b1868db8bd0ea916206b8919c69771
6
+ metadata.gz: 22b3f3a5ef861c0737eb309f77820f722ca88076913c9b99ee9c409db66832f57c9d656b50aa5c0716d24b73de9fcfa8994052692523ff22d475fea1d6ef4c30
7
+ data.tar.gz: 3e7225581937bf52e25000c34525e58565d9d85c1514b610508784f607de82abdd065d933fb56ff92cdd4b27cb86310c3da712ecad9f300fb422976c16244381
@@ -1,3 +1,7 @@
1
+ === 1.5.6 / 12.07.2017
2
+
3
+ * Handle several IPs in X_FORWARDED_FOR
4
+
1
5
  === 1.5.5 / 12.07.2017
2
6
 
3
7
  * Do not return body if HEAD is requested
@@ -163,5 +163,9 @@ module SBSM
163
163
  response.finish
164
164
  end
165
165
 
166
+ private
167
+ def self.last_session # for unit tests only
168
+ @@last_session
169
+ end
166
170
  end
167
171
  end
@@ -518,6 +518,13 @@ module SBSM
518
518
  @remote_ip ||= if(@request.respond_to?(:remote_host))
519
519
  @request.remote_host
520
520
  end
521
+ if @remote_ip.to_s.index(',')
522
+ saved = @remote_ip.clone
523
+ @remote_ip = @remote_ip.first if @remote_ip.is_a?(Array)
524
+ @remote_ip = @remote_ip.split(',').first.gsub(/[\[\]]/, '') if @remote_ip.is_a?(String)
525
+ SBSM.info("remote_ip is weird #{saved.inspect} => #{@remote_ip.inspect}")
526
+ end
527
+ @remote_ip
521
528
  end
522
529
  def set_cookie_input(key, val)
523
530
  SBSM.debug"set_cookie_input #{key} #{val}"
@@ -1,3 +1,3 @@
1
1
  module SBSM
2
- VERSION = '1.5.5'
2
+ VERSION = '1.5.6'
3
3
  end
@@ -142,6 +142,23 @@ class StubSessionSession < SBSM::Session
142
142
  end
143
143
  end
144
144
 
145
+ class TestSessionApp < Minitest::Test
146
+ include Rack::Test::Methods
147
+ # attr_reader :app
148
+ def app
149
+ app = SBSM::RackInterface.new(app: SBSM::App)
150
+ builder = Rack::Builder.new
151
+ builder.run app
152
+ end
153
+ def test_request_remote_ip
154
+ get '/'
155
+ assert_nil SBSM::RackInterface.last_session.remote_ip
156
+ header 'X_FORWARDED_FOR', '[212.51.146.241],[66.249.93.27]' # a HTTP_ will be prepended to it
157
+ get '/'
158
+ assert_equal '212.51.146.241', SBSM::RackInterface.last_session.remote_ip
159
+ end
160
+ end
161
+
145
162
  class TestSession < Minitest::Test
146
163
  include Rack::Test::Methods
147
164
  def setup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz