summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-14 18:34:57 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-14 18:34:57 +0100
commit40d8290361bff123e0b44defa0f199708b89093b (patch)
treed975c24a0b1969e2a9cc1ec7709dec2861ebce37 /app/controllers
parent13658ab197777d0b4870bfa51ac4115a9afed845 (diff)
Adds a new remote_ip_address methode to figure out the remote IP address. #245
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/controllers/config_polycom_controller.rb4
-rw-r--r--app/controllers/config_siemens_controller.rb2
-rw-r--r--app/controllers/config_snom_controller.rb4
-rw-r--r--app/controllers/gs_nodes_controller.rb2
-rw-r--r--app/controllers/trigger_controller.rb2
6 files changed, 11 insertions, 7 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d1d918e..12bea54 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -110,6 +110,10 @@ class ApplicationController < ActionController::Base
redirect_to log_in_path, :alert => 'Access denied! You need to login first.'
end
end
+
+ def request_remote_ip
+ request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip
+ end
private
diff --git a/app/controllers/config_polycom_controller.rb b/app/controllers/config_polycom_controller.rb
index fd730e3..ca314c2 100644
--- a/app/controllers/config_polycom_controller.rb
+++ b/app/controllers/config_polycom_controller.rb
@@ -67,8 +67,8 @@ class ConfigPolycomController < ApplicationController
if ! request.env['HTTP_USER_AGENT'].index('polycom')
Rails.logger.info "---> User-Agent indicates not a Polycom phone (#{request.env['HTTP_USER_AGENT'].inspect})"
else
- Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request.remote_ip.inspect}"
- @phone.update_attributes({ :ip_address => request.remote_ip })
+ Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}"
+ @phone.update_attributes({ :ip_address => request_remote_ip })
end
xml_applications_url = "#{request.protocol}#{request.host_with_port}/config_polycom/#{@phone.id}/0"
diff --git a/app/controllers/config_siemens_controller.rb b/app/controllers/config_siemens_controller.rb
index 1966d49..7d5eb3f 100644
--- a/app/controllers/config_siemens_controller.rb
+++ b/app/controllers/config_siemens_controller.rb
@@ -146,7 +146,7 @@ class ConfigSiemensController < ApplicationController
country = 'US'
language = 'en'
if ! @phone.nil?
- @phone.update_attributes(:ip_address => request.remote_ip)
+ @phone.update_attributes(:ip_address => request_remote_ip)
@sip_account = @phone.sip_accounts.where(:sip_accountable_type => @phone.phoneable_type,
:sip_accountable_id => @phone.phoneable_id).first
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb
index ae58ab8..8db1d57 100644
--- a/app/controllers/config_snom_controller.rb
+++ b/app/controllers/config_snom_controller.rb
@@ -233,8 +233,8 @@ class ConfigSnomController < ApplicationController
if ! request.env['HTTP_USER_AGENT'].index('snom')
Rails.logger.info "---> User-Agent indicates not a Snom phone (#{request.env['HTTP_USER_AGENT'].inspect})"
else
- Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request.remote_ip.inspect}"
- @phone.update_attributes({ :ip_address => request.remote_ip })
+ Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}"
+ @phone.update_attributes({ :ip_address => request_remote_ip })
end
@softkeys = Array.new()
diff --git a/app/controllers/gs_nodes_controller.rb b/app/controllers/gs_nodes_controller.rb
index 17c9e8b..6a5e0a6 100644
--- a/app/controllers/gs_nodes_controller.rb
+++ b/app/controllers/gs_nodes_controller.rb
@@ -48,7 +48,7 @@ class GsNodesController < ApplicationController
end
def sync
- if !GsNode.where(:ip_address => request.remote_ip).first
+ if !GsNode.where(:ip_address => request_remote_ip).first
render(
:status => 404,
:layout => false,
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index b8db4c9..623ea94 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -97,7 +97,7 @@ class TriggerController < ApplicationController
#
sip_account.switchboard_entries.each do |switchboard_entry|
new_html = ActionController::Base.helpers.escape_javascript(render_to_string("switchboard_entries/_switchboard_entry", :layout => false, :locals => {:switchboard_entry => switchboard_entry}))
- PrivatePub.publish_to("/switchboards/#{switchboard_entry.switchboard.id}", "$('#switchboard_entry_id_" + switchboard_entry.id.to_s + ".replaceWith('#{new_html}');")
+ PrivatePub.publish_to("/switchboards/#{switchboard_entry.switchboard.id}", "$('#switchboard_entry_id_" + switchboard_entry.id.to_s + "').replaceWith('#{new_html}');")
end
render(