int yylex(void);
/* Now all the globals we need :/... */
int tping, tconn, maxlinks, sendq, port, invert, stringno;
- char *name, *pass, *host, *origin, *hub_limit;
+ char *name, *pass, *host, *ip, *username, *origin, *hub_limit;
char *stringlist[MAX_STRINGS];
struct ConnectionClass *c_class;
struct DenyConf *dconf;
%token SENDQ
%token NAME
%token HOST
+%token IP
+%token USERNAME
%token PASS
%token LOCAL
%token SECONDS
%token TFILE
%token RULE
%token ALL
-%token IP
%token FEATURES
%token QUARANTINE
%token PSEUDO
generalvhost: VHOST '=' QSTRING ';'
{
- ircd_aton(&VirtualHost.addr, $3);
+ struct irc_in_addr addr;
+ if (!ircd_aton(&addr, $3))
+ parse_error("Invalid virtual host '%s'.", $3);
+ else if (irc_in_addr_is_ipv4(&addr))
+ memcpy(&VirtualHost_v4.addr, &addr, sizeof(addr));
+ else
+ memcpy(&VirtualHost_v6.addr, &addr, sizeof(addr));
};
adminblock: ADMIN '{' adminitems '}'
};
classblock: CLASS {
- name = NULL;
tping = 90;
- tconn = 0;
- maxlinks = 0;
- sendq = 0;
- pass = NULL;
- memset(&privs, 0, sizeof(privs));
- memset(&privs_dirty, 0, sizeof(privs_dirty));
} '{' classitems '}'
{
if (name != NULL)
else {
parse_error("Missing name in class block");
}
+ name = NULL;
pass = NULL;
+ tconn = 0;
+ maxlinks = 0;
+ sendq = 0;
+ memset(&privs, 0, sizeof(privs));
+ memset(&privs_dirty, 0, sizeof(privs_dirty));
} ';';
classitems: classitem classitems | classitem;
classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
};
classusermode: USERMODE '=' QSTRING ';'
{
- if (pass)
- MyFree(pass);
+ MyFree(pass);
DupString(pass, $3);
};
connectblock: CONNECT
{
- name = pass = host = origin = hub_limit = NULL;
- c_class = NULL;
- port = 0;
maxlinks = 65535;
} '{' connectitems '}'
{
MyFree(hub_limit);
parse_error("Bad connect block");
}
+ name = pass = host = origin = hub_limit = NULL;
+ c_class = NULL;
+ port = 0;
}';';
connectitems: connectitem connectitems | connectitem;
connectitem: connectname | connectpass | connectclass | connecthost
if (name)
{
struct ConfItem *aconf = make_conf(CONF_UWORLD);
- aconf->name = name;
+ aconf->host = name;
}
else
{
MyFree(name);
parse_error("Bad UWorld block");
}
+ name = NULL;
};
uworlditems: uworlditem uworlditems | uworlditem;
uworlditem: uworldname | error;
DupString(name, $3);
};
-operblock: OPER
-{
- name = pass = host = NULL;
- c_class = NULL;
- memset(&privs, 0, sizeof(privs));
- memset(&privs_dirty, 0, sizeof(privs_dirty));
-} '{' operitems '}' ';'
+operblock: OPER '{' operitems '}' ';'
{
if (name && pass && host && c_class)
{
struct ConfItem *aconf = make_conf(CONF_OPERATOR);
aconf->name = name;
aconf->passwd = pass;
- aconf->host = host;
+ conf_parse_userhost(aconf, host);
aconf->conn_class = c_class;
memcpy(&aconf->privs, &privs, sizeof(aconf->privs));
memcpy(&aconf->privs_dirty, &privs_dirty, sizeof(aconf->privs_dirty));
- if (!PrivHas(&privs_dirty, PRIV_PROPAGATE)
- && !PrivHas(&c_class->privs_dirty, PRIV_PROPAGATE))
+ if (!FlagHas(&privs_dirty, PRIV_PROPAGATE)
+ && !FlagHas(&c_class->privs_dirty, PRIV_PROPAGATE))
parse_error("Operator block for %s and class %s have no LOCAL setting", name, c_class->cc_name);
}
else
MyFree(pass);
MyFree(host);
}
+ name = pass = host = NULL;
+ c_class = NULL;
+ memset(&privs, 0, sizeof(privs));
+ memset(&privs_dirty, 0, sizeof(privs_dirty));
};
operitems: operitem | operitems operitem;
operitem: opername | operpass | operhost | operclass | priv | error;
priv: privtype '=' yesorno ';'
{
- PrivSet(&privs_dirty, $1);
+ FlagSet(&privs_dirty, $1);
if (($3 == 1) ^ invert)
- PrivSet(&privs, $1);
+ FlagSet(&privs, $1);
else
- PrivClr(&privs, $1);
+ FlagClr(&privs, $1);
invert = 0;
};
yesorno: YES { $$ = 1; } | NO { $$ = 0; };
/* The port block... */
-portblock: PORT {
- port = 0;
- host = NULL;
- /* Hijack these for is_server, is_hidden to cut down on globals... */
- tconn = 0;
- tping = 0;
- /* and this for mask... */
- pass = NULL;
-} '{' portitems '}' ';'
+portblock: PORT '{' portitems '}' ';'
{
if (port > 0 && port <= 0xFFFF)
{
MyFree(host);
MyFree(pass);
host = pass = NULL;
+ port = tconn = tping = 0;
};
portitems: portitem portitems | portitem;
portitem: portnumber | portvhost | portmask | portserver | porthidden | error;
clientblock: CLIENT
{
- host = name = NULL;
- c_class = NULL;
maxlinks = 65535;
}
'{' clientitems '}' ';'
{
- if (host && name)
- {
- struct ConfItem *aconf = make_conf(CONF_CLIENT);
- aconf->host = host;
- aconf->name = name;
- aconf->conn_class = c_class ? c_class : find_class("default");
- aconf->maximum = maxlinks;
- }
+ struct ConfItem *aconf = make_conf(CONF_CLIENT);
+ unsigned char addrbits;
+ aconf->username = username;
+ aconf->host = host;
+ if (ip && ipmask_parse(ip, &aconf->address.addr, &addrbits))
+ aconf->addrbits = addrbits;
else
- {
- MyFree(host);
- MyFree(name);
- parse_error("Bad client block");
- }
+ aconf->addrbits = -1;
+ aconf->conn_class = c_class ? c_class : find_class("default");
+ aconf->maximum = maxlinks;
+ host = NULL;
+ username = NULL;
+ c_class = NULL;
+ MyFree(ip);
};
clientitems: clientitem clientitems | clientitem;
-clientitem: clienthost | clientclass | clientpass | clientip
- | clientmaxlinks | error;
-clientip: IP '=' QSTRING ';'
+clientitem: clienthost | clientip | clientusername | clientclass | clientpass | clientmaxlinks | error;
+clienthost: HOST '=' QSTRING ';'
{
MyFree(host);
DupString(host, $3);
};
-clienthost: HOST '=' QSTRING ';'
+clientip: IP '=' QSTRING ';'
{
- MyFree(name);
- DupString(name, $3);
-};
+ MyFree(ip);
+ DupString(ip, $3);
+}
+clientusername: USERNAME '=' QSTRING ';'
+{
+ MyFree(username);
+ DupString(username, $3);
+}
clientclass: CLASS '=' QSTRING ';'
{
c_class = find_class($3);
killblock: KILL
{
- dconf = (struct DenyConf*) MyMalloc(sizeof(*dconf));
- memset(dconf, 0, sizeof(*dconf));
+ dconf = (struct DenyConf*) MyCalloc(1, sizeof(*dconf));
} '{' killitems '}'
{
if (dconf->hostmask != NULL)
DupString(dconf->usermask, "*");
dconf->next = denyConfList;
denyConfList = dconf;
- dconf = NULL;
}
else
{
MyFree(dconf->hostmask);
MyFree(dconf->message);
MyFree(dconf);
- dconf = NULL;
parse_error("Bad kill block");
}
+ dconf = NULL;
} ';';
killitems: killitem killitems | killitem;
killitem: killuhost | killreal | killreasonfile | killreason | error;
cruleblock: CRULE
{
- host = pass = NULL;
tconn = CRULE_AUTO;
-} '{' cruleitems '}'
+} '{' cruleitems '}' ';'
{
struct CRuleNode *node;
if (host != NULL && pass != NULL && (node=crule_parse(pass)) != NULL)
MyFree(pass);
parse_error("Bad CRule block");
}
-} ';';
+ host = pass = NULL;
+};
cruleitems: cruleitem cruleitems | cruleitem;
cruleitem: cruleserver | crulerule | cruleall | error;
tconn = CRULE_AUTO;
};
-motdblock: MOTD {
- pass = host = NULL;
-} '{' motditems '}'
+motdblock: MOTD '{' motditems '}' ';'
{
if (host != NULL && pass != NULL)
motd_add(host, pass);
MyFree(host);
MyFree(pass);
host = pass = NULL;
-} ';';
+};
motditems: motditem motditems | motditem;
motditem: motdhost | motdfile | error;
quarantineblock: QUARANTINE '{'
{
- if (qconf != NULL)
- qconf = (struct qline*) MyMalloc(sizeof(*qconf));
- else
- {
- if (qconf->chname != NULL)
- MyFree(qconf->chname);
- if (qconf->reason != NULL)
- MyFree(qconf->reason);
- }
- memset(qconf, 0, sizeof(*qconf));
+ qconf = (struct qline*) MyCalloc(1, sizeof(*qconf));
} quarantineitems '}' ';'
{
if (qconf->chname == NULL || qconf->reason == NULL)
iauthblock: IAUTH '{'
{
- pass = host = NULL;
- port = 0;
tconn = 60;
tping = 60;
} iauthitems '}' ';'
MyFree(pass);
MyFree(host);
pass = host = NULL;
+ port = 0;
};
iauthitems: iauthitem iauthitems | iauthitem;