Next Previous Contents

5. Filtering

Filters can be set for spots, announcements and WWV. You will find the directories for these under /spider/filter. You will find some examples in the directories with the suffix .issue. There are two types of filter, one for incoming information and one for outgoing information. Outgoing filters are in the form CALLSIGN.pl and incoming filters are in the form in_CALLSIGN.pl. Filters can be set for both nodes and users.

All filters work in basically the same way. There are several elements delimited by commas. There can be many lines in the filter and they are read from the top by the program. When writing a filter you need to think carefully about just what you want to achieve. You are either going to write a filter to accept or to reject. Think of a filter as having 2 main elements. For a reject filter, you would have a line or multiple lines rejecting the things you do not wish to receive and then a default line accepting everything else that is not included in the filter. Likewise, for an accept filter, you would have a line or multiple lines accepting the things you wish to receive and a default line rejecting everthing else.

In the example below, a user requires a filter that would only return SSB spots posted in Europe on the HF bands. This is achieved by first rejecting the CW section of each HF band and rejecting all of VHF, UHF etc based on frequency. Secondly, a filter rule is set based on CQ zones to only accept spots posted in Europe. Lastly, a default filter rule is set to reject anything outside the filter.

$in = [
        [ 0, 0, 'r', # reject all CW spots
                [
                1800.0, 1850.0,
                3500.0, 3600.0,
                7000.0, 7040.0,
                14000.0, 14100.0,
                18068.0, 18110.0,
                21000.0, 21150.0,
                24890.0, 24930.0,
                28000.0, 28180.0,
                30000.0, 49000000000.0,
                ] ,1 ],
        [ 1, 11, 'n', [ 14, 15, 16, 20, 33, ], 15 ], #accept EU
        [ 0, 0, 'd', 0, 1 ], # 1 = want, 'd' = everything else
];

The actual elements of each filter are described more fully in the following sections.

5.1 Spots

The elements of the Spot filter are ....

[action, field_no, sort, possible_values, hops]

There are 3 elements here to look at. Firstly, the action element. This is very simple and only 2 possible states exist, accept (1) or drop (0).

The second element is the field_no. There are 13 possiblities to choose from here ....

      0 = frequency
      1 = call
      2 = date in unix format
      3 = comment
      4 = spotter
      5 = spotted dxcc country
      6 = spotter's dxcc country
      7 = origin
      8 = spotted itu
      9 = spotted cq
      10 = spotter's itu
      11 = spotter's cq
      12 = callsign of the channel on which the spot has appeared

The third element tells us what to expect in the fourth element. There are 4 possibilities ....

     n - numeric list of numbers e.g. [ 1,2,3 ]
     r - ranges of pairs of numbers e.g. between 2 and 4 or 10 to 17 - [ 2,4, 10,17 ] 
     a - an alphanumeric regex
     d - the default rule

The fifth element is simply the hops to set in this filter. This would only be used if the filter was for a node of course and overrides the hop count in hop_table.pl.

So, let's look at an example spot filter. It does not matter in the example who the filter is to be used for. So, what do we need in the filter? We need to filter the spots the user/node requires and also set a default rule for anything else outside the filter. Below is a simple filter that stops spots arriving from outside Europe.

$in = [
  [ 0, 4, 'a', '^(K|N|A|W|VE|VA|J)'],  # 0 = drop, 'a' = alphanumeric
  [ 1, 0, 'd', 0, 1 ],                 # 1 = want, 'd' = everything else
                     ];

So the filter is wrapped in between a pair of square brackets. This tells Spider to look in between these limits. Then each line is contained within its own square brackets and ends with a comma. Lets look carefully at the first line. The first element is 0 (drop). Therefore anything we put on this line will not be accepted. The next element is 4. This means we are filtering by the spotter. The third element is the letter "a" which tells the program to expect an alphanumeric expression in the fourth element. The fourth element is a list of letters separated by the pipe symbol.

What this line does is tell the program to drop any spots posted by anyone in the USA, Canada or Japan.

The second line is the default rule for anything else. The "d" tells us this and the line simply reads... accept anything else.

