# We also need to clear CGI's globals.
CGI::initialize_globals();
Bugzilla->usage_mode(USAGE_MODE_MOJO);
+
+ # This is used by Bugzilla::Util::remote_ip().
+ state $better_xff = Bugzilla->has_feature('better_xff');
+ Bugzilla->request_cache->{remote_ip} = $better_xff ? $c->forwarded_for : $c->tx->remote_address;
+
$next->();
}
);
# Returns the real remote address of the client,
sub remote_ip {
- if (($ENV{SERVER_SOFTWARE} // '') eq 'Bugzilla::App::CGI') {
- my $c = $Bugzilla::App::CGI::C or LOGDIE("Cannot find controller!");
- state $better_xff = Bugzilla->has_feature('better_xff');
- return $better_xff ? $c->forwarded_for : $c->tx->remote_address;
- }
- else {
- WARN("remote_ip() called outside CGI controller!");
- return "";
- }
+ return Bugzilla->request_cache->{remote_ip};
}
sub validate_ip {