Closed maxdidato closed 9 years ago
Thanks @maxdidato ! Closes #154
how do I define user and password socks5 proxy credentials?
I am using PIA proxy but couldn't find how to connect this, already looking a solution for some days, but still stucked.
https://github.com/mikecmpbll/betfair/issues/6 https://github.com/astro/socksify-ruby/issues/1#issuecomment-162905681
looking at the code it appears that socks connection block is only using host and port, while http proxy uses the 4 ( plus username and password)
Please help me I'm really confused on how to settup this socks proxy with credentials.. thanks
@acegilz The pull request let the user set a socks server without authentication.
I see 😕 +1 for authentication support
I'll take a look at this tonight, I may be able to come up with a PR because I poked around a bit at this area whilst investigating mikecmpbll/betfair#6.
@mikecmpbll :+1:
Thank you so much @mikecmpbll
the code for socksify is really quite bizarre. anyways, i don't have an authenticated socks proxy which i can test against, but looking at the code you should be able to set the credentials like this:
require 'socksify/http'
uri = URI.parse('http://www.google.com/')
socks_ip = '127.0.0.1' # your socks IP
socks_port = 9050 # your socks port
TCPSocket.socks_username = "username" # socks username
TCPSocket.socks_password = "password" # socks password
Net::HTTP.SOCKSProxy(socks_ip, socks_port).start(uri.host, uri.port) do |http|
http.get(uri.path)
end
would you be able to test this @acegilz to see if you can get a page via your socks5 proxy? there's also a PR in the works on socksify, astro/socksify-ruby#24, to improve the interface when passing through credentials, which is going to be merged this weekend i understand.
if this works for you, you can actually set the socks_username and socks_password on TCPSocket outside of httpi so you can get up and running immediately. i'll probably wait for the socksify interface to be tidied up before creating a PR here.
@mikecmpbll :thumbsup:
=> #<Net::HTTPOK 200 OK readbody=true>
@mikecmpbll Thanks
This will let a user to specify a socks proxy server in order to perform a request via it