squash_matrix 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/squash_matrix/client.rb +11 -3
- data/lib/squash_matrix/constants.rb +1 -0
- data/lib/squash_matrix/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eed138cf3aa885351dd0e42f62a5501cfc3f355a4611ea619bc53abd0a138fdc
|
4
|
+
data.tar.gz: 6d4e62d6191d730691a5ab312f844da7ddfceadc8619da8c96bb41d51122bd64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ed1f044b29eca1efc4d10a3ed4d9b2c3c006ad8df85fc26444e2aa793808cd1a467c52e7ddb37c5269b79131b75a38035ef1fc95190fc04a18843a4add09747
|
7
|
+
data.tar.gz: 6e9cfa37594ad1633b75b3ab72df5b5dffb461e4e4847431d335715a9189a3afa440a0d950e0d5ee060543fa9fe51aa5ae55a5c025f6654df81f40fd9d317f2f
|
data/Gemfile.lock
CHANGED
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
|
-
|
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
|
data/lib/squash_matrix/client.rb
CHANGED
@@ -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
|
-
|
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 =
|
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'
|
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.
|
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-
|
11
|
+
date: 2018-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|