[Jifty-commit] jifty-plugin-accesslog branch, master, updated. 1b0acec53764bd0bd316e384f2507898cfe777a6

Jifty commits jifty-commit at lists.jifty.org
Thu May 6 15:17:28 EDT 2010


The branch, master has been updated
       via  1b0acec53764bd0bd316e384f2507898cfe777a6 (commit)
       via  f5219798a13c0c0a51b64e94dd91155320a9bf96 (commit)
       via  c0390461329efcf346554b0e3ecdeaf6140b1b89 (commit)
       via  00bbe1a8bcc364b0e8a38b9b82d7b85efbbd9323 (commit)
       via  57f2e3aa867d3d173214a3a6b4523abd5bcec71b (commit)
       via  9586ff1bac4fd1be80d592c0be5e5fcc4f58df75 (commit)
      from  d376c6e50d10bfe3ee857ac70a84065f77d83fdc (commit)

Summary of changes:
 .gitignore                    |    9 +++++++++
 Makefile.PL                   |    2 +-
 lib/Jifty/Plugin/AccessLog.pm |   20 +++++++++++++-------
 3 files changed, 23 insertions(+), 8 deletions(-)
 create mode 100644 .gitignore

- Log -----------------------------------------------------------------
commit 9586ff1bac4fd1be80d592c0be5e5fcc4f58df75
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 6 15:02:43 2010 -0400

    Make respecting X-Forwarded-For a configurable option, defaults to off

diff --git a/lib/Jifty/Plugin/AccessLog.pm b/lib/Jifty/Plugin/AccessLog.pm
index 1840e40..6b38bdb 100644
--- a/lib/Jifty/Plugin/AccessLog.pm
+++ b/lib/Jifty/Plugin/AccessLog.pm
@@ -2,7 +2,7 @@ package Jifty::Plugin::AccessLog;
 use strict;
 use warnings;
 use base qw/Jifty::Plugin Class::Data::Inheritable/;
-__PACKAGE__->mk_accessors(qw/path format start/);
+__PACKAGE__->mk_accessors(qw/path format start respect_proxy/);
 
 use Jifty::Util;
 use CGI::Cookie;
@@ -33,6 +33,11 @@ Add the following to your site_config.yml
 
 The file to log to; defaults to F<log/access_log>.
 
+=item respect_proxy
+
+If set to a true value, will display the C<X-Forwarded-For> header as
+the originating IP of requests.
+
 =item format
 
 The format string to use when logging.  This module attempts to be as