You can add as many lines as you need to complete the filter but if there are several lines of the same type it is neater to enclose them all as one line. An example of this is where specific bands are set. We could write this like this ....

[ 0,0,'r',[1800.0, 2000.0], 1],
[ 0,0,'r',[10100.0, 10150.0], 1],
[ 0,0,'r',[14000.0, 14350.0], 1],
[ 0,0,'r',[18000.0, 18200.0], 1],

But the line below achieves the same thing and is more efficient ....

  [ 0, 0, 'r',
    [  
      1800.0, 2000.0,         # top band 
      10100.0, 10150.0,       # WARC  
      14000.0, 14350.0,       # 20m
      18000.0, 18200.0,       # WARC
    [ ,1 ],

5.2 Announcements


# This is an example announce or filter allowing only West EU announces
# 
# The element list is:-
# 0 - callsign of announcer
# 1 - destination * = all, <callsign> = routed to the node
# 2 - text
# 3 - * - sysop, <some text> - special list eg 6MUK, ' ', normal announce
# 4 - origin
# 5 - 0 - announce, 1 - wx
# 6 - channel callsign (the interface from which this spot came)

$in = [
        [ 1, 0, 'a', '^(P[ABCDE]|DK0WCY|G|M|2|EI|F|ON)' ],
        [ 0, 0, 'd', 0 ]
];

In this example, only the prefixes listed will be allowed. It is possible to be quite specific. The Dutch prefix "P" is followed by several secondary identifiers which are allowed. So, in the example, "PA" or "PE" would be ok but not "PG". It is even possible to allow information from a single callsign. In the example this is DK0WCY, to allow the posting of his Aurora Beacon.

5.3 WWV


# This is an example WWV filter
# 
# The element list is:-
# 0 - nominal unix date of spot (ie the day + hour:13)
# 1 - the hour
# 2 - SFI
# 3 - K
# 4 - I
# 5 - text
# 6 - spotter
# 7 - origin
# 8 - incoming interface callsign

# this one doesn't filter, it just sets the hop count to 6 and is
# used mainly just to override any isolation from WWV coming from
# the internet.

$in = [
        [ 1, 0, 'd', 0, 6 ]
];

It should be noted that the filter will start to be used only once a user/node has logged out and back in again.

I am not going to spend any more time on these filters now as they will become more "comprehensive" in the near future.

5.4 Filtering Mail

In the /spider/msg directory you will find a file called badmsg.pl.issue. Rename this to badmsg.pl and edit the file. The original looks something like this ....


# the list of regexes for messages that we won't store having
# received them (bear in mind that we must receive them fully before
# we can bin them)


# The format of each line is as follows

#     type      source             pattern 
#     P/B/F     T/F/O/S            regex  

# type: P - private, B - bulletin (msg), F - file (ak1a bull)
# source: T - to field, F - from field,  O - origin, S - subject 
# pattern: a perl regex on the field requested

# Currently only type B and P 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



package DXMsg;

@badmsg = (
'B',    'T',    'SALE', 
'B',    'T',    'WANTED',
'B',    'S',    'WANTED',
'B',    'S',    'SALE', 
'B',    'S',    'WTB',
'B',    'S',    'WTS',
'B',    'T',    'FS',
);

I think this is fairly self explanatory. It is simply a list of subject headers that we do not want to pass on to either the users of the cluster or the other cluster nodes that we are linked to. This is usually because of rules and regulations pertaining to items for sale etc in a particular country.

5.5 Filtering DX callouts

In the same way as mail, there are some types of spot we do not wish to pass on to users or linked cluster nodes. In the /spider/data directory you will find a file called baddx.pl.issue. Rename this to baddx.pl and edit the file. The original looks like this ....


# the list of dx spot addresses that we don't store and don't pass on


package DXProt;

@baddx = qw 

 FROG 
 SALE
 FORSALE
 WANTED
 P1RATE
 PIRATE
 TEST
 DXTEST
 NIL
 NOCALL 
);

Again, this is simply a list of names we do not want to see in the spotted field of a DX callout.


Next Previous Contents