From ab1e2dae047ba2c778551638a0a90201b14658b2 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Sat, 15 Sep 2007 17:33:26 +0100 Subject: [PATCH 1/1] add optional INET6 capability. Need to load CPAN modules You will need IO::Socket::INET6 to use INET6 capability. Also I have enabled PC92 slugging and set it to 1 minute as default. Also I have put code in to handle empty first node slots in PC92. --- Changes | 7 +++++++ perl/DXProtHandle.pm | 8 ++++++-- perl/Msg.pm | 28 +++++++++++++++++++++------- perl/Version.pm | 2 +- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Changes b/Changes index cda62977..167d28b4 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,10 @@ +15Sep07======================================================================= +1. Add *optional* INET6 connectivity. In order to use this you must load +IO::Socket::INET6 and its dependencies from CPAN or get the distro's packaged +versions. I used 'sudo aptitude install libio-socket-inet6-perl' for ubuntu +(which should work for debian as well), for fedora/rpm based systems +'sudo yum install perl-IO-Socket-INET6' or near equiv should work. This has +been done quite simplistically, but it seems to work. 10Sep07======================================================================= 1. Remove warnings for EINPROGRESS etc for Windows perl 5.8. 2. Try to see if using just one lastid is viable in all situations. If it is diff --git a/perl/DXProtHandle.pm b/perl/DXProtHandle.pm index 1b350615..26eaea40 100644 --- a/perl/DXProtHandle.pm +++ b/perl/DXProtHandle.pm @@ -51,7 +51,7 @@ $pc9x_past_age = 62*60; # maximum age in the past of a px9x (a config record m # thing a node might send - once an hour) $pc9x_future_age = 5*60; # maximum age in the future ditto $pc10_dupe_age = 45; # just something to catch duplicate PC10->PC93 conversions -$pc92_slug_changes = 0; # slug any changes going outward for this long +$pc92_slug_changes = 60; # slug any changes going outward for this long $last_pc92_slug = 0; # the last time we sent out any delayed add or del PC92s # incoming talk commands @@ -1584,7 +1584,11 @@ sub handle_92 # this is the main route section # here is where all the routes are created and destroyed - my @ent = map {[ _decode_pc92_call($_) ]} grep {$_ && /^[0-7]/} @_[4 .. $#_]; + # cope with missing duplicate node calls in the first slot for A or D + my $me = $_[4] || ''; + $me ||= _encode_pc92_call($parent) if !$me && ($sort eq 'A' || $sort eq 'D'); + + my @ent = map {[ _decode_pc92_call($_) ]} grep {$_ && /^[0-7]/} $me, @_[5 .. $#_]; if (@ent) { diff --git a/perl/Msg.pm b/perl/Msg.pm index 00128af6..d4bfba36 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -15,11 +15,10 @@ use strict; use DXUtil; use IO::Select; -use IO::Socket; use DXDebug; use Timer; -use vars qw(%rd_callbacks %wt_callbacks %er_callbacks $rd_handles $wt_handles $er_handles $now %conns $noconns $blocking_supported $cnum $total_in $total_out); +use vars qw(%rd_callbacks %wt_callbacks %er_callbacks $rd_handles $wt_handles $er_handles $now %conns $noconns $blocking_supported $cnum $total_in $total_out $io_socket); %rd_callbacks = (); %wt_callbacks = (); @@ -37,10 +36,25 @@ BEGIN { local $^W; require POSIX; POSIX->import(qw(O_NONBLOCK F_SETFL F_GETFL)) }; + + eval { + local $^W; + require IO::Socket::INET6; + }; + + if ($@) { + dbg($@); + require IO::Socket; + $io_socket = 'IO::Socket::INET'; + } else { + $io_socket = 'IO::Socket::INET6'; + } + $io_socket->import; + if ($@ || $main::is_win) { - $blocking_supported = IO::Socket->can('blocking') ? 2 : 0; + $blocking_supported = $io_socket->can('blocking') ? 2 : 0; } else { - $blocking_supported = IO::Socket->can('blocking') ? 2 : 1; + $blocking_supported = $io_socket->can('blocking') ? 2 : 1; } @@ -194,7 +208,7 @@ sub connect { $conn->{sort} = 'Outgoing'; # Create a new internet socket - my $sock = IO::Socket::INET->new(); + my $sock = $io_socket->new(); return undef unless $sock; my $proto = getprotobyname('tcp'); @@ -225,7 +239,7 @@ sub start_program my $pid; local $^F = 10000; # make sure it ain't closed on exec - my ($a, $b) = IO::Socket->socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC); + my ($a, $b) = $io_socket->socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC); if ($a && $b) { $a->autoflush(1); $b->autoflush(1); @@ -424,7 +438,7 @@ sub new_server { my ($pkg, $my_host, $my_port, $login_proc) = @_; my $self = $pkg->new($login_proc); - $self->{sock} = IO::Socket::INET->new ( + $self->{sock} = $io_socket->new ( LocalAddr => "$my_host:$my_port", # LocalPort => $my_port, Listen => SOMAXCONN, diff --git a/perl/Version.pm b/perl/Version.pm index bf174eef..43f4f669 100644 --- a/perl/Version.pm +++ b/perl/Version.pm @@ -11,6 +11,6 @@ use vars qw($version $subversion $build); $version = '1.54'; $subversion = '0'; -$build = '139'; +$build = '140'; 1; -- 2.43.0