Module: Myips
- Defined in:
- lib/myips.rb,
lib/myips/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.local_ip ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/myips.rb', line 6 def local_ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily UDPSocket.open do |s| s.connect '13.107.21.200', 1 # Using Bing.com ip s.addr.last end ensure Socket.do_not_reverse_lookup = orig end |
.public_ip ⇒ Object
17 18 19 20 |
# File 'lib/myips.rb', line 17 def public_ip require "net/http" ip = Net::HTTP.get(URI("https://api.ipify.org")) end |