/[svn]/hopm/trunk/src/config.c
ViewVC logotype

Contents of /hopm/trunk/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5109 - (show annotations)
Wed Dec 24 13:26:29 2014 UTC (7 years, 7 months ago) by michael
File MIME type: text/x-chdr
File size: 3936 byte(s)
- Use reserved example domains as specified in rfc2606

1 /*
2 * Copyright (C) 2002 Erik Fears
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to
16 *
17 * The Free Software Foundation, Inc.
18 * 59 Temple Place - Suite 330
19 * Boston, MA 02111-1307, USA.
20 *
21 *
22 */
23
24 #include "setup.h"
25
26 #include <stdio.h>
27
28 #ifdef HAVE_STRING_H
29 # include <string.h>
30 #endif
31
32 #include "extern.h"
33 #include "config.h"
34 #include "malloc.h"
35 #include "log.h"
36 #include "scan.h"
37 #include "irc.h"
38 #include "opercmd.h"
39 #include "stats.h"
40 #include "firedns.h"
41
42 extern FILE *yyin;
43 extern int yyparse(void);
44
45 void config_setup(void);
46 void config_init(void);
47
48
49
50 /* Configuration */
51
52 struct OptionsConf *OptionsItem = NULL;
53 struct IRCConf *IRCItem = NULL;
54 struct OpmConf *OpmItem = NULL;
55 struct ExemptConf *ExemptItem = NULL;
56 list_t *UserItemList = NULL;
57 list_t *ScannerItemList = NULL;
58
59 /* End Configuration */
60
61
62
63 /* Rehash or load new configuration from filename, via flex/bison parser */
64 void config_load(const char *filename)
65 {
66
67 config_init();
68 config_setup(); /* Setup/clear current configuration */
69
70 log_printf("CONFIG -> Loading %s", filename);
71
72 if((yyin = fopen(filename, "r")) == NULL)
73 {
74 log_printf("CONFIG -> Error opening %s", filename);
75 exit(1);
76 }
77
78 yyparse();
79
80 scan_init(); /* Initialize the scanners once we have the configuration */
81 command_init(); /* Initialize the command queue */
82 stats_init(); /* Initialize stats (UPTIME) */
83 firedns_init(); /* Initialize adns */
84
85 fclose(yyin);
86 }
87
88 /* Malloc and initialize configuration data to NULL */
89 void config_init()
90 {
91 /* Init IRC block */
92 IRCItem = MyMalloc(sizeof *IRCItem);
93 IRCItem->channels = list_create();
94 IRCItem->performs = list_create();
95
96 /* Init Options block */
97 OptionsItem = MyMalloc(sizeof *OptionsItem);
98
99 /* Init OPM block */
100 OpmItem = MyMalloc(sizeof *OpmItem);
101 OpmItem->blacklists = list_create();
102
103 /* Init list of User blocks */
104 UserItemList = list_create();
105
106 /* Init list of Scanner blocks */
107 ScannerItemList = list_create();
108
109 /* Init list of Exempts */
110 ExemptItem = MyMalloc(sizeof *ExemptItem);
111 ExemptItem->masks = list_create();
112 }
113
114 /* Setup structs that hold configuration data and then reset default values */
115
116 void config_setup()
117 {
118
119 /* Setup IRC Block Defaults */
120 IRCItem->mode = xstrdup("+cs");
121 IRCItem->nick = xstrdup("hopm");
122 IRCItem->nickserv = xstrdup("");
123 IRCItem->password = xstrdup("");
124 IRCItem->port = 6667;
125 IRCItem->oper = xstrdup("undefined");
126 IRCItem->username = xstrdup("hopm");
127 IRCItem->realname = xstrdup("Hybrid Open Proxy Monitor");
128 IRCItem->server = xstrdup("irc.example.org");
129 IRCItem->vhost = xstrdup("");
130 IRCItem->connregex = xstrdup("\\*\\*\\* Notice -- Client connecting: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*");
131 IRCItem->kline = xstrdup("KLINE %u@%h :Open Proxy found on your host.");
132
133
134 /* Setup options block defaults */
135 OptionsItem->negcache = 0; /* 0 disabled negcache */
136 OptionsItem->pidfile = xstrdup("hopm.pid");
137 OptionsItem->dns_fdlimit = 50;
138 OptionsItem->scanlog = NULL;
139
140 /* Setup OPM block defaults */
141 OpmItem->sendmail = xstrdup("/usr/sbin/sendmail");
142 OpmItem->dnsbl_from = xstrdup("");
143 OpmItem->dnsbl_to = xstrdup("");
144 }
145
146 void yyerror(const char *str)
147 {
148 log_printf("CONFIG -> %s: line %d", str, linenum);
149 exit(EXIT_FAILURE);
150 }

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28