Răsfoiți Sursa

* Added 005 parsing

svn: 1041
Bryan Drewery 22 ani în urmă
părinte
comite
4f9a5b49d5

+ 1 - 0
doc/UPDATES

@@ -23,6 +23,7 @@ This is a summary of ChangeLog basically.
 19.Annoying log -NOTICE- *** should be fixed.
 20.Removed cmd_botinfo.
 21.Unrolled some loops in the botlink encrypt.
+22.Added server 005 support, fixes many potential bugs.
 
 1.1.7
 

+ 1 - 2
src/dcc.c

@@ -42,7 +42,6 @@
 struct dcc_t *dcc = NULL;	/* DCC list				   */
 time_t	timesync = 0;
 int	dcc_total = 0;		/* Total dcc's				   */
-char	network[41] = "EFnet"; /* Name of the IRC network you're on  */
 
 static int	password_timeout = 20;	/* Time to wait for a password from a user */
 static int      auth_timeout = 40;
@@ -242,7 +241,7 @@ static void greet_new_bot(int idx)
   else
     sysname = un.sysname;
 
-  dprintf(idx, "v 1001500 %d %s <%s> %d %li %s\n", HANDLEN, ver, network, localhub, buildts, egg_version);
+  dprintf(idx, "v 1001500 %d %s <%s> %d %li %s\n", HANDLEN, ver, "-", localhub, buildts, egg_version);
 /* FIXME: remove after 1.1.8 */
   dprintf(idx, "vs %s\n", sysname);
   dprintf(idx, "username %s\n", conf.username ? conf.username : "");	/* username */

+ 6 - 46
src/mod/irc.mod/irc.c

@@ -40,17 +40,17 @@ int host_synced = 0;
 static int net_type = 0;
 static int wait_split = 300;		/* Time to wait for user to return from
 					   net-split. */
-static int max_bans = 25;		/* Modified by net-type 1-4 */
-static int max_exempts = 20;
-static int max_invites = 20;
-static int max_modes = 20;		/* Modified by net-type 1-4 */
+int max_bans;		/* Modified by net-type 1-4 */
+int max_exempts;
+int max_invites;
+int max_modes;		/* Modified by net-type 1-4 */
 static int bounce_bans = 0;
 static int bounce_exempts = 0;
 static int bounce_invites = 0;
 static int bounce_modes = 0;
-static unsigned int modesperline = 4;	/* Number of modes per line to send. */
+unsigned int modesperline;	/* Number of modes per line to send. */
 static int mode_buf_len = 200;		/* Maximum bytes to send in 1 mode. */
-static int use_354 = 0;			/* Use ircu's short 354 /who
+int use_354 = 0;			/* Use ircu's short 354 /who
 					   responses. */
 static int kick_method = 1;		/* How many kicks does the irc network
 					   support at once?
@@ -60,8 +60,6 @@ static int kick_fun = 0;
 static int ban_fun = 1;
 static int keepnick = 1;		/* Keep nick */
 static int prevent_mixing = 1;		/* To prevent mixing old/new modes */
-static int rfc_compliant = 1;		/* net-type changing modifies this */
-
 static int include_lk = 1;		/* For correct calculation
 					   in real_add_mode. */
 
@@ -1321,65 +1319,27 @@ static void do_nettype()
   switch (net_type) {
   case 0:		/* Efnet */
     kick_method = 1;
-    modesperline = 4;
-    use_354 = 0;
-    use_exempts = 1;
-    use_invites = 1;
-    max_bans = 100;
-    max_modes = 100;
-    rfc_compliant = 1;
     include_lk = 0;
     break;
   case 1:		/* Ircnet */
     kick_method = 4;
-    modesperline = 3;
-    use_354 = 0;
-    use_exempts = 1;
-    use_invites = 1;
-    max_bans = 30;
-    max_modes = 30;
-    rfc_compliant = 1;
     include_lk = 1;
     break;
   case 2:		/* Undernet */
     kick_method = 1;
-    modesperline = 6;
-    use_354 = 1;
-    use_exempts = 0;
-    use_invites = 0;
-    max_bans = 30;
-    max_modes = 30;
-    rfc_compliant = 1;
     include_lk = 1;
     break;
   case 3:		/* Dalnet */
     kick_method = 1;
-    modesperline = 6;
-    use_354 = 0;
-    use_exempts = 0;
-    use_invites = 0;
-    max_bans = 100;
-    max_modes = 100;
-    rfc_compliant = 0;
     include_lk = 1;
     break;
   case 4:		/* hybrid-6+ */
     kick_method = 1;
-    modesperline = 4;
-    use_354 = 0;
-    use_exempts = 1;
-    use_invites = 0;
-    max_bans = 20;
-    max_modes = 20;
-    rfc_compliant = 1;
     include_lk = 0;
     break;
   default:
     break;
   }
