Loading ...
Sorry, an error occurred while loading the content.

using soap:lite as daemon, capturing the clients IP ?? Help

Expand Messages
  • killyourspam
    Trying to find a way to get a hold of the client s IP as they come to the soap daemon server.. Date: Tue, 17 Feb 2009 21:23:59 GMT Server:
    Message 1 of 3 , Feb 17, 2009
    • 0 Attachment
      Trying to find a way to get a hold of the client's IP as they
      come to the soap daemon server..




      Date: Tue, 17 Feb 2009 21:23:59 GMT
      Server: libwww-perl-daemon/1.36
      Content-Length: 5860
      Content-Type: text/xml; charset=utf-8
      Client-Date: Tue, 17 Feb 2009 21:23:59 GMT
      Client-Peer: 127.0.0.1:88
      Client-Response-Num: 1
      SOAPServer: SOAP::Lite/Perl/0.710.08

      here is my server script
      #!/usr/bin/perl -w
      # -- SOAP::Lite -- soaplite.com -- Copyright (C) 2001 Paul Kulchenko -
      use strict;
      use DBI;
      use SOAP::payload ;
      use Data::Dumper;
      use SOAP::Transport::HTTP

      $SIG{PIPE} = $SIG{INT} = 'IGNORE'; # don't want to die on 'Broken
      pipe' or Ctrl-C

      my $daemon = SOAP::Transport::HTTP::Daemon
      -> new (LocalAddr => 'localhost', LocalPort => 88, 'Reuse' => 1 )
      -> objects_by_reference(qw(My::PersistentIterator
      My::SessionIterator My::Chat SOAP::payload))
      -> dispatch_to('/home/tmoore/soap', 'Module::Hello', 'Module::HIBY')
      -> options({compress_threshold => 10000});
      print "Contact to SOAP server at ", $daemon->url, "\n";
      $daemon->handle;

      ###################################
      this works great but how can I obtain the clients IP address showing
      up at port 88 to get service.

      I can go back to the cgi version to use apache and its logging but
      that is way to easy.

      I dug into the IO::Socket modules looking for things but was not
      able to put anything together using the soap modules.


      use Socket;
      $mysockaddr = getsockname(SOCK);
      ($port, $myaddr) = sockaddr_in($mysockaddr);
      printf "Connect to %s [%s]\n",
      scalar gethostbyaddr($myaddr, AF_INET),
      inet_ntoa($myaddr);


      use Socket;
      $hersockaddr = getpeername(SOCK);
      ($port, $iaddr) = sockaddr_in($hersockaddr);
      $herhostname = gethostbyaddr($iaddr, AF_INET);
      $herstraddr = inet_ntoa($iaddr);


      Thanks in advance for tips on capuring at client IP ..
    • rahed
      ... You can get the address from peerhost method applied on a connected socket. The method is from IO::Socket::INET. -- Radek
      Message 2 of 3 , Feb 19, 2009
      • 0 Attachment
        On Tue, Feb 17, 2009 at 11:00 PM, killyourspam <killyourspam@...> wrote:
        > Trying to find a way to get a hold of the client's IP as they
        > come to the soap daemon server..

        You can get the address from peerhost method applied on a connected socket.
        The method is from IO::Socket::INET.


        --
        Radek
      • rahed
        On Thu, Feb 19, 2009 at 2:56 PM, dennis.davidoff ... I use ForkOnAccept module which is part of the distribution: $daemon- ForkOnAccept::handle; ... package
        Message 3 of 3 , Feb 20, 2009
        • 0 Attachment
          On Thu, Feb 19, 2009 at 2:56 PM, dennis.davidoff
          <dennis.davidoff@...> wrote:
          > Please, show an example.

          I use ForkOnAccept module which is part of the distribution:
          $daemon->ForkOnAccept::handle;
          ...

          package ForkOnAccept;
          ...
          sub handle {
          my $self = shift->new;

          CLIENT:
          while (my $c = $self->accept) {
          my $address = $c->peerhost;
          ....

          Where $c is the object of the connected socket.
          Actually I do not call peerhost to use it further.


          --
          Radek
        Your message has been successfully submitted and would be delivered to recipients shortly.