Remote IP

Matthias Jansen mail at matthiasjansen.de
Fri Oct 12 00:02:50 PDT 2007


> Hi,
>
> On Thu, Oct 11, 2007 at 11:32:01AM -0700, Matthias Jansen wrote:
> > > Matthias Jansen wrote:
> > > > ...
> > > > So, parsing the cxxxx file will be the only way to retrieve the IP at the moment?
> > >
> > > The format may change at any time; the only supported method is
> > > to issue an IPP request to the local server to get it.
> >
> > OK, I have no idea how to do that. Would it be possible to give me
> > an example? Preferable perl, but could be in any language.
>
> In python with the help of pkipplib, a pure Python implementation
> of IPP :
>
> --- CUT ---
> #�Download pkipplib from http://www.pykota.com
> from pkipplib import pkipplib
>
> cups = pkipplib.CUPS() # by default http://localhost:631
>                        #�Doesn't work yet with unix domain sockets
>
> # Retrieve all attributes of job #1563
> answer = cups.getJobAttributes(1563)
>
> #�Display the one we are interested in
> print answer.job["job-originating-host-name"][0][1]
> --- CUT ---
>
> Could this be made simpler than that ?

Thank you very much, indeed it is very simple (Shame on me).

Just for completeness, here is my perl code to receive the sending ip:

--------- CUT ----------
#!/usr/bin/perl -w

use strict;
use warnings;

use Net::IPP::IPPMethods qw(:all);
use Net::IPP::IPPUtil qw(:all);

my $url = "http://localhost:631/";

print "RemoteIP: ".&getRemoteIP($url, 1732)."\n";

sub getRemoteIP {
        my $url = shift;
        my $id = shift;

        my $response = getJobAttributes($url, $id);

        return findAttribute($response, "job-originating-host-name") if (isSuccessful($response));

        return undef;
}
--------- CUT ----------


Thank you all for support! Now, I'm able to continue with my cups-fax printer. Will be released under GPL if anybody cares to use it.

Best regards,

Matthias Jansen




More information about the cups-devel mailing list