From: Dirk Koopman Date: Thu, 17 Jun 2010 10:45:21 +0000 (+0100) Subject: add ip addresses to dxspots emitted as PC61 X-Git-Tag: 1.56~30 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=cd5b993f99b52d3c3c51779e9ea1fa150232225e;p=spider.git add ip addresses to dxspots emitted as PC61 --- diff --git a/Changes b/Changes index 4865b15b..077acc7c 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ +17Jun10======================================================================= +1. Add ip address to dxspots and default to PC61 output to dxspider nodes 16Jun10======================================================================= 1. Increase default ephemeral dupe time for PC41 and such like lines. 2. Include CTY-2004 updates. diff --git a/cmd/dx.pl b/cmd/dx.pl index 1836f1fe..d8dd56cb 100644 --- a/cmd/dx.pl +++ b/cmd/dx.pl @@ -120,10 +120,17 @@ if ($spotted le ' ') { return (1, @out) unless $valid; +my $ipaddr; + +if ($self->conn->peerhost) { + my $addr = $self->conn->peerhost; + $ipaddr = $addr unless !is_ipaddr($addr) || $addr =~ /^127\./ || $addr =~ /^::[0-9a-f]+$/; +} + # Store it here (but only if it isn't baddx) my $t = (int ($main::systime/60)) * 60; return (1, $self->msg('dup')) if Spot::dup($freq, $spotted, $t, $line, $spotter); -my @spot = Spot::prepare($freq, $spotted, $t, $line, $spotter, $main::mycall); +my @spot = Spot::prepare($freq, $spotted, $t, $line, $spotter, $main::mycall, $ipaddr); if ($freq =~ /^69/ || $localonly) { @@ -140,7 +147,11 @@ if ($freq =~ /^69/ || $localonly) { Spot::add(@spot); # send orf to the users - DXProt::send_dx_spot($self, DXProt::pc11($spotter, $freq, $spotted, $line), @spot); + if ($ipaddr) { + DXProt::send_dx_spot($self, DXProt::pc61($spotter, $freq, $spotted, $line, $ipaddr), @spot); + } else { + DXProt::send_dx_spot($self, DXProt::pc11($spotter, $freq, $spotted, $line), @spot); + } } } diff --git a/perl/DXProt.pm b/perl/DXProt.pm index 72f41194..92a36d1e 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -134,7 +134,7 @@ $pc92_find_timeout = 30; # maximum time to wait for a reply undef, undef, undef, # pc60 - undef, + [ qw(i f m d t m c c a h) ], # pc61 undef, undef, undef, @@ -205,6 +205,8 @@ sub check return $i unless $_[$i] =~ /^[012]\d[012345]\dZ$/; } elsif ($act eq 'l') { return $i unless $_[$i] =~ /^[A-Z]$/; + } elsif ($act eq 'a') { + return $i unless is_ipaddr($_[$i]); } } return 0; @@ -544,14 +546,22 @@ sub send_dx_spot my $line = shift; my @dxchan = DXChannel::get_all(); my $dxchan; + my $pc11; # send it if it isn't the except list and isn't isolated and still has a hop count # taking into account filtering and so on foreach $dxchan (@dxchan) { next if $dxchan == $main::me; next if $dxchan == $self && $self->is_node; - next if $line =~ /PC61/ && !$dxchan->is_spider && !$dxchan->is_user; - $dxchan->dx_spot($line, $self->{isolate}, @_, $self->{call}); + if ($line =~ /PC61/ && !($dxchan->is_spider || $dxchan->is_user)) { + unless ($pc11) { + my @f = split /\^/, $line; + $pc11 = join '^', 'PC11', @f[1..7,9]; + } + $dxchan->dx_spot($pc11, $self->{isolate}, @_, $self->{call}); + } else { + $dxchan->dx_spot($line, $self->{isolate}, @_, $self->{call}); + } } } diff --git a/perl/DXProtHandle.pm b/perl/DXProtHandle.pm index c5d4bf4e..43e5670c 100644 --- a/perl/DXProtHandle.pm +++ b/perl/DXProtHandle.pm @@ -171,13 +171,13 @@ sub handle_11 # convert the date to a unix date my $d = cltounix($_[3], $_[4]); # bang out (and don't pass on) if date is invalid or the spot is too old (or too young) - if (!$d || ($pcno == 11 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) { + if (!$d || (($pcno == 11 || $pcno == 61) && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) { dbg("PCPROT: Spot ignored, invalid date or out of range ($_[3] $_[4])\n") if isdbg('chanerr'); return; } # is it 'baddx' - if ($baddx->in($_[2]) || BadWords::check($_[2]) || $_[2] =~ /COCK/) { + if ($baddx->in($_[2]) || BadWords::check($_[2])) { dbg("PCPROT: Bad DX spot, ignored") if isdbg('chanerr'); return; } @@ -197,7 +197,7 @@ sub handle_11 } } - my @spot = Spot::prepare($_[1], $_[2], $d, $_[5], $nossid, $_[7]); + my @spot = Spot::prepare($_[1], $_[2], $d, $_[5], $nossid, $_[7], $_[8]); # global spot filtering on INPUT if ($self->{inspotsfilter}) { my ($filter, $hops) = $self->{inspotsfilter}->it(@spot); diff --git a/perl/DXProtout.pm b/perl/DXProtout.pm index f01a1481..ba301338 100644 --- a/perl/DXProtout.pm +++ b/perl/DXProtout.pm @@ -47,7 +47,7 @@ sub pc10 return "PC10^$from^$user1^$text^*^$user2^$origin^~"; } -# create a dx message (call, freq, dxcall, text) +# create a dx message (call, freq, dxcall, text) see also pc61 sub pc11 { my ($mycall, $freq, $dxcall, $text) = @_; @@ -58,6 +58,17 @@ sub pc11 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t); } +# create a dx message (call, freq, dxcall, text, $ipaddr) see also pc11 +sub pc61 +{ + my ($mycall, $freq, $dxcall, $text, $ipaddr) = @_; + my $hops = get_hops(61) || get_hops(11); + my $t = time; + $text = ' ' if !$text; + $text =~ s/\^/%5E/g; + return sprintf "PC61^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$ipaddr^$hops^~", $freq, cldate($t), ztime($t); +} + # create an announce message sub pc12 { diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index 512c30ef..49cba9e9 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -22,9 +22,9 @@ require Exporter; @EXPORT = qw(atime ztime cldate cldatetime slat slong yesno promptf parray parraypairs phex phash shellregex readfilestr writefilestr filecopy ptimelist - print_all_fields cltounix unpad is_callsign is_latlong + print_all_fields cltounix unpad is_callsign is_long_callsign is_latlong is_qra is_freq is_digits is_pctext is_pcflag insertitem deleteitem - is_prefix dd + is_prefix dd is_ipaddr ); @@ -383,6 +383,18 @@ sub is_callsign $!x; } +# check that a field only has callsign characters in it but has more than the standard 3 callsign letters +sub is_long_callsign +{ + return $_[0] =~ m!^(?:[A-Z]{1,2}\d+ | \d[A-Z]{1,2}\d+) # basic prefix + (?:/(?:[A-Z]{1,2}\d+ | \d[A-Z]{1,2}\d+))? # / another one (possibly) + [A-Z]{1,5} # callsign letters + (?:/(?:[A-Z]{1,2}\d+ | \d[A-Z]{1,2}\d+))? # / another prefix possibly + (?:/[0-9A-Z]{1,2})? # /0-9A-Z+ possibly + (?:-\d{1,2})? # - nn possibly + $!x; +} + sub is_prefix { return $_[0] =~ m!^(?:[A-Z]{1,2}\d+ | \d[A-Z]{1,2}\d+)!x # basic prefix @@ -427,6 +439,12 @@ sub is_latlong return $_[0] =~ /^\s*\d{1,2}\s+\d{1,2}\s*[NnSs]\s+1?\d{1,2}\s+\d{1,2}\s*[EeWw]\s*$/; } +# is it an ip address? +sub is_ipaddr +{ + return $_[0] =~ /^\d+\.\d+\.\d+\.\d+$/ || $_[0] =~ /^[0-9a-f:]+$/; +} + # insert an item into a list if it isn't already there returns 1 if there 0 if not sub insertitem { diff --git a/perl/Spot.pm b/perl/Spot.pm index e7227ab1..b8efd3d1 100644 --- a/perl/Spot.pm +++ b/perl/Spot.pm @@ -161,7 +161,7 @@ sub prefix # fix up the full spot data from the basic spot data sub prepare { - # $freq, $call, $t, $comment, $spotter = @_ + # $freq, $call, $t, $comment, $spotter, node, ip address = @_ my @out = @_[0..4]; # just up to the spotter # normalise frequency @@ -180,7 +180,9 @@ sub prepare my @spt = Prefix::cty_data($out[4]); push @out, $spt[0]; push @out, $_[5]; - return (@out, @spd[1,2], @spt[1,2], $spd[3], $spt[3]); + push @out, @spd[1,2], @spt[1,2], $spd[3], $spt[3]; + push @out, $_[6] if $_[6] && is_ipaddr($_[6]); + return @out; } sub add diff --git a/perl/Version.pm b/perl/Version.pm index ddd32c66..143e0055 100644 --- a/perl/Version.pm +++ b/perl/Version.pm @@ -11,6 +11,6 @@ use vars qw($version $subversion $build); $version = '1.55'; $subversion = '0'; -$build = '69'; +$build = '70'; 1;