ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
(Generate patch)

Comparing:
ircd-hybrid-8/src/conf_parser.y (file contents), Revision 1352 by michael, Fri Apr 13 09:57:08 2012 UTC vs.
ircd-hybrid/trunk/src/conf_parser.y (file contents), Revision 6678 by michael, Tue Oct 27 19:19:21 2015 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  conf_parser.y: Parses the ircd configuration file.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2005 by the past and present ircd coders, and others.
4 > *  Copyright (c) 2000-2015 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 16 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
21 *
22 *  $Id$
20   */
21  
22 + /*! \file conf_parser.y
23 + * \brief Parses the ircd configuration file.
24 + * \version $Id$
25 + */
26 +
27 +
28   %{
29  
27 #define YY_NO_UNPUT
30   #include <sys/types.h>
31   #include <string.h>
32  
# Line 33 | Line 35
35   #include "ircd.h"
36   #include "list.h"
37   #include "conf.h"
38 + #include "conf_class.h"
39 + #include "conf_pseudo.h"
40   #include "event.h"
41 + #include "id.h"
42   #include "log.h"
43 < #include "client.h"     /* for UMODE_ALL only */
43 > #include "client.h"     /* for UMODE_SERVNOTICE only */
44   #include "irc_string.h"
40 #include "sprintf_irc.h"
45   #include "memory.h"
46   #include "modules.h"
47 < #include "s_serv.h"
47 > #include "server.h"
48   #include "hostmask.h"
49   #include "send.h"
50   #include "listener.h"
51   #include "resv.h"
52   #include "numeric.h"
53 < #include "s_user.h"
53 > #include "user.h"
54 > #include "motd.h"
55  
56   #ifdef HAVE_LIBCRYPTO
57   #include <openssl/rsa.h>
# Line 55 | Line 60
60   #include <openssl/dh.h>
61   #endif
62  
63 < int yylex(void);
63 > #include "rsa.h"
64  
65 < static char *class_name = NULL;
61 < static struct ConfItem *yy_conf = NULL;
62 < static struct AccessItem *yy_aconf = NULL;
63 < static struct MatchItem *yy_match_item = NULL;
64 < static struct ClassItem *yy_class = NULL;
65 < static char *yy_class_name = NULL;
66 <
67 < static dlink_list col_conf_list  = { NULL, NULL, 0 };
68 < static dlink_list hub_conf_list  = { NULL, NULL, 0 };
69 < static dlink_list leaf_conf_list = { NULL, NULL, 0 };
70 < static unsigned int listener_flags = 0;
71 < static unsigned int regex_ban = 0;
72 < static char userbuf[IRCD_BUFSIZE];
73 < static char hostbuf[IRCD_BUFSIZE];
74 < static char reasonbuf[REASONLEN + 1];
75 < static char gecos_name[REALLEN * 4];
76 < static char lfile[IRCD_BUFSIZE];
77 < static unsigned int ltype = 0;
78 < static unsigned int lsize = 0;
79 < static char *resv_reason = NULL;
80 < static char *listener_address = NULL;
81 <
82 < struct CollectItem
83 < {
84 <  dlink_node node;
85 <  char *name;
86 <  char *user;
87 <  char *host;
88 <  char *passwd;
89 <  int  port;
90 <  int  flags;
91 < #ifdef HAVE_LIBCRYPTO
92 <  char *rsa_public_key_file;
93 <  RSA *rsa_public_key;
94 < #endif
95 < };
65 > int yylex(void);
66  
67 < static void
98 < free_collect_item(struct CollectItem *item)
67 > static struct
68   {
69 <  MyFree(item->name);
70 <  MyFree(item->user);
71 <  MyFree(item->host);
72 <  MyFree(item->passwd);
73 < #ifdef HAVE_LIBCRYPTO
74 <  MyFree(item->rsa_public_key_file);
75 < #endif
76 <  MyFree(item);
77 < }
69 >  struct
70 >  {
71 >    dlink_list list;
72 >  } mask,
73 >    leaf,
74 >    hub;
75 >
76 >  struct
77 >  {
78 >    char buf[IRCD_BUFSIZE];
79 >  } name,
80 >    nick,
81 >    user,
82 >    host,
83 >    addr,
84 >    bind,
85 >    file,
86 >    ciph,
87 >    cert,
88 >    rpass,
89 >    spass,
90 >    whois,
91 >    class,
92 >    target,
93 >    prepend,
94 >    command;
95 >
96 >  struct
97 >  {
98 >    unsigned int value;
99 >  } flags,
100 >    modes,
101 >    size,
102 >    type,
103 >    port,
104 >    aftype,
105 >    ping_freq,
106 >    max_perip,
107 >    con_freq,
108 >    min_idle,
109 >    max_idle,
110 >    max_total,
111 >    max_global,
112 >    max_local,
113 >    max_ident,
114 >    max_sendq,
115 >    max_recvq,
116 >    max_channels,
117 >    cidr_bitlen_ipv4,
118 >    cidr_bitlen_ipv6,
119 >    number_per_cidr;
120 > } block_state;
121  
122   static void
123 < unhook_hub_leaf_confs(void)
123 > reset_block_state(void)
124   {
125 <  dlink_node *ptr;
114 <  dlink_node *next_ptr;
115 <  struct CollectItem *yy_hconf;
116 <  struct CollectItem *yy_lconf;
125 >  dlink_node *node = NULL, *node_next = NULL;
126  
127 <  DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
127 >  DLINK_FOREACH_SAFE(node, node_next, block_state.mask.list.head)
128    {
129 <    yy_hconf = ptr->data;
130 <    dlinkDelete(&yy_hconf->node, &hub_conf_list);
131 <    free_collect_item(yy_hconf);
129 >    MyFree(node->data);
130 >    dlinkDelete(node, &block_state.mask.list);
131 >    free_dlink_node(node);
132    }
133  
134 <  DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
134 >  DLINK_FOREACH_SAFE(node, node_next, block_state.leaf.list.head)
135    {
136 <    yy_lconf = ptr->data;
137 <    dlinkDelete(&yy_lconf->node, &leaf_conf_list);
138 <    free_collect_item(yy_lconf);
136 >    MyFree(node->data);
137 >    dlinkDelete(node, &block_state.leaf.list);
138 >    free_dlink_node(node);
139    }
140 +
141 +  DLINK_FOREACH_SAFE(node, node_next, block_state.hub.list.head)
142 +  {
143 +    MyFree(node->data);
144 +    dlinkDelete(node, &block_state.hub.list);
145 +    free_dlink_node(node);
146 +  }
147 +
148 +  memset(&block_state, 0, sizeof(block_state));
149   }
150  
151   %}
# Line 138 | Line 156 | unhook_hub_leaf_confs(void)
156   }
157  
158   %token  ACCEPT_PASSWORD
141 %token  ACTION
159   %token  ADMIN
160   %token  AFTYPE
144 %token  T_ALLOW
161   %token  ANTI_NICK_FLOOD
162   %token  ANTI_SPAM_EXIT_MESSAGE_TIME
163   %token  AUTOCONN
164 < %token  T_BLOCK
165 < %token  BURST_AWAY
166 < %token  BURST_TOPICWHO
151 < %token  BYTES KBYTES MBYTES GBYTES TBYTES
164 > %token  AWAY_COUNT
165 > %token  AWAY_TIME
166 > %token  BYTES KBYTES MBYTES
167   %token  CALLER_ID_WAIT
168   %token  CAN_FLOOD
169   %token  CHANNEL
170 < %token  CIDR_BITLEN_IPV4
171 < %token  CIDR_BITLEN_IPV6
170 > %token  CIDR_BITLEN_IPV4
171 > %token  CIDR_BITLEN_IPV6
172   %token  CLASS
173 + %token  CLOSE
174   %token  CONNECT
175   %token  CONNECTFREQ
176 + %token  CYCLE_ON_HOST_CHANGE
177   %token  DEFAULT_FLOODCOUNT
178 < %token  DEFAULT_SPLIT_SERVER_COUNT
179 < %token  DEFAULT_SPLIT_USER_COUNT
178 > %token  DEFAULT_JOIN_FLOOD_COUNT
179 > %token  DEFAULT_JOIN_FLOOD_TIME
180 > %token  DEFAULT_MAX_CLIENTS
181   %token  DENY
182   %token  DESCRIPTION
183   %token  DIE
184   %token  DISABLE_AUTH
185   %token  DISABLE_FAKE_CHANNELS
168 %token  DISABLE_HIDDEN
169 %token  DISABLE_LOCAL_CHANNELS
186   %token  DISABLE_REMOTE_COMMANDS
187 + %token  DLINE_MIN_CIDR
188 + %token  DLINE_MIN_CIDR6
189   %token  DOTS_IN_IDENT
172 %token  DURATION
173 %token  EGDPOOL_PATH
190   %token  EMAIL
175 %token  ENABLE
191   %token  ENCRYPTED
192   %token  EXCEED_LIMIT
193   %token  EXEMPT
194   %token  FAILED_OPER_NOTICE
180 %token  IRCD_FLAGS
195   %token  FLATTEN_LINKS
196 + %token  FLATTEN_LINKS_DELAY
197 + %token  FLATTEN_LINKS_FILE
198   %token  GECOS
199   %token  GENERAL
184 %token  GLINE
185 %token  GLINES
186 %token  GLINE_EXEMPT
187 %token  GLINE_TIME
188 %token  GLINE_MIN_CIDR
189 %token  GLINE_MIN_CIDR6
190 %token  GLOBAL_KILL
191 %token  IRCD_AUTH
192 %token  NEED_IDENT
193 %token  HAVENT_READ_CONF
200   %token  HIDDEN
201 < %token  HIDDEN_NAME
201 > %token  HIDDEN_NAME
202 > %token  HIDE_CHANS
203 > %token  HIDE_IDLE
204 > %token  HIDE_IDLE_FROM_OPERS
205   %token  HIDE_SERVER_IPS
206   %token  HIDE_SERVERS
207 < %token  HIDE_SPOOF_IPS
207 > %token  HIDE_SERVICES
208   %token  HOST
209   %token  HUB
210   %token  HUB_MASK
211   %token  IGNORE_BOGUS_TS
212   %token  INVISIBLE_ON_CONNECT
213 + %token  INVITE_CLIENT_COUNT
214 + %token  INVITE_CLIENT_TIME
215   %token  IP
216 + %token  IRCD_AUTH
217 + %token  IRCD_FLAGS
218 + %token  IRCD_SID
219 + %token  JOIN
220   %token  KILL
221 < %token  KILL_CHASE_TIME_LIMIT
221 > %token  KILL_CHASE_TIME_LIMIT
222   %token  KLINE
223   %token  KLINE_EXEMPT
224 < %token  KLINE_REASON
225 < %token  KLINE_WITH_REASON
226 < %token  KNOCK_DELAY
224 > %token  KLINE_MIN_CIDR
225 > %token  KLINE_MIN_CIDR6
226 > %token  KNOCK_CLIENT_COUNT
227 > %token  KNOCK_CLIENT_TIME
228   %token  KNOCK_DELAY_CHANNEL
229   %token  LEAF_MASK
214 %token  LINKS_DELAY
230   %token  LISTEN
231 < %token  T_LOG
231 > %token  MASK
232   %token  MAX_ACCEPT
233   %token  MAX_BANS
234 < %token  MAX_CHANS_PER_USER
234 > %token  MAX_CHANNELS
235   %token  MAX_GLOBAL
236   %token  MAX_IDENT
237 + %token  MAX_IDLE
238   %token  MAX_LOCAL
239   %token  MAX_NICK_CHANGES
240 + %token  MAX_NICK_LENGTH
241   %token  MAX_NICK_TIME
242   %token  MAX_NUMBER
243   %token  MAX_TARGETS
244 + %token  MAX_TOPIC_LENGTH
245   %token  MAX_WATCH
246 < %token  MESSAGE_LOCALE
246 > %token  MIN_IDLE
247   %token  MIN_NONWILDCARD
248   %token  MIN_NONWILDCARD_SIMPLE
249   %token  MODULE
250   %token  MODULES
251 + %token  MOTD
252   %token  NAME
253 + %token  NEED_IDENT
254   %token  NEED_PASSWORD
255   %token  NETWORK_DESC
256   %token  NETWORK_NAME
257   %token  NICK
238 %token  NICK_CHANGES
239 %token  NO_CREATE_ON_SPLIT
240 %token  NO_JOIN_ON_SPLIT
258   %token  NO_OPER_FLOOD
259   %token  NO_TILDE
260   %token  NUMBER
244 %token  NUMBER_PER_IDENT
261   %token  NUMBER_PER_CIDR
262   %token  NUMBER_PER_IP
247 %token  NUMBER_PER_IP_GLOBAL
248 %token  OPERATOR
249 %token  OPERS_BYPASS_CALLERID
263   %token  OPER_ONLY_UMODES
251 %token  OPER_PASS_RESV
252 %token  OPER_SPY_T
264   %token  OPER_UMODES
265 < %token  JOIN_FLOOD_COUNT
266 < %token  JOIN_FLOOD_TIME
265 > %token  OPERATOR
266 > %token  OPERS_BYPASS_CALLERID
267   %token  PACE_WAIT
268   %token  PACE_WAIT_SIMPLE
269   %token  PASSWORD
270   %token  PATH
271   %token  PING_COOKIE
272   %token  PING_TIME
262 %token  PING_WARNING
273   %token  PORT
274   %token  QSTRING
275 < %token  QUIET_ON_BAN
275 > %token  RANDOM_IDLE
276   %token  REASON
277   %token  REDIRPORT
278   %token  REDIRSERV
269 %token  REGEX_T
279   %token  REHASH
271 %token  TREJECT_HOLD_TIME
280   %token  REMOTE
281   %token  REMOTEBAN
274 %token  RESTRICT_CHANNELS
275 %token  RESTRICTED
276 %token  RSA_PRIVATE_KEY_FILE
277 %token  RSA_PUBLIC_KEY_FILE
278 %token  SSL_CERTIFICATE_FILE
279 %token  SSL_DH_PARAM_FILE
280 %token  T_SSL_CLIENT_METHOD
281 %token  T_SSL_SERVER_METHOD
282 %token  T_SSLV3
283 %token  T_TLSV1
282   %token  RESV
283   %token  RESV_EXEMPT
284 < %token  SECONDS MINUTES HOURS DAYS WEEKS
285 < %token  SENDQ
284 > %token  RSA_PRIVATE_KEY_FILE
285 > %token  SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS
286   %token  SEND_PASSWORD
287 + %token  SENDQ
288   %token  SERVERHIDE
289   %token  SERVERINFO
291 %token  IRCD_SID
292 %token  TKLINE_EXPIRE_NOTICES
293 %token  T_SHARED
294 %token  T_CLUSTER
295 %token  TYPE
290   %token  SHORT_MOTD
297 %token  SILENT
291   %token  SPOOF
292   %token  SPOOF_NOTICE
293 + %token  SQUIT
294 + %token  SSL_CERTIFICATE_FILE
295 + %token  SSL_CERTIFICATE_FINGERPRINT
296 + %token  SSL_CONNECTION_REQUIRED
297 + %token  SSL_DH_ELLIPTIC_CURVE
298 + %token  SSL_DH_PARAM_FILE
299 + %token  SSL_MESSAGE_DIGEST_ALGORITHM
300   %token  STATS_E_DISABLED
301   %token  STATS_I_OPER_ONLY
302   %token  STATS_K_OPER_ONLY
303 + %token  STATS_M_OPER_ONLY
304   %token  STATS_O_OPER_ONLY
305   %token  STATS_P_OPER_ONLY
306 < %token  TBOOL
306 < %token  TMASKED
307 < %token  T_REJECT
308 < %token  TS_MAX_DELTA
309 < %token  TS_WARN_DELTA
310 < %token  TWODOTS
306 > %token  STATS_U_OPER_ONLY
307   %token  T_ALL
308   %token  T_BOTS
313 %token  T_SOFTCALLERID
309   %token  T_CALLERID
310   %token  T_CCONN
311 < %token  T_CCONN_FULL
312 < %token  T_SSL_CIPHER_LIST
318 < %token  T_CLIENT_FLOOD
311 > %token  T_COMMAND
312 > %token  T_CLUSTER
313   %token  T_DEAF
314   %token  T_DEBUG
315   %token  T_DLINE
322 %token  T_DRONE
316   %token  T_EXTERNAL
317 + %token  T_FARCONNECT
318 + %token  T_FILE
319   %token  T_FULL
320 + %token  T_GLOBOPS
321   %token  T_INVISIBLE
322   %token  T_IPV4
323   %token  T_IPV6
324   %token  T_LOCOPS
325 < %token  T_MAX_CLIENTS
325 > %token  T_LOG
326   %token  T_NCHANGE
327 < %token  T_OPERWALL
327 > %token  T_NONONREG
328 > %token  T_OPME
329 > %token  T_PREPEND
330 > %token  T_PSEUDO
331 > %token  T_RECVQ
332   %token  T_REJ
333 + %token  T_RESTART
334   %token  T_SERVER
335 + %token  T_SERVICE
336   %token  T_SERVNOTICE
337 + %token  T_SET
338 + %token  T_SHARED
339 + %token  T_SIZE
340   %token  T_SKILL
341 + %token  T_SOFTCALLERID
342   %token  T_SPY
343   %token  T_SSL
344 + %token  T_SSL_CIPHER_LIST
345 + %token  T_TARGET
346   %token  T_UMODES
347   %token  T_UNAUTH
348   %token  T_UNDLINE
349   %token  T_UNLIMITED
350   %token  T_UNRESV
351   %token  T_UNXLINE
344 %token  T_GLOBOPS
352   %token  T_WALLOP
353 < %token  T_RESTART
354 < %token  T_SERVICE
355 < %token  T_SERVICES_NAME
353 > %token  T_WALLOPS
354 > %token  T_WEBIRC
355 > %token  TBOOL
356 > %token  THROTTLE_COUNT
357   %token  THROTTLE_TIME
358 < %token  TOPICBURST
359 < %token  TRUE_NO_OPER_FLOOD
360 < %token  TKLINE
361 < %token  TXLINE
362 < %token  TRESV
358 > %token  TKLINE_EXPIRE_NOTICES
359 > %token  TMASKED
360 > %token  TS_MAX_DELTA
361 > %token  TS_WARN_DELTA
362 > %token  TWODOTS
363 > %token  TYPE
364   %token  UNKLINE
356 %token  USER
357 %token  USE_EGD
358 %token  USE_EXCEPT
359 %token  USE_INVEX
360 %token  USE_KNOCK
365   %token  USE_LOGGING
366 < %token  USE_WHOIS_ACTUALLY
366 > %token  USER
367   %token  VHOST
368   %token  VHOST6
369 + %token  WARN_NO_CONNECT_BLOCK
370 + %token  WHOIS
371   %token  XLINE
372 < %token  WARN
367 < %token  WARN_NO_NLINE
368 < %token  T_SIZE
369 < %token  T_FILE
372 > %token  XLINE_EXEMPT
373  
374 < %type <string> QSTRING
375 < %type <number> NUMBER
376 < %type <number> timespec
377 < %type <number> timespec_
378 < %type <number> sizespec
379 < %type <number> sizespec_
374 > %type  <string> QSTRING
375 > %type  <number> NUMBER
376 > %type  <number> timespec
377 > %type  <number> timespec_
378 > %type  <number> sizespec
379 > %type  <number> sizespec_
380  
381   %%
382 < conf:  
382 > conf:
383          | conf conf_item
384          ;
385  
386   conf_item:        admin_entry
387                  | logging_entry
388                  | oper_entry
389 <                | channel_entry
390 <                | class_entry
389 >                | channel_entry
390 >                | class_entry
391                  | listen_entry
392                  | auth_entry
393                  | serverinfo_entry
394 <                | serverhide_entry
394 >                | serverhide_entry
395                  | resv_entry
396                  | service_entry
397                  | shared_entry
398 <                | cluster_entry
398 >                | cluster_entry
399                  | connect_entry
400                  | kill_entry
401                  | deny_entry
402 <                | exempt_entry
403 <                | general_entry
401 <                | gline_entry
402 >                | exempt_entry
403 >                | general_entry
404                  | gecos_entry
405                  | modules_entry
406 +                | motd_entry
407 +                | pseudo_entry
408                  | error ';'
409                  | error '}'
410          ;
411  
412  
413   timespec_: { $$ = 0; } | timespec;
414 < timespec:       NUMBER timespec_
415 <                {
416 <                        $$ = $1 + $2;
417 <                }
418 <                | NUMBER SECONDS timespec_
419 <                {
420 <                        $$ = $1 + $3;
421 <                }
422 <                | NUMBER MINUTES timespec_
423 <                {
424 <                        $$ = $1 * 60 + $3;
425 <                }
426 <                | NUMBER HOURS timespec_
427 <                {
428 <                        $$ = $1 * 60 * 60 + $3;
429 <                }
426 <                | NUMBER DAYS timespec_
427 <                {
428 <                        $$ = $1 * 60 * 60 * 24 + $3;
429 <                }
430 <                | NUMBER WEEKS timespec_
431 <                {
432 <                        $$ = $1 * 60 * 60 * 24 * 7 + $3;
433 <                }
434 <                ;
435 <
436 < sizespec_:      { $$ = 0; } | sizespec;
437 < sizespec:       NUMBER sizespec_ { $$ = $1 + $2; }
438 <                | NUMBER BYTES sizespec_ { $$ = $1 + $3; }
439 <                | NUMBER KBYTES sizespec_ { $$ = $1 * 1024 + $3; }
440 <                | NUMBER MBYTES sizespec_ { $$ = $1 * 1024 * 1024 + $3; }
441 <                ;
414 > timespec:  NUMBER timespec_         { $$ = $1 + $2; } |
415 >           NUMBER SECONDS timespec_ { $$ = $1 + $3; } |
416 >           NUMBER MINUTES timespec_ { $$ = $1 * 60 + $3; } |
417 >           NUMBER HOURS timespec_   { $$ = $1 * 60 * 60 + $3; } |
418 >           NUMBER DAYS timespec_    { $$ = $1 * 60 * 60 * 24 + $3; } |
419 >           NUMBER WEEKS timespec_   { $$ = $1 * 60 * 60 * 24 * 7 + $3; } |
420 >           NUMBER MONTHS timespec_  { $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3; } |
421 >           NUMBER YEARS timespec_   { $$ = $1 * 60 * 60 * 24 * 365 + $3; }
422 >           ;
423 >
424 > sizespec_:  { $$ = 0; } | sizespec;
425 > sizespec:   NUMBER sizespec_ { $$ = $1 + $2; } |
426 >            NUMBER BYTES sizespec_ { $$ = $1 + $3; } |
427 >            NUMBER KBYTES sizespec_ { $$ = $1 * 1024 + $3; } |
428 >            NUMBER MBYTES sizespec_ { $$ = $1 * 1024 * 1024 + $3; }
429 >            ;
430  
431  
432   /***************************************************************************
433 < *  section modules
433 > * modules {} section
434   ***************************************************************************/
435 < modules_entry: MODULES
448 <  '{' modules_items '}' ';';
435 > modules_entry: MODULES '{' modules_items '}' ';';
436  
437   modules_items:  modules_items modules_item | modules_item;
438   modules_item:   modules_module | modules_path | error ';' ;
# Line 463 | Line 450 | modules_path: PATH '=' QSTRING ';'
450   };
451  
452  
453 + /***************************************************************************
454 + * serverinfo {}  section
455 + ***************************************************************************/
456   serverinfo_entry: SERVERINFO '{' serverinfo_items '}' ';';
457  
458   serverinfo_items:       serverinfo_items serverinfo_item | serverinfo_item ;
459 < serverinfo_item:        serverinfo_name | serverinfo_vhost |
460 <                        serverinfo_hub | serverinfo_description |
461 <                        serverinfo_network_name | serverinfo_network_desc |
462 <                        serverinfo_max_clients | serverinfo_ssl_dh_param_file |
463 <                        serverinfo_rsa_private_key_file | serverinfo_vhost6 |
464 <                        serverinfo_sid | serverinfo_ssl_certificate_file |
465 <                        serverinfo_ssl_client_method | serverinfo_ssl_server_method |
459 > serverinfo_item:        serverinfo_name |
460 >                        serverinfo_vhost |
461 >                        serverinfo_hub |
462 >                        serverinfo_description |
463 >                        serverinfo_network_name |
464 >                        serverinfo_network_desc |
465 >                        serverinfo_default_max_clients |
466 >                        serverinfo_max_nick_length |
467 >                        serverinfo_max_topic_length |
468 >                        serverinfo_ssl_dh_param_file |
469 >                        serverinfo_ssl_dh_elliptic_curve |
470 >                        serverinfo_rsa_private_key_file |
471 >                        serverinfo_vhost6 |
472 >                        serverinfo_sid |
473 >                        serverinfo_ssl_certificate_file |
474                          serverinfo_ssl_cipher_list |
475 <                        error ';' ;
476 <
479 <
480 < serverinfo_ssl_client_method: T_SSL_CLIENT_METHOD '=' client_method_types ';' ;
481 < serverinfo_ssl_server_method: T_SSL_SERVER_METHOD '=' server_method_types ';' ;
482 <
483 < client_method_types: client_method_types ',' client_method_type_item | client_method_type_item;
484 < client_method_type_item: T_SSLV3
485 < {
486 < #ifdef HAVE_LIBCRYPTO
487 <  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
488 <    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv3);
489 < #endif
490 < } | T_TLSV1
491 < {
492 < #ifdef HAVE_LIBCRYPTO
493 <  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
494 <    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_TLSv1);
495 < #endif
496 < };
475 >                        serverinfo_ssl_message_digest_algorithm |
476 >                        error ';' ;
477  
498 server_method_types: server_method_types ',' server_method_type_item | server_method_type_item;
499 server_method_type_item: T_SSLV3
500 {
501 #ifdef HAVE_LIBCRYPTO
502  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
503    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
504 #endif
505 } | T_TLSV1
506 {
507 #ifdef HAVE_LIBCRYPTO
508  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
509    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
510 #endif
511 };
478  
479   serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
480   {
481   #ifdef HAVE_LIBCRYPTO
482 <  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
482 >  if (conf_parser_ctx.pass == 2)
483    {
484 <    if (!ServerInfo.rsa_private_key_file)
484 >    if (!ConfigServerInfo.rsa_private_key_file)
485      {
486 <      yyerror("No rsa_private_key_file specified, SSL disabled");
486 >      conf_error_report("No rsa_private_key_file specified, SSL disabled");
487        break;
488      }
489  
490 <    if (SSL_CTX_use_certificate_file(ServerInfo.server_ctx, yylval.string,
491 <                                     SSL_FILETYPE_PEM) <= 0 ||
526 <        SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
527 <                                     SSL_FILETYPE_PEM) <= 0)
490 >    if (SSL_CTX_use_certificate_chain_file(ConfigServerInfo.server_ctx, yylval.string) <= 0 ||
491 >        SSL_CTX_use_certificate_chain_file(ConfigServerInfo.client_ctx, yylval.string) <= 0)
492      {
493 <      yyerror(ERR_lib_error_string(ERR_get_error()));
493 >      report_crypto_errors();
494 >      conf_error_report("Could not open/read certificate file");
495        break;
496      }
497  
498 <    if (SSL_CTX_use_PrivateKey_file(ServerInfo.server_ctx, ServerInfo.rsa_private_key_file,
498 >    if (SSL_CTX_use_PrivateKey_file(ConfigServerInfo.server_ctx, ConfigServerInfo.rsa_private_key_file,
499                                      SSL_FILETYPE_PEM) <= 0 ||
500 <        SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
500 >        SSL_CTX_use_PrivateKey_file(ConfigServerInfo.client_ctx, ConfigServerInfo.rsa_private_key_file,
501                                      SSL_FILETYPE_PEM) <= 0)
502      {
503 <      yyerror(ERR_lib_error_string(ERR_get_error()));
503 >      report_crypto_errors();
504 >      conf_error_report("Could not read RSA private key");
505        break;
506      }
507  
508 <    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
509 <        !SSL_CTX_check_private_key(ServerInfo.client_ctx))
508 >    if (!SSL_CTX_check_private_key(ConfigServerInfo.server_ctx) ||
509 >        !SSL_CTX_check_private_key(ConfigServerInfo.client_ctx))
510      {
511 <      yyerror(ERR_lib_error_string(ERR_get_error()));
511 >      report_crypto_errors();
512 >      conf_error_report("Could not read RSA private key");
513        break;
514      }
515    }
# Line 552 | Line 519 | serverinfo_ssl_certificate_file: SSL_CER
519   serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
520   {
521   #ifdef HAVE_LIBCRYPTO
522 <  if (conf_parser_ctx.pass == 1)
556 <  {
557 <    BIO *file;
522 >  BIO *file = NULL;
523  
524 <    if (ServerInfo.rsa_private_key)
525 <    {
561 <      RSA_free(ServerInfo.rsa_private_key);
562 <      ServerInfo.rsa_private_key = NULL;
563 <    }
524 >  if (conf_parser_ctx.pass != 1)
525 >    break;
526  
527 <    if (ServerInfo.rsa_private_key_file)
528 <    {
529 <      MyFree(ServerInfo.rsa_private_key_file);
530 <      ServerInfo.rsa_private_key_file = NULL;
531 <    }
527 >  if (ConfigServerInfo.rsa_private_key)
528 >  {
529 >    RSA_free(ConfigServerInfo.rsa_private_key);
530 >    ConfigServerInfo.rsa_private_key = NULL;
531 >  }
532  
533 <    DupString(ServerInfo.rsa_private_key_file, yylval.string);
533 >  if (ConfigServerInfo.rsa_private_key_file)
534 >  {
535 >    MyFree(ConfigServerInfo.rsa_private_key_file);
536 >    ConfigServerInfo.rsa_private_key_file = NULL;
537 >  }
538  
539 <    if ((file = BIO_new_file(yylval.string, "r")) == NULL)
574 <    {
575 <      yyerror("File open failed, ignoring");
576 <      break;
577 <    }
539 >  ConfigServerInfo.rsa_private_key_file = xstrdup(yylval.string);
540  
541 <    ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
541 >  if ((file = BIO_new_file(yylval.string, "r")) == NULL)
542 >  {
543 >    conf_error_report("File open failed, ignoring");
544 >    break;
545 >  }
546  
547 <    BIO_set_close(file, BIO_CLOSE);
582 <    BIO_free(file);
547 >  ConfigServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
548  
549 <    if (ServerInfo.rsa_private_key == NULL)
550 <    {
586 <      yyerror("Couldn't extract key, ignoring");
587 <      break;
588 <    }
549 >  BIO_set_close(file, BIO_CLOSE);
550 >  BIO_free(file);
551  
552 <    if (!RSA_check_key(ServerInfo.rsa_private_key))
553 <    {
554 <      RSA_free(ServerInfo.rsa_private_key);
555 <      ServerInfo.rsa_private_key = NULL;
552 >  if (ConfigServerInfo.rsa_private_key == NULL)
553 >  {
554 >    conf_error_report("Couldn't extract key, ignoring");
555 >    break;
556 >  }
557  
558 <      yyerror("Invalid key, ignoring");
559 <      break;
560 <    }
558 >  if (!RSA_check_key(ConfigServerInfo.rsa_private_key))
559 >  {
560 >    RSA_free(ConfigServerInfo.rsa_private_key);
561 >    ConfigServerInfo.rsa_private_key = NULL;
562  
563 <    /* require 2048 bit (256 byte) key */
564 <    if (RSA_size(ServerInfo.rsa_private_key) != 256)
565 <    {
602 <      RSA_free(ServerInfo.rsa_private_key);
603 <      ServerInfo.rsa_private_key = NULL;
563 >    conf_error_report("Invalid key, ignoring");
564 >    break;
565 >  }
566  
567 <      yyerror("Not a 2048 bit key, ignoring");
568 <    }
567 >  if (RSA_size(ConfigServerInfo.rsa_private_key) < 128)
568 >  {
569 >    RSA_free(ConfigServerInfo.rsa_private_key);
570 >    ConfigServerInfo.rsa_private_key = NULL;
571 >
572 >    conf_error_report("Ignoring serverinfo::rsa_private_key_file -- need at least a 1024 bit key size");
573    }
574   #endif
575   };
576  
577   serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
578   {
613 /* TBD - XXX: error reporting */
579   #ifdef HAVE_LIBCRYPTO
580 <  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
580 >  if (conf_parser_ctx.pass == 2)
581    {
582      BIO *file = BIO_new_file(yylval.string, "r");
583  
# Line 625 | Line 590 | serverinfo_ssl_dh_param_file: SSL_DH_PAR
590        if (dh)
591        {
592          if (DH_size(dh) < 128)
593 <          ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
593 >          conf_error_report("Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
594          else
595 <          SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
595 >          SSL_CTX_set_tmp_dh(ConfigServerInfo.server_ctx, dh);
596  
597          DH_free(dh);
598        }
599      }
600 +    else
601 +      conf_error_report("Ignoring serverinfo::ssl_dh_param_file -- could not open/read Diffie-Hellman parameter file");
602    }
603   #endif
604   };
# Line 639 | Line 606 | serverinfo_ssl_dh_param_file: SSL_DH_PAR
606   serverinfo_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
607   {
608   #ifdef HAVE_LIBCRYPTO
609 <  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
610 <    SSL_CTX_set_cipher_list(ServerInfo.server_ctx, yylval.string);
609 >  if (conf_parser_ctx.pass == 2)
610 >    SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, yylval.string);
611 > #endif
612 > };
613 >
614 > serverinfo_ssl_message_digest_algorithm: SSL_MESSAGE_DIGEST_ALGORITHM '=' QSTRING ';'
615 > {
616 > #ifdef HAVE_LIBCRYPTO
617 >  if (conf_parser_ctx.pass == 2)
618 >  {
619 >    if ((ConfigServerInfo.message_digest_algorithm = EVP_get_digestbyname(yylval.string)) == NULL)
620 >    {
621 >      ConfigServerInfo.message_digest_algorithm = EVP_sha256();
622 >      conf_error_report("Ignoring serverinfo::ssl_message_digest_algorithm -- unknown message digest algorithm");
623 >    }
624 >  }
625 > #endif
626 > }
627 >
628 > serverinfo_ssl_dh_elliptic_curve: SSL_DH_ELLIPTIC_CURVE '=' QSTRING ';'
629 > {
630 > #ifdef HAVE_LIBCRYPTO
631 > #if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
632 >  int nid = 0;
633 >  EC_KEY *key = NULL;
634 >
635 >  if (conf_parser_ctx.pass == 2)
636 >  {
637 >    if ((nid = OBJ_sn2nid(yylval.string)) == 0)
638 >    {
639 >        conf_error_report("Ignoring serverinfo::ssl_dh_elliptic_curve -- unknown curve name");
640 >        break;
641 >    }
642 >
643 >    if ((key = EC_KEY_new_by_curve_name(nid)) == NULL)
644 >    {
645 >      conf_error_report("Ignoring serverinfo::ssl_dh_elliptic_curve -- could not create curve");
646 >      break;
647 >    }
648 >
649 >    SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
650 >    EC_KEY_free(key);
651 >  }
652 > #endif
653   #endif
654   };
655  
656 < serverinfo_name: NAME '=' QSTRING ';'
656 > serverinfo_name: NAME '=' QSTRING ';'
657   {
658 <  /* this isn't rehashable */
659 <  if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
658 >  /* This isn't rehashable */
659 >  if (conf_parser_ctx.pass == 2 && !ConfigServerInfo.name)
660    {
661      if (valid_servname(yylval.string))
662 <      DupString(ServerInfo.name, yylval.string);
662 >      ConfigServerInfo.name = xstrdup(yylval.string);
663      else
664      {
665 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::name -- invalid name. Aborting.");
666 <      exit(0);
665 >      conf_error_report("Ignoring serverinfo::name -- invalid name. Aborting.");
666 >      exit(EXIT_FAILURE);
667      }
668    }
669   };
670  
671 < serverinfo_sid: IRCD_SID '=' QSTRING ';'
671 > serverinfo_sid: IRCD_SID '=' QSTRING ';'
672   {
673 <  /* this isn't rehashable */
674 <  if (conf_parser_ctx.pass == 2 && !ServerInfo.sid)
673 >  /* This isn't rehashable */
674 >  if (conf_parser_ctx.pass == 2 && !ConfigServerInfo.sid)
675    {
676      if (valid_sid(yylval.string))
677 <      DupString(ServerInfo.sid, yylval.string);
677 >      ConfigServerInfo.sid = xstrdup(yylval.string);
678      else
679      {
680 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::sid -- invalid SID. Aborting.");
681 <      exit(0);
680 >      conf_error_report("Ignoring serverinfo::sid -- invalid SID. Aborting.");
681 >      exit(EXIT_FAILURE);
682      }
683    }
684   };
# Line 678 | Line 687 | serverinfo_description: DESCRIPTION '='
687   {
688    if (conf_parser_ctx.pass == 2)
689    {
690 <    MyFree(ServerInfo.description);
691 <    DupString(ServerInfo.description,yylval.string);
690 >    MyFree(ConfigServerInfo.description);
691 >    ConfigServerInfo.description = xstrdup(yylval.string);
692 >    strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info));
693    }
694   };
695  
# Line 689 | Line 699 | serverinfo_network_name: NETWORK_NAME '=
699    {
700      char *p;
701  
702 <    if ((p = strchr(yylval.string, ' ')) != NULL)
703 <      p = '\0';
702 >    if ((p = strchr(yylval.string, ' ')))
703 >      *p = '\0';
704  
705 <    MyFree(ServerInfo.network_name);
706 <    DupString(ServerInfo.network_name, yylval.string);
705 >    MyFree(ConfigServerInfo.network_name);
706 >    ConfigServerInfo.network_name = xstrdup(yylval.string);
707    }
708   };
709  
710   serverinfo_network_desc: NETWORK_DESC '=' QSTRING ';'
711   {
712 <  if (conf_parser_ctx.pass == 2)
713 <  {
714 <    MyFree(ServerInfo.network_desc);
715 <    DupString(ServerInfo.network_desc, yylval.string);
716 <  }
712 >  if (conf_parser_ctx.pass != 2)
713 >    break;
714 >
715 >  MyFree(ConfigServerInfo.network_desc);
716 >  ConfigServerInfo.network_desc = xstrdup(yylval.string);
717   };
718  
719   serverinfo_vhost: VHOST '=' QSTRING ';'
# Line 722 | Line 732 | serverinfo_vhost: VHOST '=' QSTRING ';'
732        ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
733      else
734      {
735 <      assert(res != NULL);
735 >      assert(res);
736  
737 <      memcpy(&ServerInfo.ip, res->ai_addr, res->ai_addrlen);
738 <      ServerInfo.ip.ss.ss_family = res->ai_family;
739 <      ServerInfo.ip.ss_len = res->ai_addrlen;
737 >      memcpy(&ConfigServerInfo.ip, res->ai_addr, res->ai_addrlen);
738 >      ConfigServerInfo.ip.ss.ss_family = res->ai_family;
739 >      ConfigServerInfo.ip.ss_len = res->ai_addrlen;
740        freeaddrinfo(res);
741  
742 <      ServerInfo.specific_ipv4_vhost = 1;
742 >      ConfigServerInfo.specific_ipv4_vhost = 1;
743      }
744    }
745   };
746  
747   serverinfo_vhost6: VHOST6 '=' QSTRING ';'
748   {
739 #ifdef IPV6
749    if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
750    {
751      struct addrinfo hints, *res;
# Line 751 | Line 760 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
760        ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost6(%s)", yylval.string);
761      else
762      {
763 <      assert(res != NULL);
763 >      assert(res);
764  
765 <      memcpy(&ServerInfo.ip6, res->ai_addr, res->ai_addrlen);
766 <      ServerInfo.ip6.ss.ss_family = res->ai_family;
767 <      ServerInfo.ip6.ss_len = res->ai_addrlen;
765 >      memcpy(&ConfigServerInfo.ip6, res->ai_addr, res->ai_addrlen);
766 >      ConfigServerInfo.ip6.ss.ss_family = res->ai_family;
767 >      ConfigServerInfo.ip6.ss_len = res->ai_addrlen;
768        freeaddrinfo(res);
769  
770 <      ServerInfo.specific_ipv6_vhost = 1;
770 >      ConfigServerInfo.specific_ipv6_vhost = 1;
771      }
772    }
764 #endif
773   };
774  
775 < serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
775 > serverinfo_default_max_clients: DEFAULT_MAX_CLIENTS '=' NUMBER ';'
776   {
777 <  if (conf_parser_ctx.pass == 2)
777 >  if (conf_parser_ctx.pass != 2)
778 >    break;
779 >
780 >  if ($3 < MAXCLIENTS_MIN)
781    {
782 <    recalc_fdlimit(NULL);
782 >    char buf[IRCD_BUFSIZE] = "";
783  
784 <    if ($3 < MAXCLIENTS_MIN)
785 <    {
786 <      char buf[IRCD_BUFSIZE];
787 <      ircsprintf(buf, "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
788 <      yyerror(buf);
789 <    }
790 <    else if ($3 > MAXCLIENTS_MAX)
791 <    {
792 <      char buf[IRCD_BUFSIZE];
793 <      ircsprintf(buf, "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
794 <      yyerror(buf);
795 <    }
796 <    else
797 <      ServerInfo.max_clients = $3;
784 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
785 >    conf_error_report(buf);
786 >    ConfigServerInfo.default_max_clients = MAXCLIENTS_MIN;
787 >  }
788 >  else if ($3 > MAXCLIENTS_MAX)
789 >  {
790 >    char buf[IRCD_BUFSIZE] = "";
791 >
792 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
793 >    conf_error_report(buf);
794 >    ConfigServerInfo.default_max_clients = MAXCLIENTS_MAX;
795 >  }
796 >  else
797 >    ConfigServerInfo.default_max_clients = $3;
798 > };
799 >
800 > serverinfo_max_nick_length: MAX_NICK_LENGTH '=' NUMBER ';'
801 > {
802 >  if (conf_parser_ctx.pass != 2)
803 >    break;
804 >
805 >  if ($3 < 9)
806 >  {
807 >    conf_error_report("max_nick_length too low, setting to 9");
808 >    ConfigServerInfo.max_nick_length = 9;
809    }
810 +  else if ($3 > NICKLEN)
811 +  {
812 +    char buf[IRCD_BUFSIZE] = "";
813 +
814 +    snprintf(buf, sizeof(buf), "max_nick_length too high, setting to %d", NICKLEN);
815 +    conf_error_report(buf);
816 +    ConfigServerInfo.max_nick_length = NICKLEN;
817 +  }
818 +  else
819 +    ConfigServerInfo.max_nick_length = $3;
820   };
821  
822 < serverinfo_hub: HUB '=' TBOOL ';'
822 > serverinfo_max_topic_length: MAX_TOPIC_LENGTH '=' NUMBER ';'
823 > {
824 >  if (conf_parser_ctx.pass != 2)
825 >    break;
826 >
827 >  if ($3 < 80)
828 >  {
829 >    conf_error_report("max_topic_length too low, setting to 80");
830 >    ConfigServerInfo.max_topic_length = 80;
831 >  }
832 >  else if ($3 > TOPICLEN)
833 >  {
834 >    char buf[IRCD_BUFSIZE] = "";
835 >
836 >    snprintf(buf, sizeof(buf), "max_topic_length too high, setting to %d", TOPICLEN);
837 >    conf_error_report(buf);
838 >    ConfigServerInfo.max_topic_length = TOPICLEN;
839 >  }
840 >  else
841 >    ConfigServerInfo.max_topic_length = $3;
842 > };
843 >
844 > serverinfo_hub: HUB '=' TBOOL ';'
845   {
846    if (conf_parser_ctx.pass == 2)
847 <    ServerInfo.hub = yylval.number;
847 >    ConfigServerInfo.hub = yylval.number;
848   };
849  
850 +
851   /***************************************************************************
852 < * admin section
852 > * admin {} section
853   ***************************************************************************/
854   admin_entry: ADMIN  '{' admin_items '}' ';' ;
855  
856   admin_items: admin_items admin_item | admin_item;
857 < admin_item:  admin_name | admin_description |
858 <             admin_email | error ';' ;
857 > admin_item:  admin_name |
858 >             admin_description |
859 >             admin_email |
860 >             error ';' ;
861  
862 < admin_name: NAME '=' QSTRING ';'
862 > admin_name: NAME '=' QSTRING ';'
863   {
864 <  if (conf_parser_ctx.pass == 2)
865 <  {
866 <    MyFree(AdminInfo.name);
867 <    DupString(AdminInfo.name, yylval.string);
868 <  }
864 >  if (conf_parser_ctx.pass != 2)
865 >    break;
866 >
867 >  MyFree(ConfigAdminInfo.name);
868 >  ConfigAdminInfo.name = xstrdup(yylval.string);
869   };
870  
871   admin_email: EMAIL '=' QSTRING ';'
872   {
873 <  if (conf_parser_ctx.pass == 2)
874 <  {
875 <    MyFree(AdminInfo.email);
876 <    DupString(AdminInfo.email, yylval.string);
877 <  }
873 >  if (conf_parser_ctx.pass != 2)
874 >    break;
875 >
876 >  MyFree(ConfigAdminInfo.email);
877 >  ConfigAdminInfo.email = xstrdup(yylval.string);
878   };
879  
880   admin_description: DESCRIPTION '=' QSTRING ';'
881   {
882 +  if (conf_parser_ctx.pass != 2)
883 +    break;
884 +
885 +  MyFree(ConfigAdminInfo.description);
886 +  ConfigAdminInfo.description = xstrdup(yylval.string);
887 + };
888 +
889 +
890 + /***************************************************************************
891 + * motd {} section
892 + ***************************************************************************/
893 + motd_entry: MOTD
894 + {
895 +  if (conf_parser_ctx.pass == 2)
896 +    reset_block_state();
897 + } '{' motd_items '}' ';'
898 + {
899 +  dlink_node *node = NULL;
900 +
901 +  if (conf_parser_ctx.pass != 2)
902 +    break;
903 +
904 +  if (!block_state.file.buf[0])
905 +    break;
906 +
907 +  DLINK_FOREACH(node, block_state.mask.list.head)
908 +    motd_add(node->data, block_state.file.buf);
909 + };
910 +
911 + motd_items: motd_items motd_item | motd_item;
912 + motd_item:  motd_mask | motd_file | error ';' ;
913 +
914 + motd_mask: MASK '=' QSTRING ';'
915 + {
916 +  if (conf_parser_ctx.pass == 2)
917 +    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
918 + };
919 +
920 + motd_file: T_FILE '=' QSTRING ';'
921 + {
922 +  if (conf_parser_ctx.pass == 2)
923 +    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
924 + };
925 +
926 +
927 + /***************************************************************************
928 + * pseudo {} section
929 + ***************************************************************************/
930 + pseudo_entry: T_PSEUDO
931 + {
932 +  if (conf_parser_ctx.pass == 2)
933 +    reset_block_state();
934 + } '{' pseudo_items '}' ';'
935 + {
936 +  if (conf_parser_ctx.pass != 2)
937 +    break;
938 +
939 +  if (!block_state.command.buf[0] ||
940 +      !block_state.name.buf[0] ||
941 +      !block_state.nick.buf[0] ||
942 +      !block_state.host.buf[0])
943 +    break;
944 +
945 +  pseudo_register(block_state.name.buf, block_state.nick.buf, block_state.host.buf,
946 +                  block_state.prepend.buf, block_state.command.buf);
947 + };
948 +
949 + pseudo_items: pseudo_items pseudo_item | pseudo_item;
950 + pseudo_item:  pseudo_command | pseudo_prepend | pseudo_name | pseudo_target | error ';' ;
951 +
952 + pseudo_command: T_COMMAND '=' QSTRING ';'
953 + {
954 +  if (conf_parser_ctx.pass == 2)
955 +    strlcpy(block_state.command.buf, yylval.string, sizeof(block_state.command.buf));
956 + };
957 +
958 + pseudo_name: NAME '=' QSTRING ';'
959 + {
960 +  if (conf_parser_ctx.pass == 2)
961 +    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
962 + };
963 +
964 + pseudo_prepend: T_PREPEND '=' QSTRING ';'
965 + {
966 +  if (conf_parser_ctx.pass == 2)
967 +    strlcpy(block_state.prepend.buf, yylval.string, sizeof(block_state.prepend.buf));
968 + };
969 +
970 + pseudo_target: T_TARGET '=' QSTRING ';'
971 + {
972    if (conf_parser_ctx.pass == 2)
973    {
974 <    MyFree(AdminInfo.description);
975 <    DupString(AdminInfo.description, yylval.string);
974 >    struct split_nuh_item nuh;
975 >
976 >    nuh.nuhmask  = yylval.string;
977 >    nuh.nickptr  = NULL;
978 >    nuh.userptr  = block_state.nick.buf;
979 >    nuh.hostptr  = block_state.host.buf;
980 >    nuh.nicksize = 0;
981 >    nuh.usersize = sizeof(block_state.nick.buf);
982 >    nuh.hostsize = sizeof(block_state.host.buf);
983 >
984 >    split_nuh(&nuh);
985    }
986   };
987  
988 +
989   /***************************************************************************
990 < *  section logging
990 > * log {} section
991   ***************************************************************************/
992   logging_entry:          T_LOG  '{' logging_items '}' ';' ;
993   logging_items:          logging_items logging_item | logging_item ;
994  
995 < logging_item:           logging_use_logging | logging_file_entry |
996 <                        error ';' ;
995 > logging_item:           logging_use_logging | logging_file_entry |
996 >                        error ';' ;
997  
998   logging_use_logging: USE_LOGGING '=' TBOOL ';'
999   {
1000    if (conf_parser_ctx.pass == 2)
1001 <    ConfigLoggingEntry.use_logging = yylval.number;
1001 >    ConfigLog.use_logging = yylval.number;
1002   };
1003  
1004   logging_file_entry:
1005   {
1006 <  lfile[0] = '\0';
1007 <  ltype = 0;
851 <  lsize = 0;
1006 >  if (conf_parser_ctx.pass == 2)
1007 >    reset_block_state();
1008   } T_FILE  '{' logging_file_items '}' ';'
1009   {
1010 <  if (conf_parser_ctx.pass == 2 && ltype > 0)
1011 <    log_add_file(ltype, lsize, lfile);
1010 >  if (conf_parser_ctx.pass != 2)
1011 >    break;
1012 >
1013 >  if (block_state.type.value && block_state.file.buf[0])
1014 >    log_set_file(block_state.type.value, block_state.size.value,
1015 >                 block_state.file.buf);
1016   };
1017  
1018   logging_file_items: logging_file_items logging_file_item |
# Line 863 | Line 1023 | logging_file_item:  logging_file_name |
1023  
1024   logging_file_name: NAME '=' QSTRING ';'
1025   {
1026 <  strlcpy(lfile, yylval.string, sizeof(lfile));
1026 >  if (conf_parser_ctx.pass != 2)
1027 >    break;
1028 >
1029 >  strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
1030   }
1031  
1032   logging_file_size: T_SIZE '=' sizespec ';'
1033   {
1034 <  lsize = $3;
1034 >  block_state.size.value = $3;
1035   } | T_SIZE '=' T_UNLIMITED ';'
1036   {
1037 <  lsize = 0;
1037 >  block_state.size.value = 0;
1038   };
1039  
1040   logging_file_type: TYPE
1041   {
1042    if (conf_parser_ctx.pass == 2)
1043 <    ltype = 0;
1043 >    block_state.type.value = 0;
1044   } '='  logging_file_type_items ';' ;
1045  
1046   logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
1047   logging_file_type_item:  USER
1048   {
1049    if (conf_parser_ctx.pass == 2)
1050 <    ltype = LOG_TYPE_USER;
1050 >    block_state.type.value = LOG_TYPE_USER;
1051   } | OPERATOR
1052   {
1053    if (conf_parser_ctx.pass == 2)
1054 <    ltype = LOG_TYPE_OPER;
1055 < } | GLINE
1054 >    block_state.type.value = LOG_TYPE_OPER;
1055 > } | XLINE
1056   {
1057    if (conf_parser_ctx.pass == 2)
1058 <    ltype = LOG_TYPE_GLINE;
1058 >    block_state.type.value = LOG_TYPE_XLINE;
1059 > } | RESV
1060 > {
1061 >  if (conf_parser_ctx.pass == 2)
1062 >    block_state.type.value = LOG_TYPE_RESV;
1063   } | T_DLINE
1064   {
1065    if (conf_parser_ctx.pass == 2)
1066 <    ltype = LOG_TYPE_DLINE;
1066 >    block_state.type.value = LOG_TYPE_DLINE;
1067   } | KLINE
1068   {
1069    if (conf_parser_ctx.pass == 2)
1070 <    ltype = LOG_TYPE_KLINE;
1070 >    block_state.type.value = LOG_TYPE_KLINE;
1071   } | KILL
1072   {
1073    if (conf_parser_ctx.pass == 2)
1074 <    ltype = LOG_TYPE_KILL;
1074 >    block_state.type.value = LOG_TYPE_KILL;
1075   } | T_DEBUG
1076   {
1077    if (conf_parser_ctx.pass == 2)
1078 <    ltype = LOG_TYPE_DEBUG;
1078 >    block_state.type.value = LOG_TYPE_DEBUG;
1079   };
1080  
1081  
1082   /***************************************************************************
1083 < * section oper
1083 > * operator {} section
1084   ***************************************************************************/
1085 < oper_entry: OPERATOR
1085 > oper_entry: OPERATOR
1086   {
1087 <  if (conf_parser_ctx.pass == 2)
1088 <  {
1089 <    yy_conf = make_conf_item(OPER_TYPE);
1090 <    yy_aconf = map_to_conf(yy_conf);
1091 <    SetConfEncrypted(yy_aconf); /* Yes, the default is encrypted */
925 <  }
926 <  else
927 <  {
928 <    MyFree(class_name);
929 <    class_name = NULL;
930 <  }
1087 >  if (conf_parser_ctx.pass != 2)
1088 >    break;
1089 >
1090 >  reset_block_state();
1091 >  block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1092   } '{' oper_items '}' ';'
1093   {
1094 <  if (conf_parser_ctx.pass == 2)
934 <  {
935 <    struct CollectItem *yy_tmp;
936 <    dlink_node *ptr;
937 <    dlink_node *next_ptr;
1094 >  dlink_node *node = NULL;
1095  
1096 <    conf_add_class_to_conf(yy_conf, class_name);
1096 >  if (conf_parser_ctx.pass != 2)
1097 >    break;
1098  
1099 <    /* Now, make sure there is a copy of the "base" given oper
1100 <     * block in each of the collected copies
943 <     */
1099 >  if (!block_state.name.buf[0])
1100 >    break;
1101  
1102 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1103 <    {
947 <      struct AccessItem *new_aconf;
948 <      struct ConfItem *new_conf;
949 <      yy_tmp = ptr->data;
950 <
951 <      new_conf = make_conf_item(OPER_TYPE);
952 <      new_aconf = (struct AccessItem *)map_to_conf(new_conf);
953 <
954 <      new_aconf->flags = yy_aconf->flags;
955 <
956 <      if (yy_conf->name != NULL)
957 <        DupString(new_conf->name, yy_conf->name);
958 <      if (yy_tmp->user != NULL)
959 <        DupString(new_aconf->user, yy_tmp->user);
960 <      else
961 <        DupString(new_aconf->user, "*");
962 <      if (yy_tmp->host != NULL)
963 <        DupString(new_aconf->host, yy_tmp->host);
964 <      else
965 <        DupString(new_aconf->host, "*");
966 <
967 <      new_aconf->type = parse_netmask(new_aconf->host, &new_aconf->ipnum,
968 <                                     &new_aconf->bits);
969 <
970 <      conf_add_class_to_conf(new_conf, class_name);
971 <      if (yy_aconf->passwd != NULL)
972 <        DupString(new_aconf->passwd, yy_aconf->passwd);
973 <
974 <      new_aconf->port = yy_aconf->port;
975 < #ifdef HAVE_LIBCRYPTO
976 <      if (yy_aconf->rsa_public_key_file != NULL)
977 <      {
978 <        BIO *file;
979 <
980 <        DupString(new_aconf->rsa_public_key_file,
981 <                  yy_aconf->rsa_public_key_file);
982 <
983 <        file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
984 <        new_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file,
985 <                                                           NULL, 0, NULL);
986 <        BIO_set_close(file, BIO_CLOSE);
987 <        BIO_free(file);
988 <      }
989 < #endif
1102 >  if (!block_state.rpass.buf[0])
1103 >    break;
1104  
1105 < #ifdef HAVE_LIBCRYPTO
1106 <      if (yy_tmp->name && (yy_tmp->passwd || yy_aconf->rsa_public_key)
1107 <          && yy_tmp->host)
1108 < #else
995 <      if (yy_tmp->name && yy_tmp->passwd && yy_tmp->host)
996 < #endif
997 <      {
998 <        conf_add_class_to_conf(new_conf, class_name);
999 <        if (yy_tmp->name != NULL)
1000 <          DupString(new_conf->name, yy_tmp->name);
1001 <      }
1002 <
1003 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1004 <      free_collect_item(yy_tmp);
1005 <    }
1105 >  DLINK_FOREACH(node, block_state.mask.list.head)
1106 >  {
1107 >    struct MaskItem *conf = NULL;
1108 >    struct split_nuh_item nuh;
1109  
1110 <    yy_conf = NULL;
1111 <    yy_aconf = NULL;
1110 >    nuh.nuhmask  = node->data;
1111 >    nuh.nickptr  = NULL;
1112 >    nuh.userptr  = block_state.user.buf;
1113 >    nuh.hostptr  = block_state.host.buf;
1114 >    nuh.nicksize = 0;
1115 >    nuh.usersize = sizeof(block_state.user.buf);
1116 >    nuh.hostsize = sizeof(block_state.host.buf);
1117 >    split_nuh(&nuh);
1118  
1119 +    conf         = conf_make(CONF_OPER);
1120 +    conf->name   = xstrdup(block_state.name.buf);
1121 +    conf->user   = xstrdup(block_state.user.buf);
1122 +    conf->host   = xstrdup(block_state.host.buf);
1123 +
1124 +    if (block_state.cert.buf[0])
1125 +      conf->certfp = xstrdup(block_state.cert.buf);
1126 +
1127 +    if (block_state.rpass.buf[0])
1128 +      conf->passwd = xstrdup(block_state.rpass.buf);
1129 +
1130 +    if (block_state.whois.buf[0])
1131 +      conf->whois = xstrdup(block_state.whois.buf);
1132 +
1133 +    conf->flags = block_state.flags.value;
1134 +    conf->modes = block_state.modes.value;
1135 +    conf->port  = block_state.port.value;
1136 +    conf->htype = parse_netmask(conf->host, &conf->addr, &conf->bits);
1137  
1138 <    MyFree(class_name);
1012 <    class_name = NULL;
1138 >    conf_add_class_to_conf(conf, block_state.class.buf);
1139    }
1140 < };
1140 > };
1141  
1142   oper_items:     oper_items oper_item | oper_item;
1143 < oper_item:      oper_name | oper_user | oper_password |
1144 <                oper_umodes | oper_class | oper_encrypted |
1145 <                oper_rsa_public_key_file | oper_flags | error ';' ;
1143 > oper_item:      oper_name |
1144 >                oper_user |
1145 >                oper_password |
1146 >                oper_whois |
1147 >                oper_umodes |
1148 >                oper_class |
1149 >                oper_encrypted |
1150 >                oper_ssl_certificate_fingerprint |
1151 >                oper_ssl_connection_required |
1152 >                oper_flags |
1153 >                error ';' ;
1154  
1155   oper_name: NAME '=' QSTRING ';'
1156   {
1157    if (conf_parser_ctx.pass == 2)
1158 <  {
1025 <    if (strlen(yylval.string) > OPERNICKLEN)
1026 <      yylval.string[OPERNICKLEN] = '\0';
1027 <
1028 <    MyFree(yy_conf->name);
1029 <    DupString(yy_conf->name, yylval.string);
1030 <  }
1158 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1159   };
1160  
1161   oper_user: USER '=' QSTRING ';'
1162   {
1163    if (conf_parser_ctx.pass == 2)
1164 <  {
1037 <    struct split_nuh_item nuh;
1038 <
1039 <    nuh.nuhmask  = yylval.string;
1040 <    nuh.nickptr  = NULL;
1041 <    nuh.userptr  = userbuf;
1042 <    nuh.hostptr  = hostbuf;
1043 <
1044 <    nuh.nicksize = 0;
1045 <    nuh.usersize = sizeof(userbuf);
1046 <    nuh.hostsize = sizeof(hostbuf);
1047 <
1048 <    split_nuh(&nuh);
1049 <
1050 <    if (yy_aconf->user == NULL)
1051 <    {
1052 <      DupString(yy_aconf->user, userbuf);
1053 <      DupString(yy_aconf->host, hostbuf);
1054 <
1055 <      yy_aconf->type = parse_netmask(yy_aconf->host, &yy_aconf->ipnum,
1056 <                                    &yy_aconf->bits);
1057 <    }
1058 <    else
1059 <    {
1060 <      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
1061 <
1062 <      DupString(yy_tmp->user, userbuf);
1063 <      DupString(yy_tmp->host, hostbuf);
1064 <
1065 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1066 <    }
1067 <  }
1164 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1165   };
1166  
1167   oper_password: PASSWORD '=' QSTRING ';'
1168   {
1169    if (conf_parser_ctx.pass == 2)
1170 <  {
1074 <    if (yy_aconf->passwd != NULL)
1075 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1076 <
1077 <    MyFree(yy_aconf->passwd);
1078 <    DupString(yy_aconf->passwd, yylval.string);
1079 <  }
1170 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1171   };
1172  
1173 < oper_encrypted: ENCRYPTED '=' TBOOL ';'
1173 > oper_whois: WHOIS '=' QSTRING ';'
1174   {
1175    if (conf_parser_ctx.pass == 2)
1176 <  {
1086 <    if (yylval.number)
1087 <      SetConfEncrypted(yy_aconf);
1088 <    else
1089 <      ClearConfEncrypted(yy_aconf);
1090 <  }
1176 >    strlcpy(block_state.whois.buf, yylval.string, sizeof(block_state.whois.buf));
1177   };
1178  
1179 < oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1179 > oper_encrypted: ENCRYPTED '=' TBOOL ';'
1180   {
1181 < #ifdef HAVE_LIBCRYPTO
1182 <  if (conf_parser_ctx.pass == 2)
1097 <  {
1098 <    BIO *file;
1099 <
1100 <    if (yy_aconf->rsa_public_key != NULL)
1101 <    {
1102 <      RSA_free(yy_aconf->rsa_public_key);
1103 <      yy_aconf->rsa_public_key = NULL;
1104 <    }
1181 >  if (conf_parser_ctx.pass != 2)
1182 >    break;
1183  
1184 <    if (yy_aconf->rsa_public_key_file != NULL)
1185 <    {
1186 <      MyFree(yy_aconf->rsa_public_key_file);
1187 <      yy_aconf->rsa_public_key_file = NULL;
1188 <    }
1111 <
1112 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
1113 <    file = BIO_new_file(yylval.string, "r");
1114 <
1115 <    if (file == NULL)
1116 <    {
1117 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1118 <      break;
1119 <    }
1184 >  if (yylval.number)
1185 >    block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1186 >  else
1187 >    block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1188 > };
1189  
1190 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1190 > oper_ssl_certificate_fingerprint: SSL_CERTIFICATE_FINGERPRINT '=' QSTRING ';'
1191 > {
1192 >  if (conf_parser_ctx.pass == 2)
1193 >    strlcpy(block_state.cert.buf, yylval.string, sizeof(block_state.cert.buf));
1194 > };
1195  
1196 <    if (yy_aconf->rsa_public_key == NULL)
1197 <    {
1198 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1199 <      break;
1127 <    }
1196 > oper_ssl_connection_required: SSL_CONNECTION_REQUIRED '=' TBOOL ';'
1197 > {
1198 >  if (conf_parser_ctx.pass != 2)
1199 >    break;
1200  
1201 <    BIO_set_close(file, BIO_CLOSE);
1202 <    BIO_free(file);
1203 <  }
1204 < #endif /* HAVE_LIBCRYPTO */
1201 >  if (yylval.number)
1202 >    block_state.flags.value |= CONF_FLAGS_SSL;
1203 >  else
1204 >    block_state.flags.value &= ~CONF_FLAGS_SSL;
1205   };
1206  
1207   oper_class: CLASS '=' QSTRING ';'
1208   {
1209    if (conf_parser_ctx.pass == 2)
1210 <  {
1139 <    MyFree(class_name);
1140 <    DupString(class_name, yylval.string);
1141 <  }
1210 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1211   };
1212  
1213   oper_umodes: T_UMODES
1214   {
1215    if (conf_parser_ctx.pass == 2)
1216 <    yy_aconf->modes = 0;
1216 >    block_state.modes.value = 0;
1217   } '='  oper_umodes_items ';' ;
1218  
1219   oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1220   oper_umodes_item:  T_BOTS
1221   {
1222    if (conf_parser_ctx.pass == 2)
1223 <    yy_aconf->modes |= UMODE_BOTS;
1223 >    block_state.modes.value |= UMODE_BOTS;
1224   } | T_CCONN
1225   {
1226    if (conf_parser_ctx.pass == 2)
1227 <    yy_aconf->modes |= UMODE_CCONN;
1159 < } | T_CCONN_FULL
1160 < {
1161 <  if (conf_parser_ctx.pass == 2)
1162 <    yy_aconf->modes |= UMODE_CCONN_FULL;
1227 >    block_state.modes.value |= UMODE_CCONN;
1228   } | T_DEAF
1229   {
1230    if (conf_parser_ctx.pass == 2)
1231 <    yy_aconf->modes |= UMODE_DEAF;
1231 >    block_state.modes.value |= UMODE_DEAF;
1232   } | T_DEBUG
1233   {
1234    if (conf_parser_ctx.pass == 2)
1235 <    yy_aconf->modes |= UMODE_DEBUG;
1235 >    block_state.modes.value |= UMODE_DEBUG;
1236   } | T_FULL
1237   {
1238    if (conf_parser_ctx.pass == 2)
1239 <    yy_aconf->modes |= UMODE_FULL;
1239 >    block_state.modes.value |= UMODE_FULL;
1240   } | HIDDEN
1241   {
1242    if (conf_parser_ctx.pass == 2)
1243 <    yy_aconf->modes |= UMODE_HIDDEN;
1243 >    block_state.modes.value |= UMODE_HIDDEN;
1244 > } | HIDE_CHANS
1245 > {
1246 >  if (conf_parser_ctx.pass == 2)
1247 >    block_state.modes.value |= UMODE_HIDECHANS;
1248 > } | HIDE_IDLE
1249 > {
1250 >  if (conf_parser_ctx.pass == 2)
1251 >    block_state.modes.value |= UMODE_HIDEIDLE;
1252   } | T_SKILL
1253   {
1254    if (conf_parser_ctx.pass == 2)
1255 <    yy_aconf->modes |= UMODE_SKILL;
1255 >    block_state.modes.value |= UMODE_SKILL;
1256   } | T_NCHANGE
1257   {
1258    if (conf_parser_ctx.pass == 2)
1259 <    yy_aconf->modes |= UMODE_NCHANGE;
1259 >    block_state.modes.value |= UMODE_NCHANGE;
1260   } | T_REJ
1261   {
1262    if (conf_parser_ctx.pass == 2)
1263 <    yy_aconf->modes |= UMODE_REJ;
1263 >    block_state.modes.value |= UMODE_REJ;
1264   } | T_UNAUTH
1265   {
1266    if (conf_parser_ctx.pass == 2)
1267 <    yy_aconf->modes |= UMODE_UNAUTH;
1267 >    block_state.modes.value |= UMODE_UNAUTH;
1268   } | T_SPY
1269   {
1270    if (conf_parser_ctx.pass == 2)
1271 <    yy_aconf->modes |= UMODE_SPY;
1271 >    block_state.modes.value |= UMODE_SPY;
1272   } | T_EXTERNAL
1273   {
1274    if (conf_parser_ctx.pass == 2)
1275 <    yy_aconf->modes |= UMODE_EXTERNAL;
1203 < } | T_OPERWALL
1204 < {
1205 <  if (conf_parser_ctx.pass == 2)
1206 <    yy_aconf->modes |= UMODE_OPERWALL;
1275 >    block_state.modes.value |= UMODE_EXTERNAL;
1276   } | T_SERVNOTICE
1277   {
1278    if (conf_parser_ctx.pass == 2)
1279 <    yy_aconf->modes |= UMODE_SERVNOTICE;
1279 >    block_state.modes.value |= UMODE_SERVNOTICE;
1280   } | T_INVISIBLE
1281   {
1282    if (conf_parser_ctx.pass == 2)
1283 <    yy_aconf->modes |= UMODE_INVISIBLE;
1283 >    block_state.modes.value |= UMODE_INVISIBLE;
1284   } | T_WALLOP
1285   {
1286    if (conf_parser_ctx.pass == 2)
1287 <    yy_aconf->modes |= UMODE_WALLOP;
1287 >    block_state.modes.value |= UMODE_WALLOP;
1288   } | T_SOFTCALLERID
1289   {
1290    if (conf_parser_ctx.pass == 2)
1291 <    yy_aconf->modes |= UMODE_SOFTCALLERID;
1291 >    block_state.modes.value |= UMODE_SOFTCALLERID;
1292   } | T_CALLERID
1293   {
1294    if (conf_parser_ctx.pass == 2)
1295 <    yy_aconf->modes |= UMODE_CALLERID;
1295 >    block_state.modes.value |= UMODE_CALLERID;
1296   } | T_LOCOPS
1297   {
1298    if (conf_parser_ctx.pass == 2)
1299 <    yy_aconf->modes |= UMODE_LOCOPS;
1299 >    block_state.modes.value |= UMODE_LOCOPS;
1300 > } | T_NONONREG
1301 > {
1302 >  if (conf_parser_ctx.pass == 2)
1303 >    block_state.modes.value |= UMODE_REGONLY;
1304 > } | T_FARCONNECT
1305 > {
1306 >  if (conf_parser_ctx.pass == 2)
1307 >    block_state.modes.value |= UMODE_FARCONNECT;
1308   };
1309  
1310   oper_flags: IRCD_FLAGS
1311   {
1312    if (conf_parser_ctx.pass == 2)
1313 <    yy_aconf->port = 0;
1313 >    block_state.port.value = 0;
1314   } '='  oper_flags_items ';';
1315  
1316   oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1317 < oper_flags_item: GLOBAL_KILL
1317 > oper_flags_item: KILL ':' REMOTE
1318   {
1319    if (conf_parser_ctx.pass == 2)
1320 <    yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1321 < } | REMOTE
1320 >    block_state.port.value |= OPER_FLAG_KILL_REMOTE;
1321 > } | KILL
1322   {
1323    if (conf_parser_ctx.pass == 2)
1324 <    yy_aconf->port |= OPER_FLAG_REMOTE;
1324 >    block_state.port.value |= OPER_FLAG_KILL;
1325 > } | CONNECT ':' REMOTE
1326 > {
1327 >  if (conf_parser_ctx.pass == 2)
1328 >    block_state.port.value |= OPER_FLAG_CONNECT_REMOTE;
1329 > } | CONNECT
1330 > {
1331 >  if (conf_parser_ctx.pass == 2)
1332 >    block_state.port.value |= OPER_FLAG_CONNECT;
1333 > } | SQUIT ':' REMOTE
1334 > {
1335 >  if (conf_parser_ctx.pass == 2)
1336 >    block_state.port.value |= OPER_FLAG_SQUIT_REMOTE;
1337 > } | SQUIT
1338 > {
1339 >  if (conf_parser_ctx.pass == 2)
1340 >    block_state.port.value |= OPER_FLAG_SQUIT;
1341   } | KLINE
1342   {
1343    if (conf_parser_ctx.pass == 2)
1344 <    yy_aconf->port |= OPER_FLAG_K;
1344 >    block_state.port.value |= OPER_FLAG_KLINE;
1345   } | UNKLINE
1346   {
1347    if (conf_parser_ctx.pass == 2)
1348 <    yy_aconf->port |= OPER_FLAG_UNKLINE;
1348 >    block_state.port.value |= OPER_FLAG_UNKLINE;
1349   } | T_DLINE
1350   {
1351    if (conf_parser_ctx.pass == 2)
1352 <    yy_aconf->port |= OPER_FLAG_DLINE;
1352 >    block_state.port.value |= OPER_FLAG_DLINE;
1353   } | T_UNDLINE
1354   {
1355    if (conf_parser_ctx.pass == 2)
1356 <    yy_aconf->port |= OPER_FLAG_UNDLINE;
1356 >    block_state.port.value |= OPER_FLAG_UNDLINE;
1357   } | XLINE
1358   {
1359    if (conf_parser_ctx.pass == 2)
1360 <    yy_aconf->port |= OPER_FLAG_X;
1361 < } | GLINE
1360 >    block_state.port.value |= OPER_FLAG_XLINE;
1361 > } | T_UNXLINE
1362   {
1363    if (conf_parser_ctx.pass == 2)
1364 <    yy_aconf->port |= OPER_FLAG_GLINE;
1364 >    block_state.port.value |= OPER_FLAG_UNXLINE;
1365   } | DIE
1366   {
1367    if (conf_parser_ctx.pass == 2)
1368 <    yy_aconf->port |= OPER_FLAG_DIE;
1368 >    block_state.port.value |= OPER_FLAG_DIE;
1369   } | T_RESTART
1370   {
1371    if (conf_parser_ctx.pass == 2)
1372 <    yy_aconf->port |= OPER_FLAG_RESTART;
1372 >    block_state.port.value |= OPER_FLAG_RESTART;
1373   } | REHASH
1374   {
1375    if (conf_parser_ctx.pass == 2)
1376 <    yy_aconf->port |= OPER_FLAG_REHASH;
1376 >    block_state.port.value |= OPER_FLAG_REHASH;
1377   } | ADMIN
1378   {
1379    if (conf_parser_ctx.pass == 2)
1380 <    yy_aconf->port |= OPER_FLAG_ADMIN;
1381 < } | NICK_CHANGES
1380 >    block_state.port.value |= OPER_FLAG_ADMIN;
1381 > } | T_GLOBOPS
1382   {
1383    if (conf_parser_ctx.pass == 2)
1384 <    yy_aconf->port |= OPER_FLAG_N;
1385 < } | T_OPERWALL
1384 >    block_state.port.value |= OPER_FLAG_GLOBOPS;
1385 > } | T_WALLOPS
1386   {
1387    if (conf_parser_ctx.pass == 2)
1388 <    yy_aconf->port |= OPER_FLAG_OPERWALL;
1389 < } | T_GLOBOPS
1388 >    block_state.port.value |= OPER_FLAG_WALLOPS;
1389 > } | T_LOCOPS
1390   {
1391    if (conf_parser_ctx.pass == 2)
1392 <    yy_aconf->port |= OPER_FLAG_GLOBOPS;
1393 < } | OPER_SPY_T
1392 >    block_state.port.value |= OPER_FLAG_LOCOPS;
1393 > } | REMOTEBAN
1394   {
1395    if (conf_parser_ctx.pass == 2)
1396 <    yy_aconf->port |= OPER_FLAG_OPER_SPY;
1397 < } | REMOTEBAN
1396 >    block_state.port.value |= OPER_FLAG_REMOTEBAN;
1397 > } | T_SET
1398   {
1399    if (conf_parser_ctx.pass == 2)
1400 <    yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1400 >    block_state.port.value |= OPER_FLAG_SET;
1401   } | MODULE
1402   {
1403    if (conf_parser_ctx.pass == 2)
1404 <    yy_aconf->port |= OPER_FLAG_MODULE;
1404 >    block_state.port.value |= OPER_FLAG_MODULE;
1405 > } | T_OPME
1406 > {
1407 >  if (conf_parser_ctx.pass == 2)
1408 >    block_state.port.value |= OPER_FLAG_OPME;
1409 > } | NICK ':' RESV
1410 > {
1411 >  if (conf_parser_ctx.pass == 2)
1412 >    block_state.port.value |= OPER_FLAG_NICK_RESV;
1413 > } | JOIN ':' RESV
1414 > {
1415 >  if (conf_parser_ctx.pass == 2)
1416 >    block_state.port.value |= OPER_FLAG_JOIN_RESV;
1417 > } | RESV
1418 > {
1419 >  if (conf_parser_ctx.pass == 2)
1420 >    block_state.port.value |= OPER_FLAG_RESV;
1421 > } | T_UNRESV
1422 > {
1423 >  if (conf_parser_ctx.pass == 2)
1424 >    block_state.port.value |= OPER_FLAG_UNRESV;
1425 > } | CLOSE
1426 > {
1427 >  if (conf_parser_ctx.pass == 2)
1428 >    block_state.port.value |= OPER_FLAG_CLOSE;
1429   };
1430  
1431  
1432   /***************************************************************************
1433 < *  section class
1433 > * class {} section
1434   ***************************************************************************/
1435   class_entry: CLASS
1436   {
1437 <  if (conf_parser_ctx.pass == 1)
1438 <  {
1322 <    yy_conf = make_conf_item(CLASS_TYPE);
1323 <    yy_class = map_to_conf(yy_conf);
1324 <  }
1325 < } '{' class_items '}' ';'
1326 < {
1327 <  if (conf_parser_ctx.pass == 1)
1328 <  {
1329 <    struct ConfItem *cconf = NULL;
1330 <    struct ClassItem *class = NULL;
1331 <
1332 <    if (yy_class_name == NULL)
1333 <      delete_conf_item(yy_conf);
1334 <    else
1335 <    {
1336 <      cconf = find_exact_name_conf(CLASS_TYPE, NULL, yy_class_name, NULL, NULL);
1337 <
1338 <      if (cconf != NULL)                /* The class existed already */
1339 <      {
1340 <        int user_count = 0;
1341 <
1342 <        rebuild_cidr_class(cconf, yy_class);
1437 >  if (conf_parser_ctx.pass != 1)
1438 >    break;
1439  
1440 <        class = map_to_conf(cconf);
1440 >  reset_block_state();
1441  
1442 <        user_count = class->curr_user_count;
1443 <        memcpy(class, yy_class, sizeof(*class));
1444 <        class->curr_user_count = user_count;
1445 <        class->active = 1;
1442 >  block_state.ping_freq.value = DEFAULT_PINGFREQUENCY;
1443 >  block_state.con_freq.value  = DEFAULT_CONNECTFREQUENCY;
1444 >  block_state.max_total.value = MAXIMUM_LINKS_DEFAULT;
1445 >  block_state.max_sendq.value = DEFAULT_SENDQ;
1446 >  block_state.max_recvq.value = DEFAULT_RECVQ;
1447 > } '{' class_items '}' ';'
1448 > {
1449 >  struct ClassItem *class = NULL;
1450  
1451 <        delete_conf_item(yy_conf);
1451 >  if (conf_parser_ctx.pass != 1)
1452 >    break;
1453  
1454 <        MyFree(cconf->name);            /* Allows case change of class name */
1455 <        cconf->name = yy_class_name;
1355 <      }
1356 <      else      /* Brand new class */
1357 <      {
1358 <        MyFree(yy_conf->name);          /* just in case it was allocated */
1359 <        yy_conf->name = yy_class_name;
1360 <        yy_class->active = 1;
1361 <      }
1362 <    }
1454 >  if (!block_state.class.buf[0])
1455 >    break;
1456  
1457 <    yy_class_name = NULL;
1458 <  }
1457 >  if (!(class = class_find(block_state.class.buf, 0)))
1458 >    class = class_make();
1459 >
1460 >  class->active = 1;
1461 >  MyFree(class->name);
1462 >  class->name = xstrdup(block_state.class.buf);
1463 >  class->ping_freq = block_state.ping_freq.value;
1464 >  class->max_perip = block_state.max_perip.value;
1465 >  class->con_freq = block_state.con_freq.value;
1466 >  class->max_total = block_state.max_total.value;
1467 >  class->max_global = block_state.max_global.value;
1468 >  class->max_local = block_state.max_local.value;
1469 >  class->max_ident = block_state.max_ident.value;
1470 >  class->max_sendq = block_state.max_sendq.value;
1471 >  class->max_recvq = block_state.max_recvq.value;
1472 >  class->max_channels = block_state.max_channels.value;
1473 >
1474 >  if (block_state.min_idle.value > block_state.max_idle.value)
1475 >  {
1476 >    block_state.min_idle.value = 0;
1477 >    block_state.max_idle.value = 0;
1478 >    block_state.flags.value &= ~CLASS_FLAGS_FAKE_IDLE;
1479 >  }
1480 >
1481 >  class->flags = block_state.flags.value;
1482 >  class->min_idle = block_state.min_idle.value;
1483 >  class->max_idle = block_state.max_idle.value;
1484 >
1485 >  rebuild_cidr_list(class);
1486 >
1487 >  class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1488 >  class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1489 >  class->number_per_cidr = block_state.number_per_cidr.value;
1490   };
1491  
1492   class_items:    class_items class_item | class_item;
1493   class_item:     class_name |
1494 <                class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1494 >                class_cidr_bitlen_ipv4 |
1495 >                class_cidr_bitlen_ipv6 |
1496                  class_ping_time |
1497 <                class_ping_warning |
1373 <                class_number_per_cidr |
1497 >                class_number_per_cidr |
1498                  class_number_per_ip |
1499                  class_connectfreq |
1500 +                class_max_channels |
1501                  class_max_number |
1502 <                class_max_global |
1503 <                class_max_local |
1504 <                class_max_ident |
1505 <                class_sendq |
1506 <                error ';' ;
1502 >                class_max_global |
1503 >                class_max_local |
1504 >                class_max_ident |
1505 >                class_sendq | class_recvq |
1506 >                class_min_idle |
1507 >                class_max_idle |
1508 >                class_flags |
1509 >                error ';' ;
1510  
1511 < class_name: NAME '=' QSTRING ';'
1511 > class_name: NAME '=' QSTRING ';'
1512   {
1513    if (conf_parser_ctx.pass == 1)
1514 <  {
1387 <    MyFree(yy_class_name);
1388 <    DupString(yy_class_name, yylval.string);
1389 <  }
1514 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1515   };
1516  
1517   class_ping_time: PING_TIME '=' timespec ';'
1518   {
1519    if (conf_parser_ctx.pass == 1)
1520 <    PingFreq(yy_class) = $3;
1520 >    block_state.ping_freq.value = $3;
1521   };
1522  
1523 < class_ping_warning: PING_WARNING '=' timespec ';'
1523 > class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1524   {
1525    if (conf_parser_ctx.pass == 1)
1526 <    PingWarning(yy_class) = $3;
1526 >    block_state.max_perip.value = $3;
1527   };
1528  
1529 < class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1529 > class_connectfreq: CONNECTFREQ '=' timespec ';'
1530   {
1531    if (conf_parser_ctx.pass == 1)
1532 <    MaxPerIp(yy_class) = $3;
1532 >    block_state.con_freq.value = $3;
1533   };
1534  
1535 < class_connectfreq: CONNECTFREQ '=' timespec ';'
1535 > class_max_channels: MAX_CHANNELS '=' NUMBER ';'
1536   {
1537    if (conf_parser_ctx.pass == 1)
1538 <    ConFreq(yy_class) = $3;
1538 >    block_state.max_channels.value = $3;
1539   };
1540  
1541   class_max_number: MAX_NUMBER '=' NUMBER ';'
1542   {
1543    if (conf_parser_ctx.pass == 1)
1544 <    MaxTotal(yy_class) = $3;
1544 >    block_state.max_total.value = $3;
1545   };
1546  
1547   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1548   {
1549    if (conf_parser_ctx.pass == 1)
1550 <    MaxGlobal(yy_class) = $3;
1550 >    block_state.max_global.value = $3;
1551   };
1552  
1553   class_max_local: MAX_LOCAL '=' NUMBER ';'
1554   {
1555    if (conf_parser_ctx.pass == 1)
1556 <    MaxLocal(yy_class) = $3;
1556 >    block_state.max_local.value = $3;
1557   };
1558  
1559   class_max_ident: MAX_IDENT '=' NUMBER ';'
1560   {
1561    if (conf_parser_ctx.pass == 1)
1562 <    MaxIdent(yy_class) = $3;
1562 >    block_state.max_ident.value = $3;
1563   };
1564  
1565   class_sendq: SENDQ '=' sizespec ';'
1566   {
1567    if (conf_parser_ctx.pass == 1)
1568 <    MaxSendq(yy_class) = $3;
1568 >    block_state.max_sendq.value = $3;
1569 > };
1570 >
1571 > class_recvq: T_RECVQ '=' sizespec ';'
1572 > {
1573 >  if (conf_parser_ctx.pass == 1)
1574 >    if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1575 >      block_state.max_recvq.value = $3;
1576   };
1577  
1578   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1579   {
1580    if (conf_parser_ctx.pass == 1)
1581 <    CidrBitlenIPV4(yy_class) = $3;
1581 >    block_state.cidr_bitlen_ipv4.value = $3 > 32 ? 32 : $3;
1582   };
1583  
1584   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1585   {
1586    if (conf_parser_ctx.pass == 1)
1587 <    CidrBitlenIPV6(yy_class) = $3;
1587 >    block_state.cidr_bitlen_ipv6.value = $3 > 128 ? 128 : $3;
1588   };
1589  
1590   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1591   {
1592    if (conf_parser_ctx.pass == 1)
1593 <    NumberPerCidr(yy_class) = $3;
1593 >    block_state.number_per_cidr.value = $3;
1594 > };
1595 >
1596 > class_min_idle: MIN_IDLE '=' timespec ';'
1597 > {
1598 >  if (conf_parser_ctx.pass != 1)
1599 >    break;
1600 >
1601 >  block_state.min_idle.value = $3;
1602 >  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1603 > };
1604 >
1605 > class_max_idle: MAX_IDLE '=' timespec ';'
1606 > {
1607 >  if (conf_parser_ctx.pass != 1)
1608 >    break;
1609 >
1610 >  block_state.max_idle.value = $3;
1611 >  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1612 > };
1613 >
1614 > class_flags: IRCD_FLAGS
1615 > {
1616 >  if (conf_parser_ctx.pass == 1)
1617 >    block_state.flags.value &= CLASS_FLAGS_FAKE_IDLE;
1618 > } '='  class_flags_items ';';
1619 >
1620 > class_flags_items: class_flags_items ',' class_flags_item | class_flags_item;
1621 > class_flags_item: RANDOM_IDLE
1622 > {
1623 >  if (conf_parser_ctx.pass == 1)
1624 >    block_state.flags.value |= CLASS_FLAGS_RANDOM_IDLE;
1625 > } | HIDE_IDLE_FROM_OPERS
1626 > {
1627 >  if (conf_parser_ctx.pass == 1)
1628 >    block_state.flags.value |= CLASS_FLAGS_HIDE_IDLE_FROM_OPERS;
1629   };
1630  
1631 +
1632   /***************************************************************************
1633 < *  section listen
1633 > * listen {} section
1634   ***************************************************************************/
1635   listen_entry: LISTEN
1636   {
1637    if (conf_parser_ctx.pass == 2)
1638 <  {
1639 <    listener_address = NULL;
1472 <    listener_flags = 0;
1473 <  }
1474 < } '{' listen_items '}' ';'
1475 < {
1476 <  if (conf_parser_ctx.pass == 2)
1477 <  {
1478 <    MyFree(listener_address);
1479 <    listener_address = NULL;
1480 <  }
1481 < };
1638 >    reset_block_state();
1639 > } '{' listen_items '}' ';';
1640  
1641   listen_flags: IRCD_FLAGS
1642   {
1643 <  listener_flags = 0;
1643 >  block_state.flags.value = 0;
1644   } '='  listen_flags_items ';';
1645  
1646   listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1647   listen_flags_item: T_SSL
1648   {
1649    if (conf_parser_ctx.pass == 2)
1650 <    listener_flags |= LISTENER_SSL;
1650 >    block_state.flags.value |= LISTENER_SSL;
1651   } | HIDDEN
1652   {
1653    if (conf_parser_ctx.pass == 2)
1654 <    listener_flags |= LISTENER_HIDDEN;
1654 >    block_state.flags.value |= LISTENER_HIDDEN;
1655   } | T_SERVER
1656   {
1657    if (conf_parser_ctx.pass == 2)
1658 <    listener_flags |= LISTENER_SERVER;
1658 >   block_state.flags.value |= LISTENER_SERVER;
1659   };
1660  
1503
1504
1661   listen_items:   listen_items listen_item | listen_item;
1662   listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';';
1663  
1664 < listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1664 > listen_port: PORT '=' port_items { block_state.flags.value = 0; } ';';
1665  
1666   port_items: port_items ',' port_item | port_item;
1667  
# Line 1513 | Line 1669 | port_item: NUMBER
1669   {
1670    if (conf_parser_ctx.pass == 2)
1671    {
1672 <    if ((listener_flags & LISTENER_SSL))
1673 < #ifdef HAVE_LIBCRYPTO
1674 <      if (!ServerInfo.server_ctx)
1672 > #ifndef HAVE_LIBCRYPTO
1673 >    if (block_state.flags.value & LISTENER_SSL)
1674 >    {
1675 >      conf_error_report("SSL not available - port closed");
1676 >      break;
1677 >    }
1678   #endif
1679 <      {
1521 <        yyerror("SSL not available - port closed");
1522 <        break;
1523 <      }
1524 <    add_listener($1, listener_address, listener_flags);
1679 >    listener_add($1, block_state.addr.buf, block_state.flags.value);
1680    }
1681   } | NUMBER TWODOTS NUMBER
1682   {
1683    if (conf_parser_ctx.pass == 2)
1684    {
1685 <    int i;
1686 <
1687 <    if ((listener_flags & LISTENER_SSL))
1688 < #ifdef HAVE_LIBCRYPTO
1689 <      if (!ServerInfo.server_ctx)
1685 > #ifndef HAVE_LIBCRYPTO
1686 >    if (block_state.flags.value & LISTENER_SSL)
1687 >    {
1688 >      conf_error_report("SSL not available - port closed");
1689 >      break;
1690 >    }
1691   #endif
1536      {
1537        yyerror("SSL not available - port closed");
1538        break;
1539      }
1692  
1693 <    for (i = $1; i <= $3; ++i)
1694 <      add_listener(i, listener_address, listener_flags);
1693 >    for (int i = $1; i <= $3; ++i)
1694 >      listener_add(i, block_state.addr.buf, block_state.flags.value);
1695    }
1696   };
1697  
1698   listen_address: IP '=' QSTRING ';'
1699   {
1700    if (conf_parser_ctx.pass == 2)
1701 <  {
1550 <    MyFree(listener_address);
1551 <    DupString(listener_address, yylval.string);
1552 <  }
1701 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1702   };
1703  
1704   listen_host: HOST '=' QSTRING ';'
1705   {
1706    if (conf_parser_ctx.pass == 2)
1707 <  {
1559 <    MyFree(listener_address);
1560 <    DupString(listener_address, yylval.string);
1561 <  }
1707 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1708   };
1709  
1710 +
1711   /***************************************************************************
1712 < *  section auth
1712 > * auth {} section
1713   ***************************************************************************/
1714   auth_entry: IRCD_AUTH
1715   {
1716    if (conf_parser_ctx.pass == 2)
1717 <  {
1571 <    yy_conf = make_conf_item(CLIENT_TYPE);
1572 <    yy_aconf = map_to_conf(yy_conf);
1573 <  }
1574 <  else
1575 <  {
1576 <    MyFree(class_name);
1577 <    class_name = NULL;
1578 <  }
1717 >    reset_block_state();
1718   } '{' auth_items '}' ';'
1719   {
1720 <  if (conf_parser_ctx.pass == 2)
1582 <  {
1583 <    struct CollectItem *yy_tmp = NULL;
1584 <    dlink_node *ptr = NULL, *next_ptr = NULL;
1585 <
1586 <    if (yy_aconf->user && yy_aconf->host)
1587 <    {
1588 <      conf_add_class_to_conf(yy_conf, class_name);
1589 <      add_conf_by_address(CONF_CLIENT, yy_aconf);
1590 <    }
1591 <    else
1592 <      delete_conf_item(yy_conf);
1593 <
1594 <    /* copy over settings from first struct */
1595 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1596 <    {
1597 <      struct AccessItem *new_aconf;
1598 <      struct ConfItem *new_conf;
1599 <
1600 <      new_conf = make_conf_item(CLIENT_TYPE);
1601 <      new_aconf = map_to_conf(new_conf);
1602 <
1603 <      yy_tmp = ptr->data;
1720 >  dlink_node *node = NULL;
1721  
1722 <      assert(yy_tmp->user && yy_tmp->host);
1722 >  if (conf_parser_ctx.pass != 2)
1723 >    break;
1724  
1725 <      if (yy_aconf->passwd != NULL)
1608 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1609 <      if (yy_conf->name != NULL)
1610 <        DupString(new_conf->name, yy_conf->name);
1611 <      if (yy_aconf->passwd != NULL)
1612 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1613 <
1614 <      new_aconf->flags = yy_aconf->flags;
1615 <      new_aconf->port  = yy_aconf->port;
1616 <
1617 <      DupString(new_aconf->user, yy_tmp->user);
1618 <      collapse(new_aconf->user);
1619 <
1620 <      DupString(new_aconf->host, yy_tmp->host);
1621 <      collapse(new_aconf->host);
1622 <
1623 <      conf_add_class_to_conf(new_conf, class_name);
1624 <      add_conf_by_address(CONF_CLIENT, new_aconf);
1625 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1626 <      free_collect_item(yy_tmp);
1627 <    }
1628 <
1629 <    MyFree(class_name);
1630 <    class_name = NULL;
1631 <    yy_conf = NULL;
1632 <    yy_aconf = NULL;
1633 <  }
1634 < };
1635 <
1636 < auth_items:     auth_items auth_item | auth_item;
1637 < auth_item:      auth_user | auth_passwd | auth_class | auth_flags |
1638 <                auth_spoof | auth_redir_serv | auth_redir_port |
1639 <                auth_encrypted | error ';' ;
1640 <
1641 < auth_user: USER '=' QSTRING ';'
1642 < {
1643 <  if (conf_parser_ctx.pass == 2)
1725 >  DLINK_FOREACH(node, block_state.mask.list.head)
1726    {
1727 <    struct CollectItem *yy_tmp = NULL;
1727 >    struct MaskItem *conf = NULL;
1728      struct split_nuh_item nuh;
1729  
1730 <    nuh.nuhmask  = yylval.string;
1730 >    nuh.nuhmask  = node->data;
1731      nuh.nickptr  = NULL;
1732 <    nuh.userptr  = userbuf;
1733 <    nuh.hostptr  = hostbuf;
1652 <
1732 >    nuh.userptr  = block_state.user.buf;
1733 >    nuh.hostptr  = block_state.host.buf;
1734      nuh.nicksize = 0;
1735 <    nuh.usersize = sizeof(userbuf);
1736 <    nuh.hostsize = sizeof(hostbuf);
1656 <
1735 >    nuh.usersize = sizeof(block_state.user.buf);
1736 >    nuh.hostsize = sizeof(block_state.host.buf);
1737      split_nuh(&nuh);
1738  
1739 <    if (yy_aconf->user == NULL)
1740 <    {
1741 <      DupString(yy_aconf->user, userbuf);
1742 <      DupString(yy_aconf->host, hostbuf);
1743 <    }
1744 <    else
1745 <    {
1746 <      yy_tmp = MyMalloc(sizeof(struct CollectItem));
1739 >    conf        = conf_make(CONF_CLIENT);
1740 >    conf->user  = xstrdup(block_state.user.buf);
1741 >    conf->host  = xstrdup(block_state.host.buf);
1742 >
1743 >    if (block_state.rpass.buf[0])
1744 >      conf->passwd = xstrdup(block_state.rpass.buf);
1745 >    if (block_state.name.buf[0])
1746 >      conf->name = xstrdup(block_state.name.buf);
1747  
1748 <      DupString(yy_tmp->user, userbuf);
1749 <      DupString(yy_tmp->host, hostbuf);
1748 >    conf->flags = block_state.flags.value;
1749 >    conf->port  = block_state.port.value;
1750  
1751 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1752 <    }
1751 >    conf_add_class_to_conf(conf, block_state.class.buf);
1752 >    add_conf_by_address(CONF_CLIENT, conf);
1753    }
1754   };
1755  
1756 < /* XXX - IP/IPV6 tags don't exist anymore - put IP/IPV6 into user. */
1756 > auth_items:     auth_items auth_item | auth_item;
1757 > auth_item:      auth_user |
1758 >                auth_passwd |
1759 >                auth_class |
1760 >                auth_flags |
1761 >                auth_spoof |
1762 >                auth_redir_serv |
1763 >                auth_redir_port |
1764 >                auth_encrypted |
1765 >                error ';' ;
1766  
1767 < auth_passwd: PASSWORD '=' QSTRING ';'
1767 > auth_user: USER '=' QSTRING ';'
1768   {
1769    if (conf_parser_ctx.pass == 2)
1770 <  {
1771 <    /* be paranoid */
1683 <    if (yy_aconf->passwd != NULL)
1684 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1770 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1771 > };
1772  
1773 <    MyFree(yy_aconf->passwd);
1774 <    DupString(yy_aconf->passwd, yylval.string);
1775 <  }
1773 > auth_passwd: PASSWORD '=' QSTRING ';'
1774 > {
1775 >  if (conf_parser_ctx.pass == 2)
1776 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1777   };
1778  
1779   auth_class: CLASS '=' QSTRING ';'
1780   {
1781    if (conf_parser_ctx.pass == 2)
1782 <  {
1695 <    MyFree(class_name);
1696 <    DupString(class_name, yylval.string);
1697 <  }
1782 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1783   };
1784  
1785   auth_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 1702 | Line 1787 | auth_encrypted: ENCRYPTED '=' TBOOL ';'
1787    if (conf_parser_ctx.pass == 2)
1788    {
1789      if (yylval.number)
1790 <      SetConfEncrypted(yy_aconf);
1790 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1791      else
1792 <      ClearConfEncrypted(yy_aconf);
1792 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1793    }
1794   };
1795  
1796   auth_flags: IRCD_FLAGS
1797   {
1798 +  if (conf_parser_ctx.pass == 2)
1799 +    block_state.flags.value &= (CONF_FLAGS_ENCRYPTED | CONF_FLAGS_SPOOF_IP);
1800   } '='  auth_flags_items ';';
1801  
1802   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1803   auth_flags_item: SPOOF_NOTICE
1804   {
1805    if (conf_parser_ctx.pass == 2)
1806 <    yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1806 >    block_state.flags.value |= CONF_FLAGS_SPOOF_NOTICE;
1807   } | EXCEED_LIMIT
1808   {
1809    if (conf_parser_ctx.pass == 2)
1810 <    yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1810 >    block_state.flags.value |= CONF_FLAGS_NOLIMIT;
1811   } | KLINE_EXEMPT
1812   {
1813    if (conf_parser_ctx.pass == 2)
1814 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1814 >    block_state.flags.value |= CONF_FLAGS_EXEMPTKLINE;
1815 > } | XLINE_EXEMPT
1816 > {
1817 >  if (conf_parser_ctx.pass == 2)
1818 >    block_state.flags.value |= CONF_FLAGS_EXEMPTXLINE;
1819   } | NEED_IDENT
1820   {
1821    if (conf_parser_ctx.pass == 2)
1822 <    yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1822 >    block_state.flags.value |= CONF_FLAGS_NEED_IDENTD;
1823   } | CAN_FLOOD
1824   {
1825    if (conf_parser_ctx.pass == 2)
1826 <    yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1826 >    block_state.flags.value |= CONF_FLAGS_CAN_FLOOD;
1827   } | NO_TILDE
1828   {
1829    if (conf_parser_ctx.pass == 2)
1830 <    yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1831 < } | GLINE_EXEMPT
1830 >    block_state.flags.value |= CONF_FLAGS_NO_TILDE;
1831 > } | RESV_EXEMPT
1832   {
1833    if (conf_parser_ctx.pass == 2)
1834 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1835 < } | RESV_EXEMPT
1834 >    block_state.flags.value |= CONF_FLAGS_EXEMPTRESV;
1835 > } | T_WEBIRC
1836   {
1837    if (conf_parser_ctx.pass == 2)
1838 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
1838 >    block_state.flags.value |= CONF_FLAGS_WEBIRC;
1839   } | NEED_PASSWORD
1840   {
1841    if (conf_parser_ctx.pass == 2)
1842 <    yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
1842 >    block_state.flags.value |= CONF_FLAGS_NEED_PASSWORD;
1843   };
1844  
1845 < /* XXX - need check for illegal hostnames here */
1755 < auth_spoof: SPOOF '=' QSTRING ';'
1845 > auth_spoof: SPOOF '=' QSTRING ';'
1846   {
1847 <  if (conf_parser_ctx.pass == 2)
1848 <  {
1759 <    MyFree(yy_conf->name);
1847 >  if (conf_parser_ctx.pass != 2)
1848 >    break;
1849  
1850 <    if (strlen(yylval.string) < HOSTLEN)
1851 <    {    
1852 <      DupString(yy_conf->name, yylval.string);
1853 <      yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
1765 <    }
1766 <    else
1767 <    {
1768 <      ilog(LOG_TYPE_IRCD, "Spoofs must be less than %d..ignoring it", HOSTLEN);
1769 <      yy_conf->name = NULL;
1770 <    }
1850 >  if (valid_hostname(yylval.string))
1851 >  {
1852 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1853 >    block_state.flags.value |= CONF_FLAGS_SPOOF_IP;
1854    }
1855 +  else
1856 +    ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1857   };
1858  
1859   auth_redir_serv: REDIRSERV '=' QSTRING ';'
1860   {
1861 <  if (conf_parser_ctx.pass == 2)
1862 <  {
1863 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1864 <    MyFree(yy_conf->name);
1865 <    DupString(yy_conf->name, yylval.string);
1781 <  }
1861 >  if (conf_parser_ctx.pass != 2)
1862 >    break;
1863 >
1864 >  strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1865 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1866   };
1867  
1868   auth_redir_port: REDIRPORT '=' NUMBER ';'
1869   {
1870 <  if (conf_parser_ctx.pass == 2)
1871 <  {
1872 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1873 <    yy_aconf->port = $3;
1874 <  }
1870 >  if (conf_parser_ctx.pass != 2)
1871 >    break;
1872 >
1873 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1874 >  block_state.port.value = $3;
1875   };
1876  
1877  
1878   /***************************************************************************
1879 < *  section resv
1879 > * resv {} section
1880   ***************************************************************************/
1881   resv_entry: RESV
1882   {
1883 <  if (conf_parser_ctx.pass == 2)
1884 <  {
1885 <    MyFree(resv_reason);
1886 <    resv_reason = NULL;
1887 <  }
1883 >  if (conf_parser_ctx.pass != 2)
1884 >    break;
1885 >
1886 >  reset_block_state();
1887 >  strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1888   } '{' resv_items '}' ';'
1889   {
1890 <  if (conf_parser_ctx.pass == 2)
1891 <  {
1892 <    MyFree(resv_reason);
1893 <    resv_reason = NULL;
1810 <  }
1890 >  if (conf_parser_ctx.pass != 2)
1891 >    break;
1892 >
1893 >  create_resv(block_state.name.buf, block_state.rpass.buf, &block_state.mask.list);
1894   };
1895  
1896 < resv_items:     resv_items resv_item | resv_item;
1897 < resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
1896 > resv_items:     resv_items resv_item | resv_item;
1897 > resv_item:      resv_mask | resv_reason | resv_exempt | error ';' ;
1898  
1899 < resv_creason: REASON '=' QSTRING ';'
1899 > resv_mask: MASK '=' QSTRING ';'
1900   {
1901    if (conf_parser_ctx.pass == 2)
1902 <  {
1820 <    MyFree(resv_reason);
1821 <    DupString(resv_reason, yylval.string);
1822 <  }
1902 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1903   };
1904  
1905 < resv_channel: CHANNEL '=' QSTRING ';'
1905 > resv_reason: REASON '=' QSTRING ';'
1906   {
1907    if (conf_parser_ctx.pass == 2)
1908 <  {
1829 <    if (IsChanPrefix(*yylval.string))
1830 <    {
1831 <      char def_reason[] = "No reason";
1832 <
1833 <      create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1834 <    }
1835 <  }
1836 <  /* ignore it for now.. but we really should make a warning if
1837 <   * its an erroneous name --fl_ */
1908 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1909   };
1910  
1911 < resv_nick: NICK '=' QSTRING ';'
1911 > resv_exempt: EXEMPT '=' QSTRING ';'
1912   {
1913    if (conf_parser_ctx.pass == 2)
1914 <  {
1844 <    char def_reason[] = "No reason";
1845 <
1846 <    create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1847 <  }
1914 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1915   };
1916  
1917 +
1918   /***************************************************************************
1919 < *  section service
1919 > * service {} section
1920   ***************************************************************************/
1921   service_entry: T_SERVICE '{' service_items '}' ';';
1922  
# Line 1857 | Line 1925 | service_item:      service_name | error;
1925  
1926   service_name: NAME '=' QSTRING ';'
1927   {
1928 <  if (conf_parser_ctx.pass == 2)
1928 >  if (conf_parser_ctx.pass != 2)
1929 >    break;
1930 >
1931 >  if (valid_servname(yylval.string))
1932    {
1933 <    if (valid_servname(yylval.string))
1934 <    {
1864 <      yy_conf = make_conf_item(SERVICE_TYPE);
1865 <      DupString(yy_conf->name, yylval.string);
1866 <    }
1933 >    struct MaskItem *conf = conf_make(CONF_SERVICE);
1934 >    conf->name = xstrdup(yylval.string);
1935    }
1936   };
1937  
1938 +
1939   /***************************************************************************
1940 < *  section shared, for sharing remote klines etc.
1940 > * shared {} section, for sharing remote klines etc.
1941   ***************************************************************************/
1942   shared_entry: T_SHARED
1943   {
1944 <  if (conf_parser_ctx.pass == 2)
1945 <  {
1946 <    yy_conf = make_conf_item(ULINE_TYPE);
1947 <    yy_match_item = map_to_conf(yy_conf);
1948 <    yy_match_item->action = SHARED_ALL;
1949 <  }
1944 >  if (conf_parser_ctx.pass != 2)
1945 >    break;
1946 >
1947 >  reset_block_state();
1948 >
1949 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1950 >  strlcpy(block_state.user.buf, "*", sizeof(block_state.user.buf));
1951 >  strlcpy(block_state.host.buf, "*", sizeof(block_state.host.buf));
1952 >  block_state.flags.value = SHARED_ALL;
1953   } '{' shared_items '}' ';'
1954   {
1955 <  if (conf_parser_ctx.pass == 2)
1956 <  {
1957 <    yy_conf = NULL;
1958 <  }
1955 >  struct MaskItem *conf = NULL;
1956 >
1957 >  if (conf_parser_ctx.pass != 2)
1958 >    break;
1959 >
1960 >  conf = conf_make(CONF_SHARED);
1961 >  conf->flags = block_state.flags.value;
1962 >  conf->name = xstrdup(block_state.name.buf);
1963 >  conf->user = xstrdup(block_state.user.buf);
1964 >  conf->host = xstrdup(block_state.host.buf);
1965   };
1966  
1967   shared_items: shared_items shared_item | shared_item;
# Line 1892 | Line 1970 | shared_item:  shared_name | shared_user
1970   shared_name: NAME '=' QSTRING ';'
1971   {
1972    if (conf_parser_ctx.pass == 2)
1973 <  {
1896 <    MyFree(yy_conf->name);
1897 <    DupString(yy_conf->name, yylval.string);
1898 <  }
1973 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1974   };
1975  
1976   shared_user: USER '=' QSTRING ';'
# Line 1906 | Line 1981 | shared_user: USER '=' QSTRING ';'
1981  
1982      nuh.nuhmask  = yylval.string;
1983      nuh.nickptr  = NULL;
1984 <    nuh.userptr  = userbuf;
1985 <    nuh.hostptr  = hostbuf;
1984 >    nuh.userptr  = block_state.user.buf;
1985 >    nuh.hostptr  = block_state.host.buf;
1986  
1987      nuh.nicksize = 0;
1988 <    nuh.usersize = sizeof(userbuf);
1989 <    nuh.hostsize = sizeof(hostbuf);
1988 >    nuh.usersize = sizeof(block_state.user.buf);
1989 >    nuh.hostsize = sizeof(block_state.host.buf);
1990  
1991      split_nuh(&nuh);
1917
1918    DupString(yy_match_item->user, userbuf);
1919    DupString(yy_match_item->host, hostbuf);
1992    }
1993   };
1994  
1995   shared_type: TYPE
1996   {
1997    if (conf_parser_ctx.pass == 2)
1998 <    yy_match_item->action = 0;
1998 >    block_state.flags.value = 0;
1999   } '=' shared_types ';' ;
2000  
2001   shared_types: shared_types ',' shared_type_item | shared_type_item;
2002   shared_type_item: KLINE
2003   {
2004    if (conf_parser_ctx.pass == 2)
2005 <    yy_match_item->action |= SHARED_KLINE;
2005 >    block_state.flags.value |= SHARED_KLINE;
2006   } | UNKLINE
2007   {
2008    if (conf_parser_ctx.pass == 2)
2009 <    yy_match_item->action |= SHARED_UNKLINE;
2009 >    block_state.flags.value |= SHARED_UNKLINE;
2010   } | T_DLINE
2011   {
2012    if (conf_parser_ctx.pass == 2)
2013 <    yy_match_item->action |= SHARED_DLINE;
2013 >    block_state.flags.value |= SHARED_DLINE;
2014   } | T_UNDLINE
2015   {
2016    if (conf_parser_ctx.pass == 2)
2017 <    yy_match_item->action |= SHARED_UNDLINE;
2017 >    block_state.flags.value |= SHARED_UNDLINE;
2018   } | XLINE
2019   {
2020    if (conf_parser_ctx.pass == 2)
2021 <    yy_match_item->action |= SHARED_XLINE;
2021 >    block_state.flags.value |= SHARED_XLINE;
2022   } | T_UNXLINE
2023   {
2024    if (conf_parser_ctx.pass == 2)
2025 <    yy_match_item->action |= SHARED_UNXLINE;
2025 >    block_state.flags.value |= SHARED_UNXLINE;
2026   } | RESV
2027   {
2028    if (conf_parser_ctx.pass == 2)
2029 <    yy_match_item->action |= SHARED_RESV;
2029 >    block_state.flags.value |= SHARED_RESV;
2030   } | T_UNRESV
2031   {
2032    if (conf_parser_ctx.pass == 2)
2033 <    yy_match_item->action |= SHARED_UNRESV;
2033 >    block_state.flags.value |= SHARED_UNRESV;
2034   } | T_LOCOPS
2035   {
2036    if (conf_parser_ctx.pass == 2)
2037 <    yy_match_item->action |= SHARED_LOCOPS;
2037 >    block_state.flags.value |= SHARED_LOCOPS;
2038   } | T_ALL
2039   {
2040    if (conf_parser_ctx.pass == 2)
2041 <    yy_match_item->action = SHARED_ALL;
2041 >    block_state.flags.value = SHARED_ALL;
2042   };
2043  
2044 +
2045   /***************************************************************************
2046 < *  section cluster
2046 > * cluster {} section
2047   ***************************************************************************/
2048   cluster_entry: T_CLUSTER
2049   {
2050 <  if (conf_parser_ctx.pass == 2)
2051 <  {
2052 <    yy_conf = make_conf_item(CLUSTER_TYPE);
2053 <    yy_conf->flags = SHARED_ALL;
2054 <  }
2050 >  if (conf_parser_ctx.pass != 2)
2051 >    break;
2052 >
2053 >  reset_block_state();
2054 >
2055 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
2056 >  block_state.flags.value = SHARED_ALL;
2057   } '{' cluster_items '}' ';'
2058   {
2059 <  if (conf_parser_ctx.pass == 2)
2060 <  {
2061 <    if (yy_conf->name == NULL)
2062 <      DupString(yy_conf->name, "*");
2063 <    yy_conf = NULL;
2064 <  }
2059 >  struct MaskItem *conf = NULL;
2060 >
2061 >  if (conf_parser_ctx.pass != 2)
2062 >    break;
2063 >
2064 >  conf = conf_make(CONF_CLUSTER);
2065 >  conf->flags = block_state.flags.value;
2066 >  conf->name = xstrdup(block_state.name.buf);
2067   };
2068  
2069 < cluster_items:  cluster_items cluster_item | cluster_item;
2070 < cluster_item:   cluster_name | cluster_type | error ';' ;
2069 > cluster_items:  cluster_items cluster_item | cluster_item;
2070 > cluster_item:   cluster_name | cluster_type | error ';' ;
2071  
2072   cluster_name: NAME '=' QSTRING ';'
2073   {
2074    if (conf_parser_ctx.pass == 2)
2075 <    DupString(yy_conf->name, yylval.string);
2075 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2076   };
2077  
2078   cluster_type: TYPE
2079   {
2080    if (conf_parser_ctx.pass == 2)
2081 <    yy_conf->flags = 0;
2081 >    block_state.flags.value = 0;
2082   } '=' cluster_types ';' ;
2083  
2084 < cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
2084 > cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
2085   cluster_type_item: KLINE
2086   {
2087    if (conf_parser_ctx.pass == 2)
2088 <    yy_conf->flags |= SHARED_KLINE;
2088 >    block_state.flags.value |= SHARED_KLINE;
2089   } | UNKLINE
2090   {
2091    if (conf_parser_ctx.pass == 2)
2092 <    yy_conf->flags |= SHARED_UNKLINE;
2092 >    block_state.flags.value |= SHARED_UNKLINE;
2093   } | T_DLINE
2094   {
2095    if (conf_parser_ctx.pass == 2)
2096 <    yy_conf->flags |= SHARED_DLINE;
2096 >    block_state.flags.value |= SHARED_DLINE;
2097   } | T_UNDLINE
2098   {
2099    if (conf_parser_ctx.pass == 2)
2100 <    yy_conf->flags |= SHARED_UNDLINE;
2100 >    block_state.flags.value |= SHARED_UNDLINE;
2101   } | XLINE
2102   {
2103    if (conf_parser_ctx.pass == 2)
2104 <    yy_conf->flags |= SHARED_XLINE;
2104 >    block_state.flags.value |= SHARED_XLINE;
2105   } | T_UNXLINE
2106   {
2107    if (conf_parser_ctx.pass == 2)
2108 <    yy_conf->flags |= SHARED_UNXLINE;
2108 >    block_state.flags.value |= SHARED_UNXLINE;
2109   } | RESV
2110   {
2111    if (conf_parser_ctx.pass == 2)
2112 <    yy_conf->flags |= SHARED_RESV;
2112 >    block_state.flags.value |= SHARED_RESV;
2113   } | T_UNRESV
2114   {
2115    if (conf_parser_ctx.pass == 2)
2116 <    yy_conf->flags |= SHARED_UNRESV;
2116 >    block_state.flags.value |= SHARED_UNRESV;
2117   } | T_LOCOPS
2118   {
2119    if (conf_parser_ctx.pass == 2)
2120 <    yy_conf->flags |= SHARED_LOCOPS;
2120 >    block_state.flags.value |= SHARED_LOCOPS;
2121   } | T_ALL
2122   {
2123    if (conf_parser_ctx.pass == 2)
2124 <    yy_conf->flags = SHARED_ALL;
2124 >    block_state.flags.value = SHARED_ALL;
2125   };
2126  
2127 +
2128   /***************************************************************************
2129 < *  section connect
2129 > * connect {}  section
2130   ***************************************************************************/
2131 < connect_entry: CONNECT  
2131 > connect_entry: CONNECT
2132   {
2055  if (conf_parser_ctx.pass == 2)
2056  {
2057    yy_conf = make_conf_item(SERVER_TYPE);
2058    yy_aconf = map_to_conf(yy_conf);
2133  
2134 <    /* defaults */
2135 <    yy_aconf->port = PORTNUM;
2136 <  }
2137 <  else
2138 <  {
2139 <    MyFree(class_name);
2066 <    class_name = NULL;
2067 <  }
2134 >  if (conf_parser_ctx.pass != 2)
2135 >    break;
2136 >
2137 >  reset_block_state();
2138 >  block_state.aftype.value = AF_INET;
2139 >  block_state.port.value = PORTNUM;
2140   } '{' connect_items '}' ';'
2141   {
2142 <  if (conf_parser_ctx.pass == 2)
2143 <  {
2072 <    struct CollectItem *yy_hconf=NULL;
2073 <    struct CollectItem *yy_lconf=NULL;
2074 <    dlink_node *ptr = NULL, *next_ptr = NULL;
2075 <
2076 <    if (yy_aconf->host &&
2077 <        yy_aconf->passwd && yy_aconf->spasswd)
2078 <    {
2079 <      if (conf_add_server(yy_conf, class_name) == -1)
2080 <      {
2081 <        delete_conf_item(yy_conf);
2082 <        yy_conf = NULL;
2083 <        yy_aconf = NULL;
2084 <      }
2085 <    }
2086 <    else
2087 <    {
2088 <      /* Even if yy_conf ->name is NULL
2089 <       * should still unhook any hub/leaf confs still pending
2090 <       */
2091 <      unhook_hub_leaf_confs();
2092 <
2093 <      if (yy_conf->name != NULL)
2094 <      {
2095 <        if (yy_aconf->host == NULL)
2096 <          yyerror("Ignoring connect block -- missing host");
2097 <        else if (!yy_aconf->passwd || !yy_aconf->spasswd)
2098 <          yyerror("Ignoring connect block -- missing password");
2099 <      }
2142 >  struct MaskItem *conf = NULL;
2143 >  struct addrinfo hints, *res;
2144  
2145 +  if (conf_parser_ctx.pass != 2)
2146 +    break;
2147  
2148 <      /* XXX
2149 <       * This fixes a try_connections() core (caused by invalid class_ptr
2150 <       * pointers) reported by metalrock. That's an ugly fix, but there
2151 <       * is currently no better way. The entire config subsystem needs an
2152 <       * rewrite ASAP. make_conf_item() shouldn't really add things onto
2153 <       * a doubly linked list immediately without any sanity checks!  -Michael
2154 <       */
2155 <      delete_conf_item(yy_conf);
2148 >  if (!block_state.name.buf[0] ||
2149 >      !block_state.host.buf[0])
2150 >    break;
2151 >
2152 >  if (!block_state.rpass.buf[0] ||
2153 >      !block_state.spass.buf[0])
2154 >    break;
2155 >
2156 >  if (has_wildcards(block_state.name.buf) ||
2157 >      has_wildcards(block_state.host.buf))
2158 >    break;
2159 >
2160 >  conf = conf_make(CONF_SERVER);
2161 >  conf->port = block_state.port.value;
2162 >  conf->flags = block_state.flags.value;
2163 >  conf->aftype = block_state.aftype.value;
2164 >  conf->host = xstrdup(block_state.host.buf);
2165 >  conf->name = xstrdup(block_state.name.buf);
2166 >  conf->passwd = xstrdup(block_state.rpass.buf);
2167 >  conf->spasswd = xstrdup(block_state.spass.buf);
2168 >
2169 >  if (block_state.cert.buf[0])
2170 >    conf->certfp = xstrdup(block_state.cert.buf);
2171  
2172 <      yy_aconf = NULL;
2173 <      yy_conf = NULL;
2113 <    }
2114 <
2115 <      /*
2116 <       * yy_conf is still pointing at the server that is having
2117 <       * a connect block built for it. This means, y_aconf->name
2118 <       * points to the actual irc name this server will be known as.
2119 <       * Now this new server has a set or even just one hub_mask (or leaf_mask)
2120 <       * given in the link list at yy_hconf. Fill in the HUB confs
2121 <       * from this link list now.
2122 <       */        
2123 <      DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
2124 <      {
2125 <        struct ConfItem *new_hub_conf;
2126 <        struct MatchItem *match_item;
2172 >  if (block_state.ciph.buf[0])
2173 >    conf->cipher_list = xstrdup(block_state.ciph.buf);
2174  
2175 <        yy_hconf = ptr->data;
2175 >  dlinkMoveList(&block_state.leaf.list, &conf->leaf_list);
2176 >  dlinkMoveList(&block_state.hub.list, &conf->hub_list);
2177  
2178 <        /* yy_conf == NULL is a fatal error for this connect block! */
2179 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2180 <        {
2133 <          new_hub_conf = make_conf_item(HUB_TYPE);
2134 <          match_item = (struct MatchItem *)map_to_conf(new_hub_conf);
2135 <          DupString(new_hub_conf->name, yy_conf->name);
2136 <          if (yy_hconf->user != NULL)
2137 <            DupString(match_item->user, yy_hconf->user);
2138 <          else
2139 <            DupString(match_item->user, "*");
2140 <          if (yy_hconf->host != NULL)
2141 <            DupString(match_item->host, yy_hconf->host);
2142 <          else
2143 <            DupString(match_item->host, "*");
2144 <        }
2145 <        dlinkDelete(&yy_hconf->node, &hub_conf_list);
2146 <        free_collect_item(yy_hconf);
2147 <      }
2148 <
2149 <      /* Ditto for the LEAF confs */
2178 >  if (block_state.bind.buf[0])
2179 >  {
2180 >    memset(&hints, 0, sizeof(hints));
2181  
2182 <      DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
2183 <      {
2184 <        struct ConfItem *new_leaf_conf;
2154 <        struct MatchItem *match_item;
2182 >    hints.ai_family   = AF_UNSPEC;
2183 >    hints.ai_socktype = SOCK_STREAM;
2184 >    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2185  
2186 <        yy_lconf = ptr->data;
2186 >    if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
2187 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
2188 >    else
2189 >    {
2190 >      assert(res);
2191  
2192 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2193 <        {
2194 <          new_leaf_conf = make_conf_item(LEAF_TYPE);
2195 <          match_item = (struct MatchItem *)map_to_conf(new_leaf_conf);
2196 <          DupString(new_leaf_conf->name, yy_conf->name);
2163 <          if (yy_lconf->user != NULL)
2164 <            DupString(match_item->user, yy_lconf->user);
2165 <          else
2166 <            DupString(match_item->user, "*");
2167 <          if (yy_lconf->host != NULL)
2168 <            DupString(match_item->host, yy_lconf->host);
2169 <          else
2170 <            DupString(match_item->host, "*");
2171 <        }
2172 <        dlinkDelete(&yy_lconf->node, &leaf_conf_list);
2173 <        free_collect_item(yy_lconf);
2174 <      }
2175 <      MyFree(class_name);
2176 <      class_name = NULL;
2177 <      yy_conf = NULL;
2178 <      yy_aconf = NULL;
2192 >      memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
2193 >      conf->bind.ss.ss_family = res->ai_family;
2194 >      conf->bind.ss_len = res->ai_addrlen;
2195 >      freeaddrinfo(res);
2196 >    }
2197    }
2198 +
2199 +  conf_add_class_to_conf(conf, block_state.class.buf);
2200 +  lookup_confhost(conf);
2201   };
2202  
2203   connect_items:  connect_items connect_item | connect_item;
2204 < connect_item:   connect_name | connect_host | connect_vhost |
2205 <                connect_send_password | connect_accept_password |
2206 <                connect_aftype | connect_port | connect_ssl_cipher_list |
2207 <                connect_flags | connect_hub_mask | connect_leaf_mask |
2208 <                connect_class | connect_encrypted |
2204 > connect_item:   connect_name |
2205 >                connect_host |
2206 >                connect_vhost |
2207 >                connect_send_password |
2208 >                connect_accept_password |
2209 >                connect_ssl_certificate_fingerprint |
2210 >                connect_aftype |
2211 >                connect_port |
2212 >                connect_ssl_cipher_list |
2213 >                connect_flags |
2214 >                connect_hub_mask |
2215 >                connect_leaf_mask |
2216 >                connect_class |
2217 >                connect_encrypted |
2218                  error ';' ;
2219  
2220   connect_name: NAME '=' QSTRING ';'
2221   {
2222    if (conf_parser_ctx.pass == 2)
2223 <  {
2194 <    if (yy_conf->name != NULL)
2195 <      yyerror("Multiple connect name entry");
2196 <
2197 <    MyFree(yy_conf->name);
2198 <    DupString(yy_conf->name, yylval.string);
2199 <  }
2223 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2224   };
2225  
2226 < connect_host: HOST '=' QSTRING ';'
2226 > connect_host: HOST '=' QSTRING ';'
2227   {
2228    if (conf_parser_ctx.pass == 2)
2229 <  {
2206 <    MyFree(yy_aconf->host);
2207 <    DupString(yy_aconf->host, yylval.string);
2208 <  }
2229 >    strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
2230   };
2231  
2232 < connect_vhost: VHOST '=' QSTRING ';'
2232 > connect_vhost: VHOST '=' QSTRING ';'
2233   {
2234    if (conf_parser_ctx.pass == 2)
2235 <  {
2215 <    struct addrinfo hints, *res;
2216 <
2217 <    memset(&hints, 0, sizeof(hints));
2218 <
2219 <    hints.ai_family   = AF_UNSPEC;
2220 <    hints.ai_socktype = SOCK_STREAM;
2221 <    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2222 <
2223 <    if (getaddrinfo(yylval.string, NULL, &hints, &res))
2224 <      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
2225 <    else
2226 <    {
2227 <      assert(res != NULL);
2228 <
2229 <      memcpy(&yy_aconf->my_ipnum, res->ai_addr, res->ai_addrlen);
2230 <      yy_aconf->my_ipnum.ss.ss_family = res->ai_family;
2231 <      yy_aconf->my_ipnum.ss_len = res->ai_addrlen;
2232 <      freeaddrinfo(res);
2233 <    }
2234 <  }
2235 >    strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
2236   };
2237 <
2237 >
2238   connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2239   {
2240 <  if (conf_parser_ctx.pass == 2)
2241 <  {
2241 <    if ($3[0] == ':')
2242 <      yyerror("Server passwords cannot begin with a colon");
2243 <    else if (strchr($3, ' ') != NULL)
2244 <      yyerror("Server passwords cannot contain spaces");
2245 <    else {
2246 <      if (yy_aconf->spasswd != NULL)
2247 <        memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2240 >  if (conf_parser_ctx.pass != 2)
2241 >    break;
2242  
2243 <      MyFree(yy_aconf->spasswd);
2244 <      DupString(yy_aconf->spasswd, yylval.string);
2245 <    }
2246 <  }
2243 >  if ($3[0] == ':')
2244 >    conf_error_report("Server passwords cannot begin with a colon");
2245 >  else if (strchr($3, ' '))
2246 >    conf_error_report("Server passwords cannot contain spaces");
2247 >  else
2248 >    strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
2249   };
2250  
2251   connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2252   {
2253 <  if (conf_parser_ctx.pass == 2)
2254 <  {
2259 <    if ($3[0] == ':')
2260 <      yyerror("Server passwords cannot begin with a colon");
2261 <    else if (strchr($3, ' ') != NULL)
2262 <      yyerror("Server passwords cannot contain spaces");
2263 <    else {
2264 <      if (yy_aconf->passwd != NULL)
2265 <        memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2253 >  if (conf_parser_ctx.pass != 2)
2254 >    break;
2255  
2256 <      MyFree(yy_aconf->passwd);
2257 <      DupString(yy_aconf->passwd, yylval.string);
2258 <    }
2259 <  }
2256 >  if ($3[0] == ':')
2257 >    conf_error_report("Server passwords cannot begin with a colon");
2258 >  else if (strchr($3, ' '))
2259 >    conf_error_report("Server passwords cannot contain spaces");
2260 >  else
2261 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2262 > };
2263 >
2264 > connect_ssl_certificate_fingerprint: SSL_CERTIFICATE_FINGERPRINT '=' QSTRING ';'
2265 > {
2266 >  if (conf_parser_ctx.pass == 2)
2267 >    strlcpy(block_state.cert.buf, yylval.string, sizeof(block_state.cert.buf));
2268   };
2269  
2270   connect_port: PORT '=' NUMBER ';'
2271   {
2272    if (conf_parser_ctx.pass == 2)
2273 <    yy_aconf->port = $3;
2273 >    block_state.port.value = $3;
2274   };
2275  
2276   connect_aftype: AFTYPE '=' T_IPV4 ';'
2277   {
2278    if (conf_parser_ctx.pass == 2)
2279 <    yy_aconf->aftype = AF_INET;
2279 >    block_state.aftype.value = AF_INET;
2280   } | AFTYPE '=' T_IPV6 ';'
2281   {
2285 #ifdef IPV6
2282    if (conf_parser_ctx.pass == 2)
2283 <    yy_aconf->aftype = AF_INET6;
2288 < #endif
2283 >    block_state.aftype.value = AF_INET6;
2284   };
2285  
2286   connect_flags: IRCD_FLAGS
2287   {
2288 +  block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
2289   } '='  connect_flags_items ';';
2290  
2291   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2292   connect_flags_item: AUTOCONN
2293   {
2294    if (conf_parser_ctx.pass == 2)
2295 <    SetConfAllowAutoConn(yy_aconf);
2300 < } | BURST_AWAY
2301 < {
2302 <  if (conf_parser_ctx.pass == 2)
2303 <    SetConfAwayBurst(yy_aconf);
2304 < } | TOPICBURST
2305 < {
2306 <  if (conf_parser_ctx.pass == 2)
2307 <    SetConfTopicBurst(yy_aconf);
2295 >    block_state.flags.value |= CONF_FLAGS_ALLOW_AUTO_CONN;
2296   } | T_SSL
2297   {
2298    if (conf_parser_ctx.pass == 2)
2299 <    SetConfSSL(yy_aconf);
2299 >    block_state.flags.value |= CONF_FLAGS_SSL;
2300   };
2301  
2302   connect_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 2316 | Line 2304 | connect_encrypted: ENCRYPTED '=' TBOOL '
2304    if (conf_parser_ctx.pass == 2)
2305    {
2306      if (yylval.number)
2307 <      yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2307 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
2308      else
2309 <      yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2309 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
2310    }
2311   };
2312  
2313 < connect_hub_mask: HUB_MASK '=' QSTRING ';'
2313 > connect_hub_mask: HUB_MASK '=' QSTRING ';'
2314   {
2315    if (conf_parser_ctx.pass == 2)
2316 <  {
2329 <    struct CollectItem *yy_tmp;
2330 <
2331 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2332 <    DupString(yy_tmp->host, yylval.string);
2333 <    DupString(yy_tmp->user, "*");
2334 <    dlinkAdd(yy_tmp, &yy_tmp->node, &hub_conf_list);
2335 <  }
2316 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.hub.list);
2317   };
2318  
2319 < connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2319 > connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2320   {
2321    if (conf_parser_ctx.pass == 2)
2322 <  {
2342 <    struct CollectItem *yy_tmp;
2343 <
2344 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2345 <    DupString(yy_tmp->host, yylval.string);
2346 <    DupString(yy_tmp->user, "*");
2347 <    dlinkAdd(yy_tmp, &yy_tmp->node, &leaf_conf_list);
2348 <  }
2322 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.leaf.list);
2323   };
2324  
2325   connect_class: CLASS '=' QSTRING ';'
2326   {
2327    if (conf_parser_ctx.pass == 2)
2328 <  {
2355 <    MyFree(class_name);
2356 <    DupString(class_name, yylval.string);
2357 <  }
2328 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
2329   };
2330  
2331   connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2332   {
2333   #ifdef HAVE_LIBCRYPTO
2334    if (conf_parser_ctx.pass == 2)
2335 <  {
2365 <    MyFree(yy_aconf->cipher_list);
2366 <    DupString(yy_aconf->cipher_list, yylval.string);
2367 <  }
2335 >    strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
2336   #else
2337    if (conf_parser_ctx.pass == 2)
2338 <    yyerror("Ignoring connect::ciphers -- no OpenSSL support");
2338 >    conf_error_report("Ignoring connect::ciphers -- no OpenSSL support");
2339   #endif
2340   };
2341  
2342  
2343   /***************************************************************************
2344 < *  section kill
2344 > * kill {} section
2345   ***************************************************************************/
2346   kill_entry: KILL
2347   {
2348    if (conf_parser_ctx.pass == 2)
2349 <  {
2382 <    userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2383 <    regex_ban = 0;
2384 <  }
2349 >    reset_block_state();
2350   } '{' kill_items '}' ';'
2351   {
2352 <  if (conf_parser_ctx.pass == 2)
2388 <  {
2389 <    if (userbuf[0] && hostbuf[0])
2390 <    {
2391 <      if (regex_ban)
2392 <      {
2393 < #ifdef HAVE_LIBPCRE
2394 <        void *exp_user = NULL;
2395 <        void *exp_host = NULL;
2396 <        const char *errptr = NULL;
2397 <
2398 <        if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2399 <            !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2400 <        {
2401 <          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",
2402 <               errptr);
2403 <          break;
2404 <        }
2405 <
2406 <        yy_aconf = map_to_conf(make_conf_item(RKLINE_TYPE));
2407 <        yy_aconf->regexuser = exp_user;
2408 <        yy_aconf->regexhost = exp_host;
2352 >  struct MaskItem *conf = NULL;
2353  
2354 <        DupString(yy_aconf->user, userbuf);
2355 <        DupString(yy_aconf->host, hostbuf);
2354 >  if (conf_parser_ctx.pass != 2)
2355 >    break;
2356  
2357 <        if (reasonbuf[0])
2358 <          DupString(yy_aconf->reason, reasonbuf);
2359 <        else
2416 <          DupString(yy_aconf->reason, "No reason");
2417 < #else
2418 <        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");
2419 <        break;
2420 < #endif
2421 <      }
2422 <      else
2423 <      {
2424 <        yy_aconf = map_to_conf(make_conf_item(KLINE_TYPE));
2425 <
2426 <        DupString(yy_aconf->user, userbuf);
2427 <        DupString(yy_aconf->host, hostbuf);
2428 <
2429 <        if (reasonbuf[0])
2430 <          DupString(yy_aconf->reason, reasonbuf);
2431 <        else
2432 <          DupString(yy_aconf->reason, "No reason");
2433 <        add_conf_by_address(CONF_KILL, yy_aconf);
2434 <      }
2435 <    }
2436 <
2437 <    yy_aconf = NULL;
2438 <  }
2439 < };
2357 >  if (!block_state.user.buf[0] ||
2358 >      !block_state.host.buf[0])
2359 >    break;
2360  
2361 < kill_type: TYPE
2362 < {
2363 < } '='  kill_type_items ';';
2361 >  conf = conf_make(CONF_KLINE);
2362 >  conf->user = xstrdup(block_state.user.buf);
2363 >  conf->host = xstrdup(block_state.host.buf);
2364  
2365 < kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2366 < kill_type_item: REGEX_T
2367 < {
2368 <  if (conf_parser_ctx.pass == 2)
2369 <    regex_ban = 1;
2365 >  if (block_state.rpass.buf[0])
2366 >    conf->reason = xstrdup(block_state.rpass.buf);
2367 >  else
2368 >    conf->reason = xstrdup(CONF_NOREASON);
2369 >  add_conf_by_address(CONF_KLINE, conf);
2370   };
2371  
2372   kill_items:     kill_items kill_item | kill_item;
2373 < kill_item:      kill_user | kill_reason | kill_type | error;
2373 > kill_item:      kill_user | kill_reason | error;
2374  
2375   kill_user: USER '=' QSTRING ';'
2376   {
2377 +
2378    if (conf_parser_ctx.pass == 2)
2379    {
2380      struct split_nuh_item nuh;
2381  
2382      nuh.nuhmask  = yylval.string;
2383      nuh.nickptr  = NULL;
2384 <    nuh.userptr  = userbuf;
2385 <    nuh.hostptr  = hostbuf;
2384 >    nuh.userptr  = block_state.user.buf;
2385 >    nuh.hostptr  = block_state.host.buf;
2386  
2387      nuh.nicksize = 0;
2388 <    nuh.usersize = sizeof(userbuf);
2389 <    nuh.hostsize = sizeof(hostbuf);
2388 >    nuh.usersize = sizeof(block_state.user.buf);
2389 >    nuh.hostsize = sizeof(block_state.host.buf);
2390  
2391      split_nuh(&nuh);
2392    }
2393   };
2394  
2395 < kill_reason: REASON '=' QSTRING ';'
2395 > kill_reason: REASON '=' QSTRING ';'
2396   {
2397    if (conf_parser_ctx.pass == 2)
2398 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2398 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2399   };
2400  
2401 +
2402   /***************************************************************************
2403 < *  section deny
2403 > * deny {} section
2404   ***************************************************************************/
2405 < deny_entry: DENY
2405 > deny_entry: DENY
2406   {
2407    if (conf_parser_ctx.pass == 2)
2408 <    hostbuf[0] = reasonbuf[0] = '\0';
2408 >    reset_block_state();
2409   } '{' deny_items '}' ';'
2410   {
2411 <  if (conf_parser_ctx.pass == 2)
2411 >  struct MaskItem *conf = NULL;
2412 >
2413 >  if (conf_parser_ctx.pass != 2)
2414 >    break;
2415 >
2416 >  if (!block_state.addr.buf[0])
2417 >    break;
2418 >
2419 >  if (parse_netmask(block_state.addr.buf, NULL, NULL) != HM_HOST)
2420    {
2421 <    if (hostbuf[0] && parse_netmask(hostbuf, NULL, NULL) != HM_HOST)
2422 <    {
2493 <      yy_aconf = map_to_conf(make_conf_item(DLINE_TYPE));
2494 <      DupString(yy_aconf->host, hostbuf);
2421 >    conf = conf_make(CONF_DLINE);
2422 >    conf->host = xstrdup(block_state.addr.buf);
2423  
2424 <      if (reasonbuf[0])
2425 <        DupString(yy_aconf->reason, reasonbuf);
2426 <      else
2427 <        DupString(yy_aconf->reason, "No reason");
2428 <      add_conf_by_address(CONF_DLINE, yy_aconf);
2501 <      yy_aconf = NULL;
2502 <    }
2424 >    if (block_state.rpass.buf[0])
2425 >      conf->reason = xstrdup(block_state.rpass.buf);
2426 >    else
2427 >      conf->reason = xstrdup(CONF_NOREASON);
2428 >    add_conf_by_address(CONF_DLINE, conf);
2429    }
2430 < };
2430 > };
2431  
2432   deny_items:     deny_items deny_item | deny_item;
2433   deny_item:      deny_ip | deny_reason | error;
# Line 2509 | Line 2435 | deny_item:      deny_ip | deny_reason |
2435   deny_ip: IP '=' QSTRING ';'
2436   {
2437    if (conf_parser_ctx.pass == 2)
2438 <    strlcpy(hostbuf, yylval.string, sizeof(hostbuf));
2438 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
2439   };
2440  
2441 < deny_reason: REASON '=' QSTRING ';'
2441 > deny_reason: REASON '=' QSTRING ';'
2442   {
2443    if (conf_parser_ctx.pass == 2)
2444 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2444 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2445   };
2446  
2447 +
2448   /***************************************************************************
2449 < *  section exempt
2449 > * exempt {} section
2450   ***************************************************************************/
2451   exempt_entry: EXEMPT '{' exempt_items '}' ';';
2452  
2453 < exempt_items:     exempt_items exempt_item | exempt_item;
2454 < exempt_item:      exempt_ip | error;
2453 > exempt_items: exempt_items exempt_item | exempt_item;
2454 > exempt_item:  exempt_ip | error;
2455  
2456   exempt_ip: IP '=' QSTRING ';'
2457   {
2458    if (conf_parser_ctx.pass == 2)
2459    {
2460 <    if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2460 >    if (*yylval.string && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2461      {
2462 <      yy_aconf = map_to_conf(make_conf_item(EXEMPTDLINE_TYPE));
2463 <      DupString(yy_aconf->host, yylval.string);
2462 >      struct MaskItem *conf = conf_make(CONF_EXEMPT);
2463 >      conf->host = xstrdup(yylval.string);
2464  
2465 <      add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
2539 <      yy_aconf = NULL;
2465 >      add_conf_by_address(CONF_EXEMPT, conf);
2466      }
2467    }
2468   };
2469  
2470   /***************************************************************************
2471 < *  section gecos
2471 > * gecos {} section
2472   ***************************************************************************/
2473   gecos_entry: GECOS
2474   {
2475    if (conf_parser_ctx.pass == 2)
2476 <  {
2551 <    regex_ban = 0;
2552 <    reasonbuf[0] = gecos_name[0] = '\0';
2553 <  }
2476 >    reset_block_state();
2477   } '{' gecos_items '}' ';'
2478   {
2479 <  if (conf_parser_ctx.pass == 2)
2557 <  {
2558 <    if (gecos_name[0])
2559 <    {
2560 <      if (regex_ban)
2561 <      {
2562 < #ifdef HAVE_LIBPCRE
2563 <        void *exp_p = NULL;
2564 <        const char *errptr = NULL;
2565 <
2566 <        if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2567 <        {
2568 <          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: %s",
2569 <               errptr);
2570 <          break;
2571 <        }
2479 >  struct MaskItem *conf = NULL;
2480  
2481 <        yy_conf = make_conf_item(RXLINE_TYPE);
2482 <        yy_conf->regexpname = exp_p;
2575 < #else
2576 <        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: no PCRE support");
2577 <        break;
2578 < #endif
2579 <      }
2580 <      else
2581 <        yy_conf = make_conf_item(XLINE_TYPE);
2481 >  if (conf_parser_ctx.pass != 2)
2482 >    break;
2483  
2484 <      yy_match_item = map_to_conf(yy_conf);
2485 <      DupString(yy_conf->name, gecos_name);
2585 <
2586 <      if (reasonbuf[0])
2587 <        DupString(yy_match_item->reason, reasonbuf);
2588 <      else
2589 <        DupString(yy_match_item->reason, "No reason");
2590 <    }
2591 <  }
2592 < };
2484 >  if (!block_state.name.buf[0])
2485 >    break;
2486  
2487 < gecos_flags: TYPE
2488 < {
2596 < } '='  gecos_flags_items ';';
2487 >  conf = conf_make(CONF_XLINE);
2488 >  conf->name = xstrdup(block_state.name.buf);
2489  
2490 < gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2491 < gecos_flags_item: REGEX_T
2492 < {
2493 <  if (conf_parser_ctx.pass == 2)
2602 <    regex_ban = 1;
2490 >  if (block_state.rpass.buf[0])
2491 >    conf->reason = xstrdup(block_state.rpass.buf);
2492 >  else
2493 >    conf->reason = xstrdup(CONF_NOREASON);
2494   };
2495  
2496   gecos_items: gecos_items gecos_item | gecos_item;
2497 < gecos_item:  gecos_name | gecos_reason | gecos_flags | error;
2497 > gecos_item:  gecos_name | gecos_reason | error;
2498  
2499 < gecos_name: NAME '=' QSTRING ';'
2499 > gecos_name: NAME '=' QSTRING ';'
2500   {
2501    if (conf_parser_ctx.pass == 2)
2502 <    strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2502 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2503   };
2504  
2505 < gecos_reason: REASON '=' QSTRING ';'
2505 > gecos_reason: REASON '=' QSTRING ';'
2506   {
2507    if (conf_parser_ctx.pass == 2)
2508 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2508 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2509   };
2510  
2511 +
2512   /***************************************************************************
2513 < *  section general
2513 > * general {} section
2514   ***************************************************************************/
2515 < general_entry: GENERAL
2624 <  '{' general_items '}' ';';
2515 > general_entry: GENERAL '{' general_items '}' ';';
2516  
2517   general_items:      general_items general_item | general_item;
2518 < general_item:       general_hide_spoof_ips | general_ignore_bogus_ts |
2519 <                    general_failed_oper_notice | general_anti_nick_flood |
2520 <                    general_max_nick_time | general_max_nick_changes |
2521 <                    general_max_accept | general_anti_spam_exit_message_time |
2522 <                    general_ts_warn_delta | general_ts_max_delta |
2523 <                    general_kill_chase_time_limit | general_kline_with_reason |
2524 <                    general_kline_reason | general_invisible_on_connect |
2525 <                    general_warn_no_nline | general_dots_in_ident |
2526 <                    general_stats_o_oper_only | general_stats_k_oper_only |
2527 <                    general_pace_wait | general_stats_i_oper_only |
2528 <                    general_pace_wait_simple | general_stats_P_oper_only |
2529 <                    general_short_motd | general_no_oper_flood |
2530 <                    general_true_no_oper_flood | general_oper_pass_resv |
2531 <                    general_message_locale |
2532 <                    general_oper_only_umodes | general_max_targets |
2533 <                    general_use_egd | general_egdpool_path |
2534 <                    general_oper_umodes | general_caller_id_wait |
2535 <                    general_opers_bypass_callerid | general_default_floodcount |
2536 <                    general_min_nonwildcard | general_min_nonwildcard_simple |
2537 <                    general_disable_remote_commands |
2538 <                    general_client_flood |
2539 <                    general_throttle_time | general_havent_read_conf |
2518 > general_item:       general_away_count |
2519 >                    general_away_time |
2520 >                    general_ignore_bogus_ts |
2521 >                    general_failed_oper_notice |
2522 >                    general_anti_nick_flood |
2523 >                    general_max_nick_time |
2524 >                    general_max_nick_changes |
2525 >                    general_max_accept |
2526 >                    general_anti_spam_exit_message_time |
2527 >                    general_ts_warn_delta |
2528 >                    general_ts_max_delta |
2529 >                    general_kill_chase_time_limit |
2530 >                    general_invisible_on_connect |
2531 >                    general_warn_no_connect_block |
2532 >                    general_dots_in_ident |
2533 >                    general_stats_i_oper_only |
2534 >                    general_stats_k_oper_only |
2535 >                    general_stats_m_oper_only |
2536 >                    general_stats_o_oper_only |
2537 >                    general_stats_P_oper_only |
2538 >                    general_stats_u_oper_only |
2539 >                    general_pace_wait |
2540 >                    general_pace_wait_simple |
2541 >                    general_short_motd |
2542 >                    general_no_oper_flood |
2543 >                    general_oper_only_umodes |
2544 >                    general_max_targets |
2545 >                    general_oper_umodes |
2546 >                    general_caller_id_wait |
2547 >                    general_opers_bypass_callerid |
2548 >                    general_default_floodcount |
2549 >                    general_min_nonwildcard |
2550 >                    general_min_nonwildcard_simple |
2551 >                    general_throttle_count |
2552 >                    general_throttle_time |
2553                      general_ping_cookie |
2554 <                    general_disable_auth |
2555 <                    general_tkline_expire_notices | general_gline_min_cidr |
2556 <                    general_gline_min_cidr6 | general_use_whois_actually |
2557 <                    general_reject_hold_time | general_stats_e_disabled |
2558 <                    general_max_watch | general_services_name |
2559 <                    error;
2554 >                    general_disable_auth |
2555 >                    general_tkline_expire_notices |
2556 >                    general_dline_min_cidr |
2557 >                    general_dline_min_cidr6 |
2558 >                    general_kline_min_cidr |
2559 >                    general_kline_min_cidr6 |
2560 >                    general_stats_e_disabled |
2561 >                    general_max_watch |
2562 >                    general_cycle_on_host_change |
2563 >                    error;
2564  
2565  
2566 < general_max_watch: MAX_WATCH '=' NUMBER ';'
2566 > general_away_count: AWAY_COUNT '=' NUMBER ';'
2567   {
2568 <  ConfigFileEntry.max_watch = $3;
2568 >  ConfigGeneral.away_count = $3;
2569   };
2570  
2571 < general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2571 > general_away_time: AWAY_TIME '=' timespec ';'
2572   {
2573 <  ConfigFileEntry.gline_min_cidr = $3;
2573 >  ConfigGeneral.away_time = $3;
2574   };
2575  
2576 < general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2576 > general_max_watch: MAX_WATCH '=' NUMBER ';'
2577   {
2578 <  ConfigFileEntry.gline_min_cidr6 = $3;
2578 >  ConfigGeneral.max_watch = $3;
2579   };
2580  
2581 < general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
2581 > general_cycle_on_host_change: CYCLE_ON_HOST_CHANGE '=' TBOOL ';'
2582   {
2583 <  ConfigFileEntry.use_whois_actually = yylval.number;
2583 >  if (conf_parser_ctx.pass == 2)
2584 >    ConfigGeneral.cycle_on_host_change = yylval.number;
2585   };
2586  
2587 < general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
2587 > general_dline_min_cidr: DLINE_MIN_CIDR '=' NUMBER ';'
2588   {
2589 <  GlobalSetOptions.rejecttime = yylval.number;
2589 >  ConfigGeneral.dline_min_cidr = $3;
2590   };
2591  
2592 < general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
2592 > general_dline_min_cidr6: DLINE_MIN_CIDR6 '=' NUMBER ';'
2593   {
2594 <  ConfigFileEntry.tkline_expire_notices = yylval.number;
2594 >  ConfigGeneral.dline_min_cidr6 = $3;
2595   };
2596  
2597 < general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' timespec ';'
2597 > general_kline_min_cidr: KLINE_MIN_CIDR '=' NUMBER ';'
2598   {
2599 <  ConfigFileEntry.kill_chase_time_limit = $3;
2599 >  ConfigGeneral.kline_min_cidr = $3;
2600   };
2601  
2602 < general_hide_spoof_ips: HIDE_SPOOF_IPS '=' TBOOL ';'
2602 > general_kline_min_cidr6: KLINE_MIN_CIDR6 '=' NUMBER ';'
2603   {
2604 <  ConfigFileEntry.hide_spoof_ips = yylval.number;
2604 >  ConfigGeneral.kline_min_cidr6 = $3;
2605   };
2606  
2607 < general_ignore_bogus_ts: IGNORE_BOGUS_TS '=' TBOOL ';'
2607 > general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
2608   {
2609 <  ConfigFileEntry.ignore_bogus_ts = yylval.number;
2609 >  ConfigGeneral.tkline_expire_notices = yylval.number;
2610   };
2611  
2612 < general_disable_remote_commands: DISABLE_REMOTE_COMMANDS '=' TBOOL ';'
2612 > general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' timespec ';'
2613   {
2614 <  ConfigFileEntry.disable_remote = yylval.number;
2614 >  ConfigGeneral.kill_chase_time_limit = $3;
2615 > };
2616 >
2617 > general_ignore_bogus_ts: IGNORE_BOGUS_TS '=' TBOOL ';'
2618 > {
2619 >  ConfigGeneral.ignore_bogus_ts = yylval.number;
2620   };
2621  
2622   general_failed_oper_notice: FAILED_OPER_NOTICE '=' TBOOL ';'
2623   {
2624 <  ConfigFileEntry.failed_oper_notice = yylval.number;
2624 >  ConfigGeneral.failed_oper_notice = yylval.number;
2625   };
2626  
2627   general_anti_nick_flood: ANTI_NICK_FLOOD '=' TBOOL ';'
2628   {
2629 <  ConfigFileEntry.anti_nick_flood = yylval.number;
2629 >  ConfigGeneral.anti_nick_flood = yylval.number;
2630   };
2631  
2632   general_max_nick_time: MAX_NICK_TIME '=' timespec ';'
2633   {
2634 <  ConfigFileEntry.max_nick_time = $3;
2634 >  ConfigGeneral.max_nick_time = $3;
2635   };
2636  
2637   general_max_nick_changes: MAX_NICK_CHANGES '=' NUMBER ';'
2638   {
2639 <  ConfigFileEntry.max_nick_changes = $3;
2639 >  ConfigGeneral.max_nick_changes = $3;
2640   };
2641  
2642   general_max_accept: MAX_ACCEPT '=' NUMBER ';'
2643   {
2644 <  ConfigFileEntry.max_accept = $3;
2644 >  ConfigGeneral.max_accept = $3;
2645   };
2646  
2647   general_anti_spam_exit_message_time: ANTI_SPAM_EXIT_MESSAGE_TIME '=' timespec ';'
2648   {
2649 <  ConfigFileEntry.anti_spam_exit_message_time = $3;
2649 >  ConfigGeneral.anti_spam_exit_message_time = $3;
2650   };
2651  
2652   general_ts_warn_delta: TS_WARN_DELTA '=' timespec ';'
2653   {
2654 <  ConfigFileEntry.ts_warn_delta = $3;
2654 >  ConfigGeneral.ts_warn_delta = $3;
2655   };
2656  
2657   general_ts_max_delta: TS_MAX_DELTA '=' timespec ';'
2658   {
2659    if (conf_parser_ctx.pass == 2)
2660 <    ConfigFileEntry.ts_max_delta = $3;
2660 >    ConfigGeneral.ts_max_delta = $3;
2661   };
2662  
2663 < general_havent_read_conf: HAVENT_READ_CONF '=' NUMBER ';'
2750 < {
2751 <  if (($3 > 0) && conf_parser_ctx.pass == 1)
2752 <  {
2753 <    ilog(LOG_TYPE_IRCD, "You haven't read your config file properly.");
2754 <    ilog(LOG_TYPE_IRCD, "There is a line in the example conf that will kill your server if not removed.");
2755 <    ilog(LOG_TYPE_IRCD, "Consider actually reading/editing the conf file, and removing this line.");
2756 <    exit(0);
2757 <  }
2758 < };
2759 <
2760 < general_kline_with_reason: KLINE_WITH_REASON '=' TBOOL ';'
2663 > general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
2664   {
2665 <  ConfigFileEntry.kline_with_reason = yylval.number;
2665 >  ConfigGeneral.invisible_on_connect = yylval.number;
2666   };
2667  
2668 < general_kline_reason: KLINE_REASON '=' QSTRING ';'
2668 > general_warn_no_connect_block: WARN_NO_CONNECT_BLOCK '=' TBOOL ';'
2669   {
2670 <  if (conf_parser_ctx.pass == 2)
2768 <  {
2769 <    MyFree(ConfigFileEntry.kline_reason);
2770 <    DupString(ConfigFileEntry.kline_reason, yylval.string);
2771 <  }
2670 >  ConfigGeneral.warn_no_connect_block = yylval.number;
2671   };
2672  
2673 < general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
2673 > general_stats_e_disabled: STATS_E_DISABLED '=' TBOOL ';'
2674   {
2675 <  ConfigFileEntry.invisible_on_connect = yylval.number;
2675 >  ConfigGeneral.stats_e_disabled = yylval.number;
2676   };
2677  
2678 < general_warn_no_nline: WARN_NO_NLINE '=' TBOOL ';'
2678 > general_stats_m_oper_only: STATS_M_OPER_ONLY '=' TBOOL ';'
2679   {
2680 <  ConfigFileEntry.warn_no_nline = yylval.number;
2680 >  ConfigGeneral.stats_m_oper_only = yylval.number;
2681   };
2682  
2683 < general_stats_e_disabled: STATS_E_DISABLED '=' TBOOL ';'
2683 > general_stats_o_oper_only: STATS_O_OPER_ONLY '=' TBOOL ';'
2684   {
2685 <  ConfigFileEntry.stats_e_disabled = yylval.number;
2685 >  ConfigGeneral.stats_o_oper_only = yylval.number;
2686   };
2687  
2688 < general_stats_o_oper_only: STATS_O_OPER_ONLY '=' TBOOL ';'
2688 > general_stats_P_oper_only: STATS_P_OPER_ONLY '=' TBOOL ';'
2689   {
2690 <  ConfigFileEntry.stats_o_oper_only = yylval.number;
2690 >  ConfigGeneral.stats_P_oper_only = yylval.number;
2691   };
2692  
2693 < general_stats_P_oper_only: STATS_P_OPER_ONLY '=' TBOOL ';'
2693 > general_stats_u_oper_only: STATS_U_OPER_ONLY '=' TBOOL ';'
2694   {
2695 <  ConfigFileEntry.stats_P_oper_only = yylval.number;
2695 >  ConfigGeneral.stats_u_oper_only = yylval.number;
2696   };
2697  
2698   general_stats_k_oper_only: STATS_K_OPER_ONLY '=' TBOOL ';'
2699   {
2700 <  ConfigFileEntry.stats_k_oper_only = 2 * yylval.number;
2700 >  ConfigGeneral.stats_k_oper_only = 2 * yylval.number;
2701   } | STATS_K_OPER_ONLY '=' TMASKED ';'
2702   {
2703 <  ConfigFileEntry.stats_k_oper_only = 1;
2703 >  ConfigGeneral.stats_k_oper_only = 1;
2704   };
2705  
2706   general_stats_i_oper_only: STATS_I_OPER_ONLY '=' TBOOL ';'
2707   {
2708 <  ConfigFileEntry.stats_i_oper_only = 2 * yylval.number;
2708 >  ConfigGeneral.stats_i_oper_only = 2 * yylval.number;
2709   } | STATS_I_OPER_ONLY '=' TMASKED ';'
2710   {
2711 <  ConfigFileEntry.stats_i_oper_only = 1;
2711 >  ConfigGeneral.stats_i_oper_only = 1;
2712   };
2713  
2714   general_pace_wait: PACE_WAIT '=' timespec ';'
2715   {
2716 <  ConfigFileEntry.pace_wait = $3;
2716 >  ConfigGeneral.pace_wait = $3;
2717   };
2718  
2719   general_caller_id_wait: CALLER_ID_WAIT '=' timespec ';'
2720   {
2721 <  ConfigFileEntry.caller_id_wait = $3;
2721 >  ConfigGeneral.caller_id_wait = $3;
2722   };
2723  
2724   general_opers_bypass_callerid: OPERS_BYPASS_CALLERID '=' TBOOL ';'
2725   {
2726 <  ConfigFileEntry.opers_bypass_callerid = yylval.number;
2726 >  ConfigGeneral.opers_bypass_callerid = yylval.number;
2727   };
2728  
2729   general_pace_wait_simple: PACE_WAIT_SIMPLE '=' timespec ';'
2730   {
2731 <  ConfigFileEntry.pace_wait_simple = $3;
2731 >  ConfigGeneral.pace_wait_simple = $3;
2732   };
2733  
2734   general_short_motd: SHORT_MOTD '=' TBOOL ';'
2735   {
2736 <  ConfigFileEntry.short_motd = yylval.number;
2838 < };
2839 <  
2840 < general_no_oper_flood: NO_OPER_FLOOD '=' TBOOL ';'
2841 < {
2842 <  ConfigFileEntry.no_oper_flood = yylval.number;
2843 < };
2844 <
2845 < general_true_no_oper_flood: TRUE_NO_OPER_FLOOD '=' TBOOL ';'
2846 < {
2847 <  ConfigFileEntry.true_no_oper_flood = yylval.number;
2848 < };
2849 <
2850 < general_oper_pass_resv: OPER_PASS_RESV '=' TBOOL ';'
2851 < {
2852 <  ConfigFileEntry.oper_pass_resv = yylval.number;
2736 >  ConfigGeneral.short_motd = yylval.number;
2737   };
2738  
2739 < general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
2739 > general_no_oper_flood: NO_OPER_FLOOD '=' TBOOL ';'
2740   {
2741 <  if (conf_parser_ctx.pass == 2)
2858 <  {
2859 <    if (strlen(yylval.string) > LOCALE_LENGTH-2)
2860 <      yylval.string[LOCALE_LENGTH-1] = '\0';
2861 <
2862 <    set_locale(yylval.string);
2863 <  }
2741 >  ConfigGeneral.no_oper_flood = yylval.number;
2742   };
2743  
2744   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2745   {
2746 <  ConfigFileEntry.dots_in_ident = $3;
2746 >  ConfigGeneral.dots_in_ident = $3;
2747   };
2748  
2749   general_max_targets: MAX_TARGETS '=' NUMBER ';'
2750   {
2751 <  ConfigFileEntry.max_targets = $3;
2751 >  ConfigGeneral.max_targets = $3;
2752   };
2753  
2754 < general_use_egd: USE_EGD '=' TBOOL ';'
2877 < {
2878 <  ConfigFileEntry.use_egd = yylval.number;
2879 < };
2880 <
2881 < general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
2882 < {
2883 <  if (conf_parser_ctx.pass == 2)
2884 <  {
2885 <    MyFree(ConfigFileEntry.egdpool_path);
2886 <    DupString(ConfigFileEntry.egdpool_path, yylval.string);
2887 <  }
2888 < };
2889 <
2890 < general_services_name: T_SERVICES_NAME '=' QSTRING ';'
2754 > general_ping_cookie: PING_COOKIE '=' TBOOL ';'
2755   {
2756 <  if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
2893 <  {
2894 <    MyFree(ConfigFileEntry.service_name);
2895 <    DupString(ConfigFileEntry.service_name, yylval.string);
2896 <  }
2756 >  ConfigGeneral.ping_cookie = yylval.number;
2757   };
2758  
2759 < general_ping_cookie: PING_COOKIE '=' TBOOL ';'
2759 > general_disable_auth: DISABLE_AUTH '=' TBOOL ';'
2760   {
2761 <  ConfigFileEntry.ping_cookie = yylval.number;
2761 >  ConfigGeneral.disable_auth = yylval.number;
2762   };
2763  
2764 < general_disable_auth: DISABLE_AUTH '=' TBOOL ';'
2764 > general_throttle_count: THROTTLE_COUNT '=' NUMBER ';'
2765   {
2766 <  ConfigFileEntry.disable_auth = yylval.number;
2766 >  ConfigGeneral.throttle_count = $3;
2767   };
2768  
2769   general_throttle_time: THROTTLE_TIME '=' timespec ';'
2770   {
2771 <  ConfigFileEntry.throttle_time = yylval.number;
2771 >  ConfigGeneral.throttle_time = $3;
2772   };
2773  
2774   general_oper_umodes: OPER_UMODES
2775   {
2776 <  ConfigFileEntry.oper_umodes = 0;
2776 >  ConfigGeneral.oper_umodes = 0;
2777   } '='  umode_oitems ';' ;
2778  
2779   umode_oitems:    umode_oitems ',' umode_oitem | umode_oitem;
2780   umode_oitem:     T_BOTS
2781   {
2782 <  ConfigFileEntry.oper_umodes |= UMODE_BOTS;
2782 >  ConfigGeneral.oper_umodes |= UMODE_BOTS;
2783   } | T_CCONN
2784   {
2785 <  ConfigFileEntry.oper_umodes |= UMODE_CCONN;
2926 < } | T_CCONN_FULL
2927 < {
2928 <  ConfigFileEntry.oper_umodes |= UMODE_CCONN_FULL;
2785 >  ConfigGeneral.oper_umodes |= UMODE_CCONN;
2786   } | T_DEAF
2787   {
2788 <  ConfigFileEntry.oper_umodes |= UMODE_DEAF;
2788 >  ConfigGeneral.oper_umodes |= UMODE_DEAF;
2789   } | T_DEBUG
2790   {
2791 <  ConfigFileEntry.oper_umodes |= UMODE_DEBUG;
2791 >  ConfigGeneral.oper_umodes |= UMODE_DEBUG;
2792   } | T_FULL
2793   {
2794 <  ConfigFileEntry.oper_umodes |= UMODE_FULL;
2794 >  ConfigGeneral.oper_umodes |= UMODE_FULL;
2795   } | HIDDEN
2796   {
2797 <  ConfigFileEntry.oper_umodes |= UMODE_HIDDEN;
2797 >  ConfigGeneral.oper_umodes |= UMODE_HIDDEN;
2798 > } | HIDE_CHANS
2799 > {
2800 >  ConfigGeneral.oper_umodes |= UMODE_HIDECHANS;
2801 > } | HIDE_IDLE
2802 > {
2803 >  ConfigGeneral.oper_umodes |= UMODE_HIDEIDLE;
2804   } | T_SKILL
2805   {
2806 <  ConfigFileEntry.oper_umodes |= UMODE_SKILL;
2806 >  ConfigGeneral.oper_umodes |= UMODE_SKILL;
2807   } | T_NCHANGE
2808   {
2809 <  ConfigFileEntry.oper_umodes |= UMODE_NCHANGE;
2809 >  ConfigGeneral.oper_umodes |= UMODE_NCHANGE;
2810   } | T_REJ
2811   {
2812 <  ConfigFileEntry.oper_umodes |= UMODE_REJ;
2812 >  ConfigGeneral.oper_umodes |= UMODE_REJ;
2813   } | T_UNAUTH
2814   {
2815 <  ConfigFileEntry.oper_umodes |= UMODE_UNAUTH;
2815 >  ConfigGeneral.oper_umodes |= UMODE_UNAUTH;
2816   } | T_SPY
2817   {
2818 <  ConfigFileEntry.oper_umodes |= UMODE_SPY;
2818 >  ConfigGeneral.oper_umodes |= UMODE_SPY;
2819   } | T_EXTERNAL
2820   {
2821 <  ConfigFileEntry.oper_umodes |= UMODE_EXTERNAL;
2959 < } | T_OPERWALL
2960 < {
2961 <  ConfigFileEntry.oper_umodes |= UMODE_OPERWALL;
2821 >  ConfigGeneral.oper_umodes |= UMODE_EXTERNAL;
2822   } | T_SERVNOTICE
2823   {
2824 <  ConfigFileEntry.oper_umodes |= UMODE_SERVNOTICE;
2824 >  ConfigGeneral.oper_umodes |= UMODE_SERVNOTICE;
2825   } | T_INVISIBLE
2826   {
2827 <  ConfigFileEntry.oper_umodes |= UMODE_INVISIBLE;
2827 >  ConfigGeneral.oper_umodes |= UMODE_INVISIBLE;
2828   } | T_WALLOP
2829   {
2830 <  ConfigFileEntry.oper_umodes |= UMODE_WALLOP;
2830 >  ConfigGeneral.oper_umodes |= UMODE_WALLOP;
2831   } | T_SOFTCALLERID
2832   {
2833 <  ConfigFileEntry.oper_umodes |= UMODE_SOFTCALLERID;
2833 >  ConfigGeneral.oper_umodes |= UMODE_SOFTCALLERID;
2834   } | T_CALLERID
2835   {
2836 <  ConfigFileEntry.oper_umodes |= UMODE_CALLERID;
2836 >  ConfigGeneral.oper_umodes |= UMODE_CALLERID;
2837   } | T_LOCOPS
2838   {
2839 <  ConfigFileEntry.oper_umodes |= UMODE_LOCOPS;
2839 >  ConfigGeneral.oper_umodes |= UMODE_LOCOPS;
2840 > } | T_NONONREG
2841 > {
2842 >  ConfigGeneral.oper_umodes |= UMODE_REGONLY;
2843 > } | T_FARCONNECT
2844 > {
2845 >  ConfigGeneral.oper_umodes |= UMODE_FARCONNECT;
2846   };
2847  
2848 < general_oper_only_umodes: OPER_ONLY_UMODES
2848 > general_oper_only_umodes: OPER_ONLY_UMODES
2849   {
2850 <  ConfigFileEntry.oper_only_umodes = 0;
2850 >  ConfigGeneral.oper_only_umodes = 0;
2851   } '='  umode_items ';' ;
2852  
2853 < umode_items:    umode_items ',' umode_item | umode_item;
2854 < umode_item:     T_BOTS
2853 > umode_items:  umode_items ',' umode_item | umode_item;
2854 > umode_item:   T_BOTS
2855   {
2856 <  ConfigFileEntry.oper_only_umodes |= UMODE_BOTS;
2856 >  ConfigGeneral.oper_only_umodes |= UMODE_BOTS;
2857   } | T_CCONN
2858   {
2859 <  ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
2994 < } | T_CCONN_FULL
2995 < {
2996 <  ConfigFileEntry.oper_only_umodes |= UMODE_CCONN_FULL;
2859 >  ConfigGeneral.oper_only_umodes |= UMODE_CCONN;
2860   } | T_DEAF
2861   {
2862 <  ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
2862 >  ConfigGeneral.oper_only_umodes |= UMODE_DEAF;
2863   } | T_DEBUG
2864   {
2865 <  ConfigFileEntry.oper_only_umodes |= UMODE_DEBUG;
2865 >  ConfigGeneral.oper_only_umodes |= UMODE_DEBUG;
2866   } | T_FULL
2867 < {
2868 <  ConfigFileEntry.oper_only_umodes |= UMODE_FULL;
2867 > {
2868 >  ConfigGeneral.oper_only_umodes |= UMODE_FULL;
2869   } | T_SKILL
2870   {
2871 <  ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
2871 >  ConfigGeneral.oper_only_umodes |= UMODE_SKILL;
2872   } | HIDDEN
2873   {
2874 <  ConfigFileEntry.oper_only_umodes |= UMODE_HIDDEN;
2874 >  ConfigGeneral.oper_only_umodes |= UMODE_HIDDEN;
2875   } | T_NCHANGE
2876   {
2877 <  ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
2877 >  ConfigGeneral.oper_only_umodes |= UMODE_NCHANGE;
2878   } | T_REJ
2879   {
2880 <  ConfigFileEntry.oper_only_umodes |= UMODE_REJ;
2880 >  ConfigGeneral.oper_only_umodes |= UMODE_REJ;
2881   } | T_UNAUTH
2882   {
2883 <  ConfigFileEntry.oper_only_umodes |= UMODE_UNAUTH;
2883 >  ConfigGeneral.oper_only_umodes |= UMODE_UNAUTH;
2884   } | T_SPY
2885   {
2886 <  ConfigFileEntry.oper_only_umodes |= UMODE_SPY;
2886 >  ConfigGeneral.oper_only_umodes |= UMODE_SPY;
2887   } | T_EXTERNAL
2888   {
2889 <  ConfigFileEntry.oper_only_umodes |= UMODE_EXTERNAL;
3027 < } | T_OPERWALL
3028 < {
3029 <  ConfigFileEntry.oper_only_umodes |= UMODE_OPERWALL;
2889 >  ConfigGeneral.oper_only_umodes |= UMODE_EXTERNAL;
2890   } | T_SERVNOTICE
2891   {
2892 <  ConfigFileEntry.oper_only_umodes |= UMODE_SERVNOTICE;
2892 >  ConfigGeneral.oper_only_umodes |= UMODE_SERVNOTICE;
2893   } | T_INVISIBLE
2894   {
2895 <  ConfigFileEntry.oper_only_umodes |= UMODE_INVISIBLE;
2895 >  ConfigGeneral.oper_only_umodes |= UMODE_INVISIBLE;
2896   } | T_WALLOP
2897   {
2898 <  ConfigFileEntry.oper_only_umodes |= UMODE_WALLOP;
2898 >  ConfigGeneral.oper_only_umodes |= UMODE_WALLOP;
2899   } | T_SOFTCALLERID
2900   {
2901 <  ConfigFileEntry.oper_only_umodes |= UMODE_SOFTCALLERID;
2901 >  ConfigGeneral.oper_only_umodes |= UMODE_SOFTCALLERID;
2902   } | T_CALLERID
2903   {
2904 <  ConfigFileEntry.oper_only_umodes |= UMODE_CALLERID;
2904 >  ConfigGeneral.oper_only_umodes |= UMODE_CALLERID;
2905   } | T_LOCOPS
2906   {
2907 <  ConfigFileEntry.oper_only_umodes |= UMODE_LOCOPS;
2907 >  ConfigGeneral.oper_only_umodes |= UMODE_LOCOPS;
2908 > } | T_NONONREG
2909 > {
2910 >  ConfigGeneral.oper_only_umodes |= UMODE_REGONLY;
2911 > } | T_FARCONNECT
2912 > {
2913 >  ConfigGeneral.oper_only_umodes |= UMODE_FARCONNECT;
2914   };
2915  
2916   general_min_nonwildcard: MIN_NONWILDCARD '=' NUMBER ';'
2917   {
2918 <  ConfigFileEntry.min_nonwildcard = $3;
2918 >  ConfigGeneral.min_nonwildcard = $3;
2919   };
2920  
2921   general_min_nonwildcard_simple: MIN_NONWILDCARD_SIMPLE '=' NUMBER ';'
2922   {
2923 <  ConfigFileEntry.min_nonwildcard_simple = $3;
2923 >  ConfigGeneral.min_nonwildcard_simple = $3;
2924   };
2925  
2926   general_default_floodcount: DEFAULT_FLOODCOUNT '=' NUMBER ';'
2927   {
2928 <  ConfigFileEntry.default_floodcount = $3;
3063 < };
3064 <
3065 < general_client_flood: T_CLIENT_FLOOD '=' sizespec ';'
3066 < {
3067 <  ConfigFileEntry.client_flood = $3;
3068 < };
3069 <
3070 <
3071 < /***************************************************************************
3072 < *  section glines
3073 < ***************************************************************************/
3074 < gline_entry: GLINES
3075 < {
3076 <  if (conf_parser_ctx.pass == 2)
3077 <  {
3078 <    yy_conf = make_conf_item(GDENY_TYPE);
3079 <    yy_aconf = map_to_conf(yy_conf);
3080 <  }
3081 < } '{' gline_items '}' ';'
3082 < {
3083 <  if (conf_parser_ctx.pass == 2)
3084 <  {
3085 <    /*
3086 <     * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3087 <     * end we will have one extra, so we should free it.
3088 <     */
3089 <    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3090 <    {
3091 <      delete_conf_item(yy_conf);
3092 <      yy_conf = NULL;
3093 <      yy_aconf = NULL;
3094 <    }
3095 <  }
3096 < };
3097 <
3098 < gline_items:        gline_items gline_item | gline_item;
3099 < gline_item:         gline_enable |
3100 <                    gline_duration |
3101 <                    gline_logging |
3102 <                    gline_user |
3103 <                    gline_server |
3104 <                    gline_action |
3105 <                    error;
3106 <
3107 < gline_enable: ENABLE '=' TBOOL ';'
3108 < {
3109 <  if (conf_parser_ctx.pass == 2)
3110 <    ConfigFileEntry.glines = yylval.number;
3111 < };
3112 <
3113 < gline_duration: DURATION '=' timespec ';'
3114 < {
3115 <  if (conf_parser_ctx.pass == 2)
3116 <    ConfigFileEntry.gline_time = $3;
3117 < };
3118 <
3119 < gline_logging: T_LOG
3120 < {
3121 <  if (conf_parser_ctx.pass == 2)
3122 <    ConfigFileEntry.gline_logging = 0;
3123 < } '=' gline_logging_types ';';
3124 < gline_logging_types:     gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3125 < gline_logging_type_item: T_REJECT
3126 < {
3127 <  if (conf_parser_ctx.pass == 2)
3128 <    ConfigFileEntry.gline_logging |= GDENY_REJECT;
3129 < } | T_BLOCK
3130 < {
3131 <  if (conf_parser_ctx.pass == 2)
3132 <    ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3133 < };
3134 <
3135 < gline_user: USER '=' QSTRING ';'
3136 < {
3137 <  if (conf_parser_ctx.pass == 2)
3138 <  {
3139 <    struct split_nuh_item nuh;
3140 <
3141 <    nuh.nuhmask  = yylval.string;
3142 <    nuh.nickptr  = NULL;
3143 <    nuh.userptr  = userbuf;
3144 <    nuh.hostptr  = hostbuf;
3145 <
3146 <    nuh.nicksize = 0;
3147 <    nuh.usersize = sizeof(userbuf);
3148 <    nuh.hostsize = sizeof(hostbuf);
3149 <
3150 <    split_nuh(&nuh);
3151 <
3152 <    if (yy_aconf->user == NULL)
3153 <    {
3154 <      DupString(yy_aconf->user, userbuf);
3155 <      DupString(yy_aconf->host, hostbuf);
3156 <    }
3157 <    else
3158 <    {
3159 <      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
3160 <
3161 <      DupString(yy_tmp->user, userbuf);
3162 <      DupString(yy_tmp->host, hostbuf);
3163 <
3164 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3165 <    }
3166 <  }
3167 < };
3168 <
3169 < gline_server: NAME '=' QSTRING ';'
3170 < {
3171 <  if (conf_parser_ctx.pass == 2)  
3172 <  {
3173 <    MyFree(yy_conf->name);
3174 <    DupString(yy_conf->name, yylval.string);
3175 <  }
3176 < };
3177 <
3178 < gline_action: ACTION
3179 < {
3180 <  if (conf_parser_ctx.pass == 2)
3181 <    yy_aconf->flags = 0;
3182 < } '=' gdeny_types ';'
3183 < {
3184 <  if (conf_parser_ctx.pass == 2)
3185 <  {
3186 <    struct CollectItem *yy_tmp = NULL;
3187 <    dlink_node *ptr, *next_ptr;
3188 <
3189 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
3190 <    {
3191 <      struct AccessItem *new_aconf;
3192 <      struct ConfItem *new_conf;
3193 <
3194 <      yy_tmp = ptr->data;
3195 <      new_conf = make_conf_item(GDENY_TYPE);
3196 <      new_aconf = map_to_conf(new_conf);
3197 <
3198 <      new_aconf->flags = yy_aconf->flags;
3199 <
3200 <      if (yy_conf->name != NULL)
3201 <        DupString(new_conf->name, yy_conf->name);
3202 <      else
3203 <        DupString(new_conf->name, "*");
3204 <      if (yy_aconf->user != NULL)
3205 <         DupString(new_aconf->user, yy_tmp->user);
3206 <      else  
3207 <        DupString(new_aconf->user, "*");
3208 <      if (yy_aconf->host != NULL)
3209 <        DupString(new_aconf->host, yy_tmp->host);
3210 <      else
3211 <        DupString(new_aconf->host, "*");
3212 <
3213 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
3214 <    }
3215 <
3216 <    /*
3217 <     * In case someone has fed us with more than one action= after user/name
3218 <     * which would leak memory  -Michael
3219 <     */
3220 <    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3221 <      delete_conf_item(yy_conf);
3222 <
3223 <    yy_conf = make_conf_item(GDENY_TYPE);
3224 <    yy_aconf = map_to_conf(yy_conf);
3225 <  }
2928 >  ConfigGeneral.default_floodcount = $3;
2929   };
2930  
3228 gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3229 gdeny_type_item: T_REJECT
3230 {
3231  if (conf_parser_ctx.pass == 2)
3232    yy_aconf->flags |= GDENY_REJECT;
3233 } | T_BLOCK
3234 {
3235  if (conf_parser_ctx.pass == 2)
3236    yy_aconf->flags |= GDENY_BLOCK;
3237 };
2931  
2932   /***************************************************************************
2933 < *  section channel
2933 > * channel {} section
2934   ***************************************************************************/
2935 < channel_entry: CHANNEL
3243 <  '{' channel_items '}' ';';
2935 > channel_entry: CHANNEL '{' channel_items '}' ';';
2936  
2937   channel_items:      channel_items channel_item | channel_item;
2938 < channel_item:       channel_disable_local_channels | channel_use_except |
2939 <                    channel_use_invex | channel_use_knock |
2940 <                    channel_max_bans | channel_knock_delay |
2941 <                    channel_knock_delay_channel | channel_max_chans_per_user |
2942 <                    channel_quiet_on_ban | channel_default_split_user_count |
2943 <                    channel_default_split_server_count |
2944 <                    channel_no_create_on_split | channel_restrict_channels |
2945 <                    channel_no_join_on_split | channel_burst_topicwho |
2946 <                    channel_jflood_count | channel_jflood_time |
2947 <                    channel_disable_fake_channels | error;
2938 > channel_item:       channel_max_bans |
2939 >                    channel_invite_client_count |
2940 >                    channel_invite_client_time |
2941 >                    channel_knock_client_count |
2942 >                    channel_knock_client_time |
2943 >                    channel_knock_delay_channel |
2944 >                    channel_max_channels |
2945 >                    channel_default_join_flood_count |
2946 >                    channel_default_join_flood_time |
2947 >                    channel_disable_fake_channels |
2948 >                    error;
2949  
2950   channel_disable_fake_channels: DISABLE_FAKE_CHANNELS '=' TBOOL ';'
2951   {
2952    ConfigChannel.disable_fake_channels = yylval.number;
2953   };
2954  
2955 < channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
2955 > channel_invite_client_count: INVITE_CLIENT_COUNT '=' NUMBER ';'
2956   {
2957 <  ConfigChannel.restrict_channels = yylval.number;
2957 >  ConfigChannel.invite_client_count = $3;
2958   };
2959  
2960 < channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
2960 > channel_invite_client_time: INVITE_CLIENT_TIME '=' timespec ';'
2961   {
2962 <  ConfigChannel.disable_local_channels = yylval.number;
2962 >  ConfigChannel.invite_client_time = $3;
2963   };
2964  
2965 < channel_use_except: USE_EXCEPT '=' TBOOL ';'
2965 > channel_knock_client_count: KNOCK_CLIENT_COUNT '=' NUMBER ';'
2966   {
2967 <  ConfigChannel.use_except = yylval.number;
2967 >  ConfigChannel.knock_client_count = $3;
2968   };
2969  
2970 < channel_use_invex: USE_INVEX '=' TBOOL ';'
2970 > channel_knock_client_time: KNOCK_CLIENT_TIME '=' timespec ';'
2971   {
2972 <  ConfigChannel.use_invex = yylval.number;
3280 < };
3281 <
3282 < channel_use_knock: USE_KNOCK '=' TBOOL ';'
3283 < {
3284 <  ConfigChannel.use_knock = yylval.number;
3285 < };
3286 <
3287 < channel_knock_delay: KNOCK_DELAY '=' timespec ';'
3288 < {
3289 <  ConfigChannel.knock_delay = $3;
2972 >  ConfigChannel.knock_client_time = $3;
2973   };
2974  
2975   channel_knock_delay_channel: KNOCK_DELAY_CHANNEL '=' timespec ';'
# Line 3294 | Line 2977 | channel_knock_delay_channel: KNOCK_DELAY
2977    ConfigChannel.knock_delay_channel = $3;
2978   };
2979  
2980 < channel_max_chans_per_user: MAX_CHANS_PER_USER '=' NUMBER ';'
3298 < {
3299 <  ConfigChannel.max_chans_per_user = $3;
3300 < };
3301 <
3302 < channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
2980 > channel_max_channels: MAX_CHANNELS '=' NUMBER ';'
2981   {
2982 <  ConfigChannel.quiet_on_ban = yylval.number;
2982 >  ConfigChannel.max_channels = $3;
2983   };
2984  
2985   channel_max_bans: MAX_BANS '=' NUMBER ';'
# Line 3309 | Line 2987 | channel_max_bans: MAX_BANS '=' NUMBER ';
2987    ConfigChannel.max_bans = $3;
2988   };
2989  
2990 < channel_default_split_user_count: DEFAULT_SPLIT_USER_COUNT '=' NUMBER ';'
2990 > channel_default_join_flood_count: DEFAULT_JOIN_FLOOD_COUNT '=' NUMBER ';'
2991   {
2992 <  ConfigChannel.default_split_user_count = $3;
2992 >  ConfigChannel.default_join_flood_count = yylval.number;
2993   };
2994  
2995 < channel_default_split_server_count: DEFAULT_SPLIT_SERVER_COUNT '=' NUMBER ';'
2995 > channel_default_join_flood_time: DEFAULT_JOIN_FLOOD_TIME '=' timespec ';'
2996   {
2997 <  ConfigChannel.default_split_server_count = $3;
2997 >  ConfigChannel.default_join_flood_time = $3;
2998   };
2999  
3322 channel_no_create_on_split: NO_CREATE_ON_SPLIT '=' TBOOL ';'
3323 {
3324  ConfigChannel.no_create_on_split = yylval.number;
3325 };
3000  
3001 < channel_no_join_on_split: NO_JOIN_ON_SPLIT '=' TBOOL ';'
3002 < {
3003 <  ConfigChannel.no_join_on_split = yylval.number;
3004 < };
3001 > /***************************************************************************
3002 > * serverhide {} section
3003 > ***************************************************************************/
3004 > serverhide_entry: SERVERHIDE '{' serverhide_items '}' ';';
3005 >
3006 > serverhide_items:   serverhide_items serverhide_item | serverhide_item;
3007 > serverhide_item:    serverhide_flatten_links |
3008 >                    serverhide_flatten_links_delay |
3009 >                    serverhide_flatten_links_file |
3010 >                    serverhide_disable_remote_commands |
3011 >                    serverhide_hide_servers |
3012 >                    serverhide_hide_services |
3013 >                    serverhide_hidden |
3014 >                    serverhide_hidden_name |
3015 >                    serverhide_hide_server_ips |
3016 >                    error;
3017  
3018 < channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3018 > serverhide_flatten_links: FLATTEN_LINKS '=' TBOOL ';'
3019   {
3020 <  ConfigChannel.burst_topicwho = yylval.number;
3020 >  if (conf_parser_ctx.pass == 2)
3021 >    ConfigServerHide.flatten_links = yylval.number;
3022   };
3023  
3024 < channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
3024 > serverhide_flatten_links_delay: FLATTEN_LINKS_DELAY '=' timespec ';'
3025   {
3026 <  GlobalSetOptions.joinfloodcount = yylval.number;
3026 >  if (conf_parser_ctx.pass == 2)
3027 >  {
3028 >    if ($3 > 0)
3029 >    {
3030 >      event_write_links_file.when = $3;
3031 >      event_add(&event_write_links_file, NULL);
3032 >    }
3033 >    else
3034 >     event_delete(&event_write_links_file);
3035 >
3036 >    ConfigServerHide.flatten_links_delay = $3;
3037 >  }
3038   };
3039  
3040 < channel_jflood_time: JOIN_FLOOD_TIME '=' timespec ';'
3040 > serverhide_flatten_links_file: FLATTEN_LINKS_FILE '=' QSTRING ';'
3041   {
3042 <  GlobalSetOptions.joinfloodtime = yylval.number;
3042 >  if (conf_parser_ctx.pass == 2)
3043 >  {
3044 >    MyFree(ConfigServerHide.flatten_links_file);
3045 >    ConfigServerHide.flatten_links_file = xstrdup(yylval.string);
3046 >  }
3047   };
3048  
3049 < /***************************************************************************
3348 < *  section serverhide
3349 < ***************************************************************************/
3350 < serverhide_entry: SERVERHIDE
3351 <  '{' serverhide_items '}' ';';
3352 <
3353 < serverhide_items:   serverhide_items serverhide_item | serverhide_item;
3354 < serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
3355 <                    serverhide_links_delay |
3356 <                    serverhide_disable_hidden |
3357 <                    serverhide_hidden | serverhide_hidden_name |
3358 <                    serverhide_hide_server_ips |
3359 <                    error;
3360 <
3361 < serverhide_flatten_links: FLATTEN_LINKS '=' TBOOL ';'
3049 > serverhide_disable_remote_commands: DISABLE_REMOTE_COMMANDS '=' TBOOL ';'
3050   {
3051    if (conf_parser_ctx.pass == 2)
3052 <    ConfigServerHide.flatten_links = yylval.number;
3052 >    ConfigServerHide.disable_remote_commands = yylval.number;
3053   };
3054  
3055   serverhide_hide_servers: HIDE_SERVERS '=' TBOOL ';'
# Line 3370 | Line 3058 | serverhide_hide_servers: HIDE_SERVERS '=
3058      ConfigServerHide.hide_servers = yylval.number;
3059   };
3060  
3061 < serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
3061 > serverhide_hide_services: HIDE_SERVICES '=' TBOOL ';'
3062   {
3063    if (conf_parser_ctx.pass == 2)
3064 <  {
3377 <    MyFree(ConfigServerHide.hidden_name);
3378 <    DupString(ConfigServerHide.hidden_name, yylval.string);
3379 <  }
3064 >    ConfigServerHide.hide_services = yylval.number;
3065   };
3066  
3067 < serverhide_links_delay: LINKS_DELAY '=' timespec ';'
3067 > serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
3068   {
3069    if (conf_parser_ctx.pass == 2)
3070    {
3071 <    if (($3 > 0) && ConfigServerHide.links_disabled == 1)
3072 <    {
3388 <      eventAddIsh("write_links_file", write_links_file, NULL, $3);
3389 <      ConfigServerHide.links_disabled = 0;
3390 <    }
3391 <
3392 <    ConfigServerHide.links_delay = $3;
3071 >    MyFree(ConfigServerHide.hidden_name);
3072 >    ConfigServerHide.hidden_name = xstrdup(yylval.string);
3073    }
3074   };
3075  
# Line 3399 | Line 3079 | serverhide_hidden: HIDDEN '=' TBOOL ';'
3079      ConfigServerHide.hidden = yylval.number;
3080   };
3081  
3402 serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3403 {
3404  if (conf_parser_ctx.pass == 2)
3405    ConfigServerHide.disable_hidden = yylval.number;
3406 };
3407
3082   serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
3083   {
3084    if (conf_parser_ctx.pass == 2)

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)