diff options
author | Dylan William Hardison <dylan@hardison.net> | 2018-05-22 03:16:24 +0200 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2018-06-28 22:41:57 +0200 |
commit | 6ddd8c019a3b416603690e6254966b855e4d05fa (patch) | |
tree | ae421394fcc9ba6daa7a140439b144ef58653184 /Bugzilla/Util.pm | |
parent | 09eb2bb539c77d602985f42b040ddcacc9e03b1a (diff) | |
download | bugzilla-6ddd8c019a3b416603690e6254966b855e4d05fa.tar.gz bugzilla-6ddd8c019a3b416603690e6254966b855e4d05fa.tar.xz |
revert more unused stuff
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r-- | Bugzilla/Util.pm | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index ed1d4593c..a1316c7ef 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -321,27 +321,21 @@ sub do_ssl_redirect_if_required { # Returns the real remote address of the client, sub remote_ip { - my $cgi = Bugzilla->cgi; - if ($cgi->can('controller')) { - return $cgi->controller->tx->remote_address; - } - else { - my $remote_ip = $ENV{'REMOTE_ADDR'} || '127.0.0.1'; - my @proxies = split(/[\s,]+/, Bugzilla->localconfig->{inbound_proxies}); - my @x_forwarded_for = split(/[\s,]+/, $ENV{HTTP_X_FORWARDED_FOR} // ''); - - return $remote_ip unless @x_forwarded_for; - return $x_forwarded_for[0] if @proxies && $proxies[0] eq '*'; - return $remote_ip if none { $_ eq $remote_ip } @proxies; - - foreach my $ip (reverse @x_forwarded_for) { - if (none { $_ eq $ip } @proxies) { - # Keep the original IP address if the remote IP is invalid. - return validate_ip($ip) || $remote_ip; - } + my $remote_ip = $ENV{'REMOTE_ADDR'} || '127.0.0.1'; + my @proxies = split(/[\s,]+/, Bugzilla->localconfig->{inbound_proxies}); + my @x_forwarded_for = split(/[\s,]+/, $ENV{HTTP_X_FORWARDED_FOR} // ''); + + return $remote_ip unless @x_forwarded_for; + return $x_forwarded_for[0] if @proxies && $proxies[0] eq '*'; + return $remote_ip if none { $_ eq $remote_ip } @proxies; + + foreach my $ip (reverse @x_forwarded_for) { + if (none { $_ eq $ip } @proxies) { + # Keep the original IP address if the remote IP is invalid. + return validate_ip($ip) || $remote_ip; } - return $remote_ip; } + return $remote_ip; } sub validate_ip { |