squash_matrix 1.0.6 → 1.0.7

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
  SHA256:
3
- metadata.gz: 9d16bccb75647110f912d27dd85a00637d45e97f6cd22e121b9fa32437194ff3
4
- data.tar.gz: 12ef740678b74fe5203d07a0317f1c1e3e7e0d1c60abfc8af052321908ce856e
3
+ metadata.gz: eed138cf3aa885351dd0e42f62a5501cfc3f355a4611ea619bc53abd0a138fdc
4
+ data.tar.gz: 6d4e62d6191d730691a5ab312f844da7ddfceadc8619da8c96bb41d51122bd64
5
5
  SHA512:
6
- metadata.gz: 8df55de3ae37c996dea5c59ff4ca3ce901bbffd3b12c1d32f23bef9a158adffa28c27fd16a31bbee9f2af2a252a073a1bf5d01d3e26e24aad20a9e551aef6fd6
7
- data.tar.gz: b204d011cf005e2698bef9f1f61e08a1e5beb3b68cd9a08719e52d1330185391479cce8361067583d24ca91ba2517d822bf8f9d8ea2811f6433501bbc236c952
6
+ metadata.gz: 9ed1f044b29eca1efc4d10a3ed4d9b2c3c006ad8df85fc26444e2aa793808cd1a467c52e7ddb37c5269b79131b75a38035ef1fc95190fc04a18843a4add09747
7
+ data.tar.gz: 6e9cfa37594ad1633b75b3ab72df5b5dffb461e4e4847431d335715a9189a3afa440a0d950e0d5ee060543fa9fe51aa5ae55a5c025f6654df81f40fd9d317f2f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- squash_matrix (1.0.5)
4
+ squash_matrix (1.0.6)
5
5
  http-cookie (~> 1.0, >= 1.0.3)
6
6
  nokogiri (~> 1.8, >= 1.8.4)
7
7
  user-agent-randomizer (~> 0.2)
data/README.md CHANGED
@@ -137,7 +137,9 @@ p => {
137
137
  replica_client = SquashMatrix::Client.new(p)
138
138
  => SquashMatrix::Client
139
139
  # Don't want to use credentials, use a proxy instead
140
- client_behind_proxy = SquashMatrix::Client.new(proxy_addr: '78.186.111.109', proxy_port: 8080)
140
+ proxy_addr = '78.186.111.109'
141
+ proxy_port = 8080
142
+ client_behind_proxy = SquashMatrix::Client.new(proxy_addr: proxy_addr, proxy_port: proxy_port, proxy_custom_headers: {'X-Forwarded-For': proxy_addr}) # squash matrix tracks the X-Forwarded-For header, also depending on the proxy service you are using you may need to overwrite header params
141
143
  begin
142
144
  (100..1000).each { |i| client_behind_proxy.get_club_info(336) }
143
145
  rescue SquashMatrix::Errors::ForbiddenError => e
@@ -47,14 +47,21 @@ module SquashMatrix
47
47
  user_agent: nil,
48
48
  cookie: nil,
49
49
  expires: nil,
50
+ proxy_port: nil,
50
51
  proxy_addr: nil,
51
- proxy_port: nil)
52
+ proxy_user: nil,
53
+ proxy_pass: nil,
54
+ proxy_custom_headers: nil)
52
55
  @user_agent = user_agent || UserAgentRandomizer::UserAgent.fetch(type: 'desktop_browser').string
53
56
  @squash_matrix_home_uri = URI::HTTP.build(host: SquashMatrix::Constants::SQUASH_MATRIX_URL)
54
57
  @suppress_errors = suppress_errors
55
58
  @timeout = timeout
56
- @proxy_addr = proxy_addr
57
59
  @proxy_port = proxy_port
60
+ @proxy_addr = proxy_addr
61
+ @proxy_user = proxy_user
62
+ @proxy_pass = proxy_pass
63
+ @proxy_custom_headers = proxy_custom_headers
64
+ @request_client = @proxy_addr.nil? ? Net::HTTP::Proxy(@proxy_addr, @proxy_port&.to_i, @proxy_user, @proxy_pass) : Net::HTTP
58
65
  return unless [player || email, password].none?(&:nil?)
59
66
  @cookie_jar = HTTP::CookieJar.new
60
67
  @player = player&.to_i
@@ -176,7 +183,7 @@ module SquashMatrix
176
183
  set_headers(req, headers: headers)
177
184
  req.set_form(form_data, SquashMatrix::Constants::MULTIPART_FORM_DATA)
178
185
  end
179
- res = Net::HTTP.new(uri.hostname, uri.port, @proxy_addr, @proxy_port&.to_i, use_ssl: uri.scheme == 'https').start { |http| http.request(req) }
186
+ res = @request_client.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(req) }
180
187
  case res
181
188
  when Net::HTTPSuccess, Net::HTTPFound
182
189
  return success_proc&.call(res) || res
@@ -240,6 +247,7 @@ module SquashMatrix
240
247
  }
241
248
  headers_to_add = headers_to_add.merge(headers) if headers
242
249
  headers_to_add = headers_to_add.merge(SquashMatrix::Constants::COOKIE_HEADER => get_cookie_string) if @cookie_jar
250
+ headers_to_add = headers_to_add.merge(@proxy_custom_headers) if @proxy_custom_headers
243
251
  headers_to_add.each { |key, val| req[key.to_s] = val }
244
252
  end
245
253
 
@@ -15,6 +15,7 @@ module SquashMatrix
15
15
  X_WWW__FROM_URL_ENCODED = 'application/x-www-form-urlencoded'
16
16
  MULTIPART_FORM_DATA = 'multipart/form-data'
17
17
  CONTENT_TYPE_HEADER = 'content-type'
18
+ X_FORWARDED_FOR_HEADER = 'X-Forwarded-For'
18
19
  REFERER = 'Home/Player/:id'
19
20
  ASPXAUTH_COOKIE_NAME = '.ASPXAUTH'
20
21
  ASP_NET_SESSION_ID_COOKIE_NAME = 'ASP.NET_SessionId'
@@ -1,3 +1,3 @@
1
1
  module SquashMatrix
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squash_matrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Wilkosz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-04 00:00:00.000000000 Z
11
+ date: 2018-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler