[Bps-public-commit] Net-Server-Coro branch, master, updated. 0.7-2-gdb8e98b

Alex M Vandiver alexmv at bestpractical.com
Thu Dec 24 11:54:18 EST 2009


The branch, master has been updated
       via  db8e98bf7604c421242439432e482cca68bf1c36 (commit)
       via  12dbdc960306d50ef3fdae28af46d51b1f53793b (commit)
      from  ea13b3581b04f3d6cd630c180cadc6dd0cf0157e (commit)

Summary of changes:
 lib/Net/Server/Coro.pm |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 12dbdc960306d50ef3fdae28af46d51b1f53793b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Dec 24 11:48:32 2009 -0500

    Do reverse lookups (in to "peerhost") if reverse_lookups is set, as Net::Server does

diff --git a/lib/Net/Server/Coro.pm b/lib/Net/Server/Coro.pm
index 8fe0f6e..3de0677 100644
--- a/lib/Net/Server/Coro.pm
+++ b/lib/Net/Server/Coro.pm
@@ -7,6 +7,8 @@ use vars qw($VERSION);
 use EV;
 use Coro;
 use Coro::Specific;
+use Coro::Util ();
+use Socket ();
 use base qw(Net::Server);
 use Net::Server::Proto::Coro;
 
@@ -82,7 +84,7 @@ sub post_bind_hook {
     $prop->{sock} = [ map { $self->make_coro_socket($_) } @{ $prop->{sock} } ];
 
     # set up coro::specific variables
-    foreach my $key (qw(client sockaddr sockport peeraddr peerport)) {
+    foreach my $key (qw(client sockaddr sockport peeraddr peerport peerhost)) {
         tie $prop->{$key}, Coro::Specific::;
     }
 }
@@ -130,6 +132,10 @@ sub post_accept_hook {
 
     ($prop->{sockaddr}, $prop->{sockport}) = ($sock->sockhost, $sock->sockport);
     ($prop->{peeraddr}, $prop->{peerport}) = ($sock->peerhost, $sock->peerport);
+
+    if (defined $prop->{reverse_lookups}) {
+        $prop->{peerhost} = Coro::Util::gethostbyaddr($sock->peeraddr, Socket::AF_INET);
+    }
 }
 
 =head2 loop

commit db8e98bf7604c421242439432e482cca68bf1c36
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Dec 24 11:49:14 2009 -0500

    Override get_client_info, instead of post_accept_hook, to avoid warnings

diff --git a/lib/Net/Server/Coro.pm b/lib/Net/Server/Coro.pm
index 3de0677..c40147e 100644
--- a/lib/Net/Server/Coro.pm
+++ b/lib/Net/Server/Coro.pm
@@ -125,7 +125,7 @@ sub coro_instance {
     $self->run_client_connection;
 }
 
-sub post_accept_hook {
+sub get_client_info {
     my $self = shift;
     my $prop = $self->{server};
     my $sock = $prop->{client};
@@ -136,6 +136,10 @@ sub post_accept_hook {
     if (defined $prop->{reverse_lookups}) {
         $prop->{peerhost} = Coro::Util::gethostbyaddr($sock->peeraddr, Socket::AF_INET);
     }
+
+    $self->log(3, $self->log_time
+        ." CONNECT TCP Peer: \"$prop->{peeraddr}:$prop->{peerport}\""
+        ." Local: \"$prop->{sockaddr}:$prop->{sockport}\"\n");
 }
 
 =head2 loop

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



More information about the Bps-public-commit mailing list