lib/deputy.rb in deputy-0.1.35 vs lib/deputy.rb in deputy-0.1.36
- old
+ new
@@ -123,11 +123,13 @@
def self.get(path, options = {})
url = "#{sheriff_url}#{path}"
url = url.sub(%r{//(.*?):(.*?)@}, '//')
auth = [$1, $2].compact
- options = {:http_basic_authentication => auth} if auth.size == 2
+ options[:http_basic_authentication] = auth if auth.size == 2
+ options[:remote_host] = hostname
+
Timeout.timeout(config['timeout']||10) do
open(url, options).read
end
rescue => e
e.message << url.to_s
@@ -142,9 +144,13 @@
home = File.expand_path('~')
["#{home}/.deputy.yml", '/etc/deputy.yml'].each do |file|
return YAML.load(File.read(file)) if File.exist?(file)
end
raise "No deputy.yml found in /etc or #{home}"
+ end
+
+ def self.hostname
+ File.read('/etc/hostname') rescue "hostname_unknown"
end
# stolen from klarlack -- http://github.com/schoefmax/klarlack
# to get an reliable timeout that wont fail on other platforms
# or if sytem_timer is missing
\ No newline at end of file