This commit is contained in:
Mark 2004-08-18 21:54:13 +00:00
parent 73f0d12ffd
commit 010c25d898
4 changed files with 55 additions and 43 deletions

View file

@ -30,7 +30,7 @@
static char ban_buf[BANBUFSIZE];
typedef struct hs_map_ {
char nnick[MAXNICK];
char nick[MAXNICK];
char host[MAXHOST];
char vhost[MAXHOST];
char passwd[MAXPASS];
@ -156,22 +156,22 @@ ModuleEvent module_events[] = {
int findnick(const void *key1, const void *key2)
{
const hs_map *vhost = key1;
return (ircstrcasecmp(vhost->nnick, (char *)key2));
return (ircstrcasecmp(vhost->nick, (char *)key2));
}
void save_vhost(hs_map *vhost)
{
SetData((void *)vhost->host, CFGSTR, "Vhosts", vhost->nnick, "Host");
SetData((void *)vhost->vhost, CFGSTR, "Vhosts", vhost->nnick , "Vhost");
SetData((void *)vhost->passwd, CFGSTR, "Vhosts", vhost->nnick , "Passwd");
SetData((void *)vhost->added, CFGSTR, "Vhosts", vhost->nnick , "Added");
SetData((void *)vhost->lused, CFGINT, "Vhosts", vhost->nnick , "LastUsed");
SetData((void *)vhost->host, CFGSTR, "Vhosts", vhost->nick, "Host");
SetData((void *)vhost->vhost, CFGSTR, "Vhosts", vhost->nick , "Vhost");
SetData((void *)vhost->passwd, CFGSTR, "Vhosts", vhost->nick , "Passwd");
SetData((void *)vhost->added, CFGSTR, "Vhosts", vhost->nick , "Added");
SetData((void *)vhost->lused, CFGINT, "Vhosts", vhost->nick , "LastUsed");
list_sort(vhosts, findnick);
}
void del_vhost(hs_map *vhost)
{
DelRow("Vhosts", vhost->nnick);
DelRow("Vhosts", vhost->nick);
ns_free(vhost);
/* no need to list sort here, because its already sorted */
}
@ -350,7 +350,7 @@ static void hsdat(char *nick, char *host, char *vhost, char *pass, char *who)
hs_map *map;
map = ns_malloc(sizeof(hs_map));
strlcpy(map->nnick, nick, MAXNICK);
strlcpy(map->nick, nick, MAXNICK);
strlcpy(map->host, host, MAXHOST);
strlcpy(map->vhost, vhost, MAXHOST);
strlcpy(map->passwd, pass, MAXPASS);
@ -539,7 +539,7 @@ static int hs_chpass(CmdParams* cmdparams)
"Password Successfully changed");
irc_chanalert(hs_bot,
"%s changed the password for %s",
cmdparams->source->name, map->nnick);
cmdparams->source->name, map->nick);
map->lused = me.now;
save_vhost(map);
return NS_SUCCESS;
@ -549,11 +549,11 @@ static int hs_chpass(CmdParams* cmdparams)
"Error, Hostname Mis-Match");
irc_chanalert(hs_bot,
"%s tried to change the password for %s, but the hosts do not match (%s->%s)",
cmdparams->source->name, map->nnick, cmdparams->source->user->hostname,
cmdparams->source->name, map->nick, cmdparams->source->user->hostname,
map->host);
nlog(LOG_WARNING,
"%s tried to change the password for %s but the hosts do not match (%s -> %s)",
cmdparams->source->name, map->nnick, cmdparams->source->user->hostname, map->host);
cmdparams->source->name, map->nick, cmdparams->source->user->hostname, map->host);
return NS_SUCCESS;
}
}
@ -667,7 +667,7 @@ static int hs_list(CmdParams* cmdparams)
}
map = lnode_get(hn);
irc_prefmsg(hs_bot, cmdparams->source, "%-5d %-12s %-30s", i,
map->nnick, map->vhost);
map->nick, map->vhost);
i++;
/* limit to x entries per screen */
if (i > start + 20)
@ -708,7 +708,7 @@ static int hs_view(CmdParams* cmdparams)
if (tmpint == i) {
map = lnode_get(hn);
irc_prefmsg(hs_bot, cmdparams->source, "Virtual Host information:");
irc_prefmsg(hs_bot, cmdparams->source, "Nick: %s", map->nnick);
irc_prefmsg(hs_bot, cmdparams->source, "Nick: %s", map->nick);
irc_prefmsg(hs_bot, cmdparams->source, "Real host: %s", map->host);
irc_prefmsg(hs_bot, cmdparams->source, "Vhost: %s", map->vhost);
irc_prefmsg(hs_bot, cmdparams->source, "Password: %s", map->passwd);
@ -742,19 +742,19 @@ static void LoadHosts()
if (GetTableData("Vhosts", &LoadArray) > 0) {
for (count = 0; LoadArray[count] != NULL; count++) {
map = ns_malloc(sizeof(hs_map));
strlcpy(map->nnick, LoadArray[count], MAXNICK);
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nnick, "Host") > 0)
strlcpy(map->nick, LoadArray[count], MAXNICK);
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nick, "Host") > 0)
strlcpy(map->host, tmp, MAXHOST);
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nnick, "Vhost") > 0)
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nick, "Vhost") > 0)
strlcpy(map->vhost, tmp, MAXHOST);
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nnick, "Passwd") > 0)
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nick, "Passwd") > 0)
strlcpy(map->passwd, tmp, MAXPASS);
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nnick, "Added") > 0)
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nick, "Added") > 0)
strlcpy(map->added, tmp, MAXNICK);
GetData((void *)&map->lused, CFGINT, "Vhosts", map->nnick, "LastUsed");
GetData((void *)&map->lused, CFGINT, "Vhosts", map->nick, "LastUsed");
lnode_create_append (vhosts, map);
dlog(DEBUG1, "Loaded %s (%s) into Vhosts",
map->nnick, map->vhost);
map->nick, map->vhost);
}
}
ns_free(LoadArray);
@ -786,11 +786,11 @@ static int hs_del(CmdParams* cmdparams)
if (i == tmpint) {
map = lnode_get(hn);
irc_prefmsg(hs_bot, cmdparams->source, "removed vhost %s for %s",
map->nnick, map->vhost);
map->nick, map->vhost);
nlog(LOG_NOTICE, "%s removed the vhost %s for %s",
cmdparams->source->name, map->vhost, map->nnick);
cmdparams->source->name, map->vhost, map->nick);
irc_chanalert(hs_bot, "%s removed vhost %s for %s",
cmdparams->source->name, map->vhost, map->nnick);
cmdparams->source->name, map->vhost, map->nick);
del_vhost(map);
list_delete(vhosts, hn);
lnode_destroy(hn);
@ -854,7 +854,7 @@ int CleanupHosts()
map = lnode_get(hn);
if (map->lused < (me.now - (hs_cfg.old * 86400))) {
nlog(LOG_NOTICE, "Expiring old vhost: %s for %s",
map->vhost, map->nnick);
map->vhost, map->nick);
del_vhost(map);
hn2 = list_next(vhosts, hn);
list_delete(vhosts, hn);

