added message forwarding code
authordjk <djk>
Mon, 15 Feb 1999 16:10:24 +0000 (16:10 +0000)
committerdjk <djk>
Mon, 15 Feb 1999 16:10:24 +0000 (16:10 +0000)
Changes
msg/forward.pl.issue
perl/DXMsg.pm

diff --git a/Changes b/Changes
index 68bd6d15a4d4702bf6771ce429e85a63b18846c3..081db095ed4df7781720da6051cd0ed4e999eaaa 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,11 @@
+15Feb99========================================================================
+1. Added msg forwarding code which uses $main::root/msg/forward.pl.
+14Feb99========================================================================
+1. Changed A & K in WWV to be the other way around (I am told by G3IOR that
+this will mean that we won't have pole to pole aurora nor all the power lines
+overloading everywhere as well as a result of having values of K > 10).
+2. allow the '~' character in message bodies.
+3. Moved $main::data/badmsg.pl to $main::root/msg/badmsg.pl.
 11Feb99========================================================================
 1. Fixed a problem with isolated nodes' configurations being sent on sending 
 local configs to new connections.
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..bfee2cb8c574f1cd6fdbd6381e2e8af01d070958 100644 (file)
@@ -0,0 +1,39 @@
+#
+# this is an example message forwarding file for the system
+#
+# The format of each line is as follows
+#
+#     type    to/from/at pattern action  destinations
+#     P/B/F     T/F/A     regex   I/F    [ call [, call ...] ]
+#
+# type: P - private, B - bulletin (msg), F - file (ak1a bull)
+# to/from/at: T - to field, F - from field, A - home bbs, O - origin 
+# pattern: a perl regex on the field requested
+# action: I - ignore, F - forward
+# destinations: a reference to an array containing node callsigns
+#
+# if it is non-private and isn't in here then it won't get forwarded 
+#
+# Currently only type B msgs are affected by this code.
+# 
+# The list is read from the top down, the first pattern that matches
+# causes the action to be taken.
+#
+# The pattern can be undef or 0 in which case it will always be selected
+# for the action specified
+#
+# If the BBS list is undef or 0 and the action is 'F' (and it matches the
+# pattern) then it will always be forwarded to every node that doesn't have 
+# it (I strongly recommend you don't use this unless you REALLY mean it, if
+# you allow a new link with this on EVERY bull will be forwarded immediately
+# on first connection)
+#
+
+package DXMsg;
+
+@forward = (
+'B',   'O',    'K1XX', 'I',    0,      
+'B',   'T',    'LOCAL',        'F',    [ qw(GB7TLH GB7DJK-1) ],
+'B',   'T',    'ALL',  'F',    [ qw(GB7TLH GB7DJK-1 GB7BAA) ],
+'B',   'T',    'UK',   'F',    [ qw(GB7TLH GB7DJK-1 GB7BAA) ],
+); 
index 39bd3065ab57e0fd3e4af2550d41107c6877b842..dd6d178e1f523acd79a6f9e9f023c001b2a416c2 100644 (file)
@@ -528,9 +528,10 @@ sub queue_msg
                        my $noderef;
                        foreach $noderef (@nodelist) {
                                next if $noderef->call eq $main::mycall;
-                               next if $noderef->isolate;               # maybe add code for stuff originated here?
                                next if grep { $_ eq $noderef->call } @{$ref->{gotit}};
-                               next if DXUser->get( ${$ref->{gotit}}[0] )->isolate;  # is the origin isolated?
+                               next unless $ref->forward_it($noderef->call);           # check the forwarding file
+                               # next if $noderef->isolate;               # maybe add code for stuff originated here?
+                               # next if DXUser->get( ${$ref->{gotit}}[0] )->isolate;  # is the origin isolated?
                                
                                # if we are here we have a node that doesn't have this message
                                $ref->start_msg($noderef) if !get_busy($noderef->call)  && $noderef->state eq 'normal';
@@ -816,6 +817,39 @@ sub load_badmsg
        return @out;
 }
 
+#
+# forward that message or not according to the forwarding table
+# returns 1 for forward, 0 - to ignore
+#
+
+sub forward_it
+{
+       my $ref = shift;
+       my $call = shift;
+       my $i;
+       
+       for ($i = 0; $i < @forward; $i += 5) {
+               my ($sort, $field, $pattern, $action, $bbs) = @forward[$i..($i+4)]; 
+               my $tested;
+               
+               # are we interested?
+               last if $ref->{private} && $sort ne 'P';
+               last if !$ref->{private} && $sort ne 'B';
+               
+               # select field
+               $tested = $ref->{to} if $field eq 'T';
+               $tested = $ref->{from} if $field eq 'F';
+               $tested = $ref->{origin} if $field eq 'O';
+               $tested = $ref->{subject} if $field eq 'S';
+
+               if (!$pattern || $tested =~ m{$pattern}i) {
+                       return 0 if $action eq 'I';
+                       return 1 if !$bbs || grep $_ eq $call, @{$bbs};
+               }
+       }
+       return 0;
+}
+
 no strict;
 sub AUTOLOAD
 {