lib/perus/server/app.rb in perus-0.1.33 vs lib/perus/server/app.rb in perus-0.1.34

- old
+ new

@@ -155,15 +155,11 @@ # receive data from a client post '/systems/:id/ping' do timestamp = Time.now.to_i ping_params = params.dup - if request.ip == '127.0.0.1' && ENV['RACK_ENV'] == 'production' - system_ip = request.env['HTTP_X_FORWARDED_FOR'] - else - system_ip = request.ip - end + system_ip = request.env['HTTP_X_FORWARDED_FOR'] || request.ip Server.ping_queue << Proc.new do # update the system with its last known ip and update time system = System.with_pk!(ping_params['id']) system.last_updated = timestamp @@ -191,22 +187,16 @@ system.config_hash.to_json end # config of system based on request ip get '/systems/config_for_ip' do - ip = nil + ip = request.env['HTTP_X_FORWARDED_FOR'] || request.ip begin - if request.ip == '127.0.0.1' && ENV['RACK_ENV'] == 'production' - ip = request.env['HTTP_X_FORWARDED_FOR'] - else - ip = request.ip - end - system = System.where(ip: ip).first content_type :json system.config_hash.to_json rescue => e - puts "\nNo config for: #{ip}\n" + STDERR.puts "\nNo config for: #{ip}\n" raise e end end # render all errors in html to replace the shortened subset on the system page