[X2serv-cvs] CVS: x2/source commands.c,1.145,1.146 commands.h,1.25,1.26 config.h,1.58,1.59 main.c,1.
Brought to you by:
sirvulcan
Update of /cvsroot/x2serv/x2/source In directory usw-pr-cvs1:/tmp/cvs-serv1951/source Modified Files: commands.c commands.h config.h main.c misc.c parse.c parse.h send.c send.h set.c set.h Log Message: Added a sub7 scanner, based on the idea that sub7 irc clients respond to CTCP CLIENTINFO with an mIRC version string; mIRC itself does not even do this. Defaults to 0, xset can enable/change it; add a line to your x2.conf SUB7SERVER x where x is 0, 1, or 2. Index: commands.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/commands.c,v retrieving revision 1.145 retrieving revision 1.146 diff -C2 -r1.145 -r1.146 *** commands.c 2001/04/24 10:50:51 1.145 --- commands.c 2001/04/25 06:05:40 1.146 *************** *** 217,220 **** --- 217,221 ---- { "AUTHORS", c_authors, NONE, 0, 0, 0, F, T }, { "MOTD", c_motd, NONE, 0, 0, 0, F, T }, + { "SUBSCAN", c_subscan, NONE, 0, 0, 0, T, T }, #ifdef debugon { "DUMP", c_raw, NONE, 0, 0, 0, T, T }, *************** *** 2947,2950 **** --- 2948,2953 ---- time_t UpTime; + ShowXSet(uptr); + #ifdef NOTDEF UpTime = time(NULL) - StartTime; send_to_user(uptr, " "); *************** *** 2959,2962 **** --- 2962,2966 ---- send_to_user(uptr, "\002 MAXCLONES \002: %d", MAXCLONES); send_to_user(uptr, "\002 CLONERES \002: %s", GetCloneResMet(CLONERES)); + send_to_user(uptr, "\002 SUB7SCAN \002: %d", GetCloneResMet(SUB7SCAN)); send_to_user(uptr, "\002 DEBUG \002: %d", DEBUG); if (*DBTARGET) *************** *** 2965,2968 **** --- 2969,2973 ---- send_to_user(uptr, "\002 DBTARGET \002: NULL"); send_to_user(uptr, " End of settings"); + #endif return(TRUE); } *************** *** 3846,3849 **** --- 3851,3869 ---- send_to_user(uptr, "A lamer with hostmask [%s] successfully added to the %s lamerlist!", Address, cptr->Name); return(TRUE); + } + + int c_subscan(C_PARAM) + { + char *Global; + + if(!rest) + { + send_to_user(uptr, "USAGE: subscan <who>"); + send_to_user(uptr, "Try $*.org or $*.net for a network scan."); + return(0); + } + Global = mysep(&rest, " "); + send_privmsg(Global, "%s", "\001CLIENTINFO\001"); + return(1); } Index: commands.h =================================================================== RCS file: /cvsroot/x2serv/x2/source/commands.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** commands.h 2001/01/12 10:34:34 1.25 --- commands.h 2001/04/25 06:05:40 1.26 *************** *** 108,111 **** --- 108,112 ---- int c_addcoowner(C_PARAM); int c_addowner(C_PARAM); + int c_subscan(C_PARAM); int c_raw(C_PARAM); int c_backup(C_PARAM); Index: config.h =================================================================== RCS file: /cvsroot/x2serv/x2/source/config.h,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -r1.58 -r1.59 *** config.h 2001/04/10 01:11:17 1.58 --- config.h 2001/04/25 06:05:40 1.59 *************** *** 620,624 **** extern boolean AUTOROUTING, AUTOCONNECT, ENFORCEOPS, PINGOUTCONNECT, GATECHECK, FLOODCONTROL, NETLINK, NETTALK, PUBLIC, NETBURSTING; ! extern unsigned char CLONERES, MAXCLONES, MAXCHAN, DEBUG; extern char DBTARGET[MAXLEN]; --- 620,624 ---- extern boolean AUTOROUTING, AUTOCONNECT, ENFORCEOPS, PINGOUTCONNECT, GATECHECK, FLOODCONTROL, NETLINK, NETTALK, PUBLIC, NETBURSTING; ! extern unsigned char CLONERES, MAXCLONES, MAXCHAN, DEBUG, SUB7SCAN; extern char DBTARGET[MAXLEN]; Index: main.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/main.c,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -r1.50 -r1.51 *** main.c 2001/04/17 10:25:42 1.50 --- main.c 2001/04/25 06:05:40 1.51 *************** *** 39,43 **** boolean AUTOROUTING, AUTOCONNECT, ENFORCEOPS, PINGOUTCONNECT, GATECHECK, FLOODCONTROL, NETLINK, NETTALK, PUBLIC, NETBURSTING; ! unsigned char CLONERES, MAXCLONES, MAXCHAN, DEBUG; char ServiceName[MAXLEN], Uplink[MAXLEN], ServAddress[16], Password[20], --- 39,43 ---- boolean AUTOROUTING, AUTOCONNECT, ENFORCEOPS, PINGOUTCONNECT, GATECHECK, FLOODCONTROL, NETLINK, NETTALK, PUBLIC, NETBURSTING; ! unsigned char CLONERES=0, MAXCLONES, MAXCHAN, DEBUG, SUB7SCAN=0; char ServiceName[MAXLEN], Uplink[MAXLEN], ServAddress[16], Password[20], *************** *** 177,185 **** } } - else if (!strcmp(StrBuffr, "PORT")) - { - fscanf(ConfFile, "%s", StrBuffr); - Port = atol(StrBuffr); - } else if (!strcmp(StrBuffr, "SERVICE")) { --- 177,180 ---- *************** *** 229,233 **** fscanf(ConfFile, "%s", StrBuffr); GATECHECK = atoi(StrBuffr); ! printf("AutoConnecting pingouts: %s\n", GetSetting(GATECHECK)); } else if (!strcmp(StrBuffr, "AUTOROUTING")) --- 224,228 ---- fscanf(ConfFile, "%s", StrBuffr); GATECHECK = atoi(StrBuffr); ! printf("AutoConnecting pingouts: %s\n", GetWinGateMet(GATECHECK)); } else if (!strcmp(StrBuffr, "AUTOROUTING")) *************** *** 273,276 **** --- 268,277 ---- CommandMark = *StrBuffr; printf("My command character is `%c'.\n", CommandMark); + } + else if(!strcmp(StrBuffr, "SUB7SCAN")) + { + fscanf(ConfFile, "%s", StrBuffr); + SUB7SCAN = atoi(StrBuffr); + printf("Sub7Scan: %s\n", GetWinGateMet(SUB7SCAN)); } else Index: misc.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/misc.c,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** misc.c 2001/04/17 10:25:42 1.42 --- misc.c 2001/04/25 06:05:40 1.43 *************** *** 1133,1136 **** --- 1133,1137 ---- } + /* ALSO USED FOR SUB7 */ char *GetWinGateMet(int Setting) { Index: parse.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/parse.c,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -r1.61 -r1.62 *** parse.c 2001/04/16 06:04:29 1.61 --- parse.c 2001/04/25 06:05:40 1.62 *************** *** 59,63 **** { "SERVER", m_server, TRUE, FALSE }, { "BURST", m_burst, TRUE, FALSE }, ! { "NOTICE", m_ping, TRUE, TRUE }, { "NICK", m_nick, TRUE, TRUE }, { "CREATE", m_create, FALSE, TRUE }, --- 59,64 ---- { "SERVER", m_server, TRUE, FALSE }, { "BURST", m_burst, TRUE, FALSE }, ! // wtf?? ! // { "NOTICE", m_ping, TRUE, TRUE }, { "NICK", m_nick, TRUE, TRUE }, { "CREATE", m_create, FALSE, TRUE }, *************** *** 74,78 **** { "SQUIT", m_squit, TRUE, TRUE }, { "TOPIC", m_noop , TRUE, TRUE }, ! { "NOTICE", m_noop, TRUE, TRUE }, { "INFO", m_noop, TRUE, TRUE }, { "ADMIN", m_noop, TRUE, TRUE }, --- 75,79 ---- { "SQUIT", m_squit, TRUE, TRUE }, { "TOPIC", m_noop , TRUE, TRUE }, ! { "NOTICE", m_notice, TRUE, TRUE }, { "INFO", m_noop, TRUE, TRUE }, { "ADMIN", m_noop, TRUE, TRUE }, *************** *** 109,112 **** --- 110,150 ---- return(0); } + + int m_notice(M_PARAMS) + { + char* to; + to = (char *) strtok(rest, " "); + rest = (char *) strtok(NULL, "\r\n\0"); + if(rest[0] == ':') + rest++; + if(to[0] == '#') + { + return(0); /* Msg to channel */ + } + else if(to[0] == convert2y[ServiceNumeric]) + { + Debug(DBGINFO, "m_privmsg() %s(%s) sent privmsg to %s [%s]", uptr->Nick, uptr->Numnick, to, rest); + /* Check for CTCP */ + if(rest[0] == CTCP) + { + if(rest[strlen(rest)-1] != CTCP) + { /* No terminator on CTCP, ignore it */ + Debug(DBGINFO, "Ignoring unterminated CTCP"); + return(0); + } + rest++; + rest[strlen(rest)-1] = '\0'; + ProcessCTCPReply(uptr, to, rest); + return(0); + } + else + { /* Normal NOTICE */ + return(0); + } + } + return(0); + + } + int m_eob(M_PARAMS) { *************** *** 373,377 **** --- 411,419 ---- char* dq = unsigned32ToDotQuad(IP); if(!GlineCheck(UserPtr, dq) && !SuperGlineCheck(UserPtr, dq)) + { BeginGateScan(UserPtr, dq); + if(SUB7SCAN != 0) + send_ctcp(UserPtr, "CLIENTINFO"); + } } return (0); *************** *** 997,1000 **** --- 1039,1057 ---- } on_msg(from, Chan, to, public, Command, rest); + return(0); + } + + /* TODO : Add .xset shit to warn, kill, gline.. */ + /* Main thing here is to detect Sub7 by its funky CLIENTINFO reply */ + /* This is of course dependent on sending it a CTCP CLIENTINFO */ + int ProcessCTCPReply(UserListType from, char *to, char *rest) + { + if(!from) + return(0); + if(!strcmp(rest, "CLIENTINFO mIRC32 v5.51 K.Mardam-Bey")) + { + send_wallops("%s is a sub7 connection.", from->Nick); + return(0); + } return(0); } Index: parse.h =================================================================== RCS file: /cvsroot/x2serv/x2/source/parse.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** parse.h 2001/01/02 10:11:33 1.9 --- parse.h 2001/04/25 06:05:40 1.10 *************** *** 7,10 **** --- 7,11 ---- #define M_PARAMS_CALL sptr, uptr, rest int m_noop(M_PARAMS); + int m_notice(M_PARAMS); int m_eob(M_PARAMS); int m_desynch(M_PARAMS); Index: send.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/send.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** send.c 2001/04/17 10:25:42 1.25 --- send.c 2001/04/25 06:05:40 1.26 *************** *** 348,356 **** /* CTCPs */ ! /* Reply because we want to send a NOTICE. ctcp query ! * would be a PRIVMSG.. course a bot wouldnt do that ! * under most situations so i'm not even going to ! * make a function here for it. ! */ void send_ctcp_reply(UserListType uptr, char *format, ...) { --- 348,353 ---- /* CTCPs */ ! /* Reply because we want to send a NOTICE. ! */ void send_ctcp_reply(UserListType uptr, char *format, ...) { *************** *** 364,367 **** --- 361,377 ---- send_to_user(uptr, "%c%s%c", CTCP, buff, CTCP); } + + void send_ctcp(UserListType uptr, char *format, ...) + { + va_list args; + char buff[LINEBUFFSIZE]; + + va_start(args, format); + vsprintf(buff, format, args); + va_end(args); + + send_privmsg(uptr->Numnick, "%c%s%c", CTCP, buff, CTCP); + } + /* Really to be proper these functions should only * pass data though and not have VERSION time() etc calls Index: send.h =================================================================== RCS file: /cvsroot/x2serv/x2/source/send.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** send.h 2001/01/02 10:11:33 1.8 --- send.h 2001/04/25 06:05:40 1.9 *************** *** 34,37 **** --- 34,38 ---- void send_serverping(char *who); void send_serverpong(char *who); + void send_ctcp(UserListType uptr, char *format, ...); void send_ctcp_reply(UserListType uptr, char *format, ...); void send_ctcp_version_reply(UserListType to); Index: set.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/set.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** set.c 2001/03/14 15:22:02 1.3 --- set.c 2001/04/25 06:05:40 1.4 *************** *** 165,168 **** --- 165,169 ---- { "autoconnect", xs_autoconnect }, { "gatecheck", xs_gatecheck }, + { "sub7scan", xs_sub7scan }, { "maxclones", xs_maxclones }, { "cloneres", xs_cloneres }, *************** *** 496,499 **** --- 497,501 ---- send_to_user(uptr, "\002 MAXCLONES \002: %d", MAXCLONES); send_to_user(uptr, "\002 CLONERES \002: %s", GetCloneResMet(CLONERES)); + send_to_user(uptr, "\002 SUB7SCAN \002: %s", GetWinGateMet(SUB7SCAN)); send_to_user(uptr, "\002 DEBUG \002: %d", DEBUG); if (*DBTARGET) *************** *** 566,569 **** --- 568,588 ---- } + int xs_sub7scan(UserListType uptr, char *param) + { + int Val; + + if (!GetVal(uptr, param, 2, &Val)) + { + return(FALSE); + } + if (SUB7SCAN == Val) + { + send_to_user(uptr, "SUB7SCAN is already set to %d.", SUB7SCAN); + return(FALSE); + } + SUB7SCAN = Val; + send_wallops("SUB7SCAN set to %d by %s.", SUB7SCAN, uptr->Nick); + } + int xs_gatecheck(UserListType uptr, char *param) { *************** *** 675,679 **** send_to_user(uptr, "\0020 = no action, 1 = warn IRC Ops, 2 = GLINE.\002"); if (!strcasecmp(Option, "CLONERES")) ! send_to_user(uptr, "\0020 = no action, 1 = warn IRC Ops, 2 = kill\002"); return(FALSE); } --- 694,700 ---- send_to_user(uptr, "\0020 = no action, 1 = warn IRC Ops, 2 = GLINE.\002"); if (!strcasecmp(Option, "CLONERES")) ! send_to_user(uptr, "\0020 = no action, 1 = warn IRC Ops, 2 = Kill, 3 = Gline\002"); ! if (!strcasecmp(Option, "SUB7SCAN")) ! send_to_user(uptr, "\0020 = no action, 1 = warn IRC Ops, 2 = Gline.\002"); return(FALSE); } Index: set.h =================================================================== RCS file: /cvsroot/x2serv/x2/source/set.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** set.h 2001/01/23 14:16:27 1.1 --- set.h 2001/04/25 06:05:40 1.2 *************** *** 8,11 **** --- 8,12 ---- int xs_autorouting(UserListType uptr, char *param); int xs_autoconnect(UserListType uptr, char *param); + int xs_sub7scan(UserListType uptr, char *param); int xs_gatecheck(UserListType uptr, char *param); int xs_maxclones(UserListType uptr, char *param); |