1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
|
$FreeBSD$
--- src/parser.y.orig Sun Dec 1 18:13:36 2002
+++ src/parser.y Sun Dec 1 18:27:08 2002
@@ -90,6 +90,7 @@
statements : statement
| statements statement
+ ;
statement : logfile
| accesslog
@@ -153,6 +154,7 @@
yyerrok;
}
| L_EOS
+ ;
logfile : LOGFILE string L_EOS {
verb_printf("LOGFILE:\t<<%s>>\n", $2);
@@ -208,28 +210,36 @@
}
free($7);
}
+ ;
userid : USERID_T string L_EOS {
oops_user = $2;
}
+ ;
chroot : CHROOT_T string L_EOS {
oops_chroot = $2;
}
+ ;
blacklist : BLACKLIST_T num L_EOS {
blacklist_len = $2;
}
+ ;
refuse_at : REFUSE_AT_T num L_EOS {
refuse_at = $2;
}
+ ;
+
start_red : START_RED_T num L_EOS {
start_red = $2;
}
+ ;
dont_cache_without_last_modified : DONT_CACHE_WITHOUT_LAST_MODIFIED_T L_EOS {
dont_cache_without_last_modified = TRUE;
}
+ ;
insert_x_forwarded_for : INSERT_X_FORWARDED_FOR_T string L_EOS {
if ( !strcasecmp(yylval.STRPTR, "yes") )
@@ -241,6 +251,7 @@
printf("insert_x_forwarded_for can be 'yes' or 'no'\n");
free(yylval.STRPTR);
}
+ ;
fetch_with_client_speed : FETCH_WITH_CLIENT_SPEED_T string L_EOS {
if ( !strcasecmp(yylval.STRPTR, "yes") )
@@ -252,6 +263,7 @@
printf("fetch_with_client_speed can be 'yes' or 'no'\n");
free(yylval.STRPTR);
}
+ ;
insert_via : INSERT_VIA_T string L_EOS {
if ( !strcasecmp(yylval.STRPTR, "yes") )
@@ -263,6 +275,7 @@
printf("insert_via can be 'yes' or 'no'\n");
free(yylval.STRPTR);
}
+ ;
accesslog : ACCESSLOG string L_EOS {
verb_printf("ACCESSLOG:\t<<%s>>\n", $2);
@@ -320,6 +333,7 @@
}
free($7);
}
+ ;
refresh_pattern : REFRESH_PATTERN_T string num string num L_EOS {
char *buf;
@@ -334,23 +348,32 @@
free($2);
free($4);
}
+ ;
+
bind_acl : BIND_ACL_T STRING L_EOS {
parse_bind_acl(yylval.STRPTR);
free(yylval.STRPTR);
}
+ ;
acl_allow : ACL_ALLOW_T STRING L_EOS {
parse_acl_access(&acl_allow, yylval.STRPTR);
free(yylval.STRPTR);
}
+ ;
+
acl_deny : ACL_DENY_T STRING L_EOS {
parse_acl_access(&acl_deny, yylval.STRPTR);
free(yylval.STRPTR);
}
+ ;
+
stop_cache_acl : STOP_CACHE_ACL_T STRING L_EOS {
parse_acl_access(&stop_cache_acl, yylval.STRPTR);
free(yylval.STRPTR);
}
+ ;
+
acl : ACL_T STRING L_EOS {
char *token, *p, *tptr;
char *n=NULL, *type=NULL, *data=NULL;
@@ -409,18 +432,21 @@
done:;
free(yylval.STRPTR);
}
+ ;
statistics : STATISTICS STRING L_EOS {
verb_printf("STATISTICS:\t<<%s>>\n", yylval.STRPTR);
strncpy(statisticslog, yylval.STRPTR, sizeof(statisticslog)-1);
free(yylval.STRPTR);
}
+ ;
pidfile : PIDFILE STRING L_EOS {
verb_printf("PIDFILE:\t<<%s>>\n", yylval.STRPTR);
strncpy(pidfile, yylval.STRPTR, sizeof(pidfile)-1);
free(yylval.STRPTR);
}
+ ;
nameserver : NAMESERVER STRING L_EOS {
verb_printf("NAMESERVER:\t<<%s>>\n", yylval.STRPTR);
@@ -438,6 +464,7 @@
}
free(yylval.STRPTR);
}
+ ;
connect_from : CONNECT_FROM STRING L_EOS {
char *p;
@@ -447,83 +474,105 @@
while ( *p ) { *p=tolower(*p); p++; }
verb_printf("CONNECT_FROM:\t<<%s>>\n", connect_from);
}
+ ;
stop_cache : STOP_CACHE STRING L_EOS {
verb_printf("STOP_CACHE:\t<<%s>>\n", yylval.STRPTR);
add_to_stop_cache(yylval.STRPTR);
}
+ ;
+
maxresident : MAXRESIDENT NUMBER L_EOS {
verb_printf("MAXRESIDENT:\t %d\n", yylval.INT);
maxresident = yylval.INT;
}
+ ;
minresident : MINRESIDENT NUMBER L_EOS {
verb_printf("MINRESIDENT:\t %d\n", yylval.INT);
minresident = yylval.INT;
}
+ ;
bind : BIND_T string L_EOS {
bind_addr = $2;
}
+ ;
http_port : HTTP_PORT NUMBER L_EOS {
verb_printf("HTTP_PORT\t<<%d>>\n", yylval.INT);
http_port = yylval.INT;
}
+ ;
icp_port : ICP_PORT NUMBER L_EOS {
verb_printf("ICP_PORT\t<<%d>>\n", yylval.INT);
icp_port = yylval.INT;
}
+ ;
icp_timeout : ICP_TIMEOUT NUMBER L_EOS {
verb_printf("ICP_TIMEOUT\t<<%d>>\n", yylval.INT);
icp_timeout = 1000*yylval.INT;
}
+ ;
icons_host : ICONS_HOST STRING L_EOS {
verb_printf("ICONS_HOST:\t<<%s>>\n", yylval.STRPTR);
strncpy(icons_host, yylval.STRPTR, sizeof(icons_host)-1);
free(yylval.STRPTR);
}
+ ;
icons_port : ICONS_PORT NUMBER L_EOS {
verb_printf("ICONS_PORT:\t<<%d>>\n", yylval.INT);
sprintf(icons_port, "%d", yylval.INT);
}
+ ;
icons_path : ICONS_PATH STRING L_EOS {
verb_printf("ICONS_PATH:\t<<%s>>\n", yylval.STRPTR);
strncpy(icons_path, yylval.STRPTR, sizeof(icons_path)-1);
free(yylval.STRPTR);
}
+ ;
always_check_freshness : ALWAYS_CHECK_FRESHNESS_T L_EOS {
verb_printf("ALWAYS CHECK FRESHNESS\n");
always_check_freshness = TRUE;
}
+ ;
+
always_check_freshness_acl : ALWAYS_CHECK_FRESHNESS_ACL_T STRING L_EOS {
verb_printf("ALWAYS CHECK FRESHNESS ACL\n");
parse_acl_access(&always_check_freshness_acl, yylval.STRPTR);
free(yylval.STRPTR);
}
+ ;
force_http11 : FORCE_HTTP11_T L_EOS {
verb_printf("FORCE_HTTP11\n");
force_http11 = TRUE;
}
+ ;
+
force_completion : FORCE_COMPLETION_T NUMBER L_EOS {
verb_printf("FORCE_COMPLETION: %d%%\n", yylval.INT);
force_completion = yylval.INT;
}
+ ;
+
last_modified_factor : LAST_MODIFIED_FACTOR_T NUMBER L_EOS {
verb_printf("LAST_MODIFIED_FACTOR: %d\n", yylval.INT);
last_modified_factor = yylval.INT;
}
+ ;
+
expire_value : EXPIRE_VALUE NUMBER L_EOS {
verb_printf("EXPIRE_VALUE:\t<<%d days>>\n", yylval.INT);
default_expire_value=yylval.INT * 24 * 3600;
}
+ ;
expiretime : EXPIRE_TIME_T string_list {
struct denytime *denytime;
@@ -537,30 +586,37 @@
}
free_string_list($2);
}
+ ;
+
max_expire_value : MAX_EXPIRE_VALUE_T NUMBER L_EOS {
verb_printf("MAX_EXPIRE_VALUE:\t<<%d days>>\n", yylval.INT);
max_expire_value=yylval.INT * 24 * 3600;
}
+ ;
ftp_expire_value : FTP_EXPIRE_VALUE_T NUMBER L_EOS {
verb_printf("FTP_EXPIRE_VALUE:\t<<%d days>>\n", yylval.INT);
ftp_expire_value=yylval.INT * 24 * 3600;
}
+ ;
expire_interval : EXPIRE_INTERVAL NUMBER L_EOS {
verb_printf("EXPIRE_INTERVAL:<<%d hours>>\n", yylval.INT);
default_expire_interval=yylval.INT * 3600;
}
+ ;
disk_low_free : DISK_LOW_FREE_T NUMBER L_EOS {
verb_printf("DISK_LOW_FREE:\t<<%d %%>>\n", yylval.INT);
disk_low_free=yylval.INT ;
}
+ ;
disk_hi_free : DISK_HI_FREE_T NUMBER L_EOS {
verb_printf("DISK_HI_FREE:\t<<%d %%>>\n", yylval.INT);
disk_hi_free=yylval.INT ;
}
+ ;
parent : PARENT_T string num L_EOS{
verb_printf("PARENT: %s:%d\n", $2, $3);
@@ -568,12 +624,14 @@
parent_port = $3;
free($2);
}
+ ;
parent_auth : PARENT_AUTH_T string L_EOS{
verb_printf("PARENT_AUTH: %s\n", $2);
parent_auth = base64_encode($2);
free($2);
}
+ ;
local_domain : LOCAL_DOMAIN_T domainlist L_EOS {
struct domain_list *d;
@@ -591,6 +649,7 @@
}
}
}
+ ;
local_networks : LOCAL_NETWORKS_T network_list L_EOS {
struct cidr_net *n;
@@ -607,47 +666,55 @@
}
}
}
+ ;
dbhome : DBHOME STRING L_EOS {
printf("WARNING!!!! dbhome must be moved to module berkeley_db\n");
free(yylval.STRPTR);
}
+ ;
dbname : DBNAME STRING L_EOS {
printf("WARNING!!!! dbname must be moved to module berkeley_db\n");
free(yylval.STRPTR);
}
+ ;
db_cache_mem : DB_CACHE_MEM num L_EOS {
printf("WARNING!!!! db_cache_mem must be moved to module berkeley_db\n");
}
+ ;
mem_max : MEM_MAX num L_EOS {
verb_printf("MEM_MAX:\t<<%d>>\n", $2);
mem_max_val = $2 ;
}
+ ;
lo_mark : LO_MARK num L_EOS {
verb_printf("LO_MARK:\t<<%d>>\n", $2);
lo_mark_val = $2 ;
}
+ ;
swap_advance : SWAP_ADVANCE_T num L_EOS {
verb_printf("SWAP_ADVANCE:\t<<%d>>\n", $2);
swap_advance = $2 ;
if ( swap_advance <= 0 ) swap_advance = 1;
}
+ ;
hi_mark : HI_MARK num L_EOS {
verb_printf("HI_MARK:\t<<%d>>\n", $2);
hi_mark_val = $2 ;
}
+ ;
-num : NUMBER { $$ = yylval.INT;}
+num : NUMBER { $$ = yylval.INT;};
-offset : NUMBER { $$ = yylval.OFFSET;}
+offset : NUMBER { $$ = yylval.OFFSET;};
-string : STRING { $$ = yylval.STRPTR; }
+string : STRING { $$ = yylval.STRPTR; };
module : MODULE module_name '{' mod_ops '}' L_EOS {
struct string_list *list = $4;
@@ -683,6 +750,8 @@
if ( mod && mod->config_end ) (*mod->config_end)(0);
free($2);
}
+ ;
+
mod_ops : mod_op {
$$ = $1;
verb_printf("mod_op: %s\n", $$->string);
@@ -694,6 +763,7 @@
$$ = $1;
verb_printf("mod_op: %s\n", $2->string);
}
+ ;
mod_op : string {
struct string_list *new = xmalloc(sizeof(*new), "parser: mod_ops");
@@ -711,10 +781,12 @@
new->string = new_str;
$$=new;
}
+ ;
module_name : STRING {
$$ = yylval.STRPTR;
}
+ ;
storage : STORAGE '{' st_ops '}' L_EOS {
@@ -746,6 +818,7 @@
storage_size = 0;
storage_offset = 0;
}
+ ;
peerconfig : PEER_PARENT_T ';' {
if ( !peerc_ptr )
@@ -803,9 +876,11 @@
$1->next = peerc_ptr->acls->deny;
peerc_ptr->acls->deny = $1;
}
+ ;
peerops : peerconfig {}
| peerops peerconfig {}
+ ;
peer : PEER_T string num num '{' peerops '}' L_EOS {
struct peer *peer,*p;
@@ -837,14 +912,17 @@
peer_c.type = PEER_SIBLING;
peerc_ptr = NULL;
}
+ ;
st_ops : st_op {}
| st_op st_ops {}
+ ;
st_op : SIZE offset ';' { storage_size = $2; }
| SIZE AUTO_T ';' { storage_size = -1; }
| STORAGE_OFFSET_T offset ';' {storage_offset = $2; }
| PATH STRING ';' { storage_path = yylval.STRPTR; }
+ ;
group : GROUP group_name '{' group_ops '}' L_EOS {
struct group_ops_struct *ops, *next_ops;
@@ -977,12 +1055,16 @@
g->next = new_grp;
}
}
+ ;
+
group_name : STRING {
$$ = yylval.STRPTR;
}
+ ;
group_ops : group_op { $$ = $1;}
| group_op group_ops { $1->next = $2; $$=$1;}
+ ;
group_op : NETWORKS network_list ';' {
struct group_ops_struct *new;
@@ -1034,6 +1116,7 @@
| denytime { $$ = $1; }
| auth_mods { $$ = $1; }
| redir_mods { $$ = $1; }
+ ;
denytime : DENYTIME_T string_list {
struct group_ops_struct *new_op;
@@ -1055,6 +1138,8 @@
}
free_string_list($2);
}
+ ;
+
miss : MISS_T DENY ';' {
struct group_ops_struct *new_op;
@@ -1085,6 +1170,7 @@
$$ = new_op;
}
}
+ ;
auth_mods : AUTH_MODS_T string_list ';' {
struct group_ops_struct *new_op;
@@ -1101,6 +1187,8 @@
$$ = new_op;
}
}
+ ;
+
redir_mods : REDIR_MODS_T string_list ';' {
struct group_ops_struct *new_op;
@@ -1116,6 +1204,8 @@
$$ = new_op;
}
}
+ ;
+
bandwidth : BANDWIDTH_T num ';' {
struct group_ops_struct *new_op;
@@ -1131,6 +1221,8 @@
$$ = new_op;
}
}
+ ;
+
per_sess_bw : PER_SESS_BW_T num ';' {
struct group_ops_struct *new_op;
@@ -1146,6 +1238,8 @@
$$ = new_op;
}
}
+ ;
+
per_ip_bw : PER_IP_BW_T num ';' {
struct group_ops_struct *new_op;
@@ -1161,6 +1255,8 @@
$$ = new_op;
}
}
+ ;
+
per_ip_conn : PER_IP_CONN_T num ';' {
struct group_ops_struct *new_op;
@@ -1176,6 +1272,8 @@
$$ = new_op;
}
}
+ ;
+
conn_from : CONN_FROM_T string ';' {
struct group_ops_struct *new_op;
@@ -1205,6 +1303,8 @@
$$ = new_op;
}
}
+ ;
+
range : '[' num ':' num ']' {
if ( !badp_p ) badp_p = &badports[0];
badp_p->from = $2;
@@ -1242,9 +1342,11 @@
}
free($2);
}
+ ;
ranges : range {}
| range ',' ranges {}
+ ;
badports : BADPORTS_T ranges ';' {
struct group_ops_struct *new_op;
@@ -1270,6 +1372,7 @@
}
}
}
+ ;
icp : ICP '{' deny_acls allow_acls '}' {
struct acls *new_acls;
@@ -1371,6 +1474,7 @@
}
}
}
+ ;
http : HTTP '{' deny_acls allow_acls '}' {
struct acls *new_acls;
@@ -1472,8 +1576,11 @@
}
}
}
+ ;
+
deny_acls : deny_acl { $$ = $1; }
| deny_acl deny_acls { $2->next = $1 ; $$ = $2; }
+ ;
deny_acl : DENY DSTDOMAIN string_list ';' {
struct acl *new = xmalloc(sizeof(*new), "parser: deny_acl new acl 2");
@@ -1495,9 +1602,11 @@
}
free_string_list($3);
}
+ ;
allow_acls : allow_acl { $$ = $1; }
| allow_acl allow_acls { $1->next = $2 ; $$ = $1; }
+ ;
allow_acl : ALLOW DSTDOMAIN string_list ';' {
struct acl *new = xmalloc(sizeof(*new), "parser: allow_acl new acl 2");
@@ -1519,6 +1628,7 @@
}
free_string_list($3);
}
+ ;
string_list : string_list_e { $$ = $1; }
| string_list_e string_list {
@@ -1539,6 +1649,7 @@
d = d->next;
}
}
+ ;
string_list_e : string {
struct string_list *new;
@@ -1551,6 +1662,8 @@
$$ = new;
free($1);
}
+ ;
+
domainlist : domain {
struct domain_list *d=$1;
verb_printf("<%s>\n", d->domain);
@@ -1588,12 +1701,14 @@
new->next = NULL;
$$ = new;
}
+ ;
network_list : network
| network network_list {
$1->next = $2; $$ = $1;
}
+ ;
network : NETWORK {
char *n, *l, *dot, *dot_holder, *t;
@@ -1632,6 +1747,7 @@
free(yylval.STRPTR);
$$ = new;
}
+ ;
%%
|