4 # this is where the fun starts!
6 # Copyright (c) 1998 Dirk Koopman G1TLH
11 my ($self, $line) = @_;
12 my @f = split /\s+/, $line, 3;
13 my $spotter = $self->call;
23 return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript;
24 return (1, $self->msg('e28')) unless $self->isregistered;
27 my $addr = $self->hostname || '127.0.0.1';
28 $addr = $main::localhost_alias_ipv6 if $addr eq '::1' && $main::localhost_alias_ipv6;
29 $addr = $main::localhost_alias_ipv4 if $addr =~ /^127\./ && $main::localhost_alias_ipv4;
31 Log('cmd', "$self->{call}|$addr|dx|$line");
34 if (@bad = BadWords::check($line)) {
35 $self->badcount(($self->badcount||0) + @bad);
36 LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
40 # do we have at least two args?
41 return (1, $self->msg('dx2')) unless @f >= 2;
43 # as a result of a suggestion by Steve K9AN, I am changing the syntax of
44 # 'spotted by' things to "dx by g1tlh <freq> <call>" <freq> and <call>
47 if ($f[0] =~ /^by$/i) {
48 return (1, $self->msg('e5')) unless $main::allowdxby || $self->priv > 1;
50 $line =~ s/^\s*$f[0]\s+$f[1]\s+//;
51 @f = split /\s+/, $line, 3;
52 return (1, $self->msg('dx2')) unless @f >= 2;
56 @f = split /\s+/, $line, 3;
58 return (1, $self->msg('e5')) unless $spotter && $self->priv > 1;
59 if (is_ipaddr($f[1])) {
62 return (1, $self->msg('dx4', $f[1]));
64 $line =~ s/^\s*$f[0]\s+$f[1]\s+//;
65 @f = split /\s+/, $line, 3;
69 # get the freq and callsign either way round
70 if (is_freq($f[1]) && $f[0] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
73 } elsif (is_freq($f[0]) && $f[1] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
77 return (1, $self->msg('dx3'));
79 $line =~ s/^\s*$f[0]//;
80 $line =~ s/^\s*$f[1]//;
81 $line =~ unpad($line);
82 $line =~ s/\t+/ /g; # do this here because it needs to be stopped ASAP!
85 if ($self->conn && $self->conn->peerhost) {
86 $ipaddr ||= $addr; # force a PC61
87 } elsif ($self->inscript) {
91 # check some other things
92 # remove ssid from calls
93 my $spotternoid = basecall($spotter);
94 my $callnoid = basecall($self->{call});
98 if ($DXProt::baddx->in($spotted)) {
101 if ($DXProt::badspotter->in($spotternoid) || $self->badip) {
102 LogDbg('DXCommand', "badspotter $spotternoid as $spotter ($oline) from $addr");
106 dbg "spotter $spotternoid/$callnoid\n";
108 if (($spotted =~ /$spotternoid/ || $spotted =~ /$callnoid/) && $freq < $Spot::minselfspotqrg) {
109 LogDbg('DXCommand', "$spotternoid/$callnoid trying to self spot below ${Spot::minselfspotqrg}KHz ($oline) from $addr, not passed on to cluster");
113 # bash down the list of bands until a valid one is reached
120 foreach $bandref (Bands::get_all()) {
121 @bb = @{$bandref->band};
122 for ($i = 0; $i < @bb; $i += 2) {
123 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
133 $freq = $freq * 1000 if $freq;
136 foreach $bandref (Bands::get_all()) {
137 @bb = @{$bandref->band};
138 for ($i = 0; $i < @bb; $i += 2) {
139 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
148 push @out, $self->msg('dx1', $freq) unless $valid;
150 # check we have a callsign :-)
151 if ($spotted le ' ') {
152 push @out, $self->msg('dx2');
156 return (1, @out) unless $valid;
158 # Store it here (but only if it isn't baddx)
159 my $t = (int ($main::systime/60)) * 60;
160 return (1, $self->msg('dup')) if Spot::dup($freq, $spotted, $t, $line, $spotter, $main::mycall);
161 my @spot = Spot::prepare($freq, $spotted, $t, $line, $spotter, $main::mycall, $ipaddr);
165 if ($freq =~ /^69/ || $localonly) {
167 # heaven forfend that we get a 69Mhz band :-)
168 if ($freq =~ /^69/) {
169 $self->badcount(($self->badcount||0) + 1);
172 $self->dx_spot(undef, undef, @spot);
176 # send orf to the users
177 $ipaddr ||= $main::mycall; # emergency backstop
178 my $spot = DXProt::pc61($spotter, $freq, $spotted, unpad($line), $ipaddr);
180 $self->dx_spot(undef, undef, @spot);
181 if ($self->isslugged) {
182 push @{$self->{sluggedpcs}}, [61, $spot, \@spot];
184 # store in spots database
186 DXProt::send_dx_spot($self, $spot, @spot);