View file

@ -432,6 +432,8 @@ void StatsQuitUser(Client * u)
void StatsGlobalKill(Client * u)
{
SStats *ss;
/* Treat as a quit for stats */
StatsQuitUser (u);
ss = findserverstats(u->uplink->name);
@ -440,6 +442,8 @@ void StatsGlobalKill(Client * u)
void StatsServerKill(Client * u)
{
SStats *ss;
/* Treat as a quit for stats */
StatsQuitUser (u);
ss = findserverstats(u->name);

View file

@ -666,6 +666,11 @@ do_protocol (char *origin, char **argv, int argc)
ircd_srv.protocol |= PROTOCOL_NICKIP;
}
}
else if (!ircstrcasecmp ("NICKv2", argv[i])) {
if(protocol_info->optprotocol&PROTOCOL_NICKv2) {
ircd_srv.protocol |= PROTOCOL_NICKv2;
}
}
}
}

View file

@ -62,9 +62,6 @@ static void m_setname (char *origin, char **argv, int argc, int srv);
static void m_sethost (char *origin, char **argv, int argc, int srv);
static void m_setident (char *origin, char **argv, int argc, int srv);
#define NICKV2
#define NICKIP
/* buffer sizes */
const int proto_maxhost = (128 + 1);
const int proto_maxpass = (32 + 1);
@ -78,7 +75,7 @@ ProtocolInfo protocol_info = {
/* Protocol options required by this IRCd */
PROTOCOL_SJOIN,
/* Protocol options negotiated at link by this IRCd */
PROTOCOL_TOKEN,
PROTOCOL_TOKEN | PROTOCOL_NICKIP | PROTOCOL_NICKv2,
/* Features supported by this IRCd */
FEATURE_UMODECLOAK,
"+oSq",
@ -781,21 +778,27 @@ static void
m_nick (char *origin, char **argv, int argc, int srv)
{
if(!srv) {
#ifdef NICKV2
#ifdef NICKIP
char ip[25];
if (ircd_srv.protocol&PROTOCOL_NICKv2)
{
if (ircd_srv.protocol&PROTOCOL_NICKIP)
{
char ip[25];
ircsnprintf(ip, 25, "%d", decode_ip(argv[9]));
do_nick (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5],
ip, argv[6], argv[7], argv[8], argv[10], NULL, NULL);
#else
do_nick (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5],
NULL, argv[6], argv[7], argv[8], argv[9], NULL, NULL);
#endif
#else
do_nick (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5],
NULL, argv[6], NULL, NULL, argv[9], NULL, NULL);
#endif
ircsnprintf(ip, 25, "%d", decode_ip(argv[9]));
do_nick (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5],
ip, argv[6], argv[7], argv[8], argv[10], NULL, NULL);
}
else
{
do_nick (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5],
NULL, argv[6], argv[7], argv[8], argv[9], NULL, NULL);
}
}
else
{
do_nick (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5],
NULL, argv[6], NULL, NULL, argv[9], NULL, NULL);
}
} else {
do_nickchange (origin, argv[0], NULL);
}