@@ -153,6 +158,7 @@ sub init {
 
     $self->path(Jifty::Util->absolute_path( $args{path} ));
     $self->format($args{format});
+    $self->respect_proxy($args{respect_proxy});
     Jifty::Handler->add_trigger(
         before_cleanup => sub { $self->before_cleanup }
     );
@@ -210,7 +216,7 @@ sub before_cleanup {
         C => sub { my $c = { CGI::Cookie->fetch() }->{+shift}; $c ? $c->value : undef },
         D => sub { sprintf "%.3fms", (Time::HiRes::time - $self->start)*1000 },
         e => sub { $ENV{+shift} },
-        h => sub { $r->header("X-Forwarded-For") || $r->remote_host || $r->address },
+        h => sub { ($self->respect_proxy && $r->header("X-Forwarded-For")) || $r->remote_host || $r->address },
         i => sub { $r->header(shift) },
         l => sub { substr( Jifty->web->session->id || '-', 0, 8 ) },
         m => sub { $r->method },

commit 57f2e3aa867d3d173214a3a6b4523abd5bcec71b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 6 15:03:12 2010 -0400

    Make %a respect X-Forwarded-For, as well

diff --git a/lib/Jifty/Plugin/AccessLog.pm b/lib/Jifty/Plugin/AccessLog.pm
index 6b38bdb..acd5dfe 100644
--- a/lib/Jifty/Plugin/AccessLog.pm
+++ b/lib/Jifty/Plugin/AccessLog.pm
@@ -212,7 +212,7 @@ sub before_cleanup {
 
     my %ESCAPES = (
         '%' => sub { '%' },
-        a => sub { $r->address },
+        a => sub { ($self->respect_proxy && $r->header("X-Forwarded-For")) || $r->address },
         C => sub { my $c = { CGI::Cookie->fetch() }->{+shift}; $c ? $c->value : undef },
         D => sub { sprintf "%.3fms", (Time::HiRes::time - $self->start)*1000 },
         e => sub { $ENV{+shift} },

commit 00bbe1a8bcc364b0e8a38b9b82d7b85efbbd9323
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 6 15:12:28 2010 -0400

    Bump the dep to depend on a Plack-ified version of Jifty

diff --git a/Makefile.PL b/Makefile.PL
index 3e9944e..1ed59bb 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -2,7 +2,7 @@ use inc::Module::Install 0.46;
 name('Jifty-Plugin-AccessLog');
 version_from('lib/Jifty/Plugin/AccessLog.pm');
 
-requires('Jifty');
+requires('Jifty' => 1.00506);
 
 auto_install();
 tests(qw( t/*/t/*.t ));

commit c0390461329efcf346554b0e3ecdeaf6140b1b89
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 6 15:03:36 2010 -0400

    In a post-Plack world, we use $r->env, not %ENV

diff --git a/lib/Jifty/Plugin/AccessLog.pm b/lib/Jifty/Plugin/AccessLog.pm
index acd5dfe..fc3f673 100644
--- a/lib/Jifty/Plugin/AccessLog.pm
+++ b/lib/Jifty/Plugin/AccessLog.pm
@@ -215,7 +215,7 @@ sub before_cleanup {
         a => sub { ($self->respect_proxy && $r->header("X-Forwarded-For")) || $r->address },
         C => sub { my $c = { CGI::Cookie->fetch() }->{+shift}; $c ? $c->value : undef },
         D => sub { sprintf "%.3fms", (Time::HiRes::time - $self->start)*1000 },
-        e => sub { $ENV{+shift} },
+        e => sub { $r->env->{+shift} },
         h => sub { ($self->respect_proxy && $r->header("X-Forwarded-For")) || $r->remote_host || $r->address },
         i => sub { $r->header(shift) },
         l => sub { substr( Jifty->web->session->id || '-', 0, 8 ) },
@@ -224,8 +224,8 @@ sub before_cleanup {
         o => sub { Jifty->web->response->header(shift) },
         p => sub {
             return Jifty->config->framework("Web")->{Port} if $_[0] eq "canonical";
-            return $ENV{SERVER_PORT} if $_[0] eq "local";
-            return $ENV{REMOTE_PORT} if $_[0] eq "remote";
+            return $r->env->{SERVER_PORT} if $_[0] eq "local";
+            return $r->env->{REMOTE_PORT} if $_[0] eq "remote";
             return Jifty->config->framework("Web")->{Port};
         },
         P => sub { $$ },

commit f5219798a13c0c0a51b64e94dd91155320a9bf96
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 6 15:14:43 2010 -0400

    Version 1.0 releng

diff --git a/lib/Jifty/Plugin/AccessLog.pm b/lib/Jifty/Plugin/AccessLog.pm
index fc3f673..053693b 100644
--- a/lib/Jifty/Plugin/AccessLog.pm
+++ b/lib/Jifty/Plugin/AccessLog.pm
@@ -8,7 +8,7 @@ use Jifty::Util;
 use CGI::Cookie;
 use Time::HiRes qw();
 
-our $VERSION = 0.01;
+our $VERSION = 1.0;
 
 =head1 NAME
 

commit 1b0acec53764bd0bd316e384f2507898cfe777a6
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 6 15:16:49 2010 -0400

    Add a .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..18fdd76
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+MANIFEST
+META.yml
+Makefile
+Makefile.old
+SIGNATURE
+blib/
+inc/
+pm_to_blib
+MANIFEST.bak

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list