change the looping protoection for PC16/17/19/21 and also be more rigorous
authorminima <minima>
Mon, 1 Oct 2001 11:56:35 +0000 (11:56 +0000)
committerminima <minima>
Mon, 1 Oct 2001 11:56:35 +0000 (11:56 +0000)
in who we accept which PC16/17/21's from.

Changes
perl/DXLog.pm
perl/DXMsg.pm
perl/DXProt.pm

diff --git a/Changes b/Changes
index 0ea381128fa7475b562ff0811e903208ce323dcc..487d346768bd3efe73e2a56d3be25ba06291bf71 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 01Oct01=======================================================================
 1. made login info not the default
+2. change the looping protoection for PC16/17/19/21 and also be more rigorous
+in who we accept which PC16/17/21's from.
 30Sep01=======================================================================
 1. made some small bug fixes in rspf checking and also messages. 
 23Sep01=======================================================================
index c13e26c1d8ffac4b8c641802c1af75f1ede6643f..607630853b3a0de108a32c65c3c86f9a716afa61 100644 (file)
@@ -92,14 +92,13 @@ sub open
        
        $mode = 'r' if !$mode;
        $self->{mode} = $mode;
+       $self->{jdate} = $jdate;
        
        my $fh = new IO::File $self->{fn}, $mode, 0666;
        return undef if !$fh;
        $fh->autoflush(1) if $mode ne 'r'; # make it autoflushing if writable
        $self->{fh} = $fh;
 
-       $self->{jdate} = $jdate;
-       
 #      DXDebug::dbg("opening $self->{fn}\n") if isdbg("dxlog");
        
        return $self->{fh};
index fefcc2fae9971be47872a657a168717b3e74e56d..45de0f9fa3d6a5682c52d0ee412e2805aa4df076 100644 (file)
@@ -281,8 +281,8 @@ sub process
                                                        if ($ref->{subject} eq $m->{subject} && $ref->{t} == $m->{t} && $ref->{from} eq $m->{from} && $ref->{to} eq $m->{to}) {
                                                                $ref->stop_msg($self->call);
                                                                my $msgno = $m->{msgno};
-                                                               dbg("duplicate message from $ref->{from} -> $ref->{to} to $msgno") if isdbg('msg');
-                                                               Log('msg', "duplicate message from $ref->{from} -> $ref->{to} to $msgno");
+                                                               dbg("duplicate message from $ref->{from} -> $ref->{to} to msg: $msgno") if isdbg('msg');
+                                                               Log('msg', "duplicate message from $ref->{from} -> $ref->{to} to msg: $msgno");
                                                                return;
                                                        }
                                                }
index e6380b563e6bc5188a640249c9d7800bc8716d76..f8e2b4b99ee9d0c85c1f1a8d75880fde8f5b6b0c 100644 (file)
@@ -578,6 +578,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 +592,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 +647,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 +660,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 +683,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 +714,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 +795,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 +811,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;
@@ -820,6 +827,12 @@ sub normal
                        }
                        my $node = Route::Node::get($call);
                        if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me!
+                               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;
+                               }
+
                                if ($call eq $self->{call}) {
                                        dbg("PCPROT: Trying to disconnect myself with PC21") if isdbg('chanerr');
                                        return;
@@ -837,11 +850,6 @@ sub normal
                                return;
                        }
 
-                       if (eph_dup($line)) {
-                               dbg("PCPROT: dup PC21 detected") if isdbg('chanerr');
-                               return;
-                       }
-
                        $self->route_pc21(@rout) if @rout;
                        return;
                }