コンソールで SOCSK proxy を起動しておく
ssh -vND 8888 user@host
gem Install
gem install faraday
gem install faraday_adapter_socks
Code
require 'faraday_adapter_socks'
options = { proxy: { uri: URI.parse("socks://127.0.0.1:8888") } }
url = 'https://httpbin.org/ip'
conn = Faraday.new(url, options) do |faraday|
faraday.request :url_encoded
faraday.adapter :net_http_socks # please assign ":net_http_socks" adapter
end
response = JSON.parse(conn.get.body)
# => {"origin"=>"YYY.YYY.YYY.YYY., YYY.YYY.YYY.YYY"}
自分のIPアドレスが変わっていたら成功
🎉
元の問題
faraday で proxy を指定しても
Using socks proxy with auth leads to Faraday::ConnectionFailed: end of file reached
とエラーが返ってきて使えない。
Faraday and socks proxy with auth supporting · Issue #787 · lostisland/faraday
Ruby関係無しで curl で確認する例
$ https_proxy=socks://127.0.0.1:8888 curl https://httpbin.org/ip
{
"origin": "YYY.YYY.YYY, YYY.YYY.YYY.YYY."
}
ところで Faradayの名前の由来ってなに?
【意味】ファラデー 《1791‐1867; 英国の物理学者》...
この人?なんだろうか
Faradayに似ているスターバックスを見つけました。めりーくりすま
Original by Github issue
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。