+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.
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) {
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);
+ }
}
}
undef,
undef,
undef, # pc60
- undef,
+ [ qw(i f m d t m c c a h) ], # pc61
undef,
undef,
undef,
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;
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});
+ }
}
}
# 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;
}
}
}
- 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);
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) = @_;
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
{
@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
);
$!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
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
{
# 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
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
$version = '1.55';
$subversion = '0';
-$build = '69';
+$build = '70';
1;