ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config-parser.y
Revision: 9727
Committed: Mon Nov 16 10:29:12 2020 UTC (5 years, 8 months ago) by michael
File size: 15442 byte(s)
Log Message:
- The 'vhost' configuration directive found in the irc {} and scanner {} blocks has been renamed to 'bind'

File Contents

# Content
1 /*
2 * Copyright (c) 2002-2003 Erik Fears
3 * Copyright (c) 2014-2020 ircd-hybrid development team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18 * USA
19 */
20
21 %{
22 #include <string.h>
23
24 #include "memory.h"
25 #include "config.h"
26
27 int yylex(void);
28
29 static void *tmp; /* Variable to temporarily hold nodes before insertion to list */
30
31 %}
32
33 %token ADDRESS_FAMILY
34 %token AWAY
35 %token BAN_UNKNOWN
36 %token BIND
37 %token BLACKLIST
38 %token BYTES KBYTES MBYTES
39 %token CHANNEL
40 %token COMMAND_INTERVAL
41 %token COMMAND_QUEUE_SIZE
42 %token COMMAND_TIMEOUT
43 %token CONNREGEX
44 %token DNS_FDLIMIT
45 %token DNS_TIMEOUT
46 %token DNSBL_FROM
47 %token DNSBL_TO
48 %token EXEMPT
49 %token FD
50 %token INVITE
51 %token IPV4
52 %token IPV6
53 %token IRC
54 %token KLINE
55 %token KEY
56 %token MASK
57 %token MAX_READ
58 %token MODE
59 %token NAME
60 %token NEGCACHE
61 %token NEGCACHE_REBUILD
62 %token NICK
63 %token NICKSERV
64 %token NOTICE
65 %token OPER
66 %token OPM
67 %token OPTIONS
68 %token PASSWORD
69 %token PERFORM
70 %token PIDFILE
71 %token PORT
72 %token PROTOCOL
73 %token RSA_PRIVATE_KEY_FILE
74 %token READTIMEOUT
75 %token REALNAME
76 %token RECONNECTINTERVAL
77 %token REPLY
78 %token SCANLOG
79 %token SCANNER
80 %token SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS
81 %token SENDMAIL
82 %token SERVER
83 %token TARGET_IP
84 %token TARGET_PORT
85 %token TARGET_STRING
86 %token TIMEOUT
87 %token TLS
88 %token TLS_CERTIFICATE_FILE
89 %token TLS_HOSTNAME_VERIFICATION
90 %token TYPE
91 %token USERNAME
92 %token USER
93
94 %union
95 {
96 int number;
97 char *string;
98 }
99
100 %token <number> NUMBER
101 %token <string> STRING
102 %token <number> PROTOCOLTYPE
103 %type <number> timespec
104 %type <number> timespec_
105 %type <number> sizespec
106 %type <number> sizespec_
107
108 %%
109
110 config:
111 | config config_items
112 ;
113
114 config_items: irc_entry |
115 options_entry |
116 opm_entry |
117 user_entry |
118 scanner_entry |
119 exempt_entry;
120
121 timespec_: { $$ = 0; } | timespec;
122 timespec: NUMBER timespec_ { $$ = $1 + $2; } |
123 NUMBER SECONDS timespec_ { $$ = $1 + $3; } |
124 NUMBER MINUTES timespec_ { $$ = $1 * 60 + $3; } |
125 NUMBER HOURS timespec_ { $$ = $1 * 60 * 60 + $3; } |
126 NUMBER DAYS timespec_ { $$ = $1 * 60 * 60 * 24 + $3; } |
127 NUMBER WEEKS timespec_ { $$ = $1 * 60 * 60 * 24 * 7 + $3; } |
128 NUMBER MONTHS timespec_ { $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3; } |
129 NUMBER YEARS timespec_ { $$ = $1 * 60 * 60 * 24 * 365 + $3; }
130 ;
131
132 sizespec_: { $$ = 0; } | sizespec;
133 sizespec: NUMBER sizespec_ { $$ = $1 + $2; } |
134 NUMBER BYTES sizespec_ { $$ = $1 + $3; } |
135 NUMBER KBYTES sizespec_ { $$ = $1 * 1024 + $3; } |
136 NUMBER MBYTES sizespec_ { $$ = $1 * 1024 * 1024 + $3; }
137 ;
138
139
140 /*************************** OPTIONS BLOCK ***********************/
141 options_entry: OPTIONS '{' options_items '}' ';';
142
143 options_items: options_items options_item |
144 options_item;
145
146 options_item: options_negcache |
147 options_negcache_rebuild |
148 options_pidfile |
149 options_dns_fdlimit |
150 options_dns_timeout |
151 options_scanlog |
152 options_command_queue_size |
153 options_command_interval |
154 options_command_timeout |
155 error;
156
157 options_negcache: NEGCACHE '=' timespec ';'
158 {
159 OptionsItem.negcache = $3;
160 };
161
162 options_negcache_rebuild: NEGCACHE_REBUILD '=' timespec ';'
163 {
164 OptionsItem.negcache_rebuild = $3;
165 };
166
167 options_pidfile: PIDFILE '=' STRING ';'
168 {
169 xfree(OptionsItem.pidfile);
170 OptionsItem.pidfile = xstrdup($3);
171 };
172
173 options_dns_fdlimit: DNS_FDLIMIT '=' NUMBER ';'
174 {
175 OptionsItem.dns_fdlimit = $3;
176 };
177
178 options_dns_timeout: DNS_TIMEOUT '=' timespec ';'
179 {
180 OptionsItem.dns_timeout = $3;
181 };
182
183 options_scanlog: SCANLOG '=' STRING ';'
184 {
185 xfree(OptionsItem.scanlog);
186 OptionsItem.scanlog = xstrdup($3);
187 };
188
189 options_command_queue_size: COMMAND_QUEUE_SIZE '=' NUMBER ';'
190 {
191 OptionsItem.command_queue_size = $3;
192 };
193
194 options_command_interval: COMMAND_INTERVAL '=' timespec ';'
195 {
196 OptionsItem.command_interval = $3;
197 };
198
199 options_command_timeout: COMMAND_TIMEOUT '=' timespec ';'
200 {
201 OptionsItem.command_timeout = $3;
202 };
203
204
205 /*************************** IRC BLOCK ***************************/
206 irc_entry: IRC '{' irc_items '}' ';';
207
208 irc_items: irc_items irc_item |
209 irc_item;
210
211 irc_item: irc_away |
212 irc_connregex |
213 irc_kline |
214 irc_nick |
215 irc_nickserv |
216 irc_mode |
217 irc_oper |
218 irc_password |
219 irc_port |
220 irc_tls |
221 irc_rsa_private_key_file |
222 irc_tls_certificate_file |
223 irc_tls_hostname_verification |
224 irc_readtimeout |
225 irc_reconnectinterval |
226 irc_realname |
227 irc_server |
228 irc_username |
229 irc_bind |
230 irc_perform |
231 irc_notice |
232 channel_entry |
233 error;
234
235 irc_away: AWAY '=' STRING ';'
236 {
237 xfree(IRCItem.away);
238 IRCItem.away = xstrdup($3);
239 };
240
241 irc_kline: KLINE '=' STRING ';'
242 {
243 xfree(IRCItem.kline);
244 IRCItem.kline = xstrdup($3);
245 };
246
247 irc_mode: MODE '=' STRING ';'
248 {
249 xfree(IRCItem.mode);
250 IRCItem.mode = xstrdup($3);
251 };
252
253 irc_nick: NICK '=' STRING ';'
254 {
255 xfree(IRCItem.nick);
256 IRCItem.nick = xstrdup($3);
257 };
258
259 irc_nickserv: NICKSERV '=' STRING ';'
260 {
261 xfree(IRCItem.nickserv);
262 IRCItem.nickserv = xstrdup($3);
263 };
264
265 irc_oper: OPER '=' STRING ';'
266 {
267 xfree(IRCItem.oper);
268 IRCItem.oper = xstrdup($3);
269 };
270
271 irc_password: PASSWORD '=' STRING ';'
272 {
273 xfree(IRCItem.password);
274 IRCItem.password = xstrdup($3);
275 };
276
277 irc_perform: PERFORM '=' STRING ';'
278 {
279 list_add(xstrdup($3), node_create(), &IRCItem.performs);
280 };
281
282 irc_notice: NOTICE '=' STRING ';'
283 {
284 list_add(xstrdup($3), node_create(), &IRCItem.notices);
285 };
286
287 irc_port: PORT '=' NUMBER ';'
288 {
289 IRCItem.port = $3;
290 };
291
292 irc_tls: TLS '=' NUMBER ';'
293 {
294 IRCItem.tls = $3;
295 };
296
297 irc_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' STRING ';'
298 {
299 xfree(IRCItem.rsa_private_key_file);
300 IRCItem.rsa_private_key_file = xstrdup($3);
301 };
302
303
304 irc_tls_certificate_file: TLS_CERTIFICATE_FILE '=' STRING ';'
305 {
306 xfree(IRCItem.tls_certificate_file);
307 IRCItem.tls_certificate_file = xstrdup($3);
308 };
309
310 irc_tls_hostname_verification: TLS_HOSTNAME_VERIFICATION '=' NUMBER ';'
311 {
312 IRCItem.tls_hostname_verification = $3;
313 };
314
315 irc_readtimeout: READTIMEOUT '=' timespec ';'
316 {
317 IRCItem.readtimeout = $3;
318 };
319
320 irc_reconnectinterval: RECONNECTINTERVAL '=' timespec ';'
321 {
322 IRCItem.reconnectinterval = $3;
323 };
324
325 irc_realname: REALNAME '=' STRING ';'
326 {
327 xfree(IRCItem.realname);
328 IRCItem.realname = xstrdup($3);
329 };
330
331 irc_server: SERVER '=' STRING ';'
332 {
333 xfree(IRCItem.server);
334 IRCItem.server = xstrdup($3);
335 };
336
337 irc_username: USERNAME '=' STRING ';'
338 {
339 xfree(IRCItem.username);
340 IRCItem.username = xstrdup($3);
341 };
342
343 irc_bind: BIND '=' STRING ';'
344 {
345 xfree(IRCItem.bind);
346 IRCItem.bind = xstrdup($3);
347 };
348
349 irc_connregex: CONNREGEX '=' STRING ';'
350 {
351 xfree(IRCItem.connregex);
352 IRCItem.connregex = xstrdup($3);
353 };
354
355
356 /************************** CHANNEL BLOCK *************************/
357 channel_entry:
358 {
359 struct ChannelConf *item;
360
361 item = xcalloc(sizeof(*item));
362 item->name = xstrdup("");
363 item->key = xstrdup("");
364 item->invite = xstrdup("");
365
366 list_add(item, &item->node, &IRCItem.channels);
367 tmp = item;
368 }
369 CHANNEL '{' channel_items '}' ';';
370
371 channel_items: channel_items channel_item |
372 channel_item;
373
374 channel_item: channel_name |
375 channel_key |
376 channel_invite;
377
378 channel_name: NAME '=' STRING ';'
379 {
380 struct ChannelConf *item = tmp;
381
382 xfree(item->name);
383 item->name = xstrdup($3);
384 };
385
386 channel_key: KEY '=' STRING ';'
387 {
388 struct ChannelConf *item = tmp;
389
390 xfree(item->key);
391 item->key = xstrdup($3);
392 };
393
394 channel_invite: INVITE '=' STRING ';'
395 {
396 struct ChannelConf *item = tmp;
397
398 xfree(item->invite);
399 item->invite = xstrdup($3);
400 };
401
402
403 /*************************** USER BLOCK ***************************/
404 user_entry:
405 {
406 struct UserConf *item;
407
408 item = xcalloc(sizeof(*item));
409
410 list_add(item, &item->node, &UserItemList);
411 tmp = item;
412 }
413 USER '{' user_items '}' ';' ;
414
415 user_items: user_items user_item |
416 user_item;
417
418 user_item: user_mask |
419 user_scanner |
420 error;
421
422 user_mask: MASK '=' STRING ';'
423 {
424 struct UserConf *item = tmp;
425
426 list_add(xstrdup($3), node_create(), &item->masks);
427 };
428
429 user_scanner: SCANNER '=' STRING ';'
430 {
431 struct UserConf *item = tmp;
432
433 list_add(xstrdup($3), node_create(), &item->scanners);
434 };
435
436
437 /*************************** SCANNER BLOCK ***************************/
438 scanner_entry:
439 {
440 struct ScannerConf *item, *olditem;
441
442 item = xcalloc(sizeof(*item));
443
444 /* Setup ScannerConf defaults */
445 item->name = xstrdup("undefined");
446
447 if (LIST_SIZE(&ScannerItemList))
448 {
449 olditem = ScannerItemList.tail->data;
450
451 item->bind = xstrdup(olditem->bind);
452 item->fd = olditem->fd;
453 item->target_ip = xstrdup(olditem->target_ip);
454 item->target_port = olditem->target_port;
455 item->timeout = olditem->timeout;
456 item->max_read = olditem->max_read;
457 memcpy(&item->target_string, &olditem->target_string, sizeof(item->target_string));
458 }
459 else
460 {
461 item->bind = xstrdup("0.0.0.0");
462 item->fd = 512;
463 item->target_ip = xstrdup("127.0.0.1");
464 item->target_port = 6667;
465 item->timeout = 30;
466 item->max_read = 4096;
467 }
468
469 list_add(item, &item->node, &ScannerItemList);
470 tmp = item;
471 }
472 SCANNER '{' scanner_items '}' ';' ;
473
474 scanner_items: scanner_items scanner_item |
475 scanner_item;
476
477 scanner_item: scanner_name |
478 scanner_bind |
479 scanner_fd |
480 scanner_target_ip |
481 scanner_target_port |
482 scanner_target_string |
483 scanner_protocol |
484 scanner_timeout |
485 scanner_max_read |
486 error;
487
488 scanner_name: NAME '=' STRING ';'
489 {
490 struct ScannerConf *item = tmp;
491
492 xfree(item->name);
493 item->name = xstrdup($3);
494 };
495
496 scanner_bind: BIND '=' STRING ';'
497 {
498 struct ScannerConf *item = tmp;
499
500 xfree(item->bind);
501 item->bind = xstrdup($3);
502 };
503
504 scanner_target_ip: TARGET_IP '=' STRING ';'
505 {
506 struct ScannerConf *item = tmp;
507
508 xfree(item->target_ip);
509 item->target_ip = xstrdup($3);
510 };
511
512 scanner_target_string: TARGET_STRING '=' STRING ';'
513 {
514 struct ScannerConf *item = tmp;
515
516 if (item->target_string_created == 0)
517 {
518 memset(&item->target_string, 0, sizeof(item->target_string));
519 item->target_string_created = 1;
520 }
521
522 list_add(xstrdup($3), node_create(), &item->target_string);
523 };
524
525 scanner_fd: FD '=' NUMBER ';'
526 {
527 struct ScannerConf *item = tmp;
528
529 item->fd = $3;
530 };
531
532 scanner_target_port: TARGET_PORT '=' NUMBER ';'
533 {
534 struct ScannerConf *item = tmp;
535
536 item->target_port = $3;
537 };
538
539 scanner_timeout: TIMEOUT '=' timespec ';'
540 {
541 struct ScannerConf *item = tmp;
542
543 item->timeout = $3;
544 };
545
546 scanner_max_read: MAX_READ '=' sizespec ';'
547 {
548 struct ScannerConf *item = tmp;
549
550 item->max_read = $3;
551 };
552
553 scanner_protocol: PROTOCOL '=' PROTOCOLTYPE ':' NUMBER ';'
554 {
555 struct ProtocolConf *item;
556 struct ScannerConf *item2;
557
558 item = xcalloc(sizeof(*item));
559 item->type = $3;
560 item->port = $5;
561
562 item2 = tmp;
563
564 list_add(item, node_create(), &item2->protocols);
565 };
566
567
568 /*************************** OPM BLOCK ***************************/
569 opm_entry: OPM '{' opm_items '}' ';' ;
570
571 opm_items: opm_items opm_item |
572 opm_item;
573
574 opm_item: opm_dnsbl_from |
575 opm_dnsbl_to |
576 opm_sendmail |
577 opm_blacklist_entry |
578 error;
579
580 opm_dnsbl_from: DNSBL_FROM '=' STRING ';'
581 {
582 xfree(OpmItem.dnsbl_from);
583 OpmItem.dnsbl_from = xstrdup($3);
584 };
585
586 opm_dnsbl_to: DNSBL_TO '=' STRING ';'
587 {
588 xfree(OpmItem.dnsbl_to);
589 OpmItem.dnsbl_to = xstrdup($3);
590 };
591
592 opm_sendmail: SENDMAIL '=' STRING ';'
593 {
594 xfree(OpmItem.sendmail);
595 OpmItem.sendmail = xstrdup($3);
596 };
597
598
599 /************************** BLACKLIST BLOCK *************************/
600 opm_blacklist_entry:
601 {
602 struct BlacklistConf *item;
603
604 item = xcalloc(sizeof(*item));
605 item->name = xstrdup("");
606 item->kline = xstrdup("");
607 item->ipv4 = 1;
608 item->ban_unknown = 0;
609 item->type = A_BITMASK;
610
611 list_add(item, node_create(), &OpmItem.blacklists);
612
613 tmp = item;
614 }
615 BLACKLIST '{' blacklist_items '}' ';';
616
617 blacklist_items: blacklist_items blacklist_item |
618 blacklist_item;
619
620 blacklist_item: blacklist_name |
621 blacklist_address_family |
622 blacklist_type |
623 blacklist_kline |
624 blacklist_ban_unknown |
625 blacklist_reply |
626 error;
627
628 blacklist_name: NAME '=' STRING ';'
629 {
630 struct BlacklistConf *item = tmp;
631
632 xfree(item->name);
633 item->name = xstrdup($3);
634 };
635
636 blacklist_address_family: ADDRESS_FAMILY
637 {
638 struct BlacklistConf *item = tmp;
639
640 item->ipv4 = 0;
641 item->ipv6 = 0;
642 } '=' blacklist_address_family_items ';' ;
643
644 blacklist_address_family_items: blacklist_address_family_items ',' blacklist_address_family_item | blacklist_address_family_item;
645 blacklist_address_family_item: IPV4
646 {
647 struct BlacklistConf *item = tmp;
648
649 item->ipv4 = 1;
650 } | IPV6
651 {
652 struct BlacklistConf *item = tmp;
653
654 item->ipv6 = 1;
655 };
656
657 blacklist_kline: KLINE '=' STRING ';'
658 {
659 struct BlacklistConf *item = tmp;
660
661 xfree(item->kline);
662 item->kline = xstrdup($3);
663 };
664
665 blacklist_type: TYPE '=' STRING ';'
666 {
667 struct BlacklistConf *item = tmp;
668
669 if (strcmp("A record bitmask", $3) == 0)
670 item->type = A_BITMASK;
671 else if (strcmp("A record reply", $3) == 0)
672 item->type = A_REPLY;
673 else
674 yyerror("Unknown blacklist type defined");
675 };
676
677 blacklist_ban_unknown: BAN_UNKNOWN '=' NUMBER ';'
678 {
679 struct BlacklistConf *item = tmp;
680
681 item->ban_unknown = $3;
682 };
683
684 blacklist_reply: REPLY '{' blacklist_reply_items '}' ';';
685
686 blacklist_reply_items: blacklist_reply_items blacklist_reply_item |
687 blacklist_reply_item;
688
689 blacklist_reply_item: NUMBER '=' STRING ';'
690 {
691 struct BlacklistReplyConf *item;
692 struct BlacklistConf *blacklist = tmp;
693
694 item = xcalloc(sizeof(*item));
695 item->number = $1;
696 item->type = xstrdup($3);
697
698 list_add(item, node_create(), &blacklist->reply);
699 };
700
701
702 /*************************** EXEMPT BLOCK ***************************/
703 exempt_entry: EXEMPT '{' exempt_items '}' ';' ;
704
705 exempt_items: exempt_items exempt_item |
706 exempt_item;
707
708 exempt_item: exempt_mask |
709 error;
710
711 exempt_mask: MASK '=' STRING ';'
712 {
713 list_add(xstrdup($3), node_create(), &ExemptItem.masks);
714 };
715
716 %%

Properties

Name Value
svn:eol-style native
svn:keywords Id