"M.J.T. Guy" <mjtg@cus.cam.ac.uk> writes: > Gisle Aas <gisle@aas.no> wrote > > I have had several requests for a way to control the 'LocalAddr' used > > for connections made by LWP. I think the best way to deal with this > > is to make is configurable at the IO::Socket::INET level. In this > > patch I have chosen to make it default from an environment variable. > > Another approach could be to provide a class method or simply a global > > variable like $IO::Socket::INET::DEFAULT_LOCAL_ADDR. Any other > > thoughts or suggestiong for a better environment variable name? > > a) I don't see the need to do this at the IO::Socket level. The alternative for me would be to either modify every LWP protocol module to pass on LocalAddr based on some request headers or to make a module like this one: package LWP::IO::Socket::INET; use base 'IO::Socket::INET'; use vars qw($LOCAL_ADDR); sub new { my $class = shift; unshift(@_, "PeerAddr") if @_ == 1; my %arg = @_; $arg{LocalAddr} = $LOCAL_ADDR if $LOCAL_ADDR && !exists $arg{LocalAddr} && !exists $arg{LocalHost}; return $class->SUPER::new(%arg); } 1; ...and then change every occurrence of "IO::Socket::INET" to "LWP::IO::Socket::INET". I prefer to do it at the IO::Socket level, because then this feature also become available for the libnet modules and other modules based on IO::Socket::INET. > b) If it is done, a global variable is preferable to an environment > variable. I now agree. > c) Shouldn't environment variables used by Perl have names starting > PERL... ? Probably a good convention. Regards, GisleThread Previous | Thread Next