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