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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5052 - (show annotations)
Mon Dec 22 11:56:03 2014 UTC (7 years, 11 months ago) by michael
File MIME type: text/x-chdr
File size: 4224 byte(s)
- Initial import of bopm 3.1.3
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 memset(IRCItem, 0, sizeof *IRCItem);
94 IRCItem->channels = list_create();
95 IRCItem->performs = list_create();
96
97 /* Init Options block */
98 OptionsItem = MyMalloc(sizeof *OptionsItem);
99 memset(OptionsItem, 0, sizeof *OptionsItem);
100
101 /* Init OPM block */
102 OpmItem = MyMalloc(sizeof *OpmItem);
103 memset(OpmItem, 0, sizeof *OpmItem);
104 OpmItem->blacklists = list_create();
105
106 /* Init list of User blocks */
107 UserItemList = list_create();
108
109 /* Init list of Scanner blocks */
110 ScannerItemList = list_create();
111
112 /* Init list of Exempts */
113 ExemptItem = MyMalloc(sizeof *ExemptItem);
114 ExemptItem->masks = list_create();
115 }
116
117 /* Setup structs that hold configuration data and then reset default values */
118
119 void config_setup()
120 {
121
122 /* Setup IRC Block Defaults */
123 IRCItem->away = DupString("I'm a bot, don't message me");
124 IRCItem->mode = DupString("+cs");
125 IRCItem->nick = DupString("bopm");
126 IRCItem->nickserv = DupString("");
127 IRCItem->password = DupString("");
128 IRCItem->port = 6667;
129 IRCItem->oper = DupString("undefined");
130 IRCItem->username = DupString("bopm");
131 IRCItem->realname = DupString("Blitzed Open Proxy Monitor");
132 IRCItem->server = DupString("myserver.blitzed.org");
133 IRCItem->vhost = DupString("");
134 IRCItem->connregex = DupString("\\*\\*\\* Notice -- Client connecting: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*");
135 IRCItem->kline = DupString("KLINE %u@%h :Open Proxy found on your host. Please visit www.blitzed.org/proxy?ip=%i for more information.");
136
137
138 /* Setup options block defaults */
139 OptionsItem->negcache = 0; /* 0 disabled negcache */
140 OptionsItem->pidfile = DupString("bopm.pid");
141 OptionsItem->dns_fdlimit = 50;
142 OptionsItem->scanlog = NULL;
143
144 /* Setup OPM block defaults */
145 OpmItem->sendmail = DupString("/usr/sbin/sendmail");
146 OpmItem->dnsbl_from = DupString("");
147 OpmItem->dnsbl_to = DupString("");
148 }
149
150 void yyerror(const char *str)
151 {
152 log_printf("CONFIG -> %s: line %d", str, linenum);
153 exit(EXIT_FAILURE);
154 }

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