Skip to content
Browse files

Add external_ip and finialize ip info

  • Loading branch information...
1 parent 64e7b0d commit 95e3c80cf41e0a178b8acebb1ef76f7ac9970e07 @ErebusBat committed May 25, 2011
Showing with 15 additions and 8 deletions.
  1. +11 −8 current_ips.rb
  2. +4 −0 framework/network.rb
View
19 current_ips.rb
@@ -3,16 +3,19 @@
require "framework/colors"
require "framework/network"
+ignore_interfaces = ['lo0', 'fw', 'vmnet1', 'vmnet8']
+
ips = []
-current_ips = Network.ips
-current_ips.each do |ip|
- show_ip = true
- #show_ip = false if Network.ip_matches_pattern ip,
- ips << ip
+ips << ['world', Network.external_ip]
+Network.interface_list.each do |iif|
+ next if ignore_interfaces.include? iif
+ if_ip = Network.ip_for_interface iif
+ ips << [iif, if_ip] unless if_ip.to_s.empty?
end
+
# Print them
-puts "#{Colors.white}Current IPs#{Colors.normal}"
-ips.each do |ip|
- puts " #{ip}"
+#puts "#{Colors.white}Current IPs#{Colors.normal}"
+ips.each do |iif, ip|
+ puts "#{'%5s' % iif}: #{ip}"
end
View
4 framework/network.rb
@@ -1,4 +1,8 @@
class Network
+ def self.external_ip
+ %x[curl -s www.icanhazip.com].strip
+ end
+
def self.ips
ips = []
ifconfig = %x[ifconfig]

0 comments on commit 95e3c80

Please sign in to comment.
Something went wrong with that request. Please try again.