SPVM-Mojolicious

 view release on metacpan or  search on metacpan

lib/SPVM/Mojo/Transaction.pm  view on Meta::CPAN


C<has original_remote_address : rw string;>

Remote interface address.

=head2 remote_address

C<has remote_address : virtual rw string;>

Same as L</"original_remote_address"> unless L</"req"> has been performed via a L<Mojo::Message::Request#reverse_proxy|SPVM::Mojo::Message::Request/"reverse_proxy">.
If so then the last value of C<X-Forwarded-For> header is returned. Additionally if
L<Mojo::Message::Request#trusted_proxies|SPVM::Mojo::Message::Request/"trusted_proxies"> are also provided then the original address must be trusted and any
C<X-Forwarded-For> entries that are trusted are ignored, returning the last untrusted address or the first address if
all are trusted.

=head2 remote_port

C<has remote_port : rw int;>

Remote interface port.

=head2 req

lib/SPVM/Mojo/Transaction.spvm  view on Meta::CPAN

  
  has original_remote_address : rw string;
  
  has remote_address : virtual rw string
    get {
      
      unless ($self->req->reverse_proxy) {
        return $self->original_remote_address;
      }
      
      my $x_forwarded_for = $self->req->headers->header("X-Forwarded-For");
      unless ($x_forwarded_for) {
        $x_forwarded_for = "";
      }
      
      my $addrs   = Re->split("\s*,\s*", $x_forwarded_for);
      my $trusted = $self->req->trusted_proxies;
      
      unless (@$trusted) {
        if (@$addrs) {
          return $addrs->[@$addrs - 1];



( run in 0.635 second using v1.01-cache-2.11-cpan-a1d94b6210f )