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 Log('cmd', "$self->{call}|$addr|dx|$line");
31 if (@bad = BadWords::check($line)) {
32 $self->badcount(($self->badcount||0) + @bad);
33 LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
37 # do we have at least two args?
38 return (1, $self->msg('dx2')) unless @f >= 2;
40 # as a result of a suggestion by Steve K9AN, I am changing the syntax of
41 # 'spotted by' things to "dx by g1tlh <freq> <call>" <freq> and <call>
44 if ($f[0] =~ /^by$/i) {
45 return (1, $self->msg('e5')) unless $main::allowdxby || $self->priv > 1;
47 $line =~ s/^\s*$f[0]\s+$f[1]\s+//;
48 @f = split /\s+/, $line, 3;
49 return (1, $self->msg('dx2')) unless @f >= 2;
53 @f = split /\s+/, $line, 3;
55 return (1, $self->msg('e5')) unless $spotter && $self->priv > 1;
56 if (is_ipaddr($f[1])) {
59 return (1, $self->msg('dx4', $f[1]));
61 $line =~ s/^\s*$f[0]\s+$f[1]\s+//;
62 @f = split /\s+/, $line, 3;
66 # get the freq and callsign either way round
67 if (is_freq($f[1]) && $f[0] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
70 } elsif (is_freq($f[0]) && $f[1] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
74 return (1, $self->msg('dx3'));
76 $line =~ s/^\s*$f[0]//;
77 $line =~ s/^\s*$f[1]//;
78 $line =~ unpad($line);
79 $line =~ s/\t+/ /g; # do this here because it needs to be stopped ASAP!
82 if ($self->conn && $self->conn->peerhost) {
83 $ipaddr ||= $addr; # force a PC61
84 } elsif ($self->inscript) {
88 # check some other things
89 # remove ssid from calls
90 my $spotternoid = basecall($spotter);
91 my $callnoid = basecall($self->{call});
95 if ($DXProt::baddx->in($spotted)) {
98 if ($DXProt::badspotter->in($spotternoid)) {
99 LogDbg('DXCommand', "badspotter $spotternoid as $spotter ($oline) from $ipaddr");
102 if ($ipaddr && DXCIDR::find($ipaddr)) {
103 LogDbg('DXCommand', "Bad IP address $ipaddr $spotternoid as $spotter ($oline)");
107 #dbg "spotter $spotternoid/$callnoid\";
109 if (($spotted =~ /$spotternoid/ || $spotted =~ /$callnoid/) && $freq < $Spot::minselfspotqrg) {
110 LogDbg('DXCommand', "$spotternoid/$callnoid trying to self spot below ${Spot::minselfspotqrg}KHz ($oline) from $addr, not passed on to cluster");
114 # bash down the list of bands until a valid one is reached
121 foreach $bandref (Bands::get_all()) {
122 @bb = @{$bandref->band};
123 for ($i = 0; $i < @bb; $i += 2) {
124 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
134 $freq = $freq * 1000 if $freq;
137 foreach $bandref (Bands::get_all()) {
138 @bb = @{$bandref->band};
139 for ($i = 0; $i < @bb; $i += 2) {
140 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
149 push @out, $self->msg('dx1', $freq) unless $valid;
151 # check we have a callsign :-)
152 if ($spotted le ' ') {
153 push @out, $self->msg('dx2');
157 return (1, @out) unless $valid;
159 # Store it here (but only if it isn't baddx)
160 my $t = (int ($main::systime/60)) * 60;
161 return (1, $self->msg('dup')) if Spot::dup($freq, $spotted, $t, $line, $spotter, $main::mycall);
162 my @spot = Spot::prepare($freq, $spotted, $t, $line, $spotter, $main::mycall, $ipaddr);
166 if ($freq =~ /^69/ || $localonly) {
168 # heaven forfend that we get a 69Mhz band :-)
169 if ($freq =~ /^69/) {
170 $self->badcount(($self->badcount||0) + 1);
173 $self->dx_spot(undef, undef, @spot);
177 # send orf to the users
178 $ipaddr ||= $main::mycall; # emergency backstop
179 my $spot = DXProt::pc61($spotter, $freq, $spotted, unpad($line), $ipaddr);
181 $self->dx_spot(undef, undef, @spot);
182 if ($self->isslugged) {
183 push @{$self->{sluggedpcs}}, [61, $spot, \@spot];
185 # store in spots database
187 DXProt::send_dx_spot($self, $spot, @spot);