changed help for filters freq->on
[spider.git] / html / adminmanual-5.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4  <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
5  <TITLE>The DXSpider Installation and Administration Manual : Filtering (Old Style upto v1.44)</TITLE>
6  <LINK HREF="adminmanual-6.html" REL=next>
7  <LINK HREF="adminmanual-4.html" REL=previous>
8  <LINK HREF="adminmanual.html#toc5" REL=contents>
9 </HEAD>
10 <BODY>
11 <A HREF="adminmanual-6.html">Next</A>
12 <A HREF="adminmanual-4.html">Previous</A>
13 <A HREF="adminmanual.html#toc5">Contents</A>
14 <HR>
15 <H2><A NAME="s5">5. Filtering (Old Style upto v1.44)</A></H2>
16
17 <P>Filters can be set for spots, announcements and WWV.  You will find the directories for these under /spider/filter.  You will 
18 find some examples in the directories with the suffix <EM>.issue</EM>.  There are two types of filter, one for incoming 
19 information and one for outgoing information. Outgoing filters are in the form <EM>CALLSIGN.pl</EM> and incoming filters 
20 are in the form <EM>in_CALLSIGN.pl</EM>.  Filters can be set for both nodes and users.
21 <P>
22 <P>All filters work in basically the same way.  There are several elements delimited by commas.
23 There can be many lines in the filter and they are read from the top by the program.
24 When writing a filter you need to think carefully about just what you want to achieve.  You
25 are either going to write a filter to <EM>accept</EM> or to <EM>reject</EM>.
26 Think of a filter as having 2 main elements.  For a reject filter, you would have a line
27 or multiple lines rejecting the things you do not wish to receive and then a default
28 line accepting everything else that is not included in the filter.  Likewise, for an
29 accept filter, you would have a line or multiple lines accepting the things you wish
30 to receive and a default line rejecting everthing else.
31 <P>
32 <P>In the example below, a user requires a filter that would only return SSB spots
33 posted in Europe on the HF bands.  This is achieved by first rejecting the CW section 
34 of each HF band and rejecting all of VHF, UHF etc based on frequency.
35 Secondly, a filter rule is set based on CQ zones to only accept spots posted in
36 Europe.  Lastly, a default filter rule is set to reject anything outside the filter.
37 <P>
38 <BLOCKQUOTE><CODE>
39 <PRE>
40 $in = [
41         [ 0, 0, 'r', # reject all CW spots
42                 [
43                 1800.0, 1850.0,
44                 3500.0, 3600.0,
45                 7000.0, 7040.0,
46                 14000.0, 14100.0,
47                 18068.0, 18110.0,
48                 21000.0, 21150.0,
49                 24890.0, 24930.0,
50                 28000.0, 28180.0,
51                 30000.0, 49000000000.0,
52                 ] ,1 ],
53         [ 1, 11, 'n', [ 14, 15, 16, 20, 33, ], 15 ], #accept EU
54         [ 0, 0, 'd', 0, 1 ], # 1 = want, 'd' = everything else
55 ];
56 </PRE>
57 </CODE></BLOCKQUOTE>
58 <P>
59 <P>The actual elements of each filter are described more fully in the following sections.
60 <P>
61 <H2><A NAME="ss5.1">5.1 Spots</A>
62 </H2>
63
64 <P>The elements of the Spot filter are ....
65 <P>
66 <BLOCKQUOTE><CODE>
67 <PRE>
68 [action, field_no, sort, possible_values, hops]
69 </PRE>
70 </CODE></BLOCKQUOTE>
71 <P>
72 <P>There are 3 elements here to look at.  Firstly, the action element.  This is very simple and only 2 possible states exist, 
73 accept (1) or drop (0).
74 <P>
75 <P>The second element is the field_no.  There are 13 possiblities to choose from here ....
76 <P>
77 <BLOCKQUOTE><CODE>
78 <PRE>
79       0 = frequency
80       1 = call
81       2 = date in unix format
82       3 = comment
83       4 = spotter
84       5 = spotted dxcc country
85       6 = spotter's dxcc country
86       7 = origin
87       8 = spotted itu
88       9 = spotted cq
89       10 = spotter's itu
90       11 = spotter's cq
91       12 = callsign of the channel on which the spot has appeared
92 </PRE>
93 </CODE></BLOCKQUOTE>
94 <P>
95 <P>The third element tells us what to expect in the fourth element.  There are 4 possibilities ....
96 <P>
97 <BLOCKQUOTE><CODE>
98 <PRE>
99      n - numeric list of numbers e.g. [ 1,2,3 ]
100      r - ranges of pairs of numbers e.g. between 2 and 4 or 10 to 17 - [ 2,4, 10,17 ] 
101      a - an alphanumeric regex
102      d - the default rule
103 </PRE>
104 </CODE></BLOCKQUOTE>
105 <P>
106 <P>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 
107 course and overrides the hop count in hop_table.pl.
108 <P>
109 <P>So, let's look at an example spot filter.  It does not matter in the example who the filter is to be used for.
110 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 
111 anything else outside the filter.  Below is a simple filter that stops spots arriving from outside Europe.
112 <P>
113 <BLOCKQUOTE><CODE>
114 <PRE>
115 $in = [
116   [ 0, 4, 'a', '^(K|N|A|W|VE|VA|J)'],  # 0 = drop, 'a' = alphanumeric
117   [ 1, 0, 'd', 0, 1 ],                 # 1 = want, 'd' = everything else
118                      ];
119 </PRE>
120 </CODE></BLOCKQUOTE>
121 <P>
122 <P>So the filter is wrapped in between a pair of square brackets.  This tells Spider to look in between these limits.  
123 Then each line is contained within its own square brackets and ends with a comma. Lets look carefully at the first line.  
124 The first element is 0 (drop).  Therefore anything we put on this line will not be accepted.  The next element is 4.  
125 This means we are filtering by the spotter.  The third element is the letter "a" which tells the program to expect an 
126 alphanumeric expression in the fourth element.  The fourth element is a list of letters separated by the pipe symbol.
127 <P>
128 <P>What this line does is tell the program to drop any spots posted by anyone in the USA, Canada or Japan.
129 <P>
130 <P>The second line is the default rule for anything else.  The "d" tells us this and the line simply reads... accept anything else.
131 <P>
132 <P>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 
133 to enclose them all as one line.  An example of this is where specific bands are set.  We could write this like this ....
134 <P>
135 <BLOCKQUOTE><CODE>
136 <PRE>
137 [ 0,0,'r',[1800.0, 2000.0], 1],
138 [ 0,0,'r',[10100.0, 10150.0], 1],
139 [ 0,0,'r',[14000.0, 14350.0], 1],
140 [ 0,0,'r',[18000.0, 18200.0], 1],
141 </PRE>
142 </CODE></BLOCKQUOTE>
143 <P>
144 <P>But the line below achieves the same thing and is more efficient ....
145 <P>
146 <BLOCKQUOTE><CODE>
147 <PRE>
148   [ 0, 0, 'r',
149     [  
150       1800.0, 2000.0,         # top band 
151       10100.0, 10150.0,       # WARC  
152       14000.0, 14350.0,       # 20m
153       18000.0, 18200.0,       # WARC
154     [ ,1 ],
155 </PRE>
156 </CODE></BLOCKQUOTE>
157 <P>
158 <P>
159 <H2><A NAME="ss5.2">5.2 Announcements</A>
160 </H2>
161
162 <P>
163 <BLOCKQUOTE><CODE>
164 <PRE>
165
166 # This is an example announce or filter allowing only West EU announces
167
168 # The element list is:-
169 # 0 - callsign of announcer
170 # 1 - destination * = all, &lt;callsign> = routed to the node
171 # 2 - text
172 # 3 - * - sysop, &lt;some text> - special list eg 6MUK, ' ', normal announce
173 # 4 - origin
174 # 5 - 0 - announce, 1 - wx
175 # 6 - channel callsign (the interface from which this spot came)
176
177 $in = [
178         [ 1, 0, 'a', '^(P[ABCDE]|DK0WCY|G|M|2|EI|F|ON)' ],
179         [ 0, 0, 'd', 0 ]
180 ];
181 </PRE>
182 </CODE></BLOCKQUOTE>
183 <P>In this example, only the prefixes listed will be allowed.  It is possible to be quite specific.  The Dutch prefix "P" is 
184 followed by several secondary identifiers which are allowed.  So, in the example, "PA" or "PE" would be ok but not "PG".  It 
185 is even possible to allow information from a single callsign.  In the example this is DK0WCY, to allow the posting of his 
186 Aurora Beacon.
187 <P>
188 <H2><A NAME="ss5.3">5.3 WWV</A>
189 </H2>
190
191 <P>
192 <BLOCKQUOTE><CODE>
193 <PRE>
194
195 # This is an example WWV filter
196
197 # The element list is:-
198 # 0 - nominal unix date of spot (ie the day + hour:13)
199 # 1 - the hour
200 # 2 - SFI
201 # 3 - K
202 # 4 - I
203 # 5 - text
204 # 6 - spotter
205 # 7 - origin
206 # 8 - incoming interface callsign
207
208 # this one doesn't filter, it just sets the hop count to 6 and is
209 # used mainly just to override any isolation from WWV coming from
210 # the internet.
211
212 $in = [
213         [ 1, 0, 'd', 0, 6 ]
214 ];
215 </PRE>
216 </CODE></BLOCKQUOTE>
217 <P>
218 <P>It should be noted that the filter will start to be used only once a user/node has logged out and back in again.
219 <P>I am not going to spend any more time on these filters now as they will become more "comprehensive" in the near future.
220 <P>
221 <HR>
222 <A HREF="adminmanual-6.html">Next</A>
223 <A HREF="adminmanual-4.html">Previous</A>
224 <A HREF="adminmanual.html#toc5">Contents</A>
225 </BODY>
226 </HTML>