ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config.c
Revision: 9865
Committed: Sat Jan 2 18:42:37 2021 UTC (3 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 3081 byte(s)
Log Message:
- Bump copyright years

File Contents

# Content
1 /*
2 * Copyright (c) 2002 Erik Fears
3 * Copyright (c) 2014-2021 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 #include "setup.h"
22
23 #include <stdio.h>
24 #include <errno.h>
25 #include <string.h>
26 #include <stdlib.h>
27
28 #include "config.h"
29 #include "config-parser.h"
30 #include "compat.h"
31 #include "memory.h"
32 #include "log.h"
33 #include "scan.h"
34 #include "irc.h"
35 #include "opercmd.h"
36 #include "stats.h"
37 #include "firedns.h"
38 #include "misc.h"
39
40
41 FILE *conf_file;
42 struct OptionsConf OptionsItem;
43 struct IRCConf IRCItem;
44 struct OpmConf OpmItem;
45 struct ExemptConf ExemptItem;
46 list_t UserItemList;
47 list_t ScannerItemList;
48
49
50 /* Setup structs that hold configuration data and then reset default values */
51 static void
52 config_setup(void)
53 {
54 /* Setup irc {} block defaults */
55 IRCItem.nick = xstrdup("hopm");
56 IRCItem.port = 6667;
57 IRCItem.tls_hostname_verification = 1;
58 IRCItem.readtimeout = 900;
59 IRCItem.reconnectinterval = 30;
60 IRCItem.username = xstrdup("hopm");
61 IRCItem.realname = xstrdup("Hybrid Open Proxy Monitor");
62 IRCItem.server = xstrdup("irc.example.org");
63 IRCItem.connregex = xstrdup("\\*\\*\\* Notice -- Client connecting: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9a-f\\.:]+)\\].*");
64 IRCItem.kline = xstrdup("KLINE %u@%h :Open Proxy found on your host.");
65
66 /* Setup options {} block defaults */
67 OptionsItem.command_queue_size = 64;
68 OptionsItem.command_interval = 10;
69 OptionsItem.command_timeout = 180;
70 OptionsItem.negcache_rebuild = 43200;
71 OptionsItem.pidfile = xstrdup("hopm.pid");
72 OptionsItem.dns_fdlimit = 50;
73 OptionsItem.dns_timeout = 5;
74 }
75
76 /* Load configuration from filename, via flex/bison parser */
77 void
78 config_load(const char *filename)
79 {
80 config_setup(); /* Setup/clear current configuration */
81
82 log_printf("CONFIG -> Loading %s", filename);
83
84 strlcpy(conffilebuf, filename, sizeof(conffilebuf));
85
86 conf_file = fopen(filename, "r");
87 if (conf_file == NULL)
88 {
89 log_printf("CONFIG -> Error opening %s: %s", filename, strerror(errno));
90 exit(EXIT_FAILURE);
91 }
92
93 yyparse();
94 fclose(conf_file);
95
96 scan_init(); /* Initialize the scanners once we have the configuration */
97 stats_init(); /* Initialize stats (UPTIME) */
98 firedns_init(); /* Initialize adns */
99 }
100
101 void
102 yyerror(const char *str)
103 {
104 log_printf("CONFIG -> \"%s\", line %u: %s: %s", conffilebuf, lineno, str, stripws(linebuf));
105 exit(EXIT_FAILURE);
106 }

Properties

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