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-7.2/src/ircd_parser.y (file contents), Revision 595 by michael, Fri May 12 21:17:16 2006 UTC vs.
ircd-hybrid/trunk/src/conf_parser.y (file contents), Revision 8792 by michael, Thu Jan 17 18:35:32 2019 UTC

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

Comparing:
ircd-hybrid-7.2/src/ircd_parser.y (property svn:keywords), Revision 595 by michael, Fri May 12 21:17:16 2006 UTC vs.
ircd-hybrid/trunk/src/conf_parser.y (property svn:keywords), Revision 8792 by michael, Thu Jan 17 18:35:32 2019 UTC

# Line 1 | Line 1
1 < Id Revision
1 > Id

Diff Legend

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