-
-  /* Update all rfc_ function pointers */
-  /* add_hook(HOOK_RFC_CASECMP, (Function) rfc_compliant); */
 }
 
 static cmd_t irc_bot[] = {

+ 2 - 0
src/mod/irc.mod/irc.h

@@ -74,6 +74,8 @@ void recheck_channel_modes(struct chanset_t *);
 void irc_report(int, int);
 void flush_modes();
 
+extern int		max_bans, max_exempts, max_invites, max_modes, use_354;
+extern unsigned int	modesperline;
 #endif				/* _EGG_MOD_IRC_IRC_H */
 
 #endif /* LEAF */

+ 1 - 8
src/mod/server.mod/server.c

@@ -21,6 +21,7 @@
 #include "src/dns.h"
 #include "src/egg_timer.h"
 #include "src/mod/channels.mod/channels.h"
+#include "src/mod/irc.mod/irc.h"
 #include "server.h"
 
 int checked_hostmask;	/* Used in request_op()/check_hostmask() cleared on connect */
@@ -64,7 +65,6 @@ port_t default_port;		/* default IRC port */
 static char oldnick[NICKLEN] = "";	/* previous nickname *before* rehash */
 int trigger_on_ignore;	/* trigger bindings if user is ignored ? */
 int answer_ctcp;		/* answer how many stacked ctcp's ? */
-static int lowercase_ctcp;	/* answer lowercase CTCP's (non-standard) */
 static int check_mode_r;	/* check for IRCNET +r modes */
 static int net_type;
 static int resolvserv;		/* in the process of resolving a server host */
@@ -1069,33 +1069,27 @@ static void do_nettype(void)
   switch (net_type) {
   case NETT_EFNET:
     check_mode_r = 0;
-    nick_len = 9;
     break;
   case NETT_IRCNET:
     check_mode_r = 1;
-    use_penalties = 1;
     use_fastdeq = 3;
-    nick_len = 9;
     simple_sprintf(stackablecmds, "INVITE AWAY VERSION NICK");
     kick_method = 4;
     break;
   case NETT_UNDERNET:
     check_mode_r = 0;
     use_fastdeq = 2;
-    nick_len = 9;
     simple_sprintf(stackablecmds, "PRIVMSG NOTICE TOPIC PART WHOIS USERHOST USERIP ISON");
     simple_sprintf(stackable2cmds, "USERHOST USERIP ISON");
     break;
   case NETT_DALNET:
     check_mode_r = 0;
     use_fastdeq = 2;
-    nick_len = 32;
     simple_sprintf(stackablecmds, "PRIVMSG NOTICE PART WHOIS WHOWAS USERHOST ISON WATCH DCCALLOW");
     simple_sprintf(stackable2cmds, "USERHOST ISON WATCH");
     break;
   case NETT_HYBRID_EFNET:
     check_mode_r = 0;
-    nick_len = 9;
     break;
   }
 }
@@ -1381,7 +1375,6 @@ void server_init()
   oldnick[0] = 0;
   trigger_on_ignore = 0;
   answer_ctcp = 1;
-  lowercase_ctcp = 0;
   check_mode_r = 0;
   maxqmsg = 300;
   burst = 0;

+ 1 - 1
src/mod/server.mod/server.h

@@ -54,7 +54,7 @@ extern int 		serv, servidx, cycle_time, newserverport,
 extern port_t		default_port;
 extern time_t		server_online;
 extern char		cursrvname[], botrealname[], botuserhost[], ctcp_reply[],
-			newserver[], newserverpass[];
+			newserver[], newserverpass[], curnetwork[];
 extern struct server_list *serverlist;
 
 int check_bind_ctcpr(char *, char *, struct userrec *, char *, char *, char *, bind_table_t *);

+ 66 - 3
src/mod/server.mod/servmsg.c

@@ -14,7 +14,8 @@
 #define msgident CFG_MSGIDENT.ldata ? CFG_MSGIDENT.ldata : CFG_MSGIDENT.gdata ? CFG_MSGIDENT.gdata : ""
 
 
-char cursrvname[120]="";
+char cursrvname[120] = "";
+char curnetwork[120] = "";
 static time_t last_ctcp    = (time_t) 0L;
 static int    count_ctcp   = 0;
 static char   altnick_char = 0;
@@ -215,6 +216,67 @@ static int got001(char *from, char *msg)
   return 0;
 }
 
