[MAILER-DAEMON@tmtowtdi.perl.org] failure notice

Gisle Aas (gisle@aas.no)
07 Apr 2000 13:04:12 +0200


Last week I tried a crosspost between <libwww@perl.org> and
comp.lang.perl.misc that failed.  It described a way to specify the
interface on a multihomed host to send requests from.

Regards,
Gisle




--=-=-=
Content-Type: message/rfc822
Content-Disposition: inline

X-From-Line: MAILER-DAEMON Fri Mar 31 12:02:05 2000
X-Gnus-Mail-Source: file:/var/spool/mail/gisle
Message-ID: <m3bt3v9wl1.fsf@totally-fudged-out-message-id>
Return-Path: <>
Delivered-To: gisle@g.aas.no
Received: (qmail 7631 invoked from network); 31 Mar 2000 12:02:05 -0000
Received: from localhost (127.0.0.1)
  by localhost with QMTP; 31 Mar 2000 12:02:05 -0000
Received: (qmail 28587 invoked by uid 414); 31 Mar 2000 10:23:58 -0000
Delivered-To: aas-gisle@aas.no
Received: (qmail 28584 invoked from network); 31 Mar 2000 10:23:57 -0000
Received: from tmtowtdi.perl.org (209.85.3.25)
  by mail.linpro.no with SMTP; 31 Mar 2000 10:23:57 -0000
Received: (qmail 10535 invoked for bounce); 31 Mar 2000 10:23:56 -0000
Date: 31 Mar 2000 10:23:56 -0000
From: MAILER-DAEMON@tmtowtdi.perl.org
To: gisle@aas.no
Subject: failure notice
Lines: 106
Xref: eik.g.aas.no box:18435

Hi. This is the qmail-send program at tmtowtdi.perl.org.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<libwww@perl.org>:
This mailinglist does not accept postings crossposted to newsgroups - Contact list-owner@perl.org for help

--- Below this line is a copy of the message.

Return-Path: <gisle@aas.no>
Received: (qmail 10528 invoked from network); 31 Mar 2000 10:23:55 -0000
Received: from mail49-s.fg.online.no (HELO mail49.fg.online.no) (148.122.161.49)
  by tmtowtdi.perl.org with SMTP; 31 Mar 2000 10:23:55 -0000
Received: from eik (ti21a62-0097.dialup.online.no [130.67.197.225])
	by mail49.fg.online.no (8.9.3/8.9.3) with ESMTP id MAA14176
	for <libwww@perl.org>; Fri, 31 Mar 2000 12:23:52 +0200 (MET DST)
Received: (qmail 7340 invoked by uid 500); 31 Mar 2000 10:22:31 -0000
Sender: gisle@eik.g.aas.no
Newsgroups: comp.lang.perl.misc
Cc: libwww@perl.org
Subject: Re: HTTP Request
References: <EEQE4.609$fV5.30166@news.uswest.net>
From: Gisle Aas <gisle@aas.no>
Date: 31 Mar 2000 11:53:30 +0200
Message-ID: <m3ln2zxy79.fsf@eik.g.aas.no>
Organization: Aas Software
User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.3
In-Reply-To: "Dan Manion"'s message of "Thu, 30 Mar 2000 15:29:50 -0700"
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Posted-To: comp.lang.perl.misc
Lines: 72

The following message is a courtesy copy of an article
that has been posted to comp.lang.perl.misc as well.

"Dan Manion" <news@webneeds.com> writes:

> Ok let me fist start off with the problem I am trying to solve.  I need to
> make a web request where I can specify the IP that the request is being
> sending with.  I am not trying to spoof.  Lets say I have the IP's
> 10.10.10.1-100 bound to one virtual hosting machine who's IP is 10.10.10.1 .
> If I run the code below I the request comes from host computers IP.  I would
> like to be able to specify the IP that I am sending with.  So if I have
> 10.10.10.50 bound to mybutt.com .. I can make a request as if the request
> was being sent from mybutt.com and not my default IP (10.10.10.1).
> 
> So I guess I'm wondering if this is even possible using a standard library
> and if so what libraries will I have to sub class to get it to work.  Any
> advice / input / suggestions are appreciated!

This has been requested enough times that I think I just have to make
it easier :-)

What you can do for now is to replace the class that handles lower
level http communication by calling LWP::Protocol::implementor().  The
new class would then have to set up a socket where it specify
LocalAddr as well.  The rest of its implementation it could just
inherit from the standard http protocol module.

This should be an demo:

#!/usr/bin/perl -w
use strict; #of course

package MyHTTP;
use base 'LWP::Protocol::http';

sub _new_socket  # mostly copied from LWP::Protocol::http, added LocalAddr
{
    my($self, $host, $port, $timeout) = @_;

    local($^W) = 0;  # IO::Socket::INET can be noisy
    my $sock = IO::Socket::INET->new(PeerAddr => $host,
                                     PeerPort => $port,
                                     LocalAddr => "mybutt.com",
                                     Proto    => 'tcp',
                                     Timeout  => $timeout,
                                    );
    unless ($sock) {
        # IO::Socket::INET leaves additional error messages in $@
        $@ =~ s/^.*?: //;
        die "Can't connect to $host:$port ($@)";
    }
    $sock;
}

package main;

use LWP::UserAgent;
use HTTP::Request;

use LWP::Protocol;
LWP::Protocol::implementor("http", "MyHTTP");

my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new(GET => 'http://www.microshaft.com/');
my $response = $ua->request($request);

print $response->as_string;

__END__

Regards,
Gisle


--=-=-=--