X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProt.pm;h=2df6b03ac511c4b333021bea6f3ed322174ec4e1;hb=4176dc3ee603f4b13c27d4267f8acbec3bf8f851;hp=bc27c417c8df7f85b5e5c15e582e0a507fb8f5d7;hpb=aacad2408c6b383a381378a20d59abc6b6a9c417;p=spider.git diff --git a/perl/DXProt.pm b/perl/DXProt.pm index bc27c417..2df6b03a 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -500,11 +500,26 @@ sub normal # add it to the node table if it isn't present and it's # connected locally $node = DXNode->new($dxchan, $field[1], 0, 1, 5400); - broadcast_ak1a(pc19($dxchan, $node), $dxchan, $self) unless $dxchan->{isolate}; + dbg('chan', "$field[1] no PC19 yet, autovivified as node"); +# broadcast_ak1a(pc19($dxchan, $node), $dxchan, $self) unless $dxchan->{isolate}; } - return unless $node; # ignore if havn't seen a PC19 for this one yet - return unless $node->isa('DXNode'); + if ($field[1] eq $main::mycall || $field[2] eq $main::mycall) { + dbg('chan', "LOOP: trying to alter config on this node from outside!"); + return; + } + if ($field[2] eq $main::myalias && DXChannel->get($field[1])) { + dbg('chan', "LOOP: trying to connect sysop from outside!"); + return; + } + unless ($node) { + dbg('chan', "Node $field[1] not in config"); + return; + } + unless ($node->isa('DXNode')) { + dbg('chan', "$field[1] is not a node"); + return; + } if ($node->dxchan != $self) { dbg('chan', "LOOP: $field[1] came in on wrong channel"); return; @@ -517,10 +532,17 @@ sub normal for ($i = 2; $i < $#field; $i++) { my ($call, $confmode, $here) = $field[$i] =~ /^(\S+) (\S) (\d)/o; - next if !$call || length $call < 3 || length $call > 8; - next if !$confmode; - $call = uc $call; - next if DXCluster->get_exact($call); # we already have this (loop?) + next unless $call && $confmode && defined $here && is_callsign($call); + my $ref = DXCluster->get_exact($call); + if ($ref) { + if ($ref->isa('DXNode')) { + dbg('chan', "LOOP: $call is a node"); + next; + } + my $rcall = $ref->mynode->call; + dbg('chan', "LOOP: already have $call on $rcall"); + next; + } $confmode = $confmode eq '*'; DXNodeuser->new($self, $node, $call, $confmode, $here); @@ -547,11 +569,25 @@ sub normal # add it to the node table if it isn't present and it's # connected locally $node = DXNode->new($dxchan, $field[2], 0, 1, 5400); - broadcast_ak1a(pc19($dxchan, $node), $dxchan, $self) unless $dxchan->{isolate}; + dbg('chan', "$field[2] no PC19 yet, autovivified as node"); +# broadcast_ak1a(pc19($dxchan, $node), $dxchan, $self) unless $dxchan->{isolate}; + } + if ($field[1] eq $main::mycall || $field[2] eq $main::mycall) { + dbg('chan', "LOOP: trying to alter config on this node from outside!"); + return; + } + if ($field[1] eq $main::myalias && DXChannel->get($field[1])) { + dbg('chan', "LOOP: trying to disconnect sysop from outside!"); + return; + } + unless ($node) { + dbg('chan', "Node $field[2] not in config"); + return; + } + unless ($node->isa('DXNode')) { + dbg('chan', "LOOP: $field[2] is not a node"); return; } - return unless $node; - return unless $node->isa('DXNode'); if ($node->dxchan != $self) { dbg('chan', "LOOP: $field[2] came in on wrong channel"); return; @@ -561,7 +597,12 @@ sub normal return; } my $ref = DXCluster->get_exact($field[1]); - $ref->del() if $ref; + if ($ref) { + $ref->del; + } else { + dbg('chan', "$field[1] not known" ); + return; + } last SWITCH; } @@ -588,6 +629,7 @@ sub normal my $call = uc $field[$i+1]; my $confmode = $field[$i+2]; my $ver = $field[$i+3]; + next unless defined $here && defined $confmode && is_callsign($call); $ver = 5400 if !$ver && $allowzero; @@ -602,7 +644,8 @@ sub normal dbg('chan', "LOOP: $call come in on wrong channel"); next; } - dbg('chan', "already have $call"); + my $rcall = $node->mynode->call; + dbg('chan', "already have $call on $rcall"); next; } @@ -652,6 +695,10 @@ sub normal if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me! my $node = DXCluster->get_exact($call); if ($node) { + unless ($node->isa('DXNode')) { + dbg('chan', "$call is not a node"); + return; + } if ($call eq $self->{call}) { dbg('chan', "LOOP: Trying to disconnect myself with PC21"); return; @@ -670,6 +717,9 @@ sub normal dbg('chan', "$call not in table, dropped"); return; } + } else { + dbg('chan', "I WILL NOT be disconnected!"); + return; } last SWITCH; } @@ -836,18 +886,17 @@ sub normal } if ($pcno == 39) { # incoming disconnect - $self->disconnect(1); + if ($field[1] eq $self->{call}) { + $self->disconnect(1); + } else { + dbg('chan', "LOOP: came in on wrong channel"); + } return; } if ($pcno == 41) { # user info # add this station to the user database, if required my $user = DXUser->get_current($field[1]); - if (!$user) { - # then try without an SSID - $field[1] =~ s/-\d+$//o; - $user = DXUser->get_current($field[1]); - } $user = DXUser->new($field[1]) if !$user; if ($field[2] == 1) { @@ -1231,7 +1280,7 @@ sub send_wcy_spot ($filter, $hops) = $dxchan->{wcyfilter}->it(@_, $self->{call} ); next unless $filter; } - if ($dxchan->is_clx || $dxchan->is_spider) { + if ($dxchan->is_clx || $dxchan->is_spider || $dxchan->is_dxnet) { next if $dxchan == $self; if ($hops) { $routeit = $line; @@ -1291,13 +1340,13 @@ sub send_announce if ($dxchan->{annfilter}) { my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0); - my @dxcc = Prefix::extract($_[1]); + my @dxcc = Prefix::extract($_[0]); if (@dxcc > 0) { $ann_dxcc = $dxcc[1]->dxcc; $ann_itu = $dxcc[1]->itu; $ann_cq = $dxcc[1]->cq; } - @dxcc = Prefix::extract($_[5]); + @dxcc = Prefix::extract($_[4]); if (@dxcc > 0) { $org_dxcc = $dxcc[1]->dxcc; $org_itu = $dxcc[1]->itu;