[srvx-commits] CVS: services/src chanserv.c,1.275,1.276 chanserv.h,1.42,1.43 helpserv.c,1.26,1.27 he
Brought to you by:
entrope
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv25353/src
Modified Files:
chanserv.c chanserv.h helpserv.c helpserv.h modcmd.c opserv.c
proto-common.c sockcheck.c sockcheck.h
Log Message:
move !god from ChanServ module to modcmd
move note control commands from OpServ to ChanServ
move proxy-checking control commands from OpServ to ProxyCheck
remove extra #includes
Index: chanserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.c,v
retrieving revision 1.275
retrieving revision 1.276
diff -C2 -r1.275 -r1.276
*** chanserv.c 18 Aug 2002 05:50:23 -0000 1.275
--- chanserv.c 18 Aug 2002 16:04:33 -0000 1.276
***************
*** 24,28 ****
#include "modcmd.h"
#include "opserv.h" /* for opserv_bad_channel() */
- #include "policer.h"
#include "saxdb.h"
#include "timeq.h"
--- 24,27 ----
***************
*** 272,275 ****
--- 271,280 ----
#define CSMSG_NOTE_SET "Note $b%s$b set in channel $b%s$b."
#define CSMSG_NOTE_REMOVED "Note $b%s$b removed in channel $b%s$b."
+ #define CSMSG_BAD_NOTE_ACCESS "$b%s$b is not a valid note access type."
+ #define CSMSG_BAD_MAX_LENGTH "$b%s$b is not a valid maximum length (must be between 20 and 450 inclusive)."
+ #define CSMSG_NOTE_MODIFIED "Note type $b%s$b modified."
+ #define CSMSG_NOTE_CREATED "Note type $b%s$b deleted."
+ #define CSMSG_NOTE_TYPE_USED "Note type $b%s$b is in use; give the FORCE argument to delete it."
+ #define CSMSG_NOTE_DELETED "Note type $b%s$b deleted."
/* Channel [un]suspension */
***************
*** 351,360 ****
#define CSMSG_SEARCH_DATA "%s"
- /* Security override */
- #define CSMSG_ALREADY_HELPING "You already have security override enabled."
- #define CSMSG_ALREADY_NOT_HELPING "You already have security override disabled."
- #define CSMSG_NOW_HELPING "Security override has been enabled."
- #define CSMSG_NOW_NOT_HELPING "Security override has been disabled."
-
/* Channel configuration */
#define CSMSG_INVALID_OPTION "$b%s$b is not a valid option."
--- 356,359 ----
***************
*** 411,415 ****
extern time_t boot_time;
- extern struct policer_params *oper_policer_params, *luser_policer_params, *god_policer_params;
struct userNode *chanserv;
--- 410,413 ----
***************
*** 795,798 ****
--- 793,893 ----
}
+ static MODCMD_FUNC(cmd_createnote) {
+ struct note_type *ntype;
+ unsigned int arg = 1, existed = 0, max_length;
+ extern char *accessNames[];
+
+ if ((ntype = dict_find(note_types, argv[1], NULL))) {
+ existed = 1;
+ } else {
+ ntype = chanserv_create_note_type(argv[arg]);
+ }
+ if (!irccasecmp(argv[++arg], "privileged")) {
+ arg++;
+ ntype->set_access_type = NOTE_SET_PRIVILEGED;
+ ntype->set_access.min_opserv = strtoul(argv[arg], NULL, 0);
+ } else if (!irccasecmp(argv[arg], "channel")) {
+ enum userLevel ulvl;
+ arg++;
+ ntype->set_access_type = NOTE_SET_CHANNEL_ACCESS;
+ for (ulvl = ulPeon; ulvl < ulHelper; ulvl++) {
+ if (!(irccasecmp(argv[arg], accessNames[ulvl]))) break;
+ }
+ if (ulvl == ulHelper) {
+ send_message(user, cmd->parent->bot, CSMSG_INVALID_ACCESS, argv[arg]);
+ goto fail;
+ }
+ ntype->set_access.min_ulevel = ulvl;
+ } else if (!irccasecmp(argv[arg], "setter")) {
+ ntype->set_access_type = NOTE_SET_CHANNEL_SETTER;
+ } else {
+ send_message(user, cmd->parent->bot, CSMSG_BAD_NOTE_ACCESS, argv[arg]);
+ goto fail;
+ }
+
+ if (!irccasecmp(argv[++arg], "privileged")) {
+ ntype->visible_type = NOTE_VIS_PRIVILEGED;
+ } else if (!irccasecmp(argv[arg], "channel_users")) {
+ ntype->visible_type = NOTE_VIS_CHANNEL_USERS;
+ } else if (!irccasecmp(argv[arg], "all")) {
+ ntype->visible_type = NOTE_VIS_ALL;
+ } else {
+ send_message(user, cmd->parent->bot, CSMSG_BAD_NOTE_ACCESS, argv[arg]);
+ goto fail;
+ }
+
+ if ((arg+1) >= argc) {
+ send_message(user, cmd->parent->bot, MSG_MISSING_PARAMS, argv[0]);
+ goto fail;
+ }
+ max_length = strtoul(argv[++arg], NULL, 0);
+ if (max_length < 20 || max_length > 450) {
+ send_message(user, cmd->parent->bot, CSMSG_BAD_MAX_LENGTH, argv[arg]);
+ goto fail;
+ }
+ if(existed && (max_length < ntype->max_length)) {
+ ntype->max_length = max_length;
+ chanserv_truncate_notes(ntype);
+ }
+ ntype->max_length = max_length;
+
+ if (existed) {
+ send_message(user, cmd->parent->bot, CSMSG_NOTE_MODIFIED, ntype->name);
+ } else {
+ send_message(user, cmd->parent->bot, CSMSG_NOTE_CREATED, ntype->name);
+ }
+ return 1;
+
+ fail:
+ if(!existed)
+ {
+ dict_remove(note_types, ntype->name);
+ free(ntype);
+ }
+ return 0;
+ }
+
+ static MODCMD_FUNC(cmd_removenote) {
+ struct note_type *ntype;
+ int force;
+
+ ntype = dict_find(note_types, argv[1], NULL);
+ force = (argc > 2) && !irccasecmp(argv[2], "force");
+ if (!ntype) {
+ send_message(user, cmd->parent->bot, CSMSG_BAD_NOTE_TYPE, argv[1]);
+ return 0;
+ }
+ if (ntype->refs > 1) {
+ if (!force) {
+ send_message(user, cmd->parent->bot, CSMSG_NOTE_TYPE_USED, ntype->name);
+ return 0;
+ }
+ chanserv_flush_note_type(ntype);
+ }
+ dict_remove(note_types, argv[1]);
+ send_message(user, cmd->parent->bot, CSMSG_NOTE_DELETED, argv[1]);
+ return 1;
+ }
+
static int
parse_mode_lock(unsigned char *mode[], int count, struct chanData *channel)
***************
*** 4550,4616 ****
}
- static CHANSERV_FUNC(cmd_god)
- {
- int helping = 0;
- (void)channel;
-
- if(argc > 1)
- {
- if(enabled_string(argv[1]))
- {
- helping = 1;
- }
- else if(disabled_string(argv[1]))
- {
- helping = 0;
- }
- else
- {
- chanserv_notice(user, MSG_INVALID_BINARY, argv[1]);
- return 0;
- }
- }
- else
- {
- helping = !IsHelping(user);
- }
-
- if(HANDLE_FLAGGED(user->handle_info, HELPING))
- {
- if(helping)
- {
- chanserv_notice(user, CSMSG_ALREADY_HELPING);
- }
- else
- {
- HANDLE_CLEAR_FLAG(user->handle_info, HELPING);
- chanserv_notice(user, CSMSG_NOW_NOT_HELPING);
- }
- }
- else
- {
- if(helping)
- {
- HANDLE_SET_FLAG(user->handle_info, HELPING);
- chanserv_notice(user, CSMSG_NOW_HELPING);
- }
- else
- {
- chanserv_notice(user, CSMSG_ALREADY_NOT_HELPING);
- }
- }
-
- if(IsHelping(user))
- {
- policer_set_params(user->command_policer, god_policer_params);
- }
- else
- {
- policer_set_params(user->command_policer, IsOper(user) ? oper_policer_params : luser_policer_params);
- }
-
- return 1;
- }
-
static CHANSERV_FUNC(cmd_expire)
{
--- 4645,4648 ----
***************
*** 6844,6848 ****
chanserv_module = module_register("ChanServ", CS_LOG, "chanserv.help", chanserv_expand_variable);
- DEFINE_COMMAND(god, 1, MODCMD_REQUIRE_AUTHED, "flags", "+oper,+networkhelper", NULL);
DEFINE_COMMAND(register, 1, MODCMD_REQUIRE_AUTHED, "account_flags", "+g", "flags", "+acceptchan", NULL);
DEFINE_COMMAND(noregister, 2, MODCMD_REQUIRE_AUTHED, "account_flags", "+g", NULL);
--- 6876,6879 ----
***************
*** 6852,6855 ****
--- 6883,6888 ----
DEFINE_COMMAND(csuspend, 2, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "account_flags", "+g", NULL);
DEFINE_COMMAND(cunsuspend, 2, MODCMD_REQUIRE_AUTHED, "template", "csuspend", NULL);
+ DEFINE_COMMAND(createnote, 5, 0, "access", "800", NULL);
+ DEFINE_COMMAND(removenote, 5, 0, "access", "800", NULL);
DEFINE_COMMAND(unregister, 1, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "access", "owner", "flags", "+loghostmask", NULL);
Index: chanserv.h
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -r1.42 -r1.43
*** chanserv.h 30 Jul 2002 02:15:11 -0000 1.42
--- chanserv.h 18 Aug 2002 16:04:33 -0000 1.43
***************
*** 219,225 ****
void init_chanserv(const char *nick);
void del_channel_user(struct chanData *channel, struct userData *user);
- struct note_type *chanserv_create_note_type(const char *name);
- void chanserv_flush_note_type(struct note_type *ntype);
- void chanserv_truncate_notes(struct note_type *ntype);
struct chanNode *chanserv_support_channel(void);
enum userLevel user_level_from_name(const char *name);
--- 219,222 ----
Index: helpserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/helpserv.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** helpserv.c 18 Aug 2002 05:50:23 -0000 1.26
--- helpserv.c 18 Aug 2002 16:04:33 -0000 1.27
***************
*** 782,840 ****
}
- /* Handle a control command from an IRC operator */
- int helpserv_oper_cmd(struct userNode *user, int argc, unsigned char *argv[]) {
- struct helpserv_bot *hs = NULL;
- struct helpserv_cmd *cmd;
- const int from_opserv = 1; /* for helpserv_notice */
- char botnick[NICKLEN+1]; /* in case command is unregister */
- int retval;
-
- if (!helpserv_enabled) {
- helpserv_notice(user, HSMSG_DISABLED);
- return 0;
- }
-
- if (argc < 1) {
- send_help(user, opserv, helpserv_helpfile, NULL);
- return 0;
- }
-
- if (!(cmd = dict_find(helpserv_func_dict, argv[0], NULL))) {
- helpserv_notice(user, MSG_COMMAND_UNKNOWN, argv[0]);
- return 0;
- }
-
- if (!cmd->func) {
- helpserv_notice(user, HSMSG_INTERNAL_COMMAND, argv[0]);
- return 0;
- }
-
- if ((cmd->flags & CMD_NEED_BOT) && ((argc < 2) || !(hs = dict_find(helpserv_bots_dict, argv[1], NULL)))) {
- helpserv_notice(user, HSMSG_INVALID_BOT);
- return 0;
- }
-
- if (cmd->flags & CMD_NEVER_FROM_OPSERV) {
- helpserv_notice(user, HSMSG_NO_USE_OPSERV);
- return 0;
- }
-
- if (hs) {
- argv[1] = argv[0];
- strcpy(botnick, hs->helpserv->nick);
- retval = cmd->func(user, hs, 1, argc-1, argv+1);
- } else {
- strcpy(botnick, "No bot");
- retval = cmd->func(user, hs, 1, argc, argv);
- }
-
- if (retval && !(cmd->flags & CMD_IGNORE_EVENT)) {
- char *cmd_text = unsplit_string(argv, argc, NULL);
- log(HS_LOG, LOG_INFO, "%s[%s] (%s): %s%s\n", user->nick, user->handle_info->handle, botnick, cmd_text, (cmd->flags & (CMD_NOT_OVERRIDE|CMD_FROM_OPSERV_ONLY) ? "" : " (override)"));
- }
-
- return retval;
- }
-
static HELPSERV_FUNC(cmd_version) {
(void)hs;
--- 782,785 ----
Index: helpserv.h
===================================================================
RCS file: /cvsroot/srvx/services/src/helpserv.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** helpserv.h 6 May 2002 23:33:12 -0000 1.2
--- helpserv.h 18 Aug 2002 16:04:33 -0000 1.3
***************
*** 23,27 ****
void init_helpserv();
- int helpserv_oper_cmd(struct userNode *user, int argc, unsigned char *argv[]);
#endif
--- 23,26 ----
Index: modcmd.c
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** modcmd.c 18 Aug 2002 05:50:24 -0000 1.18
--- modcmd.c 18 Aug 2002 16:04:33 -0000 1.19
***************
*** 70,73 ****
--- 70,77 ----
#define MCMSG_INHERITED_REQS "Some of the above requirements may have been inherited from the %s requirements."
#define MCMSG_END_REQUIREMENTS "End of requirements for $b%s$b."
+ #define MSMSG_ALREADY_HELPING "You already have security override enabled."
+ #define MSMSG_ALREADY_NOT_HELPING "You already have security override disabled."
+ #define MSMSG_NOW_HELPING "Security override has been enabled."
+ #define MSMSG_NOW_NOT_HELPING "Security override has been disabled."
struct pending_template {
***************
*** 1112,1115 ****
--- 1116,1157 ----
}
+ static MODCMD_FUNC(cmd_god) {
+ extern struct policer_params *luser_policer_params, *god_policer_params;
+ int helping;
+
+ if (argc > 1) {
+ if (enabled_string(argv[1])) {
+ if (HANDLE_FLAGGED(user->handle_info, HELPING)) {
+ send_message(user, cmd->parent->bot, MSMSG_ALREADY_HELPING);
+ return 0;
+ }
+ helping = 1;
+ } else if (disabled_string(argv[1])) {
+ if (!HANDLE_FLAGGED(user->handle_info, HELPING)) {
+ send_message(user, cmd->parent->bot, MSMSG_ALREADY_NOT_HELPING);
+ return 0;
+ }
+ helping = 0;
+ } else {
+ send_message(user, cmd->parent->bot, MSG_INVALID_BINARY, argv[1]);
+ return 0;
+ }
+ } else {
+ helping = !IsHelping(user);
+ }
+
+ if (helping) {
+ HANDLE_SET_FLAG(user->handle_info, HELPING);
+ send_message(user, cmd->parent->bot, MSMSG_NOW_HELPING);
+ if (!IsOper(user)) policer_set_params(user->command_policer, god_policer_params);
+ } else {
+ HANDLE_CLEAR_FLAG(user->handle_info, HELPING);
+ send_message(user, cmd->parent->bot, MSMSG_NOW_NOT_HELPING);
+ if (!IsOper(user)) policer_set_params(user->command_policer, luser_policer_params);
+ }
+
+ return 1;
+ }
+
void
modcmd_nick_change(struct userNode *user, const char *new_nick) {
***************
*** 1213,1216 ****
--- 1255,1259 ----
modcmd_register(modcmd_module, "command", cmd_command, 2, 0, NULL);
modcmd_register(modcmd_module, "modcmd", cmd_modcmd, 4, MODCMD_KEEP_BOUND, "access", "999", NULL);
+ modcmd_register(modcmd_module, "god", cmd_god, 0, MODCMD_REQUIRE_AUTHED, "flags", "+oper,+networkhelper", NULL);
modcmd_register(modcmd_module, "readhelp", cmd_readhelp, 2, 0, "access", "650", NULL);
modcmd_register(modcmd_module, "timecmd", cmd_timecmd, 2, 0, "access", "1", NULL);
***************
*** 1394,1397 ****
--- 1437,1441 ----
service_make_alias(service, "delpeon", "*chanserv.deluser", "peon", "$1", NULL);
service_make_alias(service, "command", "*modcmd.command", NULL);
+ service_make_alias(service, "god", "*modcmd.god", NULL);
}
}
Index: opserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/opserv.c,v
retrieving revision 1.265
retrieving revision 1.266
diff -C2 -r1.265 -r1.266
*** opserv.c 18 Aug 2002 05:50:24 -0000 1.265
--- opserv.c 18 Aug 2002 16:04:33 -0000 1.266
***************
*** 20,27 ****
#include "conf.h"
- #include "chanserv.h"
#include "gline.h"
#include "global.h"
! #include "helpserv.h"
#include "modcmd.h"
#include "opserv.h"
--- 20,26 ----
#include "conf.h"
#include "gline.h"
#include "global.h"
! #include "nickserv.h"
#include "modcmd.h"
#include "opserv.h"
***************
*** 29,40 ****
#include "timeq.h"
#include "saxdb.h"
- #include "sockcheck.h"
- #ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
- #endif
- #ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
- #endif
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
--- 28,32 ----
***************
*** 164,173 ****
#define OSMSG_SOCKCHECK_STATS "Since booting, I have checked %d clients for illicit proxies, and detected %d proxy hosts.\nI am currently checking %d clients (out of %d max) and have a backlog of %d more to start on.\nI currently have %d hosts cached.\nI know how to detect %d kinds of proxies."
#define OSMSG_UNKNOWN_STATS "Unknown statistics type $b%s$b"
- #define OSMSG_SPOOFED_IP "%s has a spoofed, hidden or localnet IP."
- #define OSMSG_ADDRESS_QUEUED "$b%s$b is now queued to be proxy-checked."
- #define OSMSG_HOST_CLEARED "$b%s$b was cleared from the cached hosts list."
- #define OSMSG_HOST_NOTCLEARED "$b%s$b was not cached and therefore was not cleared."
- #define OSMSG_HOST_BUSY "$b%s$b is currently being checked; unable to clear it."
- #define OSMSG_NO_SUCH_ADDRESS "Unable to resolve $b%s$b to an IP address."
#define OSMSG_LINE_DUMPED "Raw line sent."
#define OSMSG_RAW_PARSE_ERROR "Error parsing raw line (not dumping to uplink)."
--- 156,159 ----
***************
*** 219,224 ****
#define OSMSG_UNGAG_ADDED "Ungagged $b%s$b."
#define OSMSG_TIMEQ_INFO "%u events in timeq; next in %lu seconds."
- #define OSMSG_DEFPROXY_FAILED "Proxy definition failed: %s"
- #define OSMSG_DEFPROXY_SUCCESS "New proxy type defined."
#define OSMSG_ALERT_TRIGGERED "Alert $b%s$b triggered by user $b%s$b (%s)."
#define OSMSG_ALERT_EXISTS "An alert named $b%s$b already exists!"
--- 205,208 ----
***************
*** 249,261 ****
#define OSMSG_CURRENT_UPLINK "$b%s$b is already the current uplink."
#define OSMSG_INVALID_UPLINK "$b%s$b is not a valid uplink name."
- #define OSMSG_NOTE_EXISTS "Note $b%s$b already exists."
- #define OSMSG_BAD_CHANNEL_ACCESS "$b%s$b is not a valid channel access level."
- #define OSMSG_BAD_NOTE_ACCESS "$b%s$b is not a valid note access type."
- #define OSMSG_BAD_MAX_LENGTH "$b%s$b is not a valid maximum length (must be at least 20 and less than 512)."
- #define OSMSG_NOTE_CREATED "New note type $b%s$b created."
- #define OSMSG_NOTE_MODIFIED "Note type $b%s$b modified."
- #define OSMSG_NO_SUCH_NOTE "Note type $b%s$b does not exist."
- #define OSMSG_NOTE_TYPE_USED "Note type $b%s$b is in use; give the FORCE argument to delete it."
- #define OSMSG_NOTE_DELETED "Note type $b%s$b deleted."
#define OSMSG_STUPID_GLINE "Gline %s? Now $bthat$b would be smooth."
--- 233,236 ----
***************
*** 1523,1537 ****
}
- static void
- cmd_stats_proxycheck(struct userNode *user)
- {
- struct sockcheck_stats stats;
- sockcheck_get_stats(&stats);
- opserv_notice(user, OSMSG_SOCKCHECK_STATS, stats.checked_ip_count,
- stats.failed_ip_count, stats.checking_ip_count,
- stats.checking_ip_max, stats.pending_ip_count,
- stats.cached_ip_count, stats.test_count);
- }
-
static int
cmd_stats_alerts_helper(const char *key, void *data, void *extra)
--- 1498,1501 ----
***************
*** 1632,1636 ****
else if (!irccasecmp(argv[1], "uptime")) cmd_stats_uptime(user);
else if (!irccasecmp(argv[1], "warn")) cmd_stats_warn(user);
- else if (!irccasecmp(argv[1], "proxycheck")) cmd_stats_proxycheck(user);
else {
opserv_notice(user, OSMSG_UNKNOWN_STATS, argv[1]);
--- 1596,1599 ----
***************
*** 1641,1705 ****
}
- static OPSERV_FUNC(cmd_hostscan)
- {
- unsigned int n;
- unsigned long addr;
- char hnamebuf[64];
-
- OPSERV_MIN_PARMS(2, false);
- for (n=1; n<argc; n++) {
- struct userNode *un = GetUserH(argv[n]);
-
- if (un) {
- if ((un->ip == 0) || (un->ip == 0x7f000001)) {
- opserv_notice(user, OSMSG_SPOOFED_IP, un->nick);
- } else {
- sprintf(hnamebuf, "%ld.%ld.%ld.%ld", (un->ip >> 24) & 255, (un->ip >> 16) & 255, (un->ip >> 8) & 255, un->ip & 255);
- sockcheck_queue_address(un->ip);
- opserv_notice(user, OSMSG_ADDRESS_QUEUED, hnamebuf);
- }
- } else {
- char *scanhost = argv[n];
- if (getipbyname(scanhost, &addr)) {
- sockcheck_queue_address(addr);
- opserv_notice(user, OSMSG_ADDRESS_QUEUED, scanhost);
- } else {
- opserv_notice(user, OSMSG_NO_SUCH_ADDRESS, scanhost);
- }
- }
- }
- return 1;
- }
-
- static OPSERV_FUNC(cmd_clearhost)
- {
- unsigned int n;
- char hnamebuf[64];
-
- OPSERV_MIN_PARMS(2, false);
-
- for (n=1; n<argc; n++) {
- struct userNode *un = GetUserH(argv[n]);
- const char *scanhost;
- int i;
-
- if (un) {
- sprintf(hnamebuf, "%ld.%ld.%ld.%ld", (un->ip >> 24) & 255, (un->ip >> 16) & 255, (un->ip >> 8) & 255, un->ip & 255);
- scanhost = hnamebuf;
- } else {
- scanhost = argv[n];
- }
- i = sockcheck_uncache_host(scanhost);
- if (i == -1) {
- opserv_notice(user, OSMSG_HOST_BUSY, scanhost);
- } else if (i == 0) {
- opserv_notice(user, OSMSG_HOST_NOTCLEARED, scanhost);
- } else {
- opserv_notice(user, OSMSG_HOST_CLEARED, scanhost);
- }
- }
- return 1;
- }
-
static OPSERV_FUNC(cmd_dump)
{
--- 1604,1607 ----
***************
*** 1819,1836 ****
}
- static OPSERV_FUNC(cmd_defproxy)
- {
- const char *reason;
-
- OPSERV_MIN_PARMS(2, false);
-
- if ((reason = sockcheck_add_test(unsplit_string(argv+1, argc-1, NULL)))) {
- opserv_notice(user, OSMSG_DEFPROXY_FAILED, reason);
- return 0;
- }
- opserv_notice(user, OSMSG_DEFPROXY_SUCCESS);
- return 1;
- }
-
static void
opserv_part_channel(void *data)
--- 1721,1724 ----
***************
*** 1875,1879 ****
/* Only proxy check or warn of new user floods outside of bursts. */
if (!user->uplink->burst) {
- sockcheck_queue_address(htonl(user->ip));
if (!policer_conforms(opserv_conf.new_user_policer, now, 10)) {
if (!new_user_flood) {
--- 1763,1766 ----
***************
*** 1886,1890 ****
}
! /* And only warn or G-lie if there's an untrusted max. */
if (opserv_conf.untrusted_max) {
struct trusted_host *th = dict_find(opserv_trusted_hosts, user->hostname, NULL);
--- 1773,1777 ----
}
! /* And only warn or G-line if there's an untrusted max. */
if (opserv_conf.untrusted_max) {
struct trusted_host *th = dict_find(opserv_trusted_hosts, user->hostname, NULL);
***************
*** 3183,3194 ****
static int
- trace_scan_func(struct userNode *match, void *extra)
- {
- (void)extra;
- sockcheck_queue_address(htonl(match->ip));
- return 0;
- }
-
- static int
is_oper_victim(struct userNode *user, struct userNode *target, int match_opers)
{
--- 3070,3073 ----
***************
*** 3344,3348 ****
if (!irccasecmp(argv[1], "print")) action = trace_print_func;
else if (!irccasecmp(argv[1], "count")) action = trace_count_func;
- else if (!irccasecmp(argv[1], "scan")) action = trace_scan_func;
else if (!irccasecmp(argv[1], "domains")) action = trace_domains_func;
else if (!irccasecmp(argv[1], "gline")) action = trace_gline_func;
--- 3223,3226 ----
***************
*** 3777,3881 ****
}
- static OPSERV_FUNC(cmd_addnote)
- {
- struct note_type *ntype;
- unsigned int arg = 1, existed = 0, max_length;
- extern char *accessNames[];
-
- OPSERV_MIN_PARMS(5, false);
- if ((ntype = dict_find(note_types, argv[1], NULL))) {
- existed = 1;
- } else {
- ntype = chanserv_create_note_type(argv[arg]);
- }
- if (!irccasecmp(argv[++arg], "privileged")) {
- arg++;
- ntype->set_access_type = NOTE_SET_PRIVILEGED;
- ntype->set_access.min_opserv = strtoul(argv[arg], NULL, 0);
- } else if (!irccasecmp(argv[arg], "channel")) {
- enum userLevel ulvl;
- arg++;
- ntype->set_access_type = NOTE_SET_CHANNEL_ACCESS;
- for (ulvl = ulPeon; ulvl < ulHelper; ulvl++) {
- if (!(irccasecmp(argv[arg], accessNames[ulvl]))) break;
- }
- if (ulvl == ulHelper) {
- opserv_notice(user, OSMSG_BAD_CHANNEL_ACCESS, argv[arg]);
- goto fail;
- }
- ntype->set_access.min_ulevel = ulvl;
- } else if (!irccasecmp(argv[arg], "setter")) {
- ntype->set_access_type = NOTE_SET_CHANNEL_SETTER;
- } else {
- opserv_notice(user, OSMSG_BAD_NOTE_ACCESS, argv[arg]);
- goto fail;
- }
-
- if (!irccasecmp(argv[++arg], "privileged")) {
- ntype->visible_type = NOTE_VIS_PRIVILEGED;
- } else if (!irccasecmp(argv[arg], "channel_users")) {
- ntype->visible_type = NOTE_VIS_CHANNEL_USERS;
- } else if (!irccasecmp(argv[arg], "all")) {
- ntype->visible_type = NOTE_VIS_ALL;
- } else {
- opserv_notice(user, OSMSG_BAD_NOTE_ACCESS, argv[arg]);
- goto fail;
- }
-
- if ((arg+1) >= argc) {
- opserv_notice(user, MSG_MISSING_PARAMS, argv[0]);
- goto fail;
- }
- max_length = strtoul(argv[++arg], NULL, 0);
- if (max_length < 20 || max_length > 512) {
- opserv_notice(user, OSMSG_BAD_MAX_LENGTH, argv[arg]);
- goto fail;
- }
- if(existed && (max_length < ntype->max_length)) {
- ntype->max_length = max_length;
- chanserv_truncate_notes(ntype);
- }
- ntype->max_length = max_length;
-
- if (existed) {
- opserv_notice(user, OSMSG_NOTE_MODIFIED, ntype->name);
- } else {
- opserv_notice(user, OSMSG_NOTE_CREATED, ntype->name);
- }
- return 1;
-
- fail:
- if(!existed)
- {
- dict_remove(note_types, ntype->name);
- free(ntype);
- }
- return 0;
- }
-
- static OPSERV_FUNC(cmd_delnote)
- {
- struct note_type *ntype;
- int force;
-
- OPSERV_MIN_PARMS(2, false);
- ntype = dict_find(note_types, argv[1], NULL);
- force = (argc > 2) && !irccasecmp(argv[2], "force");
- if (!ntype) {
- opserv_notice(user, OSMSG_NO_SUCH_NOTE, argv[1]);
- return 0;
- }
- if (ntype->refs > 1) {
- if (!force) {
- opserv_notice(user, OSMSG_NOTE_TYPE_USED, ntype->name);
- return 0;
- }
- chanserv_flush_note_type(ntype);
- }
- dict_remove(note_types, argv[1]);
- opserv_notice(user, OSMSG_NOTE_DELETED, argv[1]);
- return 1;
- }
-
static int
gag_helper_func(struct userNode *match, void *extra)
--- 3655,3658 ----
***************
*** 4042,4051 ****
}
- static OPSERV_FUNC(cmd_helpserv)
- {
- (void)channel;
- return helpserv_oper_cmd(user, argc-1, argv+1);
- }
-
static void
opserv_conf_read(void)
--- 3819,3822 ----
***************
*** 4191,4195 ****
opserv_define_func("ADDBAD", cmd_addbad, 800, 0);
opserv_define_func("ADDEXEMPT", cmd_addexempt, 800, 0);
- opserv_define_func("ADDNOTE", cmd_addnote, 800, 0);
opserv_define_func("ADDTRUST", cmd_addtrust, 800, 0);
opserv_define_func("BAN", cmd_ban, 100, 2);
--- 3962,3965 ----
***************
*** 4197,4209 ****
opserv_define_func("CHANINFO", cmd_chaninfo, 0, 3);
opserv_define_func("CLEARBANS", cmd_clearbans, 300, 2);
- opserv_define_func("CLEARHOST", cmd_clearhost, 650, 0);
opserv_define_func("CLEARMODES", cmd_clearmodes, 400, 2);
opserv_define_func("CLONE", cmd_clone, 999, 0);
opserv_define_func("COLLIDE", cmd_collide, 800, 0);
- opserv_define_func("DEFPROXY", cmd_defproxy, 999, 0);
opserv_define_func("DELALERT", cmd_delalert, 800, 0);
opserv_define_func("DELBAD", cmd_delbad, 800, 0);
opserv_define_func("DELEXEMPT", cmd_delexempt, 800, 0);
- opserv_define_func("DELNOTE", cmd_delnote, 800, 0);
opserv_define_func("DELTRUST", cmd_deltrust, 800, 0);
opserv_define_func("DEOP", cmd_deop, 100, 2);
--- 3967,3976 ----
***************
*** 4214,4219 ****
opserv_define_func("GAG", cmd_gag, 600, 0);
opserv_define_func("GLINE", cmd_gline, 600, 0);
- opserv_define_func("HELPSERV", cmd_helpserv, 800, 0);
- opserv_define_func("HOSTSCAN", cmd_hostscan, 650, 0);
opserv_define_func("INVITEME", cmd_inviteme, 100, 0);
opserv_define_func("JOIN", cmd_join, 601, 1);
--- 3981,3984 ----
***************
*** 4246,4250 ****
opserv_define_func("TRACE COUNT", NULL, 0, 0);
opserv_define_func("TRACE DOMAINS", NULL, 0, 0);
- opserv_define_func("TRACE SCAN", NULL, 650, 0);
opserv_define_func("TRACE GLINE", NULL, 600, 0);
opserv_define_func("TRACE GAG", NULL, 600, 0);
--- 4011,4014 ----
Index: proto-common.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-common.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** proto-common.c 14 Aug 2002 03:03:58 -0000 1.8
--- proto-common.c 18 Aug 2002 16:04:33 -0000 1.9
***************
*** 26,36 ****
#include "timeq.h"
- #ifdef HAVE_NETDB_H
- #include <netdb.h>
- #endif
- #ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
- #endif
-
unsigned int lines_processed;
FILE *replay_file;
--- 26,29 ----
Index: sockcheck.c
===================================================================
RCS file: /cvsroot/srvx/services/src/sockcheck.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -r1.76 -r1.77
*** sockcheck.c 14 Aug 2002 03:03:58 -0000 1.76
--- sockcheck.c 18 Aug 2002 16:04:33 -0000 1.77
***************
*** 22,26 ****
#include "gline.h"
#include "ioset.h"
! #include "log.h"
#include "timeq.h"
#include "sockcheck.h"
--- 22,26 ----
#include "gline.h"
#include "ioset.h"
! #include "modcmd.h"
#include "timeq.h"
#include "sockcheck.h"
***************
*** 134,137 ****
--- 134,138 ----
static struct sockcheck_client **client_list;
static unsigned int proxies_detected, checked_ip_count;
+ static struct module *sockcheck_module;
static struct sockcheck_list *
***************
*** 968,971 ****
--- 969,1060 ----
}
+ static MODCMD_FUNC(cmd_defproxy)
+ {
+ const char *reason;
+
+ if ((reason = sockcheck_add_test(unsplit_string(argv+1, argc-1, NULL)))) {
+ send_message(user, cmd->parent->bot, "Proxy definition failed: %s", reason);
+ return 0;
+ }
+ send_message(user, cmd->parent->bot, "New proxy type defined.");
+ return 1;
+ }
+
+ static MODCMD_FUNC(cmd_hostscan)
+ {
+ unsigned int n;
+ unsigned long addr;
+ char hnamebuf[64];
+
+ for (n=1; n<argc; n++) {
+ struct userNode *un = GetUserH(argv[n]);
+
+ if (un) {
+ if ((un->ip == 0) || (un->ip == 0x7f000001)) {
+ send_message(user, cmd->parent->bot, "%s has a spoofed, hidden or localnet IP.", un->nick);
+ } else {
+ sprintf(hnamebuf, "%ld.%ld.%ld.%ld", (un->ip >> 24) & 255, (un->ip >> 16) & 255, (un->ip >> 8) & 255, un->ip & 255);
+ sockcheck_queue_address(un->ip);
+ send_message(user, cmd->parent->bot, "$b%s$b is now queued to be proxy-checked.", hnamebuf);
+ }
+ } else {
+ char *scanhost = argv[n];
+ if (getipbyname(scanhost, &addr)) {
+ sockcheck_queue_address(addr);
+ send_message(user, cmd->parent->bot, "$b%s$b is now queued to be proxy-checked.", scanhost);
+ } else {
+ send_message(user, cmd->parent->bot, "Unable to resolve $b%s$b to an IP address.", scanhost);
+ }
+ }
+ }
+ return 1;
+ }
+
+ static MODCMD_FUNC(cmd_clearhost)
+ {
+ unsigned int n;
+ char hnamebuf[64];
+
+ for (n=1; n<argc; n++) {
+ struct userNode *un = GetUserH(argv[n]);
+ const char *scanhost;
+
+ if (un) {
+ sprintf(hnamebuf, "%ld.%ld.%ld.%ld", (un->ip >> 24) & 255, (un->ip >> 16) & 255, (un->ip >> 8) & 255, un->ip & 255);
+ scanhost = hnamebuf;
+ } else {
+ scanhost = argv[n];
+ }
+ switch (sockcheck_uncache_host(scanhost)) {
+ case -1:
+ send_message(user, cmd->parent->bot, "$b%s$b is currently being checked; unable to clear it.", scanhost);
+ break;
+ case 0:
+ send_message(user, cmd->parent->bot, "$b%s$b was not cached and therefore was not cleared.", scanhost);
+ break;
+ default:
+ send_message(user, cmd->parent->bot, "$b%s$b was cleared from the cached hosts list.", scanhost);
+ break;
+ }
+ }
+ return 1;
+ }
+
+ static MODCMD_FUNC(cmd_stats_proxycheck)
+ {
+ (void)argv;
+ send_message(user, cmd->parent->bot, "Since booting, I have checked %d clients for illicit proxies, and detected %d proxy hosts.\nI am currently checking %d clients (out of %d max) and have a backlog of %d more to start on.\nI currently have %d hosts cached.\nI know how to detect %d kinds of proxies.",
+ checked_ip_count, proxies_detected, sockcheck_num_clients, sockcheck_conf.max_clients, pending_sci_list.used, dict_size(checked_ip_dict), (tests ? tests->used : 0));
+ return 0;
+ }
+
+ static int
+ sockcheck_new_user(struct userNode *user) {
+ /* If they have a bum IP, or are bursting in, don't proxy-check or G-line them. */
+ if ((user->ip == 0) || (user->ip == htonl(0x7f000001)) || user->uplink->burst) return 0;
+ sockcheck_queue_address(htonl(user->ip));
+ return 0;
+ }
+
static void
_sockcheck_init(void)
***************
*** 982,986 ****
}
! void
sockcheck_read_conf(void)
{
--- 1071,1075 ----
}
! static void
sockcheck_read_conf(void)
{
***************
*** 1049,1063 ****
reg_exit_func(sockcheck_shutdown);
_sockcheck_init();
! }
!
! void
! sockcheck_get_stats(struct sockcheck_stats *stats)
! {
! stats->checked_ip_count = checked_ip_count;
! stats->failed_ip_count = proxies_detected;
! stats->checking_ip_count = sockcheck_num_clients;
! stats->checking_ip_max = sockcheck_conf.max_clients;
! stats->pending_ip_count = pending_sci_list.used;
! stats->test_count = tests ? tests->used : 0;
! stats->cached_ip_count = dict_size(checked_ip_dict);
}
--- 1138,1146 ----
reg_exit_func(sockcheck_shutdown);
_sockcheck_init();
! sockcheck_module = module_register("ProxyCheck", PC_LOG, "sockcheck.help", NULL);
! modcmd_register(sockcheck_module, "defproxy", cmd_defproxy, 2, 0, "access", "999", NULL);
! modcmd_register(sockcheck_module, "hostscan", cmd_hostscan, 2, 0, "access", "650", NULL);
! modcmd_register(sockcheck_module, "clearhost", cmd_clearhost, 2, 0, "access", "650", NULL);
! modcmd_register(sockcheck_module, "stats proxycheck", cmd_stats_proxycheck, 0, 0, NULL);
! reg_new_user_func(sockcheck_new_user);
}
Index: sockcheck.h
===================================================================
RCS file: /cvsroot/srvx/services/src/sockcheck.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** sockcheck.h 6 May 2002 23:33:12 -0000 1.11
--- sockcheck.h 18 Aug 2002 16:04:33 -0000 1.12
***************
*** 22,40 ****
#define SOCKCHECK_H
- struct sockcheck_stats {
- unsigned int checked_ip_count;
- unsigned int failed_ip_count;
- unsigned int checking_ip_count;
- unsigned int checking_ip_max;
- unsigned int pending_ip_count;
- unsigned int test_count;
- unsigned int cached_ip_count;
- };
-
void sockcheck_init(void);
- const char *sockcheck_add_test(const char *desc);
- void sockcheck_queue_address(unsigned long addr);
- int sockcheck_uncache_host(const char *name);
- void sockcheck_get_stats(struct sockcheck_stats *stats);
#endif /* !defined(SOCKCHECK_H) */
--- 22,26 ----
|