Author: Isomer <isomer@undernet.org>
[ircu2.10.12-pk.git] / ircd / ircd_parser.y
index 6b6469dd2401cb5c1a5a07bf59d18e4c0cea144f..d47a9414787bb5c61e8d79f59160acc6dcf05be9 100644 (file)
@@ -69,7 +69,7 @@
   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;
@@ -108,6 +108,8 @@ static void parse_error(char *pattern,...) {
 %token SENDQ
 %token NAME
 %token HOST
+%token IP
+%token USERNAME
 %token PASS
 %token LOCAL
 %token SECONDS
@@ -147,7 +149,6 @@ static void parse_error(char *pattern,...) {
 %token TFILE
 %token RULE
 %token ALL
-%token IP
 %token FEATURES
 %token QUARANTINE
 %token PSEUDO
@@ -298,7 +299,13 @@ generaldesc: DESCRIPTION '=' QSTRING ';'
 
 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 '}'
@@ -462,14 +469,14 @@ connecthublimit: HUB '=' QSTRING ';'
 connectmaxhops: MAXHOPS '=' expr ';'
 {
   maxlinks = $3;
-}
+};
 
 uworldblock: UWORLD '{' uworlditems '}' ';'
 {
  if (name)
  {
   struct ConfItem *aconf = make_conf(CONF_UWORLD);
-  aconf->name = name;
+  aconf->host = name;
  }
  else
  {
@@ -493,7 +500,7 @@ operblock: OPER '{' operitems '}' ';'
     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));
@@ -643,35 +650,37 @@ clientblock: CLIENT
 }
 '{' 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");
-  }
-  host = name = NULL;
+    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 ';'
 {