ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/releases/1.0.0beta2/src/config.c
Revision: 5236
Committed: Wed Dec 31 15:43:14 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3818 byte(s)
Log Message:
RELEASE TAG 1.0.0beta2

File Contents

# Content
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 #include <string.h>
28
29 #include "config.h"
30 #include "malloc.h"
31 #include "log.h"
32 #include "scan.h"
33 #include "irc.h"
34 #include "opercmd.h"
35 #include "stats.h"
36 #include "firedns.h"
37
38 extern FILE *yyin;
39 extern int yyparse(void);
40
41 void config_setup(void);
42 void config_init(void);
43
44
45
46 struct OptionsConf *OptionsItem = NULL;
47 struct IRCConf *IRCItem = NULL;
48 struct OpmConf *OpmItem = NULL;
49 struct ExemptConf *ExemptItem = NULL;
50 list_t *UserItemList = NULL;
51 list_t *ScannerItemList = NULL;
52
53
54 /* Rehash or load new configuration from filename, via flex/bison parser */
55 void
56 config_load(const char *filename)
57 {
58 config_init();
59 config_setup(); /* Setup/clear current configuration */
60
61 log_printf("CONFIG -> Loading %s", filename);
62
63 if ((yyin = fopen(filename, "r")) == NULL)
64 {
65 log_printf("CONFIG -> Error opening %s", filename);
66 exit(EXIT_FAILURE);
67 }
68
69 yyparse();
70
71 scan_init(); /* Initialize the scanners once we have the configuration */
72 command_init(); /* Initialize the command queue */
73 stats_init(); /* Initialize stats (UPTIME) */
74 firedns_init(); /* Initialize adns */
75
76 fclose(yyin);
77 }
78
79 /* Malloc and initialize configuration data to NULL */
80 void
81 config_init(void)
82 {
83 /* Init IRC block */
84 IRCItem = MyMalloc(sizeof *IRCItem);
85 IRCItem->channels = list_create();
86 IRCItem->performs = list_create();
87
88 /* Init Options block */
89 OptionsItem = MyMalloc(sizeof *OptionsItem);
90
91 /* Init OPM block */
92 OpmItem = MyMalloc(sizeof *OpmItem);
93 OpmItem->blacklists = list_create();
94
95 /* Init list of User blocks */
96 UserItemList = list_create();
97
98 /* Init list of Scanner blocks */
99 ScannerItemList = list_create();
100
101 /* Init list of Exempts */
102 ExemptItem = MyMalloc(sizeof *ExemptItem);
103 ExemptItem->masks = list_create();
104 }
105
106 /* Setup structs that hold configuration data and then reset default values */
107 void
108 config_setup(void)
109 {
110 /* Setup IRC Block Defaults */
111 IRCItem->mode = xstrdup("+c");
112 IRCItem->nick = xstrdup("hopm");
113 IRCItem->nickserv = xstrdup("");
114 IRCItem->password = xstrdup("");
115 IRCItem->port = 6667;
116 IRCItem->readtimeout = 900;
117 IRCItem->oper = xstrdup("undefined");
118 IRCItem->username = xstrdup("hopm");
119 IRCItem->realname = xstrdup("Hybrid Open Proxy Monitor");
120 IRCItem->server = xstrdup("irc.example.org");
121 IRCItem->vhost = xstrdup("");
122 IRCItem->connregex = xstrdup("\\*\\*\\* Notice -- Client connecting: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*");
123 IRCItem->kline = xstrdup("KLINE %u@%h :Open Proxy found on your host.");
124
125
126 /* Setup options block defaults */
127 OptionsItem->negcache = 0; /* 0 disabled negcache */
128 OptionsItem->pidfile = xstrdup("hopm.pid");
129 OptionsItem->dns_fdlimit = 50;
130 OptionsItem->scanlog = NULL;
131
132 /* Setup OPM block defaults */
133 OpmItem->sendmail = xstrdup("/usr/sbin/sendmail");
134 OpmItem->dnsbl_from = xstrdup("");
135 OpmItem->dnsbl_to = xstrdup("");
136 }
137
138 void
139 yyerror(const char *str)
140 {
141 log_printf("CONFIG -> %s: line %d", str, linenum);
142 exit(EXIT_FAILURE);
143 }

Properties

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