+/* <server> 005 <to> <option> <option> <... option> :are supported by this server */
+static int
+got005(char *from, char *msg)
+{
+  char *tmp = NULL;
+
+  newsplit(&msg); /* nick */
+
+  while ((tmp = newsplit(&msg))[0]) {
+    char *p = NULL;
+
+    if ((p = strchr(tmp, '=')))
+      *p++ = 0;
+    if (!egg_strcasecmp(tmp, ":are"))
+      break;
+    else if (!egg_strcasecmp(tmp, "MODES"))
+      modesperline = atoi(p);
+    else if (!egg_strcasecmp(tmp, "NICKLEN"))
+      nick_len = atoi(p);
+    else if (!egg_strcasecmp(tmp, "NETWORK"))
+      strncpyz(curnetwork, p, 120);
+    else if (!egg_strcasecmp(tmp, "PENALTY"))
+      use_penalties = 1;
+    else if (!egg_strcasecmp(tmp, "WHOX"))
+      use_354 = 1;
+    else if (!egg_strcasecmp(tmp, "EXCEPTS"))
+      use_exempts = 1;
+    else if (!egg_strcasecmp(tmp, "INVEX"))
+      use_invites = 1;
+    else if (!egg_strcasecmp(tmp, "MAXBANS")) {
+      max_bans = atoi(p);
+      max_modes = max_bans;
+      max_exempts = max_bans;
+      max_invites = max_bans;
+    }
+    else if (!egg_strcasecmp(tmp, "MAXLIST")) {
+      char *p2 = NULL;
+      
+      if ((p2 = strchr(p, ':'))) {
+        *p2++ = 0;
+        max_modes = atoi(p2);
+        if (strchr(p, 'e'))
+          max_exempts = max_modes;
+        if (strchr(p, 'b'))
+          max_bans = max_modes;
+        if (strchr(p, 'I'))
+          max_invites = max_modes;
+      
+      }
+    }
+    else if (!egg_strcasecmp(tmp, "CASEMAPPING")) {
+      /* we are default set to rfc1459, so only switch if NOT rfc1459 */
+      if (egg_strcasecmp(p, "rfc1459")) {
+        rfc_casecmp = egg_strcasecmp;
+        rfc_toupper = toupper;
+      }
+    }
+  }
+  return 0;
+}
+
 /* Got 442: not on channel
  */
 static int got442(char *from, char *msg)
@@ -418,7 +480,7 @@ static int gotmsg(char *from, char *msg)
 	    u = get_user_by_host(from);
 	    if (!ignoring || trigger_on_ignore) {
 	      if (check_bind_ctcp(nick, uhost, u, to, code, ctcp) == BIND_RET_LOG && !ignoring) {
-                if ((lowercase_ctcp && !egg_strcasecmp(code, "DCC")) || (!lowercase_ctcp && !strcmp(code, "DCC"))) {
+                if (!strcmp(code, "DCC")) {
                   /* If it gets this far unhandled, it means that
                    * the user is totally unknown.
                    */
@@ -437,7 +499,7 @@ static int gotmsg(char *from, char *msg)
                   } else {
                     putlog(LOG_MISC, "*", "Refused DCC %s: %s", code, from);
                   }
-                } else if ((lowercase_ctcp && !egg_strcasecmp(code, "CHAT")) || (!lowercase_ctcp && !strcmp(code, "CHAT"))) {
+                } else if (!strcmp(code, "CHAT")) {
                   if (!quiet_reject) {
                     if (u)
                       dprintf(DP_HELP, "NOTICE %s :%s\n", nick, "I'm not accepting call at the moment.");
@@ -1115,6 +1177,7 @@ static cmd_t my_raw_binds[] =
   {"PONG",	"",	(Function) gotpong,		NULL},
   {"WALLOPS",	"",	(Function) gotwall,		NULL},
   {"001",	"",	(Function) got001,		NULL},
+  {"005",	"",	(Function) got005,		NULL},
   {"303",	"",	(Function) got303,		NULL},
   {"432",	"",	(Function) got432,		NULL},
   {"433",	"",	(Function) got433,		NULL},

+ 5 - 2
src/rfc1459.c

@@ -5,8 +5,11 @@
 #include "common.h"
 #include "rfc1459.h"
 
+int (*rfc_casecmp) (const char *, const char *) = _rfc_casecmp;
+int (*rfc_toupper) (int) = _rfc_toupper;
+
 int
-rfc_casecmp(const char *s1, const char *s2)
+_rfc_casecmp(const char *s1, const char *s2)
 {
   register unsigned char *str1 = (unsigned char *) s1;
   register unsigned char *str2 = (unsigned char *) s2;
@@ -24,7 +27,7 @@ rfc_casecmp(const char *s1, const char *s2)
 unsigned char rfc_touppertab[];
 
 int
-rfc_toupper(int c)
+_rfc_toupper(int c)
 {
   return rfc_touppertab[(unsigned char) (c)];
 }

+ 5 - 2
src/rfc1459.h

@@ -1,7 +1,10 @@
 #ifndef _RFC1459_H
 #define _RFC1459_H
 
-int rfc_casecmp(const char *, const char *);
-int rfc_toupper(int);
+int _rfc_casecmp(const char *, const char *);
+int _rfc_toupper(int);
+
+extern int (*rfc_casecmp) (const char *, const char *);
+extern int (*rfc_toupper) (int);
 
 #endif /* !_RFC1459_H */