stealth_browser_automation 1.1.37 → 1.2.38

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: b80fcddc9f371e2bae32154d438f5efa866a35f1
4
- data.tar.gz: a7fd2daf0f8e445e2f48eb3120922e2c5914ec64
3
+ metadata.gz: 4e0724c65c5e9b2ba3cac47a2c1dc03eec05feb7
4
+ data.tar.gz: a3219482f992c116ec77cd886be6396e093a7e8c
5
5
  SHA512:
6
- metadata.gz: 5ff59f5ba2fb0e2639a063001be4ba349fd54157869416df7d637b63a4090f42326f634b33346f40c28117c35b9add5b1c4609acbbc6845f4d8887d69f5f9812
7
- data.tar.gz: 88ddbb60e9033385698c14f3d7ba51178be2f070d1e94669d6f3bbe65f3ac233f5bae3c41bccb90afa86f022788b72c2b5ac5705070886644bf5b17c7df741f9
6
+ metadata.gz: 30482c1c81718f78a70dd2861c56c4ca11dad27cfb2c77aa6b9a81a19401f4be6d9572d2d115ff3825a7b105f73aa16c09bce43d3245f2dfaa2d4beab024be85
7
+ data.tar.gz: 24bb6b8a536929c277d84eee07703df2612cc96e5d16204832019e7b70538e53e677df7eb768427260bb4a186ab8a030ad370f7148a06c28c66e0d21e395a05e
data/lib/baseproxy.rb CHANGED
@@ -1,7 +1,31 @@
1
1
  module BlackStack
2
2
 
3
3
  module BaseProxy
4
-
4
+
5
+ ##
6
+ # creates new connection to google.com using +Faraday+ lib. Uses CGI::Cookie class
7
+ # to parse the cookie returned in the response. It then checks for the presense of
8
+ # "NID" cookie set by Google. If the cookie exists, proxy server is working just fine.
9
+ #
10
+ # references:
11
+ # - https://github.com/apoorvparijat/proxy-test
12
+ # - https://github.com/lostisland/faraday
13
+ #
14
+ def self.test(proxy_str)
15
+ begin
16
+ f = Faraday.new(:proxy => { :uri => "http://" + proxy_str})
17
+ response = f.get "http://www.google.com"
18
+ cookie = CGI::Cookie.parse(response.headers["set-cookie"])
19
+ if(cookie["NID"].empty?)
20
+ raise "#{proxy_str} is NOT working."
21
+ else
22
+ return true
23
+ end
24
+ rescue
25
+ raise "Connection to #{proxy_str} timed out"
26
+ end
27
+ end
28
+
5
29
  #
6
30
  def chrome_switches
7
31
  return ["--proxy-server=#{self.ip}:#{self.port}","--proxy-user-and-password=#{self.user}:#{self.password}"]