Skip Menu |

This queue is for tickets about the Net-Telnet CPAN distribution.

Report information
The Basics
Id: 29331
Status: resolved
Priority: 0/
Queue: Net-Telnet

People
Owner: Nobody in particular
Requestors: markpf [...] mlp-consulting.com.au
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 3.03
Fixed in: 3.04



Subject: Addtional 'bind' option for hosts with virtual IPs
Hi Jay, great module! I have a very simple patch that will allow a user to bind the local end of your socket to any virtual interface. It creates the 'bind' option. My code is not very pretty and I could have used better names but you'll understand I think. -- cheers markpf Here is a simple diff against 3.03 diff Telnet.pm.orig /usr/share/perl5/Net/Telnet.pm 86a87 Show quoted text
> bind => undef,
175a177,179 Show quoted text
> elsif (/^-?bind$/i) { > $self->Bind($args{$_}); > }
888a893,910 Show quoted text
> sub Bind { > my ($self, $host) = @_; > my ( $prev, $s,); > > $s = *$self->{net_telnet}; > $prev = $s->{bind}; > > if (@_ >= 2) { > unless (defined $host) { > $host = ""; > } > > $s->{bind} = $host; > } > > $prev; > } # end sub bind >
1203a1226 Show quoted text
> $bind,
1252a1276 Show quoted text
> $bind = $self->Bind;
1284a1309,1314 Show quoted text
> if(defined $bind) > { > my $name = sockaddr_in(0,inet_aton($bind)) ||
die "bind name: $!"; Show quoted text
> bind($self, $name) || die "bind: $!"; > } >
Чтв. Сен. 13 00:46:01 2007, MARKPF писал: Show quoted text
> Hi Jay, great module! > > I have a very simple patch that will allow a user to bind the local end > of your socket to any virtual interface. It creates the 'bind' option. > > My code is not very pretty and I could have used better names but you'll > understand I think.
Hi. Here is more complicated patch for that task.
154a155,157 > elsif (/^-?lhost$/i) { > $self->lhost($args{$_}); > } 909a913,932 > sub lhost { > my ($self, $host) = @_; > my ( > $prev, > $s, > ); > > $s = *$self->{net_telnet}; > $prev = $s->{lhost}; > > if (@_ >= 2) { > unless (defined $host) { > $host = ""; > } > > $s->{lhost} = $host; > } > > $prev; > } # end sub lhost 1203a1227 > $lhost, 1251a1276 > $lhost = $self->lhost; 1284a1310,1315 > if ($lhost) { > my $local_ip_addr = inet_aton $lhost > or die "unknown local host: $lhost\n"; > bind $self, sockaddr_in(0, $local_ip_addr); > } > 1320a1352,1357 > if ($lhost) { > my $local_ip_addr = inet_aton $lhost > or die "unknown local host: $lhost\n"; > bind $self, sockaddr_in(0, $local_ip_addr); > } > 3544a3582 > [LHost => $lhost,]
Hi, Jay. Can you apply at least one patch and solve this problem? ;) I can rework my patch if there is a need -- can update documentation etc.
I've added the localhost() method and parameters for binding to a local network interface. It is in the development version for 3.04. You can find the development version at ftp://ftp.rgrs.com Thanks for submitting this request.