Fixed some Aliasing problems.
[spider.git] / perl / DXProt.pm
index e6380b563e6bc5188a640249c9d7800bc8716d76..ee9c92f103410f54bfc3c78d20c764fc8085b71d 100644 (file)
@@ -238,6 +238,9 @@ sub start
        $self->{here} = 1;
        $self->{width} = 80;
 
+       # sort out registration
+       $self->{registered} = 1;
+
        # get the output filters
        $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'node_default', 0);
        $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'node_default', 0);
@@ -256,6 +259,7 @@ sub start
        # set unbuffered and no echo
        $self->send_now('B',"0");
        $self->send_now('E',"0");
+       $self->conn->echo(0) if $self->conn->can('echo');
        
        # ping neighbour node stuff
        my $ping = $user->pingint;
@@ -415,7 +419,7 @@ sub normal
                        }
 
                        # is it 'baddx'
-                       if ($baddx->in($field[2])) {
+                       if ($baddx->in($field[2]) || BadWords::check($field[2]) || $field[2] =~ /COCK/) {
                                dbg("PCPROT: Bad DX spot, ignored") if isdbg('chanerr');
                                return;
                        }
@@ -578,6 +582,11 @@ sub normal
                
                if ($pcno == 16) {              # add a user
 
+                       if (eph_dup($line)) {
+                               dbg("PCPROT: dup PC16 detected") if isdbg('chanerr');
+                               return;
+                       }
+
                        # general checks
                        my $dxchan;
                        my $ncall = $field[1];
@@ -587,17 +596,17 @@ sub normal
                                dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
                                return;
                        }
-                       $dxchan = DXChannel->get($ncall);
-                       if ($dxchan && $dxchan ne $self) {
-                               dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
-                               return;
-                       }
                        my $parent = Route::Node::get($ncall); 
                        unless ($parent) {
                                dbg("PCPROT: Node $ncall not in config") if isdbg('chanerr');
                                return;
                        }
-                       
+                       $dxchan = $parent->dxchan;
+                       if ($dxchan && $dxchan ne $self) {
+                               dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
+                               return;
+                       }
+
                        # input filter if required
                        return unless $self->in_filter_route($parent);
                        
@@ -642,11 +651,6 @@ sub normal
                                $user->lastin($main::systime) unless DXChannel->get($call);
                                $user->put;
                        }
-
-                       if (eph_dup($line)) {
-                               dbg("PCPROT: dup PC16 detected") if isdbg('chanerr');
-                               return;
-                       }
                        
                        # queue up any messages (look for privates only)
                        DXMsg::queue_msg(1) if $self->state eq 'normal';     
@@ -660,17 +664,17 @@ sub normal
                        my $ncall = $field[2];
                        my $ucall = $field[1];
 
+                       if (eph_dup($line)) {
+                               dbg("PCPROT: dup PC17 detected") if isdbg('chanerr');
+                               return;
+                       }
+
                        eph_del_regex("^PC16.*$ncall.*$ucall");
                        
                        if ($ncall eq $main::mycall) {
                                dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
                                return;
                        }
-                       $dxchan = DXChannel->get($ncall);
-                       if ($dxchan && $dxchan ne $self) {
-                               dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
-                               return;
-                       }
 
                        my $uref = Route::User::get($ucall);
                        unless ($uref) {
@@ -683,16 +687,17 @@ sub normal
                                return;
                        }                       
 
+                       $dxchan = $parent->dxchan;
+                       if ($dxchan && $dxchan ne $self) {
+                               dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
+                               return;
+                       }
+
                        # input filter if required
                        return unless $self->in_filter_route($parent);
                        
                        my @rout = $parent->del_user($uref);
 
-                       if (eph_dup($line)) {
-                               dbg("PCPROT: dup PC17 detected") if isdbg('chanerr');
-                               return;
-                       }
-
                        $self->route_pc17($parent, @rout) if @rout;
                        return;
                }
@@ -713,6 +718,11 @@ sub normal
                        my $i;
                        my $newline = "PC19^";
 
+                       if (eph_dup($line)) {
+                               dbg("PCPROT: dup PC19 detected") if isdbg('chanerr');
+                               return;
+                       }
+
                        # new routing list
                        my @rout;
                        my $parent = Route::Node::get($self->{call});
@@ -789,10 +799,6 @@ sub normal
                                $user->put;
                        }
 
-                       if (eph_dup($line)) {
-                               dbg("PCPROT: dup PC19 detected") if isdbg('chanerr');
-                               return;
-                       }
 
                        $self->route_pc19(@rout) if @rout;
                        return;
@@ -809,6 +815,11 @@ sub normal
                if ($pcno == 21) {              # delete a cluster from the list
                        my $call = uc $field[1];
 
+                       if (eph_dup($line)) {
+                               dbg("PCPROT: dup PC21 detected") if isdbg('chanerr');
+                               return;
+                       }
+
                        eph_del_regex("^PC1[79].*$call");
                        
                        my @rout;
@@ -818,14 +829,21 @@ sub normal
                                $self->disconnect;
                                return;
                        }
-                       my $node = Route::Node::get($call);
                        if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me!
                                if ($call eq $self->{call}) {
                                        dbg("PCPROT: Trying to disconnect myself with PC21") if isdbg('chanerr');
                                        return;
                                }
 
+                               my $node = Route::Node::get($call);
                                if ($node) {
+
+                                       my $dxchan = $node->dxchan;
+                                       if ($dxchan && $dxchan ne $self) {
+                                               dbg("PCPROT: PC21 from $self->{call} trying to alter locally connected $call, ignored!") if isdbg('chanerr');
+                                               return;
+                                       }
+
                                        # input filter it
                                        return unless $self->in_filter_route($node);
 
@@ -837,11 +855,6 @@ sub normal
                                return;
                        }
 
-                       if (eph_dup($line)) {
-                               dbg("PCPROT: dup PC21 detected") if isdbg('chanerr');
-                               return;
-                       }
-
                        $self->route_pc21(@rout) if @rout;
                        return;
                }
@@ -948,6 +961,7 @@ sub normal
                }
 
                if (($pcno >= 28 && $pcno <= 33) || $pcno == 40 || $pcno == 42 || $pcno == 49) { # mail/file handling
+                       return if $pcno == 49 && eph_dup($line);
                        if ($pcno == 49 || $field[1] eq $main::mycall) {
                                DXMsg::process($self, $line);
                        } else {
@@ -1760,7 +1774,7 @@ sub talk
        
        $line =~ s/\^/\\5E/g;                   # remove any ^ characters
        $self->send(DXProt::pc10($from, $to, $via, $line, $origin));
-       Log('talk', $self->call, $from, $via?$via:$main::mycall, $line) unless $origin && $origin ne $main::mycall;
+       Log('talk', $to, $from, $via?$via:$self->call, $line) unless $origin && $origin ne $main::mycall;
 }
 
 # send it if it isn't the except list and isn't isolated and still has a hop count