Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Kill external IP cache if # of interfaces changes.

 - Quick and dirty way to pick up external IP changes on VPN connections
  • Loading branch information...
commit fca116d56e001c4fefa7e4730e8c25d9ffd162a0 1 parent 77fc1b5
Andrew Burns authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 current_ips.rb
8 current_ips.rb
View
@@ -54,13 +54,19 @@ def get_external_ip cache_entry
def get_ips cache_entry
ips = []
+ interfaces = Network.interface_list
+
+ ## See if the interface count has changed, if it has, then throw away the cache
+ cache_entry[:external_ip] = '' if cache_entry[:if_count].to_s.empty? || cache_entry[:if_count].to_i != interfaces.size
+ cache_entry[:if_count] = interfaces.size ## Save current list
+
external_ip = get_external_ip cache_entry
if external_ip.empty?
ips << ['No Active Interfaces', '']
else
ips << ['world', external_ip]
end
- Network.interface_list.each do |iif|
+ interfaces.each do |iif|
iif[:status] = :active if iif[:name] =~ /^(utun|ppp)/i
next if iif[:status] != :active || iif[:ip].to_s.empty?
next if iif[:name] =~ /(?:lo\d+|vmnet\d+)/i # Ignored interfaces
Please sign in to comment.
Something went wrong with that request. Please try again.