lib/deputy.rb in deputy-0.1.57 vs lib/deputy.rb in deputy-0.1.58

- old
+ new

@@ -144,10 +144,11 @@ return if config['disabled'] url = "#{sheriff_url}#{path}" url = "http://#{url}" unless url =~ %r{://} options[:http_basic_authentication] = extract_auth_from_url!(url) url = add_host_to_url(url, options.delete(:host)) + url = add_ip_to_url(url) puts "getting #{url} with options: #{options.inspect}" if options[:verbose] http_options = {} http_options[:http_basic_authentication] = options[:http_basic_authentication] if options[:http_basic_authentication] @@ -226,9 +227,23 @@ auth.empty? ? nil : auth end def self.add_host_to_url(url, host=nil) query = "hostname=#{host || Socket.gethostname}#{'&forced_host=true' if host}" + add_query_to_url(url, query) + end + + + def self.add_ip_to_url(url, ip=nil) + query = "ip=#{ip ||real_ip}" + add_query_to_url(url, query) + end + + def self.real_ip + %x(host $(hostname))[/\d+.\d+.\d+.\d+/] + end + + def self.add_query_to_url(url, query) separator = (url.include?('?') ? "&" : "?") url + separator + query end end