You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require 'socket'
# @return [String] public IP address of workstation used for egress traffic
def local_ip
@local_ip ||= begin
# turn off reverse DNS resolution temporarily
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
UDPSocket.open do |s|
s.connect '64.233.187.99', 1 # a google IP, does not hit network
s.addr.last
end
ensure
Socket.do_not_reverse_lookup = orig
end
end
# @return [Integer] default polipo listening port
def local_port ; 8123 ; end
# @return [String] the polipo proxy URL
def http_proxy_url ; "http://#{local_ip}:#{local_port}" ; end
# @return [TrueClass,FalseClass] whether or not the polipo port is listening
def proxy_running?
socket = TCPSocket.new(local_ip, local_port)
true
rescue SocketError, Errno::ECONNREFUSED,
Errno::EHOSTUNREACH, Errno::ENETUNREACH, IOError
false
rescue Errno::EPERM, Errno::ETIMEDOUT
false
ensure
socket && socket.close
end
Hi @tmatilai,
Would it be possible to have some sort of proxy auto-detection added?
Example:
I'm using @fnicols snippet in my Vagrantfile: https://gist.github.com/fnichol/7551540
Further down:
Would be nice to have this in the plugin already and a cleaner Vagrantfile.
Enrico
The text was updated successfully, but these errors were encountered: