Re: Possibility to force domain=>ip for useragent->request($request....

Bradley Dean <[email protected]> Fri, 23 Sep 2011 21:06:11 +1000
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Hi Jesper,

Here's one way that I've used:

  my $override_ip = '10.1.2.3';
  my $ua = LWP::UserAgent->new();
  @LWP::Protocol::http::EXTRA_SOCK_OPTS = ( PeerAddr => $override_ip );

Cheerio,

  Brad

On 23/09/11 21:01, Jesper Persson wrote:
> Hi everybody,
>
> is there some way of forcing what ip-address useragent->request connects to
> when you make a http request to some website?
> If I already know what ip-address a domain resolves to and dont want to rely
> on the local dns og hosts file, it would be great if you could force perl to
> use a specific ip-address.
>
> In site/lib/LWP/Protocol/http.pm I can see the line:
>     # connect to remote site
>     my $socket = $self->_new_socket($host, $port, $timeout);
>
> I am guessing that it should be there that an ip should be inserted instead
> of the $host.
>
> If there isn't a way to do it already, do you think it could be relevant in
> the LWP?
>
> Regards
> Jesper Persson
>

-- 
Bradley Dean
Email: [email protected] Skype: [email protected]
Mobile(Aus): +61-413014395 WWW: http://bjdean.id.au/