hybrid rc4 fixes... Persistant Channel fixes
This commit is contained in:
parent
b03bef5f8e
commit
70592e1740
46 changed files with 1636 additions and 3163 deletions
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -464,9 +464,6 @@ tools/.cvsignore -text
|
|||
tools/Makefile.in -text
|
||||
tools/README -text
|
||||
tools/README.mkpasswd -text
|
||||
tools/convertconf.c -text
|
||||
tools/convertilines.c -text
|
||||
tools/convertklines.c -text
|
||||
tools/descrip.mms -text
|
||||
tools/encspeed.c -text
|
||||
tools/mkkeypair -text
|
||||
|
|
|
@ -4,6 +4,10 @@ Symbols are:
|
|||
(F) - Fish (fish@dynam.ac)
|
||||
(S) - Shmad (shmad@#neostats.net)
|
||||
(HP) - Hybrid Team Patches to Hybrid Source
|
||||
* NeoIRCd Version 0.9.3 - 19th Sept, 2002 - Fish
|
||||
(HP) - Merged in Hybrid rc4 Patches (including Rc3 and Rc3 fixes)
|
||||
(F) - Fixed up Persistant Channels.
|
||||
|
||||
|
||||
* NeoIRCd Version 0.9.2 - 17th Sept, 2002 - Fish
|
||||
(F) - Fixed a problem with servers setting modes
|
||||
|
@ -13,6 +17,7 @@ Symbols are:
|
|||
(F) - Moved m_opme m_ojoin and m_clearchan to standard modules (and fixed them up)
|
||||
(F) - added svsjoin and svspart (based on m_force.c contrib module)
|
||||
(F) - Maybe fixed a segfault when a server gets disconnected
|
||||
(F) - Fix some of the global oper messages being broadcast network wide by each server.
|
||||
|
||||
* NeoIRCd Version 0.9.1 - 12th August, 2002 - Fish
|
||||
(F) - Added +S UserMode. For Services. Allow them to override anything
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: channel.h,v 1.9 2002/09/16 07:47:00 fishwaldo Exp $
|
||||
* $Id: channel.h,v 1.10 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_channel_h
|
||||
|
@ -103,7 +103,9 @@ extern int is_any_op (struct Channel *chptr,struct Client *who);
|
|||
extern int is_half_op (struct Channel *chptr,struct Client *who);
|
||||
extern int is_voiced (struct Channel *chptr,struct Client *who);
|
||||
|
||||
extern dlink_node *find_user_link (dlink_list *, struct Client *);
|
||||
#define find_user_link(list,who) who!=NULL?dlinkFind(list,who):NULL
|
||||
#define FIND_AND_DELETE(list,who) who!=NULL?dlinkFindDelete(list,who)
|
||||
|
||||
extern void add_user_to_channel(struct Channel *chptr,
|
||||
struct Client *who, int flags);
|
||||
extern int remove_user_from_channel(struct Channel *chptr,
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: hostmask.h,v 1.3 2002/09/13 06:50:06 fishwaldo Exp $
|
||||
* $Id: hostmask.h,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_hostmask_h
|
||||
|
@ -53,7 +53,9 @@ void clear_out_address_conf(void);
|
|||
void init_host_hash(void);
|
||||
struct ConfItem* find_address_conf(const char*, const char*,
|
||||
struct irc_inaddr*, int);
|
||||
struct ConfItem* find_dline(struct irc_inaddr *, int);
|
||||
struct ConfItem* find_kline_conf(const char*, const char*,
|
||||
struct irc_inaddr*, int);
|
||||
struct ConfItem* find_dline_conf(struct irc_inaddr *, int);
|
||||
|
||||
void report_Klines(struct Client*, int temp);
|
||||
void report_auth(struct Client*);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: irc_string.h,v 1.3 2002/09/13 06:50:06 fishwaldo Exp $
|
||||
* $Id: irc_string.h,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_irc_string_h
|
||||
|
@ -30,9 +30,11 @@
|
|||
* match - returns 1 on successful match, 0 otherwise
|
||||
*
|
||||
* match_esc - compare with support for escaping chars
|
||||
* match_cidr - compares u!h@addr with u!h@addr/cidr
|
||||
*/
|
||||
extern int match(const char *mask, const char *name);
|
||||
extern int match_esc(const char *mask, const char *name);
|
||||
extern int match_cidr(const char *mask, const char *name);
|
||||
|
||||
/*
|
||||
* collapse - collapse a string in place, converts multiple adjacent *'s
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: numeric.h,v 1.7 2002/09/13 16:30:03 fishwaldo Exp $
|
||||
* $Id: numeric.h,v 1.8 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_numeric_h
|
||||
|
@ -249,6 +249,7 @@ extern const char* form_str(int);
|
|||
/* RPL_COMMANDSYNTAX 334 Dalnet */
|
||||
/* RPL_LISTSYNTAX 334 unreal */
|
||||
/* RPL_CHANPASSOK 338 IRCnet extension (?)*/
|
||||
#define RPL_WHOISACTUALLY 338 /* dalnet */
|
||||
/* RPL_WHOISACTUALLY 338 Undernet extension, dalnet */
|
||||
/* RPL_BADCHANPASS 339 IRCnet extension (?)*/
|
||||
/* RPL_USERIP 340 (old) Undernet extension */
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: patchlevel.h,v 1.4 2002/09/17 06:50:46 fishwaldo Exp $
|
||||
* $Id: patchlevel.h,v 1.5 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#ifndef PATCHLEVEL
|
||||
#define PATCHLEVEL "NeoIRCd 0.9.2"
|
||||
#define PATCHLEVEL "NeoIRCd 0.9.3"
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_log.h,v 1.3 2002/09/13 06:50:06 fishwaldo Exp $
|
||||
* $Id: s_log.h,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_s_log_h
|
||||
|
@ -44,5 +44,6 @@ extern const char *get_log_level_as_string(int level);
|
|||
|
||||
extern void log_user_exit(struct Client *);
|
||||
extern void log_oper(struct Client *, char *name);
|
||||
extern void log_failed_oper(struct Client *, char *name);
|
||||
|
||||
#endif /* INCLUDED_s_log_h */
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_stats.h,v 1.3 2002/09/13 06:50:06 fishwaldo Exp $
|
||||
* $Id: s_stats.h,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_s_stats_h
|
||||
|
@ -33,9 +33,12 @@ struct Client;
|
|||
* statistics structures
|
||||
*/
|
||||
struct ServerStatistics {
|
||||
|
||||
/* These are trivially derived from dlink_list_length */
|
||||
unsigned int is_cl; /* number of client connections */
|
||||
unsigned int is_sv; /* number of server connections */
|
||||
unsigned int is_ni; /* connection but no idea who it was */
|
||||
|
||||
unsigned short is_cbs; /* bytes sent to clients */
|
||||
unsigned short is_cbr; /* bytes received to clients */
|
||||
unsigned short is_sbs; /* bytes sent to servers */
|
||||
|
@ -54,11 +57,8 @@ struct ServerStatistics {
|
|||
unsigned int is_empt; /* empty message */
|
||||
unsigned int is_num; /* numeric message */
|
||||
unsigned int is_kill; /* number of kills generated on collisions */
|
||||
unsigned int is_fake; /* MODE 'fakes' */
|
||||
unsigned int is_asuc; /* successful auth requests */
|
||||
unsigned int is_abad; /* bad auth requests */
|
||||
unsigned int is_udp; /* packets recv'd on udp port */
|
||||
unsigned int is_loc; /* local connections made */
|
||||
};
|
||||
|
||||
extern struct ServerStatistics* ServerStats;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: tools.h,v 1.3 2002/09/13 06:50:06 fishwaldo Exp $
|
||||
* $Id: tools.h,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TOOLS_H__
|
||||
|
@ -42,6 +42,7 @@ struct _dlink_node {
|
|||
struct _dlink_list {
|
||||
dlink_node *head;
|
||||
dlink_node *tail;
|
||||
unsigned long length;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -59,18 +60,43 @@ dlinkDelete(dlink_node *m, dlink_list *list);
|
|||
void
|
||||
dlinkMoveList(dlink_list *from, dlink_list *to);
|
||||
|
||||
int
|
||||
dlink_list_length(dlink_list *m);
|
||||
|
||||
dlink_node *
|
||||
dlinkFind(dlink_list *m, void *data);
|
||||
|
||||
dlink_node *
|
||||
dlinkFindDelete(dlink_list *m, void *data);
|
||||
|
||||
#ifndef NDEBUG
|
||||
void mem_frob(void *data, int len);
|
||||
#else
|
||||
#define mem_frob(x, y)
|
||||
#endif
|
||||
|
||||
/* These macros are basically swiped from the linux kernel
|
||||
* they are simple yet effective
|
||||
*/
|
||||
|
||||
/*
|
||||
* Walks forward of a list.
|
||||
* pos is your node
|
||||
* head is your list head
|
||||
*/
|
||||
#define DLINK_FOREACH(pos, head) for (pos = (head); pos != NULL; pos = pos->next)
|
||||
|
||||
/*
|
||||
* Walks forward of a list safely while removing nodes
|
||||
* pos is your node
|
||||
* n is another list head for temporary storage
|
||||
* head is your list head
|
||||
*/
|
||||
#define DLINK_FOREACH_SAFE(pos, n, head) for (pos = (head), n = pos ? pos->next : NULL; pos != NULL; pos = n, n = pos ? pos->next : NULL)
|
||||
|
||||
#define DLINK_FOREACH_PREV(pos, head) for (pos = (head); pos != NULL; pos = pos->prev)
|
||||
|
||||
|
||||
/* Returns the list length */
|
||||
#define dlink_list_length(list) (list)->length
|
||||
|
||||
/*
|
||||
* The functions below are included for the sake of inlining
|
||||
* hopefully this will speed up things just a bit
|
||||
|
@ -97,6 +123,7 @@ dlinkAdd(void *data, dlink_node * m, dlink_list * list)
|
|||
else if (list->tail == NULL)
|
||||
list->tail = m;
|
||||
list->head = m;
|
||||
list->length++;
|
||||
}
|
||||
|
||||
extern inline void
|
||||
|
@ -111,6 +138,7 @@ dlinkAddBefore(dlink_node *b, void *data, dlink_node *m, dlink_list *list)
|
|||
m->prev = b->prev;
|
||||
b->prev = m;
|
||||
m->next = b;
|
||||
list->length++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,6 +154,7 @@ dlinkAddTail(void *data, dlink_node *m, dlink_list *list)
|
|||
else if (list->head == NULL)
|
||||
list->head = m;
|
||||
list->tail = m;
|
||||
list->length++;
|
||||
}
|
||||
|
||||
/* Execution profiles show that this function is called the most
|
||||
|
@ -145,25 +174,9 @@ dlinkDelete(dlink_node *m, dlink_list *list)
|
|||
m->prev->next = m->next;
|
||||
else
|
||||
list->head = m->next;
|
||||
/* XXX - does this ever matter? */
|
||||
/* Set this to NULL does matter */
|
||||
m->next = m->prev = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* dlink_list_length
|
||||
* inputs - pointer to a dlink_list
|
||||
* output - return the length (>=0) of a chain of links.
|
||||
* side effects -
|
||||
*/
|
||||
extern inline int dlink_list_length(dlink_list *list)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
int count = 0;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = ptr->next)
|
||||
count++;
|
||||
return count;
|
||||
list->length--;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -201,6 +214,8 @@ dlinkMoveList(dlink_list *from, dlink_list *to)
|
|||
to->head = from->head;
|
||||
to->tail = from->tail;
|
||||
from->head = from->tail = NULL;
|
||||
to->length = from->length;
|
||||
from->length = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -211,6 +226,8 @@ dlinkMoveList(dlink_list *from, dlink_list *to)
|
|||
to->head->prev = from->tail;
|
||||
to->head = from->head;
|
||||
from->head = from->tail = NULL;
|
||||
to->length += from->length;
|
||||
from->length = 0;
|
||||
|
||||
/* I think I got that right */
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_nick.c,v 1.8 2002/09/13 16:30:04 fishwaldo Exp $
|
||||
* $Id: m_nick.c,v 1.9 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -97,7 +97,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&client_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.8 $";
|
||||
const char *_version = "$Revision: 1.9 $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -106,15 +106,16 @@ const char *_version = "$Revision: 1.8 $";
|
|||
* parv[0] = sender prefix
|
||||
* parv[1] = nickname
|
||||
*/
|
||||
static void mr_nick(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
static void
|
||||
mr_nick(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
struct Client *target_p, *uclient_p;
|
||||
char nick[NICKLEN];
|
||||
char* s;
|
||||
dlink_node *ptr;
|
||||
|
||||
if(parc < 2)
|
||||
if(parc < 2 || BadPtr(parv[1]))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
|
||||
me.name, BadPtr(parv[0]) ? "*" : parv[0]);
|
||||
|
@ -203,7 +204,8 @@ static void mr_nick(struct Client *client_p, struct Client *source_p,
|
|||
char nick[NICKLEN];
|
||||
struct Client *target_p;
|
||||
|
||||
if(parc < 2)
|
||||
/* XXX BadPtr is needed */
|
||||
if(parc < 2 || BadPtr(parv[1]))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
|
||||
me.name, parv[0]);
|
||||
|
@ -313,14 +315,16 @@ static void mr_nick(struct Client *client_p, struct Client *source_p,
|
|||
* parv[8] = svsid
|
||||
* parv[9] = ircname
|
||||
*/
|
||||
static void ms_nick(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
static void
|
||||
ms_nick(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
struct Client* target_p;
|
||||
char nick[NICKLEN];
|
||||
time_t newts = 0;
|
||||
|
||||
if(parc < 2)
|
||||
/* XXX BadPtr is needed */
|
||||
if(parc < 2 || BadPtr(parv[1]))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
|
||||
return;
|
||||
|
@ -414,8 +418,9 @@ static void ms_nick(struct Client *client_p, struct Client *source_p,
|
|||
/*
|
||||
* ms_client()
|
||||
*/
|
||||
static void ms_client(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
static void
|
||||
ms_client(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
struct Client* target_p;
|
||||
char nick[NICKLEN];
|
||||
|
@ -424,7 +429,11 @@ static void ms_client(struct Client *client_p, struct Client *source_p,
|
|||
char *name;
|
||||
|
||||
id = parv[8];
|
||||
name = parv[10];
|
||||
name = parv[9];
|
||||
|
||||
/* XXX can this happen ? */
|
||||
if (BadPtr(parv[1]))
|
||||
return;
|
||||
|
||||
/* parse the nickname */
|
||||
strlcpy(nick, parv[1], NICKLEN);
|
||||
|
@ -541,8 +550,9 @@ static int check_clean_nick(struct Client *client_p, struct Client *source_p,
|
|||
* output - none
|
||||
* side effects - if username is erroneous, return 1
|
||||
*/
|
||||
static int check_clean_user(struct Client *client_p, char *nick,
|
||||
char *user, char *server)
|
||||
static int
|
||||
check_clean_user(struct Client *client_p, char *nick,
|
||||
char *user, char *server)
|
||||
{
|
||||
if(strlen(user) > USERLEN)
|
||||
{
|
||||
|
@ -574,8 +584,9 @@ static int check_clean_user(struct Client *client_p, char *nick,
|
|||
* output - none
|
||||
* side effects - if hostname is erroneous, return 1
|
||||
*/
|
||||
static int check_clean_host(struct Client *client_p, char *nick,
|
||||
char *host, char *server)
|
||||
static int
|
||||
check_clean_host(struct Client *client_p, char *nick,
|
||||
char *host, char *server)
|
||||
{
|
||||
if(strlen(host) > HOSTLEN)
|
||||
{
|
||||
|
@ -604,14 +615,17 @@ static int check_clean_host(struct Client *client_p, char *nick,
|
|||
* output - none
|
||||
* side effects - walks through the nickname, returning 0 if erroneous
|
||||
*/
|
||||
static int clean_nick_name(char *nick)
|
||||
static int
|
||||
clean_nick_name(char *nick)
|
||||
{
|
||||
assert(nick);
|
||||
if(nick == NULL)
|
||||
return 0;
|
||||
|
||||
/* nicks cant start with a digit or - */
|
||||
if (*nick == '-' || IsDigit(*nick))
|
||||
/* nicks cant start with a digit or - or be 0 length */
|
||||
/* This closer duplicates behaviour of hybrid-6 */
|
||||
|
||||
if (*nick == '-' || IsDigit(*nick) || *nick == '\0')
|
||||
return 0;
|
||||
|
||||
for(; *nick; nick++)
|
||||
|
@ -629,7 +643,8 @@ static int clean_nick_name(char *nick)
|
|||
* output - none
|
||||
* side effects - walks through the username, returning 0 if erroneous
|
||||
*/
|
||||
static int clean_user_name(char *user)
|
||||
static int
|
||||
clean_user_name(char *user)
|
||||
{
|
||||
assert(user);
|
||||
if(user == NULL)
|
||||
|
@ -650,7 +665,8 @@ static int clean_user_name(char *user)
|
|||
* output - none
|
||||
* side effects - walks through the hostname, returning 0 if erroneous
|
||||
*/
|
||||
static int clean_host_name(char *host)
|
||||
static int
|
||||
clean_host_name(char *host)
|
||||
{
|
||||
assert(host);
|
||||
if(host == NULL)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_server.c,v 1.6 2002/09/13 16:30:04 fishwaldo Exp $
|
||||
* $Id: m_server.c,v 1.7 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -67,7 +67,7 @@ _moddeinit(void)
|
|||
{
|
||||
mod_del_cmd(&server_msgtab);
|
||||
}
|
||||
const char *_version = "$Revision: 1.6 $";
|
||||
const char *_version = "$Revision: 1.7 $";
|
||||
#endif
|
||||
|
||||
int bogus_host(char *host);
|
||||
|
@ -505,7 +505,7 @@ static void ms_server(struct Client *client_p, struct Client *source_p,
|
|||
|
||||
set_server_gecos(target_p, info);
|
||||
|
||||
if (IsUlined(target_p)) sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL, "Link %s introduced a dynamic Ulined server %s", client_p->name, target_p->name);
|
||||
if (IsUlined(target_p)) sendto_realops_flags(FLAGS_ALL, L_ALL, "Link %s introduced a dynamic Ulined server %s", client_p->name, target_p->name);
|
||||
|
||||
target_p->serv->up = find_or_add(parv[0]);
|
||||
target_p->servptr = source_p;
|
||||
|
@ -553,7 +553,7 @@ static void ms_server(struct Client *client_p, struct Client *source_p,
|
|||
target_p->info);
|
||||
}
|
||||
|
||||
sendto_realops_flags(FLAGS_EXTERNAL|FLAGS_REMOTE, L_ALL,
|
||||
sendto_realops_flags(FLAGS_EXTERNAL, L_ALL,
|
||||
"Server %s being introduced by %s",
|
||||
target_p->name, source_p->name);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_accept.c,v 1.3 2002/09/13 06:50:06 fishwaldo Exp $
|
||||
* $Id: m_accept.c,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -60,7 +60,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&accept_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.3 $";
|
||||
const char *_version = "$Revision: 1.4 $";
|
||||
#endif
|
||||
/*
|
||||
* m_accept - ACCEPT command handler
|
||||
|
@ -247,7 +247,7 @@ static void list_accepts(struct Client *source_p)
|
|||
*nicks = '\0';
|
||||
len2= strlen(source_p->name) + 10;
|
||||
|
||||
for(ptr = source_p->allow_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, source_p->allow_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_challenge.c,v 1.4 2002/09/13 16:30:03 fishwaldo Exp $
|
||||
* $Id: m_challenge.c,v 1.5 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -55,7 +55,7 @@ _moddeinit(void)
|
|||
return;
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.4 $";
|
||||
const char *_version = "$Revision: 1.5 $";
|
||||
#endif
|
||||
#else
|
||||
|
||||
|
@ -80,7 +80,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&challenge_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.4 $";
|
||||
const char *_version = "$Revision: 1.5 $";
|
||||
#endif
|
||||
/*
|
||||
* m_challenge - generate RSA challenge for wouldbe oper
|
||||
|
@ -106,52 +106,54 @@ static void m_challenge( struct Client *client_p, struct Client *source_p,
|
|||
}
|
||||
|
||||
if (*parv[1] == '+')
|
||||
{
|
||||
/* Ignore it if we aren't expecting this... -A1kmm */
|
||||
if (!source_p->user->response)
|
||||
return;
|
||||
|
||||
if (irccmp(source_p->user->response, ++parv[1]))
|
||||
{
|
||||
/* Ignore it if we aren't expecting this... -A1kmm */
|
||||
if (!source_p->user->response)
|
||||
return;
|
||||
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name,
|
||||
source_p->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (irccmp(source_p->user->response, ++parv[1]))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name,
|
||||
source_p->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(aconf = find_conf_by_name(source_p->user->auth_oper, CONF_OPERATOR)))
|
||||
{
|
||||
sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
|
||||
return;
|
||||
}
|
||||
if (!(aconf = find_conf_by_name(source_p->user->auth_oper, CONF_OPERATOR)))
|
||||
{
|
||||
sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
|
||||
log_failed_oper(source_p, source_p->user->auth_oper);
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = source_p->localClient->confs.head;
|
||||
oconf = ptr->data;
|
||||
detach_conf(source_p,oconf);
|
||||
|
||||
if(attach_conf(source_p, aconf) != 0)
|
||||
{
|
||||
sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
|
||||
me.name,source_p->name);
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
"Failed OPER attempt by %s (%s@%s) can't attach conf!",
|
||||
source_p->name, source_p->username, source_p->host);
|
||||
attach_conf(source_p, oconf);
|
||||
return;
|
||||
}
|
||||
{
|
||||
sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
|
||||
me.name,source_p->name);
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
"Failed OPER attempt by %s (%s@%s) can't attach conf!",
|
||||
source_p->name, source_p->username, source_p->host);
|
||||
attach_conf(source_p, oconf);
|
||||
log_failed_oper(source_p, source_p->user->auth_oper);
|
||||
return;
|
||||
}
|
||||
|
||||
oper_up(source_p, aconf);
|
||||
|
||||
ilog(L_TRACE, "OPER %s by %s!%s@%s",
|
||||
source_p->user->auth_oper, source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
source_p->user->auth_oper, source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
log_oper(source_p, source_p->user->auth_oper);
|
||||
|
||||
MyFree(source_p->user->response);
|
||||
MyFree(source_p->user->auth_oper);
|
||||
source_p->user->response = NULL;
|
||||
source_p->user->auth_oper = NULL;
|
||||
return;
|
||||
}
|
||||
MyFree(source_p->user->response);
|
||||
MyFree(source_p->user->auth_oper);
|
||||
source_p->user->response = NULL;
|
||||
source_p->user->auth_oper = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
MyFree(source_p->user->response);
|
||||
MyFree(source_p->user->auth_oper);
|
||||
|
@ -160,27 +162,28 @@ static void m_challenge( struct Client *client_p, struct Client *source_p,
|
|||
|
||||
if (!(aconf = find_conf_exact(parv[1], source_p->username, source_p->host,
|
||||
CONF_OPERATOR)) &&
|
||||
!(aconf = find_conf_exact(parv[1], source_p->username,
|
||||
!(aconf = find_conf_exact(parv[1], source_p->username,
|
||||
source_p->localClient->sockhost,
|
||||
CONF_OPERATOR)))
|
||||
{
|
||||
sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
|
||||
return;
|
||||
}
|
||||
{
|
||||
sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
|
||||
log_failed_oper(source_p, source_p->user->auth_oper);
|
||||
return;
|
||||
}
|
||||
if (!aconf->rsa_public_key)
|
||||
{
|
||||
sendto_one (source_p, ":%s NOTICE %s :I'm sorry, PK authentication "
|
||||
"is not enabled for your oper{} block.", me.name,
|
||||
parv[0]);
|
||||
return;
|
||||
}
|
||||
{
|
||||
sendto_one (source_p, ":%s NOTICE %s :I'm sorry, PK authentication "
|
||||
"is not enabled for your oper{} block.", me.name,
|
||||
parv[0]);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!generate_challenge (&challenge, &(source_p->user->response), aconf->rsa_public_key)
|
||||
)
|
||||
{
|
||||
sendto_one (source_p, form_str(RPL_RSACHALLENGE), me.name, parv[0],
|
||||
challenge);
|
||||
}
|
||||
{
|
||||
sendto_one (source_p, form_str(RPL_RSACHALLENGE), me.name, parv[0],
|
||||
challenge);
|
||||
}
|
||||
DupString(source_p->user->auth_oper, aconf->name);
|
||||
MyFree(challenge);
|
||||
return;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: m_clearchan.c,v 1.1 2002/09/17 11:03:21 fishwaldo Exp $
|
||||
* $Id: m_clearchan.c,v 1.2 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
#include "stdinc.h"
|
||||
#include "tools.h"
|
||||
|
@ -76,7 +76,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&clearchan_msgtab);
|
||||
}
|
||||
|
||||
char *_version = "$Revision: 1.1 $";
|
||||
char *_version = "$Revision: 1.2 $";
|
||||
|
||||
/*
|
||||
** mo_clearchan
|
||||
|
@ -117,11 +117,11 @@ static void mo_clearchan(struct Client *client_p, struct Client *source_p,
|
|||
|
||||
sendto_wallops_flags(FLAGS_WALLOP, &me,
|
||||
"CLEARCHAN called for [%s] by %s!%s@%s",
|
||||
parv[1], source_p->name, source_p->username, source_p->host);
|
||||
parv[1], source_p->name, source_p->username, source_p->vhost);
|
||||
sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
|
||||
":%s WALLOPS :CLEARCHAN called for [%s] by %s!%s@%s",
|
||||
me.name, parv[1], source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
source_p->vhost);
|
||||
ilog(L_NOTICE, "CLEARCHAN called for [%s] by %s!%s@%s",
|
||||
parv[1], source_p->name, source_p->username, source_p->host);
|
||||
|
||||
|
@ -137,7 +137,7 @@ static void mo_clearchan(struct Client *client_p, struct Client *source_p,
|
|||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
||||
source_p->name,
|
||||
source_p->username,
|
||||
source_p->host,
|
||||
source_p->vhost,
|
||||
root_chptr->chname);
|
||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
|
||||
me.name, chptr->chname, source_p->name);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_close.c,v 1.3 2002/09/13 06:50:06 fishwaldo Exp $
|
||||
* $Id: m_close.c,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -54,14 +54,15 @@ _moddeinit(void)
|
|||
mod_del_cmd(&close_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.3 $";
|
||||
const char *_version = "$Revision: 1.4 $";
|
||||
#endif
|
||||
/*
|
||||
* mo_close - CLOSE message handler
|
||||
* - added by Darren Reed Jul 13 1992.
|
||||
*/
|
||||
static void mo_close(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
static void
|
||||
mo_close(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
struct Client *target_p;
|
||||
dlink_node *ptr;
|
||||
|
@ -70,10 +71,9 @@ static void mo_close(struct Client *client_p, struct Client *source_p,
|
|||
|
||||
|
||||
|
||||
for (ptr = unknown_list.head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, unknown_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
ptr_next = ptr->next;
|
||||
|
||||
/* Which list would connecting servers be found in? serv_list ? */
|
||||
#if 0
|
||||
|
|
191
modules/m_join.c
191
modules/m_join.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_join.c,v 1.9 2002/09/16 08:32:53 fishwaldo Exp $
|
||||
* $Id: m_join.c,v 1.10 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -64,7 +64,7 @@ _moddeinit(void)
|
|||
{
|
||||
mod_del_cmd(&join_msgtab);
|
||||
}
|
||||
const char *_version = "$Revision: 1.9 $";
|
||||
const char *_version = "$Revision: 1.10 $";
|
||||
|
||||
#endif
|
||||
static void do_join_0(struct Client *client_p, struct Client *source_p);
|
||||
|
@ -92,6 +92,9 @@ m_join(struct Client *client_p,
|
|||
int i, flags = 0;
|
||||
char *p = NULL, *p2 = NULL, *p3 = NULL;
|
||||
int successful_join_count = 0; /* Number of channels successfully joined */
|
||||
int burst_modes = NO;
|
||||
char modebuf[MODEBUFLEN];
|
||||
char parabuf[MODEBUFLEN];
|
||||
|
||||
if (*parv[1] == '\0')
|
||||
{
|
||||
|
@ -111,6 +114,10 @@ m_join(struct Client *client_p,
|
|||
vkey = (parc>3) ? ((vkey) ? strtoken(&p3, NULL, ",") : NULL) : key,
|
||||
name = strtoken(&p, NULL, ","))
|
||||
{
|
||||
modebuf[0] = '+';
|
||||
modebuf[1] = '\0';
|
||||
parabuf[0] = '\0';
|
||||
burst_modes = NO;
|
||||
|
||||
if(!check_channel_name(name))
|
||||
{
|
||||
|
@ -144,8 +151,7 @@ m_join(struct Client *client_p,
|
|||
continue;
|
||||
}
|
||||
|
||||
if(ConfigServerHide.disable_local_channels &&
|
||||
(*name == '&'))
|
||||
if(ConfigServerHide.disable_local_channels && (*name == '&'))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
|
||||
me.name, source_p->name, name);
|
||||
|
@ -171,6 +177,17 @@ m_join(struct Client *client_p,
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((source_p->user->joined >= ConfigChannel.max_chans_per_user) &&
|
||||
(!IsOper(source_p) || (source_p->user->joined >=
|
||||
ConfigChannel.max_chans_per_user*3)))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_TOOMANYCHANNELS),
|
||||
me.name, parv[0], name);
|
||||
if(successful_join_count != 0)
|
||||
source_p->localClient->last_join_time = CurrentTime;
|
||||
return;
|
||||
}
|
||||
|
||||
/* look for the channel */
|
||||
if((chptr = hash_find_channel(name)) != NULL)
|
||||
{
|
||||
|
@ -184,17 +201,25 @@ m_join(struct Client *client_p,
|
|||
continue;
|
||||
}
|
||||
|
||||
{
|
||||
joining_vchan = 0;
|
||||
root_chptr = chptr;
|
||||
}
|
||||
|
||||
/* save the expense of calling channel_modes()
|
||||
* if zero users on channel, then I have to call channel_modes().
|
||||
* (N.B. if channel_modes() was rewritten to be sane and fast
|
||||
* this check wouldn't be worth the bother.)
|
||||
* Just because client ends up a chanop, doesn't mean
|
||||
* channel_modes() has to be called.
|
||||
* -Dianora
|
||||
*/
|
||||
if (chptr->users == 0)
|
||||
{
|
||||
flags = CHFL_ADMIN;
|
||||
burst_modes = YES;
|
||||
}
|
||||
else
|
||||
flags = 0;
|
||||
}
|
||||
else
|
||||
else /* channel does NOT exist, so create it */
|
||||
{
|
||||
if(splitmode && !IsOper(source_p) && (*name != '&') &&
|
||||
(ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split))
|
||||
|
@ -217,35 +242,16 @@ m_join(struct Client *client_p,
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((source_p->user->joined >= ConfigChannel.max_chans_per_user) &&
|
||||
(!IsOper(source_p) || (source_p->user->joined >=
|
||||
ConfigChannel.max_chans_per_user*3)))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_TOOMANYCHANNELS),
|
||||
me.name, parv[0], name);
|
||||
if(successful_join_count)
|
||||
source_p->localClient->last_join_time = CurrentTime;
|
||||
return;
|
||||
}
|
||||
|
||||
if(flags == 0) /* if channel doesn't exist, don't penalize */
|
||||
successful_join_count++;
|
||||
|
||||
if(chptr == NULL) /* If I already have a chptr, no point doing this */
|
||||
{
|
||||
chptr = get_or_create_channel(source_p, name, NULL);
|
||||
root_chptr = chptr;
|
||||
}
|
||||
|
||||
if(chptr == NULL)
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
|
||||
me.name, parv[0], name);
|
||||
if(successful_join_count > 0)
|
||||
successful_join_count--;
|
||||
continue;
|
||||
/* So create it */
|
||||
if ((chptr = get_or_create_channel(source_p, name, NULL)) == NULL)
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
|
||||
me.name, parv[0], name);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
root_chptr = chptr;
|
||||
}
|
||||
|
||||
if (!IsOper(source_p))
|
||||
|
@ -255,18 +261,14 @@ m_join(struct Client *client_p,
|
|||
* can_join checks for +i key, bans.
|
||||
*/
|
||||
|
||||
if ( (i = can_join(source_p, chptr, key)) )
|
||||
if ((i = can_join(source_p, chptr, key)))
|
||||
{
|
||||
sendto_one(source_p,
|
||||
form_str(i), me.name, parv[0], name);
|
||||
if(successful_join_count > 0)
|
||||
successful_join_count--;
|
||||
sendto_one(source_p, form_str(i), me.name, parv[0], name);
|
||||
successful_join_count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
** Complete user entry to the new channel (if any)
|
||||
*/
|
||||
/* add the user to the channel */
|
||||
|
||||
add_user_to_channel(chptr, source_p, flags);
|
||||
|
||||
|
@ -279,50 +281,56 @@ m_join(struct Client *client_p,
|
|||
{
|
||||
chptr->channelts = CurrentTime;
|
||||
|
||||
/* detected a persistent channel, so
|
||||
* have to call channel_modes() here.
|
||||
*/
|
||||
if (burst_modes)
|
||||
{
|
||||
channel_modes(chptr, client_p, modebuf, parabuf);
|
||||
}
|
||||
else /* Otherwise, its a stock +nt */
|
||||
{
|
||||
chptr->mode.mode |= MODE_TOPICLIMIT;
|
||||
chptr->mode.mode |= MODE_NOPRIVMSGS;
|
||||
modebuf[0] = '+';
|
||||
modebuf[1] = 'n';
|
||||
modebuf[2] = 't';
|
||||
modebuf[3] = '\0';
|
||||
}
|
||||
|
||||
sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
|
||||
LL_ICLIENT,
|
||||
":%s SJOIN %lu %s + :¤%s",
|
||||
me.name,
|
||||
(unsigned long) chptr->channelts,
|
||||
chptr->chname,
|
||||
parv[0]);
|
||||
":%s SJOIN %lu %s %s %s:¤%s",
|
||||
me.name, (unsigned long) chptr->channelts,
|
||||
chptr->chname, modebuf, parabuf, parv[0]);
|
||||
/*
|
||||
* notify all other users on the new channel
|
||||
*/
|
||||
/* XXX just exactly who is going to be =on= this new channel
|
||||
* other than just the creator at this time? ? ?
|
||||
*/
|
||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
|
||||
source_p->name, source_p->username,
|
||||
source_p->vhost, root_chptr->chname);
|
||||
|
||||
sendto_channel_local(ONLY_CHANOPS_HALFOPS,chptr,
|
||||
":%s MODE %s %s %s",
|
||||
me.name, root_chptr->chname,
|
||||
modebuf, parabuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
|
||||
LL_ICLIENT,
|
||||
":%s SJOIN %lu %s + :%s",
|
||||
me.name,
|
||||
(unsigned long) chptr->channelts,
|
||||
chptr->chname,
|
||||
parv[0]);
|
||||
":%s SJOIN %lu %s %s %s:%s",
|
||||
me.name, (unsigned long) chptr->channelts,
|
||||
chptr->chname, modebuf, parabuf, parv[0]);
|
||||
|
||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
|
||||
source_p->name, source_p->username,
|
||||
source_p->vhost, root_chptr->chname);
|
||||
}
|
||||
|
||||
/*
|
||||
** notify all other users on the new channel
|
||||
*/
|
||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
|
||||
source_p->name,
|
||||
source_p->username,
|
||||
source_p->vhost,
|
||||
root_chptr->chname);
|
||||
|
||||
if( flags & CHFL_ADMIN )
|
||||
{
|
||||
chptr->mode.mode |= MODE_TOPICLIMIT;
|
||||
chptr->mode.mode |= MODE_NOPRIVMSGS;
|
||||
|
||||
sendto_channel_local(ONLY_CHANOPS_HALFOPS,chptr,
|
||||
":%s MODE %s +nt",
|
||||
me.name,
|
||||
root_chptr->chname);
|
||||
|
||||
sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
|
||||
LL_ICLIENT,
|
||||
":%s MODE %s +nt",
|
||||
me.name,
|
||||
chptr->chname);
|
||||
}
|
||||
|
||||
del_invite(chptr, source_p);
|
||||
|
||||
|
@ -350,7 +358,7 @@ m_join(struct Client *client_p,
|
|||
|
||||
channel_member_names(source_p, chptr, root_chptr->chname, 1);
|
||||
|
||||
if(successful_join_count)
|
||||
if(successful_join_count != 0)
|
||||
source_p->localClient->last_join_time = CurrentTime;
|
||||
}
|
||||
}
|
||||
|
@ -368,19 +376,23 @@ m_join(struct Client *client_p,
|
|||
*/
|
||||
|
||||
static void
|
||||
ms_join(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
int parc,
|
||||
char *parv[])
|
||||
ms_join(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
char *name;
|
||||
int new_ts;
|
||||
|
||||
if (!(source_p->user))
|
||||
if ((source_p->user) == NULL)
|
||||
return;
|
||||
|
||||
name = parv[1];
|
||||
|
||||
/*
|
||||
* stupid legacy here. If remote server joins someone to "0"
|
||||
* thats a signal to remove this client from all channels.
|
||||
* note, the string "0" is simply '0' '\0' this following "if"
|
||||
* is faster then a strcmp.
|
||||
*/
|
||||
if ((name[0] == '0') && (name[1] == '\0'))
|
||||
{
|
||||
do_join_0(client_p, source_p);
|
||||
|
@ -410,7 +422,8 @@ ms_join(struct Client *client_p,
|
|||
* anti spambot code.
|
||||
*/
|
||||
|
||||
static void do_join_0(struct Client *client_p, struct Client *source_p)
|
||||
static void
|
||||
do_join_0(struct Client *client_p, struct Client *source_p)
|
||||
{
|
||||
struct Channel *chptr=NULL;
|
||||
dlink_node *lp;
|
||||
|
@ -426,10 +439,8 @@ static void do_join_0(struct Client *client_p, struct Client *source_p)
|
|||
{
|
||||
chptr = lp->data;
|
||||
sendto_channel_local(ALL_MEMBERS,chptr, ":%s!%s@%s PART %s",
|
||||
source_p->name,
|
||||
source_p->username,
|
||||
source_p->vhost,
|
||||
chptr->chname);
|
||||
source_p->name, source_p->username,
|
||||
source_p->vhost, chptr->chname);
|
||||
remove_user_from_channel(chptr, source_p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_kline.c,v 1.8 2002/09/13 16:30:03 fishwaldo Exp $
|
||||
* $Id: m_kline.c,v 1.9 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -86,7 +86,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&dline_msgtab[0]);
|
||||
mod_del_cmd(&dline_msgtab[1]);
|
||||
}
|
||||
const char *_version = "$Revision: 1.8 $";
|
||||
const char *_version = "$Revision: 1.9 $";
|
||||
#endif
|
||||
|
||||
/* Local function prototypes */
|
||||
|
@ -717,7 +717,7 @@ mo_dline(struct Client *client_p, struct Client *source_p,
|
|||
char *creason;
|
||||
(void)parse_netmask(dlhost, &daddr, NULL);
|
||||
|
||||
if((aconf = find_dline(&daddr, t)) != NULL)
|
||||
if((aconf = find_dline_conf(&daddr, t)) != NULL)
|
||||
{
|
||||
creason = aconf->passwd ? aconf->passwd : "<No Reason>";
|
||||
if (IsConfExemptKline(aconf))
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_knock.c,v 1.6 2002/09/13 09:17:13 fishwaldo Exp $
|
||||
* $Id: m_knock.c,v 1.7 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -80,7 +80,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&knockll_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.6 $";
|
||||
const char *_version = "$Revision: 1.7 $";
|
||||
#endif
|
||||
|
||||
/* m_knock
|
||||
|
@ -102,9 +102,9 @@ const char *_version = "$Revision: 1.6 $";
|
|||
* dont know about, for us to answer.
|
||||
*/
|
||||
|
||||
static void m_knock(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
static void
|
||||
m_knock(struct Client *client_p, struct Client *source_p, int parc,
|
||||
char *parv[])
|
||||
{
|
||||
char *sockhost = NULL;
|
||||
|
||||
|
@ -143,10 +143,9 @@ static void m_knock(struct Client *client_p,
|
|||
* parv[2] = vchan id
|
||||
*/
|
||||
|
||||
static void ms_knock(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
int parc,
|
||||
char *parv[])
|
||||
static void
|
||||
ms_knock(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
if(IsClient(source_p))
|
||||
parse_knock_remote(client_p, source_p, parc, parv);
|
||||
|
@ -166,8 +165,8 @@ static void ms_knock(struct Client *client_p,
|
|||
* or sends failure message to source_p
|
||||
*/
|
||||
|
||||
static void parse_knock_local(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
static void
|
||||
parse_knock_local(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[], char *sockhost)
|
||||
{
|
||||
/* We will cut at the first comma reached, however we will not *
|
||||
|
@ -179,7 +178,7 @@ static void parse_knock_local(struct Client *client_p,
|
|||
name = parv[1];
|
||||
key = (parc > 2) ? parv[2] : NULL;
|
||||
|
||||
if( (p = strchr(name,',')) )
|
||||
if((p = strchr(name,',')) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
if(!IsChannelName(name))
|
||||
|
@ -274,9 +273,9 @@ static void parse_knock_local(struct Client *client_p,
|
|||
* side effects - knock is checked for validity, if valid send_knock() is
|
||||
* called
|
||||
*/
|
||||
static void parse_knock_remote(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
static void
|
||||
parse_knock_remote(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
struct Channel *chptr;
|
||||
char *p, *name, *key;
|
||||
|
@ -284,7 +283,7 @@ static void parse_knock_remote(struct Client *client_p,
|
|||
name = parv[1];
|
||||
key = (parc > 2) ? parv[2] : NULL;
|
||||
|
||||
if( (p = strchr(name,',')) )
|
||||
if((p = strchr(name,',')) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
if(!IsChannelName(name) || !(chptr = hash_find_channel(name)))
|
||||
|
@ -315,9 +314,9 @@ static void parse_knock_remote(struct Client *client_p,
|
|||
* side effects - knock is sent locally (if enabled) and propagated
|
||||
*/
|
||||
|
||||
static void send_knock(struct Client *client_p, struct Client *source_p,
|
||||
struct Channel *chptr, char *name, char *key,
|
||||
int llclient)
|
||||
static void
|
||||
send_knock(struct Client *client_p, struct Client *source_p,
|
||||
struct Channel *chptr, char *name, char *key, int llclient)
|
||||
{
|
||||
chptr->last_knock = CurrentTime;
|
||||
|
||||
|
@ -393,7 +392,7 @@ static int check_banned_knock(struct Channel *chptr, struct Client *who,
|
|||
struct Ban *actualBan = NULL;
|
||||
struct Ban *actualExcept = NULL;
|
||||
|
||||
for (ban = chptr->banlist.head; ban; ban = ban->next)
|
||||
DLINK_FOREACH(ban, chptr->banlist.head)
|
||||
{
|
||||
actualBan = ban->data;
|
||||
|
||||
|
@ -405,7 +404,7 @@ static int check_banned_knock(struct Channel *chptr, struct Client *who,
|
|||
|
||||
if ((actualBan != NULL))
|
||||
{
|
||||
for (except = chptr->exceptlist.head; except; except = except->next)
|
||||
DLINK_FOREACH(except, chptr->exceptlist.head)
|
||||
{
|
||||
actualExcept = except->data;
|
||||
|
||||
|
|
136
modules/m_oper.c
136
modules/m_oper.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_oper.c,v 1.5 2002/09/13 16:30:03 fishwaldo Exp $
|
||||
* $Id: m_oper.c,v 1.6 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -74,7 +74,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&oper_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.5 $";
|
||||
const char *_version = "$Revision: 1.6 $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -97,77 +97,79 @@ m_oper(struct Client *client_p, struct Client *source_p,
|
|||
password = parv[2];
|
||||
|
||||
if (EmptyString(password))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
|
||||
me.name, source_p->name, "OPER");
|
||||
return;
|
||||
}
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
|
||||
me.name, source_p->name, "OPER");
|
||||
return;
|
||||
}
|
||||
|
||||
/* end the grace period */
|
||||
if(!IsFloodDone(source_p))
|
||||
flood_endgrace(source_p);
|
||||
|
||||
if((aconf = find_password_aconf(name,source_p)) == NULL)
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
|
||||
if (ConfigFileEntry.failed_oper_notice)
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
|
||||
if (ConfigFileEntry.failed_oper_notice)
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
"Failed OPER attempt - host mismatch by %s (%s@%s)",
|
||||
source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
}
|
||||
return;
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"Failed OPER attempt - host mismatch by %s (%s@%s)",
|
||||
source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
}
|
||||
log_failed_oper(source_p, name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (match_oper_password(password,aconf))
|
||||
{
|
||||
/*
|
||||
* 20001216:
|
||||
* detach old iline
|
||||
* -einride
|
||||
*/
|
||||
if ((ptr = source_p->localClient->confs.head) != NULL)
|
||||
{
|
||||
oconf = ptr->data;
|
||||
detach_conf(source_p,oconf);
|
||||
}
|
||||
|
||||
if(attach_conf(source_p, aconf) != 0)
|
||||
{
|
||||
sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
|
||||
me.name,source_p->name);
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"Failed OPER attempt by %s (%s@%s) can't attach conf!",
|
||||
source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
/*
|
||||
20001216:
|
||||
detach old iline
|
||||
-einride
|
||||
*/
|
||||
if ((ptr = source_p->localClient->confs.head) != NULL)
|
||||
{
|
||||
oconf = ptr->data;
|
||||
detach_conf(source_p,oconf);
|
||||
}
|
||||
|
||||
if(attach_conf(source_p, aconf) != 0)
|
||||
{
|
||||
sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
|
||||
me.name,source_p->name);
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
"Failed OPER attempt by %s (%s@%s) can't attach conf!",
|
||||
source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
/*
|
||||
20001216:
|
||||
Reattach old iline
|
||||
-einride
|
||||
*/
|
||||
attach_conf(source_p, oconf);
|
||||
return;
|
||||
}
|
||||
|
||||
oper_up(source_p, aconf);
|
||||
|
||||
ilog(L_TRACE, "OPER %s by %s!%s@%s",
|
||||
name, source_p->name, source_p->username, source_p->host);
|
||||
log_oper(source_p, name);
|
||||
* 20001216:
|
||||
* Reattach old iline
|
||||
* -einride
|
||||
*/
|
||||
attach_conf(source_p, oconf);
|
||||
log_failed_oper(source_p, name);
|
||||
return;
|
||||
}
|
||||
|
||||
oper_up(source_p, aconf);
|
||||
|
||||
ilog(L_TRACE, "OPER %s by %s!%s@%s",
|
||||
name, source_p->name, source_p->username, source_p->host);
|
||||
log_oper(source_p, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendto_one(source_p,form_str(ERR_PASSWDMISMATCH),me.name, parv[0]);
|
||||
if (ConfigFileEntry.failed_oper_notice)
|
||||
{
|
||||
sendto_one(source_p,form_str(ERR_PASSWDMISMATCH),me.name, parv[0]);
|
||||
if (ConfigFileEntry.failed_oper_notice)
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
"Failed OPER attempt by %s (%s@%s)",
|
||||
source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
}
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"Failed OPER attempt by %s (%s@%s)",
|
||||
source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
}
|
||||
log_failed_oper(source_p, name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -198,15 +200,15 @@ ms_oper(struct Client *client_p, struct Client *source_p,
|
|||
/* if message arrived from server, trust it, and set to oper */
|
||||
|
||||
if (!IsOper(source_p))
|
||||
{
|
||||
if (source_p->status == STAT_CLIENT)
|
||||
source_p->handler = OPER_HANDLER;
|
||||
{
|
||||
if (source_p->status == STAT_CLIENT)
|
||||
source_p->handler = OPER_HANDLER;
|
||||
|
||||
source_p->flags |= FLAGS_OPER;
|
||||
Count.oper++;
|
||||
sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, NOFLAGS,
|
||||
":%s MODE %s :+o", parv[0], parv[0]);
|
||||
}
|
||||
source_p->umodes |= FLAGS_OPER;
|
||||
Count.oper++;
|
||||
sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, NOFLAGS,
|
||||
":%s MODE %s :+o", parv[0], parv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -223,12 +225,12 @@ find_password_aconf(char *name, struct Client *source_p)
|
|||
|
||||
if ((aconf = find_conf_exact(name, source_p->username, source_p->host,
|
||||
CONF_OPERATOR)) != NULL)
|
||||
return aconf;
|
||||
return (aconf);
|
||||
else if ((aconf = find_conf_exact(name, source_p->username,
|
||||
source_p->localClient->sockhost,
|
||||
CONF_OPERATOR)) != NULL)
|
||||
return aconf;
|
||||
return NULL;
|
||||
return (aconf);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_stats.c,v 1.5 2002/09/13 06:50:07 fishwaldo Exp $
|
||||
* $Id: m_stats.c,v 1.6 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -80,7 +80,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&stats_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.5 $";
|
||||
const char *_version = "$Revision: 1.6 $";
|
||||
#endif
|
||||
|
||||
const char* Lformat = ":%s %d %s %s %u %u %u %u %u :%u %u %s";
|
||||
|
@ -371,7 +371,8 @@ static void stats_exempt(struct Client *source_p)
|
|||
}
|
||||
|
||||
|
||||
static void stats_events(struct Client *source_p)
|
||||
static void
|
||||
stats_events(struct Client *source_p)
|
||||
{
|
||||
show_events(source_p);
|
||||
}
|
||||
|
@ -421,13 +422,15 @@ static void stats_glines(struct Client *source_p)
|
|||
}
|
||||
|
||||
|
||||
static void stats_hubleaf(struct Client *source_p)
|
||||
static void
|
||||
stats_hubleaf(struct Client *source_p)
|
||||
{
|
||||
report_configured_links(source_p, CONF_HUB|CONF_LEAF);
|
||||
}
|
||||
|
||||
|
||||
static void stats_auth(struct Client *source_p)
|
||||
static void
|
||||
stats_auth(struct Client *source_p)
|
||||
{
|
||||
/* Oper only, if unopered, return ERR_NOPRIVS */
|
||||
if((ConfigFileEntry.stats_i_oper_only == 2) && !IsOper(source_p))
|
||||
|
@ -469,7 +472,8 @@ static void stats_auth(struct Client *source_p)
|
|||
}
|
||||
|
||||
|
||||
static void stats_tklines(struct Client *source_p)
|
||||
static void
|
||||
stats_tklines(struct Client *source_p)
|
||||
{
|
||||
/* Oper only, if unopered, return ERR_NOPRIVS */
|
||||
if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
|
||||
|
@ -512,7 +516,8 @@ static void stats_tklines(struct Client *source_p)
|
|||
}
|
||||
|
||||
|
||||
static void stats_klines(struct Client *source_p)
|
||||
static void
|
||||
stats_klines(struct Client *source_p)
|
||||
{
|
||||
/* Oper only, if unopered, return ERR_NOPRIVS */
|
||||
if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
|
||||
|
@ -555,12 +560,14 @@ static void stats_klines(struct Client *source_p)
|
|||
report_Klines(source_p, 0);
|
||||
}
|
||||
|
||||
static void stats_messages(struct Client *source_p)
|
||||
static void
|
||||
stats_messages(struct Client *source_p)
|
||||
{
|
||||
report_messages(source_p);
|
||||
}
|
||||
|
||||
static void stats_oper(struct Client *source_p)
|
||||
static void
|
||||
stats_oper(struct Client *source_p)
|
||||
{
|
||||
if (!IsOper(source_p) && ConfigFileEntry.stats_o_oper_only)
|
||||
sendto_one(source_p, form_str(ERR_NOPRIVILEGES),me.name,source_p->name);
|
||||
|
@ -575,7 +582,8 @@ static void stats_oper(struct Client *source_p)
|
|||
* output - none
|
||||
* side effects - client is shown a list of active opers
|
||||
*/
|
||||
static void stats_operedup(struct Client *source_p)
|
||||
static void
|
||||
stats_operedup(struct Client *source_p)
|
||||
{
|
||||
struct Client *target_p;
|
||||
struct ConfItem *aconf;
|
||||
|
@ -617,7 +625,8 @@ static void stats_operedup(struct Client *source_p)
|
|||
stats_p_spy(source_p);
|
||||
}
|
||||
|
||||
static void stats_ports(struct Client *source_p)
|
||||
static void
|
||||
stats_ports(struct Client *source_p)
|
||||
{
|
||||
if (!IsOper(source_p) && ConfigFileEntry.stats_P_oper_only)
|
||||
sendto_one(source_p, form_str(ERR_NOPRIVILEGES),me.name,source_p->name);
|
||||
|
@ -625,22 +634,26 @@ static void stats_ports(struct Client *source_p)
|
|||
show_ports(source_p);
|
||||
}
|
||||
|
||||
static void stats_resv(struct Client *source_p)
|
||||
static void
|
||||
stats_resv(struct Client *source_p)
|
||||
{
|
||||
report_resv(source_p);
|
||||
}
|
||||
|
||||
static void stats_usage(struct Client *source_p)
|
||||
static void
|
||||
stats_usage(struct Client *source_p)
|
||||
{
|
||||
send_usage(source_p);
|
||||
}
|
||||
|
||||
static void stats_tstats(struct Client *source_p)
|
||||
static void
|
||||
stats_tstats(struct Client *source_p)
|
||||
{
|
||||
tstats(source_p);
|
||||
}
|
||||
|
||||
static void stats_uptime(struct Client *source_p)
|
||||
static void
|
||||
stats_uptime(struct Client *source_p)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
|
@ -652,7 +665,8 @@ static void stats_uptime(struct Client *source_p)
|
|||
MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
|
||||
}
|
||||
|
||||
static void stats_shared(struct Client *source_p)
|
||||
static void
|
||||
stats_shared(struct Client *source_p)
|
||||
{
|
||||
report_specials(source_p, CONF_ULINE, RPL_STATSULINE);
|
||||
}
|
||||
|
@ -664,13 +678,14 @@ static void stats_shared(struct Client *source_p)
|
|||
* output - none
|
||||
* side effects - client is shown lists of who connected servers
|
||||
*/
|
||||
static void stats_servers(struct Client *source_p)
|
||||
static void
|
||||
stats_servers(struct Client *source_p)
|
||||
{
|
||||
struct Client *target_p;
|
||||
dlink_node *ptr;
|
||||
int j=0;
|
||||
|
||||
for(ptr = serv_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
@ -687,28 +702,32 @@ static void stats_servers(struct Client *source_p)
|
|||
source_p->name, j);
|
||||
}
|
||||
|
||||
static void stats_gecos(struct Client *source_p)
|
||||
static void
|
||||
stats_gecos(struct Client *source_p)
|
||||
{
|
||||
report_specials(source_p, CONF_XLINE, RPL_STATSXLINE);
|
||||
}
|
||||
|
||||
static void stats_class(struct Client *source_p)
|
||||
static void
|
||||
stats_class(struct Client *source_p)
|
||||
{
|
||||
report_classes(source_p);
|
||||
}
|
||||
|
||||
static void stats_memory(struct Client *source_p)
|
||||
static void
|
||||
stats_memory(struct Client *source_p)
|
||||
{
|
||||
count_memory(source_p);
|
||||
}
|
||||
|
||||
static void stats_ziplinks(struct Client *source_p)
|
||||
static void
|
||||
stats_ziplinks(struct Client *source_p)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
struct Client *target_p;
|
||||
int sent_data = 0;
|
||||
|
||||
for(ptr = serv_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
if (IsCapable(target_p, CAP_ZIP))
|
||||
|
@ -730,7 +749,8 @@ static void stats_ziplinks(struct Client *source_p)
|
|||
me.name, RPL_STATSDEBUG, source_p->name, sent_data);
|
||||
}
|
||||
|
||||
static void stats_servlinks(struct Client *source_p)
|
||||
static void
|
||||
stats_servlinks(struct Client *source_p)
|
||||
{
|
||||
static char Sformat[] = ":%s %d %s %s %u %u %u %u %u :%u %u %s";
|
||||
long uptime, sendK, receiveK;
|
||||
|
@ -746,7 +766,7 @@ static void stats_servlinks(struct Client *source_p)
|
|||
|
||||
sendK = receiveK = 0;
|
||||
|
||||
for(ptr = serv_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
@ -791,16 +811,15 @@ static void stats_servlinks(struct Client *source_p)
|
|||
(float)((float)me.localClient->receiveK / (float)uptime));
|
||||
}
|
||||
|
||||
static void stats_ltrace(struct Client *source_p, int parc, char *parv[])
|
||||
static void
|
||||
stats_ltrace(struct Client *source_p, int parc, char *parv[])
|
||||
{
|
||||
int doall = 0;
|
||||
int wilds = 0;
|
||||
char *name=NULL;
|
||||
char statchar;
|
||||
|
||||
name = parse_stats_args(parc,parv,&doall,&wilds);
|
||||
|
||||
if(name)
|
||||
if ((name = parse_stats_args(parc,parv,&doall,&wilds)) != NULL)
|
||||
{
|
||||
statchar=parv[1][0];
|
||||
|
||||
|
@ -821,7 +840,8 @@ static void stats_ltrace(struct Client *source_p, int parc, char *parv[])
|
|||
* parv[2] = server name (current server defaulted, if omitted)
|
||||
*/
|
||||
|
||||
static void ms_stats(struct Client *client_p, struct Client *source_p,
|
||||
static void
|
||||
ms_stats(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv)!=HUNTED_ISME)
|
||||
|
@ -841,7 +861,8 @@ static void ms_stats(struct Client *client_p, struct Client *source_p,
|
|||
* output - NONE
|
||||
* side effects -
|
||||
*/
|
||||
static void stats_L(struct Client *source_p,char *name,int doall,
|
||||
static void
|
||||
stats_L(struct Client *source_p,char *name,int doall,
|
||||
int wilds,char statchar)
|
||||
{
|
||||
stats_L_list(source_p, name, doall, wilds, &unknown_list, statchar);
|
||||
|
@ -849,7 +870,8 @@ static void stats_L(struct Client *source_p,char *name,int doall,
|
|||
stats_L_list(source_p, name, doall, wilds, &serv_list, statchar);
|
||||
}
|
||||
|
||||
static void stats_L_list(struct Client *source_p,char *name, int doall, int wilds,
|
||||
static void
|
||||
stats_L_list(struct Client *source_p,char *name, int doall, int wilds,
|
||||
dlink_list *list,char statchar)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
|
@ -861,7 +883,7 @@ static void stats_L_list(struct Client *source_p,char *name, int doall, int wild
|
|||
* are invisible not being visible to 'foreigners' who use
|
||||
* a wild card based search to list it.
|
||||
*/
|
||||
for(ptr = list->head;ptr;ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, list->head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
@ -942,7 +964,8 @@ static void stats_L_list(struct Client *source_p,char *name, int doall, int wild
|
|||
* any damage with stats requests now anyway. So, why show them?
|
||||
* -Dianora
|
||||
*/
|
||||
static void stats_spy(struct Client *source_p, char statchar)
|
||||
static void
|
||||
stats_spy(struct Client *source_p, char statchar)
|
||||
{
|
||||
struct hook_stats_data data;
|
||||
|
||||
|
@ -959,7 +982,8 @@ static void stats_spy(struct Client *source_p, char statchar)
|
|||
* ouput -
|
||||
* side effects - call hook doing_stats_p
|
||||
*/
|
||||
static void stats_p_spy(struct Client *source_p)
|
||||
static void
|
||||
stats_p_spy(struct Client *source_p)
|
||||
{
|
||||
struct hook_stats_data data;
|
||||
|
||||
|
@ -980,7 +1004,8 @@ static void stats_p_spy(struct Client *source_p)
|
|||
* side effects - a notice is sent to opers, IF spy mode is configured
|
||||
* in the conf file.
|
||||
*/
|
||||
static void stats_L_spy(struct Client *source_p, char statchar, char *name)
|
||||
static void
|
||||
stats_L_spy(struct Client *source_p, char statchar, char *name)
|
||||
{
|
||||
struct hook_stats_data data;
|
||||
|
||||
|
@ -1003,7 +1028,8 @@ static void stats_L_spy(struct Client *source_p, char statchar, char *name)
|
|||
* common parse routine for m_stats args
|
||||
*
|
||||
*/
|
||||
static char *parse_stats_args(int parc,char *parv[],int *doall,int *wilds)
|
||||
static char *
|
||||
parse_stats_args(int parc,char *parv[],int *doall,int *wilds)
|
||||
{
|
||||
char *name;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_testline.c,v 1.3 2002/09/13 06:50:07 fishwaldo Exp $
|
||||
* $Id: m_testline.c,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -59,7 +59,7 @@ _moddeinit(void)
|
|||
mod_del_cmd(&testline_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.3 $";
|
||||
const char *_version = "$Revision: 1.4 $";
|
||||
#endif
|
||||
/*
|
||||
* mo_testline
|
||||
|
@ -92,7 +92,7 @@ static void mo_testline(struct Client *client_p, struct Client *source_p,
|
|||
{
|
||||
if ((t=parse_netmask(given_name, &ip, &host_mask))!= HM_HOST)
|
||||
{
|
||||
aconf = find_dline(&ip,
|
||||
aconf = find_dline_conf(&ip,
|
||||
#ifdef IPV6
|
||||
(t==HM_IPV6) ? AF_INET6 : AF_INET
|
||||
#else
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_trace.c,v 1.3 2002/09/13 06:50:07 fishwaldo Exp $
|
||||
* $Id: m_trace.c,v 1.4 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -68,7 +68,7 @@ _moddeinit(void)
|
|||
hook_del_event("doing_trace");
|
||||
mod_del_cmd(&trace_msgtab);
|
||||
}
|
||||
const char *_version = "$Revision: 1.3 $";
|
||||
const char *_version = "$Revision: 1.4 $";
|
||||
#endif
|
||||
static int report_this_status(struct Client *source_p, struct Client *target_p,int dow,
|
||||
int link_u_p, int link_u_s);
|
||||
|
@ -98,7 +98,8 @@ static void m_trace(struct Client *client_p, struct Client *source_p,
|
|||
** parv[0] = sender prefix
|
||||
** parv[1] = servername
|
||||
*/
|
||||
static void mo_trace(struct Client *client_p, struct Client *source_p,
|
||||
static void
|
||||
mo_trace(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
struct Client *target_p = NULL;
|
||||
|
@ -212,7 +213,7 @@ static void mo_trace(struct Client *client_p, struct Client *source_p,
|
|||
}
|
||||
|
||||
/* report all direct connections */
|
||||
for (ptr = lclient_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, lclient_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
@ -228,7 +229,7 @@ static void mo_trace(struct Client *client_p, struct Client *source_p,
|
|||
cnt = report_this_status(source_p,target_p,dow,0,0);
|
||||
}
|
||||
|
||||
for (ptr = serv_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
@ -243,7 +244,7 @@ static void mo_trace(struct Client *client_p, struct Client *source_p,
|
|||
}
|
||||
|
||||
/* This section is to report the unknowns */
|
||||
for (ptr = unknown_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, unknown_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
@ -291,8 +292,9 @@ static void mo_trace(struct Client *client_p, struct Client *source_p,
|
|||
** parv[0] = sender prefix
|
||||
** parv[1] = servername
|
||||
*/
|
||||
static void ms_trace(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
static void
|
||||
ms_trace(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
if (hunt_server(client_p, source_p, ":%s TRACE %s :%s", 2, parc, parv))
|
||||
return;
|
||||
|
@ -311,8 +313,9 @@ static void ms_trace(struct Client *client_p, struct Client *source_p,
|
|||
* output - counter of number of hits
|
||||
* side effects - NONE
|
||||
*/
|
||||
static int report_this_status(struct Client *source_p, struct Client *target_p,
|
||||
int dow, int link_u_p, int link_s_p)
|
||||
static int
|
||||
report_this_status(struct Client *source_p, struct Client *target_p,
|
||||
int dow, int link_u_p, int link_s_p)
|
||||
{
|
||||
const char* name;
|
||||
const char* class_name;
|
||||
|
@ -412,7 +415,8 @@ static int report_this_status(struct Client *source_p, struct Client *target_p,
|
|||
* output - none
|
||||
* side effects - hook event doing_trace is called
|
||||
*/
|
||||
static void trace_spy(struct Client *source_p)
|
||||
static void
|
||||
trace_spy(struct Client *source_p)
|
||||
{
|
||||
struct hook_spy_data data;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_who.c,v 1.10 2002/09/16 07:36:01 fishwaldo Exp $
|
||||
* $Id: m_who.c,v 1.11 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
#include "stdinc.h"
|
||||
#include "tools.h"
|
||||
|
@ -60,7 +60,7 @@ _moddeinit(void)
|
|||
{
|
||||
mod_del_cmd(&who_msgtab);
|
||||
}
|
||||
const char *_version = "$Revision: 1.10 $";
|
||||
const char *_version = "$Revision: 1.11 $";
|
||||
#endif
|
||||
static void do_who_on_channel(struct Client *source_p,
|
||||
struct Channel *chptr, char *real_name,
|
||||
|
@ -241,43 +241,43 @@ static void m_who(struct Client *client_p,
|
|||
* marks matched clients.
|
||||
*
|
||||
*/
|
||||
static void who_common_channel(struct Client *source_p,dlink_list chain,
|
||||
char *mask,int server_oper, int *maxmatches)
|
||||
static void
|
||||
who_common_channel(struct Client *source_p,dlink_list chain,
|
||||
char *mask,int server_oper, int *maxmatches)
|
||||
{
|
||||
dlink_node *clp;
|
||||
struct Client *target_p;
|
||||
struct Client *target_p;
|
||||
|
||||
for (clp = chain.head; clp; clp = clp->next)
|
||||
{
|
||||
target_p = clp->data;
|
||||
DLINK_FOREACH(clp, chain.head)
|
||||
{
|
||||
target_p = clp->data;
|
||||
|
||||
if (!IsInvisible(target_p) || IsMarked(target_p))
|
||||
continue;
|
||||
if (!IsInvisible(target_p) || IsMarked(target_p))
|
||||
continue;
|
||||
|
||||
if (server_oper && !IsOper(target_p))
|
||||
continue;
|
||||
if (server_oper && !IsOper(target_p))
|
||||
continue;
|
||||
|
||||
SetMark(target_p);
|
||||
SetMark(target_p);
|
||||
|
||||
if ((mask == NULL) ||
|
||||
match(mask, target_p->name) || match(mask, target_p->username) ||
|
||||
match(mask, target_p->host) || match(mask, target_p->vhost) ||
|
||||
(match(mask, target_p->user->server) &&
|
||||
(IsOper(source_p) || !ConfigServerHide.hide_servers)) ||
|
||||
match(mask, target_p->info))
|
||||
{
|
||||
if ((mask == NULL) ||
|
||||
match(mask, target_p->name) || match(mask, target_p->username) ||
|
||||
match(mask, target_p->host) ||
|
||||
(match(mask, target_p->user->server) &&
|
||||
(IsOper(source_p) || !ConfigServerHide.hide_servers)) ||
|
||||
match(mask, target_p->info))
|
||||
{
|
||||
|
||||
do_who(source_p, target_p, NULL, "");
|
||||
do_who(source_p, target_p, NULL, "");
|
||||
|
||||
if (*maxmatches > 0)
|
||||
{
|
||||
--(*maxmatches);
|
||||
if(*maxmatches == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (*maxmatches > 0)
|
||||
{
|
||||
--(*maxmatches);
|
||||
if(*maxmatches == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -291,7 +291,8 @@ static void who_common_channel(struct Client *source_p,dlink_list chain,
|
|||
* this is slightly expensive on EFnet ...
|
||||
*/
|
||||
|
||||
static void who_global(struct Client *source_p,char *mask, int server_oper)
|
||||
static void
|
||||
who_global(struct Client *source_p,char *mask, int server_oper)
|
||||
{
|
||||
struct Channel *chptr=NULL;
|
||||
struct Client *target_p;
|
||||
|
@ -299,7 +300,7 @@ static void who_global(struct Client *source_p,char *mask, int server_oper)
|
|||
int maxmatches = 500;
|
||||
|
||||
/* first, list all matching INvisible clients on common channels */
|
||||
for (lp = source_p->user->channel.head; lp; lp = lp->next)
|
||||
DLINK_FOREACH(lp, source_p->user->channel.head)
|
||||
{
|
||||
chptr = lp->data;
|
||||
who_common_channel(source_p,chptr->chanadmins,mask,server_oper,&maxmatches);
|
||||
|
@ -356,10 +357,9 @@ static void who_global(struct Client *source_p,char *mask, int server_oper)
|
|||
* side effects - do a who on given channel
|
||||
*/
|
||||
|
||||
static void do_who_on_channel(struct Client *source_p,
|
||||
struct Channel *chptr,
|
||||
char *chname,
|
||||
int server_oper, int member)
|
||||
static void
|
||||
do_who_on_channel(struct Client *source_p, struct Channel *chptr,
|
||||
char *chname, int server_oper, int member)
|
||||
{
|
||||
char flags[NUMLISTS][2];
|
||||
|
||||
|
@ -482,14 +482,13 @@ static void do_who_list(struct Client *source_p, struct Channel *chptr,
|
|||
* side effects - do a who on given person
|
||||
*/
|
||||
|
||||
static void do_who(struct Client *source_p,
|
||||
struct Client *target_p,
|
||||
char *chname,
|
||||
char *op_flags)
|
||||
static void
|
||||
do_who(struct Client *source_p, struct Client *target_p,
|
||||
char *chname, char *op_flags)
|
||||
{
|
||||
char status[5];
|
||||
ircsprintf(status,"%c%s%s",
|
||||
target_p->user->away ? 'G' : 'H',
|
||||
|
||||
ircsprintf(status,"%c%s%s", target_p->user->away ? 'G' : 'H',
|
||||
IsOper(target_p) ? "*" : "", op_flags );
|
||||
|
||||
if(ConfigServerHide.hide_servers)
|
||||
|
@ -517,10 +516,9 @@ static void do_who(struct Client *source_p,
|
|||
** parv[1] = nickname mask list
|
||||
** parv[2] = additional selection flag, only 'o' for now.
|
||||
*/
|
||||
static void ms_who(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
int parc,
|
||||
char *parv[])
|
||||
static void
|
||||
ms_who(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
/* If its running as a hub, and linked with lazy links
|
||||
* then allow leaf to use normal client m_who()
|
||||
|
@ -528,10 +526,10 @@ static void ms_who(struct Client *client_p,
|
|||
*/
|
||||
|
||||
if( ServerInfo.hub )
|
||||
{
|
||||
if(!IsCapable(client_p->from,CAP_LL))
|
||||
return;
|
||||
}
|
||||
{
|
||||
if(!IsCapable(client_p->from,CAP_LL))
|
||||
return;
|
||||
}
|
||||
|
||||
m_who(client_p,source_p,parc,parv);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: m_whois.c,v 1.8 2002/09/14 04:40:49 fishwaldo Exp $
|
||||
* $Id: m_whois.c,v 1.9 2002/09/19 05:41:10 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -35,7 +35,7 @@
|
|||
#include "numeric.h"
|
||||
#include "s_conf.h"
|
||||
#include "s_serv.h"
|
||||
#include "s_user.h"
|
||||
#include "s_user.h"
|
||||
#include "send.h"
|
||||
#include "list.h"
|
||||
#include "irc_string.h"
|
||||
|
@ -76,54 +76,53 @@ _moddeinit(void)
|
|||
mod_del_cmd(&whois_msgtab);
|
||||
}
|
||||
|
||||
const char *_version = "$Revision: 1.8 $";
|
||||
const char *_version = "$Revision: 1.9 $";
|
||||
#endif
|
||||
/*
|
||||
** m_whois
|
||||
** parv[0] = sender prefix
|
||||
** parv[1] = nickname masklist
|
||||
*/
|
||||
static void m_whois(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
int parc,
|
||||
char *parv[])
|
||||
static void
|
||||
m_whois(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
static time_t last_used = 0;
|
||||
|
||||
if (parc < 2)
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
|
||||
me.name, parv[0]);
|
||||
return;
|
||||
}
|
||||
if (parc < 2 || BadPtr(parv[1]))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
|
||||
me.name, parv[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(parc > 2)
|
||||
{
|
||||
/* seeing as this is going across servers, we should limit it */
|
||||
if((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
|
||||
{
|
||||
/* seeing as this is going across servers, we should limit it */
|
||||
if((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
|
||||
{
|
||||
if(MyClient(source_p))
|
||||
sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,source_p->name);
|
||||
return;
|
||||
}
|
||||
else
|
||||
last_used = CurrentTime;
|
||||
if(MyClient(source_p))
|
||||
sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,source_p->name);
|
||||
return;
|
||||
}
|
||||
else
|
||||
last_used = CurrentTime;
|
||||
|
||||
/* if we have serverhide enabled, they can either ask the clients
|
||||
* server, or our server.. I dont see why they would need to ask
|
||||
* anything else for info about the client.. --fl_
|
||||
*/
|
||||
if(ConfigServerHide.disable_remote)
|
||||
parv[1] = parv[2];
|
||||
|
||||
if (hunt_server(client_p,source_p,":%s WHOIS %s :%s", 1, parc, parv) !=
|
||||
HUNTED_ISME)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* if we have serverhide enabled, they can either ask the clients
|
||||
* server, or our server.. I dont see why they would need to ask
|
||||
* anything else for info about the client.. --fl_
|
||||
*/
|
||||
if(ConfigServerHide.disable_remote)
|
||||
parv[1] = parv[2];
|
||||
|
||||
if (hunt_server(client_p,source_p,":%s WHOIS %s :%s", 1, parc, parv) !=
|
||||
HUNTED_ISME)
|
||||
{
|
||||
return;
|
||||
}
|
||||
parv[1] = parv[2];
|
||||
|
||||
}
|
||||
do_whois(client_p,source_p,parc,parv);
|
||||
}
|
||||
|
||||
|
@ -132,12 +131,12 @@ static void m_whois(struct Client *client_p,
|
|||
** parv[0] = sender prefix
|
||||
** parv[1] = nickname masklist
|
||||
*/
|
||||
static void mo_whois(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
int parc,
|
||||
char *parv[])
|
||||
static void
|
||||
mo_whois(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
if(parc < 2)
|
||||
/* XXX Need BadPtr */
|
||||
if (parc < 2 || BadPtr(parv[1]))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
|
||||
me.name, parv[0]);
|
||||
|
@ -164,8 +163,9 @@ static void mo_whois(struct Client *client_p,
|
|||
* output -
|
||||
* side effects -
|
||||
*/
|
||||
static int do_whois(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
static int
|
||||
do_whois(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
struct Client *target_p;
|
||||
char *nick;
|
||||
|
@ -186,63 +186,64 @@ static int do_whois(struct Client *client_p, struct Client *source_p,
|
|||
nick++;
|
||||
if ((p = strchr(nick,',')) != NULL)
|
||||
*p = '\0';
|
||||
if (!*nick)
|
||||
return 0;
|
||||
|
||||
if (*nick == '\0')
|
||||
return(0);
|
||||
|
||||
(void)collapse(nick);
|
||||
wilds = (strchr(nick, '?') || strchr(nick, '*'));
|
||||
|
||||
if(!wilds)
|
||||
{
|
||||
if((target_p = find_client(nick)) != NULL)
|
||||
{
|
||||
if((target_p = find_client(nick)) != NULL)
|
||||
{
|
||||
/* im being asked to reply to a client that isnt mine..
|
||||
* I cant answer authoritively, so better make it non-detailed
|
||||
*/
|
||||
if(!MyClient(target_p))
|
||||
glob=0;
|
||||
/* im being asked to reply to a client that isnt mine..
|
||||
* I cant answer authoritively, so better make it non-detailed
|
||||
*/
|
||||
if(!MyClient(target_p))
|
||||
glob=0;
|
||||
|
||||
if (IsServer(client_p))
|
||||
client_burst_if_needed(client_p,target_p);
|
||||
if (IsServer(client_p))
|
||||
client_burst_if_needed(client_p,target_p);
|
||||
|
||||
if(IsPerson(target_p))
|
||||
{
|
||||
(void)single_whois(source_p,target_p,wilds,glob);
|
||||
found = YES;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ServerInfo.hub && uplink && IsCapable(uplink,CAP_LL))
|
||||
{
|
||||
if(glob == 1)
|
||||
sendto_one(uplink,":%s WHOIS %s :%s",
|
||||
source_p->name, nick, nick);
|
||||
else
|
||||
sendto_one(uplink,":%s WHOIS %s",
|
||||
source_p->name, nick);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(IsPerson(target_p))
|
||||
{
|
||||
(void)single_whois(source_p,target_p,wilds,glob);
|
||||
found = YES;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/* disallow wild card whois on lazylink leafs for now */
|
||||
|
||||
if (!ServerInfo.hub && uplink && IsCapable(uplink,CAP_LL))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/* Oh-oh wilds is true so have to do it the hard expensive way */
|
||||
found = global_whois(source_p,nick,wilds,glob);
|
||||
{
|
||||
if(glob)
|
||||
sendto_one(uplink,":%s WHOIS %s :%s",
|
||||
source_p->name, nick, nick);
|
||||
else
|
||||
sendto_one(uplink,":%s WHOIS %s",
|
||||
source_p->name, nick);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* wilds is true */
|
||||
{
|
||||
/* disallow wild card whois on lazylink leafs for now */
|
||||
|
||||
if (!ServerInfo.hub && uplink && IsCapable(uplink,CAP_LL))
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
/* Oh-oh wilds is true so have to do it the hard expensive way */
|
||||
found = global_whois(source_p,nick,wilds,glob);
|
||||
}
|
||||
|
||||
if(found)
|
||||
sendto_one(source_p, form_str(RPL_ENDOFWHOIS), me.name, parv[0], parv[1]);
|
||||
else
|
||||
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], nick);
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -255,41 +256,41 @@ static int do_whois(struct Client *client_p, struct Client *source_p,
|
|||
* Side Effects - do a single whois on given client
|
||||
* writing results to source_p
|
||||
*/
|
||||
static int global_whois(struct Client *source_p, char *nick,
|
||||
int wilds, int glob)
|
||||
static int
|
||||
global_whois(struct Client *source_p, char *nick, int wilds, int glob)
|
||||
{
|
||||
struct Client *target_p;
|
||||
int found = NO;
|
||||
|
||||
for (target_p = GlobalClientList; (target_p = next_client(target_p, nick));
|
||||
target_p = target_p->next)
|
||||
{
|
||||
if (IsServer(target_p))
|
||||
continue;
|
||||
/*
|
||||
* I'm always last :-) and target_p->next == NULL!!
|
||||
*/
|
||||
if (IsMe(target_p))
|
||||
break;
|
||||
/*
|
||||
* 'Rules' established for sending a WHOIS reply:
|
||||
*
|
||||
*
|
||||
* - if wildcards are being used dont send a reply if
|
||||
* the querier isnt any common channels and the
|
||||
* client in question is invisible and wildcards are
|
||||
* in use (allow exact matches only);
|
||||
*
|
||||
* - only send replies about common or public channels
|
||||
* the target user(s) are on;
|
||||
*/
|
||||
{
|
||||
if (IsServer(target_p))
|
||||
continue;
|
||||
/*
|
||||
* I'm always last :-) and target_p->next == NULL!!
|
||||
*/
|
||||
if (IsMe(target_p))
|
||||
break;
|
||||
/*
|
||||
* 'Rules' established for sending a WHOIS reply:
|
||||
*
|
||||
*
|
||||
* - if wildcards are being used dont send a reply if
|
||||
* the querier isnt any common channels and the
|
||||
* client in question is invisible and wildcards are
|
||||
* in use (allow exact matches only);
|
||||
*
|
||||
* - only send replies about common or public channels
|
||||
* the target user(s) are on;
|
||||
*/
|
||||
|
||||
if(!IsRegistered(target_p))
|
||||
continue;
|
||||
if(!IsRegistered(target_p))
|
||||
continue;
|
||||
|
||||
if(single_whois(source_p, target_p, wilds, glob))
|
||||
found = 1;
|
||||
}
|
||||
if(single_whois(source_p, target_p, wilds, glob))
|
||||
found = (YES);
|
||||
}
|
||||
|
||||
return (found);
|
||||
}
|
||||
|
@ -304,8 +305,9 @@ static int global_whois(struct Client *source_p, char *nick,
|
|||
* Side Effects - do a single whois on given client
|
||||
* writing results to source_p
|
||||
*/
|
||||
static int single_whois(struct Client *source_p,struct Client *target_p,
|
||||
int wilds, int glob)
|
||||
static int
|
||||
single_whois(struct Client *source_p,struct Client *target_p,
|
||||
int wilds, int glob)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
struct Channel *chptr;
|
||||
|
@ -334,27 +336,27 @@ static int single_whois(struct Client *source_p,struct Client *target_p,
|
|||
member = (target_p->user->channel.head) ? 1 : 0;
|
||||
showperson = (wilds && !invis && !member) || !wilds;
|
||||
|
||||
for (ptr = target_p->user->channel.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, target_p->user->channel.head)
|
||||
{
|
||||
chptr = ptr->data;
|
||||
member = IsMember(source_p, chptr);
|
||||
if (invis && !member)
|
||||
continue;
|
||||
if (member || (!invis && PubChannel(chptr)))
|
||||
{
|
||||
chptr = ptr->data;
|
||||
member = IsMember(source_p, chptr);
|
||||
if (invis && !member)
|
||||
continue;
|
||||
if (member || (!invis && PubChannel(chptr)))
|
||||
{
|
||||
showperson = 1;
|
||||
break;
|
||||
}
|
||||
if (!invis && HiddenChannel(chptr) && !SecretChannel(chptr))
|
||||
{
|
||||
showperson = 1;
|
||||
break;
|
||||
}
|
||||
showperson = 1;
|
||||
break;
|
||||
}
|
||||
if (!invis && HiddenChannel(chptr) && !SecretChannel(chptr))
|
||||
{
|
||||
showperson = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(showperson)
|
||||
whois_person(source_p,target_p,glob);
|
||||
return 0;
|
||||
return (YES);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -365,7 +367,8 @@ static int single_whois(struct Client *source_p,struct Client *target_p,
|
|||
* Output - NONE
|
||||
* Side Effects -
|
||||
*/
|
||||
static void whois_person(struct Client *source_p,struct Client *target_p, int glob)
|
||||
static void
|
||||
whois_person(struct Client *source_p,struct Client *target_p, int glob)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
char *chname;
|
||||
|
@ -395,38 +398,35 @@ static void whois_person(struct Client *source_p,struct Client *target_p, int gl
|
|||
cur_len = mlen;
|
||||
t = buf + mlen;
|
||||
|
||||
for (lp = target_p->user->channel.head; lp; lp = lp->next)
|
||||
DLINK_FOREACH(lp, target_p->user->channel.head)
|
||||
{
|
||||
chptr = lp->data;
|
||||
chname = chptr->chname;
|
||||
|
||||
if (ShowChannel(source_p, chptr))
|
||||
{
|
||||
chptr = lp->data;
|
||||
chname = chptr->chname;
|
||||
if ((cur_len + strlen(chname) + 2) > (BUFSIZE - 4))
|
||||
{
|
||||
sendto_one(source_p, "%s", buf);
|
||||
cur_len = mlen;
|
||||
t = buf + mlen;
|
||||
}
|
||||
|
||||
if (ShowChannel(source_p, chptr))
|
||||
{
|
||||
if (chptr->mode.mode & MODE_HIDEOPS && !is_any_op(chptr,source_p))
|
||||
{
|
||||
ircsprintf(t,"%s ",chname);
|
||||
}
|
||||
else
|
||||
{
|
||||
ircsprintf(t,"%s%s ", channel_chanop_or_voice(chptr,target_p), chname);
|
||||
}
|
||||
|
||||
if ((cur_len + strlen(chname) + 2) > (BUFSIZE - 4))
|
||||
{
|
||||
sendto_one(source_p, "%s", buf);
|
||||
cur_len = mlen;
|
||||
t = buf + mlen;
|
||||
}
|
||||
|
||||
if (chptr->mode.mode & MODE_HIDEOPS && !is_any_op(chptr,source_p))
|
||||
{
|
||||
ircsprintf(t,"%s ",chname);
|
||||
}
|
||||
else
|
||||
{
|
||||
ircsprintf(t,"%s%s ", channel_chanop_or_voice(chptr,target_p),
|
||||
chname);
|
||||
}
|
||||
|
||||
tlen = strlen(t);
|
||||
t += tlen;
|
||||
cur_len += tlen;
|
||||
reply_to_send = YES;
|
||||
|
||||
}
|
||||
tlen = strlen(t);
|
||||
t += tlen;
|
||||
cur_len += tlen;
|
||||
reply_to_send = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (reply_to_send)
|
||||
sendto_one(source_p, "%s", buf);
|
||||
|
@ -446,14 +446,15 @@ static void whois_person(struct Client *source_p,struct Client *target_p, int gl
|
|||
source_p->name, target_p->name, target_p->user->away);
|
||||
|
||||
if (IsOper(target_p))
|
||||
{
|
||||
sendto_one(source_p, form_str(RPL_WHOISOPERATOR),
|
||||
me.name, source_p->name, target_p->name);
|
||||
{
|
||||
sendto_one(source_p, form_str(RPL_WHOISOPERATOR),
|
||||
me.name, source_p->name, target_p->name);
|
||||
|
||||
if (IsAdmin(target_p))
|
||||
sendto_one(source_p, form_str(RPL_WHOISADMIN),
|
||||
me.name, source_p->name, target_p->name);
|
||||
}
|
||||
|
||||
if (IsAdmin(target_p))
|
||||
sendto_one(source_p, form_str(RPL_WHOISADMIN),
|
||||
me.name, source_p->name, target_p->name);
|
||||
}
|
||||
if (IsServices(target_p))
|
||||
sendto_one(source_p, form_str(RPL_WHOISSERVICES),
|
||||
me.name, source_p->name, target_p->name);
|
||||
|
@ -488,7 +489,8 @@ static void whois_person(struct Client *source_p,struct Client *target_p, int gl
|
|||
hd.source_p = source_p;
|
||||
|
||||
/* although we should fill in parc and parv, we don't ..
|
||||
be careful of this when writing whois hooks */
|
||||
* be careful of this when writing whois hooks
|
||||
*/
|
||||
if(MyClient(source_p))
|
||||
hook_call_event("doing_whois", &hd);
|
||||
|
||||
|
@ -504,13 +506,13 @@ static void whois_person(struct Client *source_p,struct Client *target_p, int gl
|
|||
* that can happen, and as people might not understand the code, I
|
||||
* stuck heavy comments in it.. it looks ugly.. but at least you
|
||||
* know what it does.. --fl_ */
|
||||
static void ms_whois(struct Client *client_p,
|
||||
struct Client *source_p,
|
||||
int parc,
|
||||
char *parv[])
|
||||
static void
|
||||
ms_whois(struct Client *client_p, struct Client *source_p,
|
||||
int parc, char *parv[])
|
||||
{
|
||||
/* its a misconfigured server */
|
||||
if (parc < 2)
|
||||
/* XXX Need BadPtr */
|
||||
if (parc < 2 || BadPtr(parv[1]))
|
||||
{
|
||||
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
|
||||
me.name, parv[0]);
|
||||
|
@ -561,14 +563,12 @@ static void ms_whois(struct Client *client_p,
|
|||
* if the target isnt on that server.. answer it for them, as the
|
||||
* LL might not know that the target exists..
|
||||
*/
|
||||
if(MyConnect(target_p) && ServerInfo.hub &&
|
||||
IsCapable(target_p, CAP_LL))
|
||||
if(MyConnect(target_p) && ServerInfo.hub && IsCapable(target_p, CAP_LL))
|
||||
{
|
||||
struct Client *whois_p;
|
||||
|
||||
/* try to find the client */
|
||||
whois_p = find_client(parv[2]);
|
||||
if (whois_p)
|
||||
if ((whois_p = find_client(parv[2])) != NULL)
|
||||
{
|
||||
/* check the server being asked to perform the whois, is that
|
||||
* clients uplink */
|
||||
|
@ -611,7 +611,7 @@ static void ms_whois(struct Client *client_p,
|
|||
* the target isnt a LL.. why would I need to burst? */
|
||||
sendto_one(target_p->from, ":%s WHOIS %s :%s", parv[0], parv[1],
|
||||
parv[2]);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
113
src/channel.c
113
src/channel.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: channel.c,v 1.11 2002/09/16 07:47:00 fishwaldo Exp $
|
||||
* $Id: channel.c,v 1.12 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -227,10 +227,8 @@ remove_user_from_channel(struct Channel *chptr, struct Client *who)
|
|||
|
||||
chptr->users_last = CurrentTime;
|
||||
|
||||
for (ptr = who->user->channel.head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, who->user->channel.head)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
|
||||
if (ptr->data == chptr)
|
||||
{
|
||||
dlinkDelete(ptr, &who->user->channel);
|
||||
|
@ -249,33 +247,17 @@ remove_user_from_channel(struct Channel *chptr, struct Client *who)
|
|||
return(sub1_from_channel(chptr));
|
||||
}
|
||||
|
||||
/*
|
||||
* find_user_link
|
||||
* inputs -
|
||||
* - client pointer to find
|
||||
* output - pointer to link or NULL if not found
|
||||
* side effects - Look for ptr in the linked listed pointed to by link.
|
||||
*/
|
||||
dlink_node *
|
||||
find_user_link(dlink_list * list, struct Client *who)
|
||||
{
|
||||
if (who != NULL)
|
||||
return (dlinkFind(list, who));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* inputs -
|
||||
* output - NONE
|
||||
* side effects -
|
||||
*/
|
||||
static void
|
||||
send_members(struct Client *client_p,
|
||||
char *lmodebuf,
|
||||
char *lparabuf,
|
||||
send_members(struct Client *client_p, char *lmodebuf, char *lparabuf,
|
||||
struct Channel *chptr, dlink_list * list, char *op_flag)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
dlink_node *next_ptr;
|
||||
int tlen; /* length of t (temp pointer) */
|
||||
int mlen; /* minimum length */
|
||||
int cur_len = 0; /* current length */
|
||||
|
@ -289,7 +271,7 @@ send_members(struct Client *client_p,
|
|||
|
||||
t = buf + mlen;
|
||||
|
||||
for (ptr = list->head; ptr && ptr->data; ptr = ptr->next)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
ircsprintf(t, "%s%s ", op_flag, target_p->name);
|
||||
|
@ -380,7 +362,7 @@ send_mode_list(struct Client *client_p,
|
|||
*mp = '\0';
|
||||
pp = pbuf;
|
||||
|
||||
for (lp = top->head; lp; lp = lp->next)
|
||||
DLINK_FOREACH(lp, top->head)
|
||||
{
|
||||
banptr = lp->data;
|
||||
tlen = strlen(banptr->banstr);
|
||||
|
@ -447,13 +429,14 @@ sub1_from_channel(struct Channel *chptr)
|
|||
* It should never happen but...
|
||||
*/
|
||||
/* persistent channel */
|
||||
if ((chptr->channelts + ConfigChannel.persist_time) > CurrentTime)
|
||||
{
|
||||
destroy_channel(chptr);
|
||||
return 1;
|
||||
}
|
||||
/* NeoIRCd caches all channels */
|
||||
// if ((chptr->channelts + ConfigChannel.persist_time) < CurrentTime)
|
||||
// {
|
||||
// destroy_channel(chptr);
|
||||
// return (1);
|
||||
// }
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -470,10 +453,8 @@ free_channel_list(dlink_list * list)
|
|||
dlink_node *next_ptr;
|
||||
struct Ban *actualBan;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
|
||||
actualBan = ptr->data;
|
||||
MyFree(actualBan->banstr);
|
||||
MyFree(actualBan->who);
|
||||
|
@ -599,7 +580,7 @@ destroy_channel(struct Channel *chptr)
|
|||
del_from_channel_hash_table(chptr->chname, chptr);
|
||||
if (ServerInfo.hub == 1)
|
||||
{
|
||||
for (m = lazylink_channels.head; m; m = m->next)
|
||||
DLINK_FOREACH(m, lazylink_channels.head)
|
||||
{
|
||||
if (m->data != chptr)
|
||||
continue;
|
||||
|
@ -629,7 +610,7 @@ delete_members(struct Channel *chptr, dlink_list * list)
|
|||
|
||||
struct Client *who;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
who = (struct Client *)ptr->data;
|
||||
|
@ -830,7 +811,7 @@ del_invite(struct Channel *chptr, struct Client *who)
|
|||
{
|
||||
dlink_node *ptr;
|
||||
|
||||
for (ptr = chptr->invites.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->invites.head)
|
||||
{
|
||||
if (ptr->data == who)
|
||||
{
|
||||
|
@ -840,7 +821,7 @@ del_invite(struct Channel *chptr, struct Client *who)
|
|||
}
|
||||
}
|
||||
|
||||
for (ptr = who->user->invited.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, who->user->invited.head)
|
||||
{
|
||||
if (ptr->data == chptr)
|
||||
{
|
||||
|
@ -927,7 +908,7 @@ check_banned(struct Channel *chptr, struct Client *who, char *s, char *s2, char
|
|||
struct Ban *actualBan = NULL;
|
||||
struct Ban *actualExcept = NULL;
|
||||
|
||||
for (ban = chptr->banlist.head; ban; ban = ban->next)
|
||||
DLINK_FOREACH(ban, chptr->banlist.head)
|
||||
{
|
||||
actualBan = ban->data;
|
||||
if (match(actualBan->banstr, s) || match(actualBan->banstr, s2) || match(actualBan->banstr, s3))
|
||||
|
@ -938,7 +919,7 @@ check_banned(struct Channel *chptr, struct Client *who, char *s, char *s2, char
|
|||
|
||||
if (actualBan != NULL)
|
||||
{
|
||||
for (except = chptr->exceptlist.head; except; except = except->next)
|
||||
DLINK_FOREACH(except, chptr->exceptlist.head)
|
||||
{
|
||||
actualExcept = except->data;
|
||||
|
||||
|
@ -988,7 +969,8 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key)
|
|||
for (lp = source_p->user->invited.head; lp; lp = lp->next)
|
||||
if (lp->data == chptr)
|
||||
break;
|
||||
if (!lp)
|
||||
|
||||
if (lp == NULL)
|
||||
{
|
||||
for (ptr = chptr->invexlist.head; ptr; ptr = ptr->next)
|
||||
{
|
||||
|
@ -1043,7 +1025,7 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key)
|
|||
int
|
||||
is_chan_op(struct Channel *chptr, struct Client *who)
|
||||
{
|
||||
if (chptr)
|
||||
if (chptr != NULL)
|
||||
{
|
||||
if (find_user_link(&chptr->chanops, who) != NULL)
|
||||
return 1;
|
||||
|
@ -1082,7 +1064,7 @@ is_chan_admin(struct Channel *chptr, struct Client *who)
|
|||
int
|
||||
is_any_op(struct Channel *chptr, struct Client *who)
|
||||
{
|
||||
if (chptr)
|
||||
if (chptr != NULL)
|
||||
{
|
||||
if (find_user_link(&chptr->chanops, who) != NULL)
|
||||
return 1;
|
||||
|
@ -1091,7 +1073,7 @@ is_any_op(struct Channel *chptr, struct Client *who)
|
|||
if (find_user_link(&chptr->chanadmins, who) != NULL)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1105,13 +1087,13 @@ is_any_op(struct Channel *chptr, struct Client *who)
|
|||
int
|
||||
is_half_op(struct Channel *chptr, struct Client *who)
|
||||
{
|
||||
if (chptr)
|
||||
if (chptr != NULL)
|
||||
{
|
||||
if ((find_user_link(&chptr->halfops, who)))
|
||||
return (1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1125,12 +1107,12 @@ is_half_op(struct Channel *chptr, struct Client *who)
|
|||
int
|
||||
is_voiced(struct Channel *chptr, struct Client *who)
|
||||
{
|
||||
if (chptr)
|
||||
if (chptr != NULL)
|
||||
{
|
||||
if (find_user_link(&chptr->voiced, who) != NULL)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1149,17 +1131,17 @@ int
|
|||
can_send(struct Channel *chptr, struct Client *source_p)
|
||||
{
|
||||
if(MyClient(source_p) && find_channel_resv(chptr->chname))
|
||||
return CAN_SEND_NO;
|
||||
return (CAN_SEND_NO);
|
||||
|
||||
if (is_any_op(chptr, source_p))
|
||||
return CAN_SEND_OPV;
|
||||
return (CAN_SEND_OPV);
|
||||
if (is_voiced(chptr, source_p))
|
||||
return CAN_SEND_OPV;
|
||||
return (CAN_SEND_OPV);
|
||||
if (IsServer(source_p))
|
||||
return CAN_SEND_OPV;
|
||||
return (CAN_SEND_OPV);
|
||||
|
||||
if (chptr->mode.mode & MODE_MODERATED)
|
||||
return CAN_SEND_NO;
|
||||
return (CAN_SEND_NO);
|
||||
|
||||
if (ConfigChannel.quiet_on_ban && MyClient(source_p) &&
|
||||
(is_banned(chptr, source_p) == CHFL_BAN))
|
||||
|
@ -1170,7 +1152,7 @@ can_send(struct Channel *chptr, struct Client *source_p)
|
|||
if (chptr->mode.mode & MODE_NOPRIVMSGS && !IsMember(source_p, chptr))
|
||||
return (CAN_SEND_NO);
|
||||
|
||||
return CAN_SEND_NONOP;
|
||||
return (CAN_SEND_NONOP);
|
||||
}
|
||||
|
||||
/* void check_spambot_warning(struct Client *source_p)
|
||||
|
@ -1243,13 +1225,13 @@ check_spambot_warning(struct Client *source_p, const char *name)
|
|||
* side effects - compares usercount and servercount against their split
|
||||
* values and adjusts splitmode accordingly
|
||||
*/
|
||||
void check_splitmode(void *unused)
|
||||
void
|
||||
check_splitmode(void *unused)
|
||||
{
|
||||
if(splitchecking && (ConfigChannel.no_join_on_split ||
|
||||
ConfigChannel.no_create_on_split))
|
||||
{
|
||||
if((Count.server < split_servers) &&
|
||||
(Count.total < split_users))
|
||||
if((Count.server < split_servers) && (Count.total < split_users))
|
||||
{
|
||||
if(!splitmode)
|
||||
{
|
||||
|
@ -1278,7 +1260,8 @@ void check_splitmode(void *unused)
|
|||
* side effects - Allocates a new topic
|
||||
*/
|
||||
|
||||
int allocate_topic(struct Channel *chptr)
|
||||
int
|
||||
allocate_topic(struct Channel *chptr)
|
||||
{
|
||||
void *ptr;
|
||||
if(chptr == NULL)
|
||||
|
@ -1295,12 +1278,13 @@ int allocate_topic(struct Channel *chptr)
|
|||
chptr->topic_info = (char *)ptr + TOPICLEN+1;
|
||||
*chptr->topic = '\0';
|
||||
*chptr->topic_info = '\0';
|
||||
return TRUE;
|
||||
return (TRUE);
|
||||
}
|
||||
return FALSE;
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
void free_topic(struct Channel *chptr)
|
||||
void
|
||||
free_topic(struct Channel *chptr)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
|
@ -1320,16 +1304,19 @@ void free_topic(struct Channel *chptr)
|
|||
/*
|
||||
* set_channel_topic - Sets the channel topic
|
||||
*/
|
||||
void set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_info, time_t topicts)
|
||||
void
|
||||
set_channel_topic(struct Channel *chptr, const char *topic,
|
||||
const char *topic_info, time_t topicts)
|
||||
{
|
||||
if(strlen(topic) > 0)
|
||||
{
|
||||
if(chptr->topic == NULL)
|
||||
allocate_topic(chptr);
|
||||
strlcpy(chptr->topic, topic, TOPICLEN);
|
||||
strlcpy(chptr->topic, topic, TOPICLEN+1);
|
||||
strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN);
|
||||
chptr->topic_time = topicts;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if(chptr->topic != NULL)
|
||||
free_topic(chptr);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: channel_mode.c,v 1.15 2002/09/17 06:09:35 fishwaldo Exp $
|
||||
* $Id: channel_mode.c,v 1.16 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -136,7 +136,7 @@ static int mode_count;
|
|||
|
||||
static int hideops_changed;
|
||||
|
||||
static int mode_limit;
|
||||
static int mode_limit; /* number of modes set other than simple */
|
||||
|
||||
extern BlockHeap *ban_heap;
|
||||
|
||||
|
@ -214,7 +214,7 @@ add_id(struct Client *client_p, struct Channel *chptr, char *banid, int type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (ban = list->head; ban; ban = ban->next)
|
||||
DLINK_FOREACH(ban, list->head)
|
||||
{
|
||||
actualBan = ban->data;
|
||||
if (match(actualBan->banstr, banid))
|
||||
|
@ -256,6 +256,12 @@ add_id(struct Client *client_p, struct Channel *chptr, char *banid, int type)
|
|||
* from orabidoo
|
||||
* modified 8/9/00 by is: now we handle add ban types here
|
||||
* (invex/excemp/etc)
|
||||
*
|
||||
* inputs - pointer to channel
|
||||
* - pointer to ban id
|
||||
* - type of ban, i.e. ban, exception, invex
|
||||
* output - 0 for failure, 1 for success
|
||||
* side effects -
|
||||
*/
|
||||
static int
|
||||
del_id(struct Channel *chptr, char *banid, int type)
|
||||
|
@ -264,8 +270,8 @@ del_id(struct Channel *chptr, char *banid, int type)
|
|||
dlink_node *ban;
|
||||
struct Ban *banptr;
|
||||
|
||||
if (!banid)
|
||||
return 0;
|
||||
if (banid == NULL)
|
||||
return (0);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
@ -281,10 +287,10 @@ del_id(struct Channel *chptr, char *banid, int type)
|
|||
default:
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
"del_id() called with unknown ban type %d!", type);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
for (ban = list->head; ban; ban = ban->next)
|
||||
DLINK_FOREACH(ban, list->head)
|
||||
{
|
||||
banptr = ban->data;
|
||||
|
||||
|
@ -303,10 +309,10 @@ del_id(struct Channel *chptr, char *banid, int type)
|
|||
dlinkDelete(ban, list);
|
||||
free_dlink_node(ban);
|
||||
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -738,7 +744,7 @@ chm_hideops(struct Client *client_p, struct Client *source_p,
|
|||
if (alev < CHACCESS_ADMIN)
|
||||
{
|
||||
if (!(*errors & SM_ERR_NOOPS))
|
||||
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name,
|
||||
sendto_one(source_p, form_str(ERR_CHANAPRIVSNEEDED), me.name,
|
||||
source_p->name, chname);
|
||||
*errors |= SM_ERR_NOOPS;
|
||||
return;
|
||||
|
@ -784,7 +790,7 @@ chm_ban(struct Client *client_p, struct Client *source_p,
|
|||
*errors |= SM_ERR_RPL_B;
|
||||
|
||||
if ((chptr->mode.mode & MODE_HIDEOPS) && (alev < CHACCESS_HALFOP))
|
||||
for (ptr = chptr->banlist.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->banlist.head)
|
||||
{
|
||||
banptr = ptr->data;
|
||||
sendto_one(client_p, form_str(RPL_BANLIST),
|
||||
|
@ -792,7 +798,7 @@ chm_ban(struct Client *client_p, struct Client *source_p,
|
|||
banptr->banstr, me.name, banptr->when);
|
||||
}
|
||||
else
|
||||
for (ptr = chptr->banlist.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->banlist.head)
|
||||
{
|
||||
banptr = ptr->data;
|
||||
sendto_one(client_p, form_str(RPL_BANLIST),
|
||||
|
@ -823,12 +829,9 @@ chm_ban(struct Client *client_p, struct Client *source_p,
|
|||
else
|
||||
mask = pretty_mask(raw_mask);
|
||||
|
||||
/* Cant do this - older servers dont.. it WILL cause a desync, but should
|
||||
* be limited by our input buffer anyway --fl_
|
||||
*
|
||||
* if (strlen(mask) > HOSTLEN+NICKLEN+USERLEN)
|
||||
* return;
|
||||
*/
|
||||
/* We'd have problems parsing this, hyb6 does it too */
|
||||
if (strlen(mask) > (MODEBUFLEN - 2))
|
||||
return;
|
||||
|
||||
/* if we're adding a NEW id */
|
||||
if (dir == MODE_ADD)
|
||||
|
@ -844,10 +847,10 @@ chm_ban(struct Client *client_p, struct Client *source_p,
|
|||
}
|
||||
else if (dir == MODE_DEL)
|
||||
{
|
||||
if (del_id(chptr, mask, CHFL_BAN) != 0)
|
||||
if (del_id(chptr, mask, CHFL_BAN) == 0)
|
||||
{
|
||||
/* mask isn't a valid ban, check raw_mask */
|
||||
if((del_id(chptr, raw_mask, CHFL_BAN) != 0) && MyClient(source_p))
|
||||
if((del_id(chptr, raw_mask, CHFL_BAN) == 0) && MyClient(source_p))
|
||||
{
|
||||
/* nope */
|
||||
return;
|
||||
|
@ -888,7 +891,7 @@ chm_except(struct Client *client_p, struct Client *source_p,
|
|||
return;
|
||||
*errors |= SM_ERR_RPL_E;
|
||||
|
||||
for (ptr = chptr->exceptlist.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->exceptlist.head)
|
||||
{
|
||||
banptr = ptr->data;
|
||||
sendto_one(client_p, form_str(RPL_EXCEPTLIST),
|
||||
|
@ -909,6 +912,10 @@ chm_except(struct Client *client_p, struct Client *source_p,
|
|||
else
|
||||
mask = pretty_mask(raw_mask);
|
||||
|
||||
/* We'd have problems parsing this, hyb6 does it too */
|
||||
if (strlen(mask) > (MODEBUFLEN - 2))
|
||||
return;
|
||||
|
||||
/* If we're adding a NEW id */
|
||||
if (dir == MODE_ADD)
|
||||
{
|
||||
|
@ -923,10 +930,10 @@ chm_except(struct Client *client_p, struct Client *source_p,
|
|||
}
|
||||
else if (dir == MODE_DEL)
|
||||
{
|
||||
if (del_id(chptr, mask, CHFL_EXCEPTION) != 0)
|
||||
if (del_id(chptr, mask, CHFL_EXCEPTION) == 0)
|
||||
{
|
||||
/* mask isn't a valid ban, check raw_mask */
|
||||
if((del_id(chptr, raw_mask, CHFL_EXCEPTION) != 0) && MyClient(source_p))
|
||||
if((del_id(chptr, raw_mask, CHFL_EXCEPTION) == 0) && MyClient(source_p))
|
||||
{
|
||||
/* nope */
|
||||
return;
|
||||
|
@ -967,7 +974,7 @@ chm_invex(struct Client *client_p, struct Client *source_p,
|
|||
return;
|
||||
*errors |= SM_ERR_RPL_I;
|
||||
|
||||
for (ptr = chptr->invexlist.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->invexlist.head)
|
||||
{
|
||||
banptr = ptr->data;
|
||||
sendto_one(client_p, form_str(RPL_INVITELIST), me.name,
|
||||
|
@ -988,6 +995,10 @@ chm_invex(struct Client *client_p, struct Client *source_p,
|
|||
else
|
||||
mask = pretty_mask(raw_mask);
|
||||
|
||||
/* We'd have problems parsing this, hyb6 does it too */
|
||||
if (strlen(mask) > (MODEBUFLEN - 2))
|
||||
return;
|
||||
|
||||
if(dir == MODE_ADD)
|
||||
{
|
||||
if((add_id(source_p, chptr, mask, CHFL_INVEX) == 0) && MyClient(source_p))
|
||||
|
@ -1001,10 +1012,10 @@ chm_invex(struct Client *client_p, struct Client *source_p,
|
|||
}
|
||||
else if (dir == MODE_DEL)
|
||||
{
|
||||
if (del_id(chptr, mask, CHFL_INVEX) != 0)
|
||||
if (del_id(chptr, mask, CHFL_INVEX) == 0)
|
||||
{
|
||||
/* mask isn't a valid ban, check raw_mask */
|
||||
if((del_id(chptr, raw_mask, CHFL_INVEX) != 0) && MyClient(source_p))
|
||||
if((del_id(chptr, raw_mask, CHFL_INVEX) == 0) && MyClient(source_p))
|
||||
{
|
||||
/* nope */
|
||||
return;
|
||||
|
@ -1730,14 +1741,9 @@ get_channel_access(struct Client *source_p, struct Channel *chptr)
|
|||
* of the number of servers which each combination as an optimisation, so
|
||||
* the capabs combinations which are not needed are not worked out. -A1kmm
|
||||
*/
|
||||
|
||||
|
||||
/* THIS needs to be re-coded, but tonight I'm to tired to think straigh */
|
||||
|
||||
|
||||
|
||||
static void
|
||||
send_cap_mode_changes(struct Client *client_p, struct Client *source_p, struct Channel *chptr)
|
||||
send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
|
||||
struct Channel *chptr)
|
||||
{
|
||||
int i, mbl, pbl, nc, mc;
|
||||
char *arg;
|
||||
|
@ -1898,9 +1904,9 @@ send_mode_changes(struct Client *client_p, struct Client *source_p,
|
|||
mc = 0;
|
||||
|
||||
if (IsServer(source_p))
|
||||
mbl = ircsprintf(modebuf, ":%s MODE %s -", me.name, chname);
|
||||
mbl = ircsprintf(modebuf, ":%s MODE %s ", me.name, chname);
|
||||
else
|
||||
mbl = ircsprintf(modebuf, ":%s!%s@%s MODE %s -", source_p->name,
|
||||
mbl = ircsprintf(modebuf, ":%s!%s@%s MODE %s ", source_p->name,
|
||||
source_p->username, source_p->vhost, chname);
|
||||
|
||||
pbl = 0;
|
||||
|
@ -2142,7 +2148,7 @@ send_oplist(const char *chname, struct Client *client_p, dlink_list * list,
|
|||
*mcbuf = *opbuf = '\0';
|
||||
t = opbuf;
|
||||
|
||||
for (ptr = list->head; ptr && ptr->data; ptr = ptr->next)
|
||||
DLINK_FOREACH (ptr, list->head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
if (dir == MODE_DEL && *prefix == 'v' && target_p == client_p)
|
||||
|
@ -2241,7 +2247,8 @@ static void mode_get_status(struct Channel *chptr, struct Client *target_p,
|
|||
}
|
||||
}
|
||||
|
||||
static void update_channel_info(struct Channel *chptr)
|
||||
static void
|
||||
update_channel_info(struct Channel *chptr)
|
||||
{
|
||||
int i;
|
||||
int t_voice, t_hop, t_op, t_admin;
|
||||
|
@ -2256,36 +2263,34 @@ static void update_channel_info(struct Channel *chptr)
|
|||
{
|
||||
if(chptr->mode.mode & MODE_HIDEOPS)
|
||||
{
|
||||
for (ptr = chptr->locpeons.head; ptr != NULL && ptr->data != NULL;
|
||||
ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->locpeons.head)
|
||||
{
|
||||
mode_get_status(chptr, ptr->data, &t_op, &t_hop, &t_voice, &t_admin, 0);
|
||||
if (!t_hop && !t_op && !t_admin)
|
||||
sync_oplists(chptr, ptr->data, MODE_DEL, chptr->chname);
|
||||
}
|
||||
|
||||
for (ptr = chptr->locvoiced.head; ptr != NULL && ptr->data != NULL;
|
||||
ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->locvoiced.head)
|
||||
{
|
||||
mode_get_status(chptr, ptr->data, &t_op, &t_hop, &t_voice, &t_admin, 0);
|
||||
if (!t_hop && !t_op && !t_admin)
|
||||
sync_oplists(chptr, ptr->data, MODE_DEL, chptr->chname);
|
||||
}
|
||||
|
||||
for(ptr = chptr->lochalfops.head; ptr != NULL; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->lochalfops.head)
|
||||
{
|
||||
mode_get_status(chptr, ptr->data, &t_op, &t_hop, &t_voice, &t_admin, 1);
|
||||
if(!t_hop && !t_op && !t_admin)
|
||||
sync_oplists(chptr, ptr->data, MODE_DEL, chptr->chname);
|
||||
}
|
||||
|
||||
for(ptr = chptr->locchanops.head; ptr != NULL; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->locchanops.head)
|
||||
{
|
||||
mode_get_status(chptr, ptr->data, &t_op, &t_hop, &t_voice, &t_admin, 1);
|
||||
if(!t_hop && !t_op && !t_admin)
|
||||
sync_oplists(chptr, ptr->data, MODE_DEL, chptr->chname);
|
||||
}
|
||||
for(ptr = chptr->locchanadmins.head; ptr != NULL; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, chptr->locchanadmins.head)
|
||||
{
|
||||
mode_get_status(chptr, ptr->data, &t_op, &t_hop, &t_voice, &t_admin, 1);
|
||||
if(!t_hop && !t_op && !t_admin)
|
||||
|
@ -2346,16 +2351,15 @@ static void update_channel_info(struct Channel *chptr)
|
|||
}
|
||||
|
||||
/* ..and send a resync to them */
|
||||
for (ptr=deopped.head; ptr != NULL && ptr->data != NULL; ptr=ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, deopped.head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
sync_oplists(chptr, ptr->data, MODE_DEL, chptr->chname);
|
||||
free_dlink_node(ptr);
|
||||
}
|
||||
|
||||
for(ptr = opped.head; ptr != NULL; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, opped.head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
sync_oplists(chptr, ptr->data, MODE_ADD, chptr->chname);
|
||||
free_dlink_node(ptr);
|
||||
}
|
||||
|
@ -2441,7 +2445,7 @@ do_channel_integrity_check(void)
|
|||
{
|
||||
if (!IsRegisteredUser(cl) || IsDead(cl))
|
||||
continue;
|
||||
for (ptr=cl->user->channel.head; ptr; ptr=ptr->next)
|
||||
DLINK_FOREACH(ptr, cl->user->channel.head)
|
||||
{
|
||||
dlink_node *ptr2;
|
||||
int matched = 0, matched_local;
|
||||
|
@ -2452,7 +2456,7 @@ do_channel_integrity_check(void)
|
|||
matched_local = 0;
|
||||
/* Make sure that they match once, and only once... */
|
||||
#define SEARCH_LIST(listname) \
|
||||
for (ptr2=ch->listname.head; ptr2; ptr2=ptr2->next) \
|
||||
DLINK_FOREACH(ptr2, ch->listname.head) \
|
||||
if (ptr2->data == cl) \
|
||||
{ \
|
||||
assert(matched == 0); \
|
||||
|
@ -2461,7 +2465,8 @@ do_channel_integrity_check(void)
|
|||
for (ptr2=ch->loc ## listname.head; ptr2; ptr2=ptr2->next) \
|
||||
if (ptr2->data == cl) \
|
||||
{ \
|
||||
assert(matched_local == 0); \ matched_local = -1; \
|
||||
assert(matched_local == 0); \
|
||||
matched_local = -1; \
|
||||
}
|
||||
SEARCH_LIST(chanops)
|
||||
SEARCH_LIST(halfops)
|
||||
|
|
143
src/class.c
143
src/class.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: class.c,v 1.4 2002/09/17 06:09:35 fishwaldo Exp $
|
||||
* $Id: class.c,v 1.5 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -45,17 +45,19 @@
|
|||
|
||||
struct Class* ClassList;
|
||||
|
||||
static struct Class *make_class()
|
||||
static struct Class *
|
||||
make_class()
|
||||
{
|
||||
struct Class *tmp;
|
||||
struct Class *tmp;
|
||||
|
||||
tmp = (struct Class *)MyMalloc(sizeof(struct Class));
|
||||
tmp->className = NULL;
|
||||
tmp->servname = NULL;
|
||||
return tmp;
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
void free_class(struct Class *tmp)
|
||||
void
|
||||
free_class(struct Class *tmp)
|
||||
{
|
||||
MyFree(tmp->className);
|
||||
MyFree((char *)tmp);
|
||||
|
@ -68,7 +70,8 @@ void free_class(struct Class *tmp)
|
|||
* output - ping frequency
|
||||
* side effects - NONE
|
||||
*/
|
||||
static int get_conf_ping(struct ConfItem *aconf)
|
||||
static int
|
||||
get_conf_ping(struct ConfItem *aconf)
|
||||
{
|
||||
if ((aconf) && ClassPtr(aconf))
|
||||
return (ConfPingFreq(aconf));
|
||||
|
@ -86,14 +89,16 @@ static int get_conf_ping(struct ConfItem *aconf)
|
|||
* output - pointer to name of class
|
||||
* side effects - NONE
|
||||
*/
|
||||
const char* get_client_class(struct Client *target_p)
|
||||
const char*
|
||||
get_client_class(struct Client *target_p)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
struct ConfItem *aconf;
|
||||
const char* retc = "unknown";
|
||||
|
||||
if (target_p && !IsMe(target_p) && (target_p->localClient->confs.head))
|
||||
for (ptr = target_p->localClient->confs.head; ptr; ptr = ptr->next)
|
||||
{
|
||||
DLINK_FOREACH(ptr, target_p->localClient->confs.head)
|
||||
{
|
||||
aconf = ptr->data;
|
||||
if(aconf->className == NULL)
|
||||
|
@ -101,7 +106,7 @@ const char* get_client_class(struct Client *target_p)
|
|||
else
|
||||
retc= aconf->className;
|
||||
}
|
||||
|
||||
}
|
||||
Debug((DEBUG_DEBUG,"Returning Class %s For %s",retc,target_p->name));
|
||||
|
||||
return (retc);
|
||||
|
@ -114,32 +119,32 @@ const char* get_client_class(struct Client *target_p)
|
|||
* output - ping frequency
|
||||
* side effects - NONE
|
||||
*/
|
||||
int get_client_ping(struct Client *target_p)
|
||||
int
|
||||
get_client_ping(struct Client *target_p)
|
||||
{
|
||||
int ping = 0;
|
||||
int ping2;
|
||||
struct ConfItem *aconf;
|
||||
dlink_node *nlink;
|
||||
|
||||
|
||||
if(target_p->localClient->confs.head != NULL)
|
||||
{
|
||||
DLINK_FOREACH(nlink, target_p->localClient->confs.head)
|
||||
{
|
||||
for(nlink = target_p->localClient->confs.head; nlink; nlink = nlink->next)
|
||||
{
|
||||
aconf = nlink->data;
|
||||
if (aconf->status & (CONF_CLIENT|CONF_SERVER))
|
||||
{
|
||||
ping2 = get_conf_ping(aconf);
|
||||
if ((ping2 != BAD_PING) && ((ping > ping2) || !ping))
|
||||
ping = ping2;
|
||||
}
|
||||
}
|
||||
aconf = nlink->data;
|
||||
if (aconf->status & (CONF_CLIENT|CONF_SERVER))
|
||||
{
|
||||
ping2 = get_conf_ping(aconf);
|
||||
if ((ping2 != BAD_PING) && ((ping > ping2) || !ping))
|
||||
ping = ping2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ping = DEFAULT_PINGFREQUENCY;
|
||||
Debug((DEBUG_DEBUG,"No Attached Confs"));
|
||||
}
|
||||
{
|
||||
ping = DEFAULT_PINGFREQUENCY;
|
||||
Debug((DEBUG_DEBUG,"No Attached Confs"));
|
||||
}
|
||||
|
||||
if (ping <= 0)
|
||||
ping = DEFAULT_PINGFREQUENCY;
|
||||
|
@ -154,9 +159,10 @@ int get_client_ping(struct Client *target_p)
|
|||
* output - connection frequency
|
||||
* side effects - NONE
|
||||
*/
|
||||
int get_con_freq(struct Class *clptr)
|
||||
int
|
||||
get_con_freq(struct Class *clptr)
|
||||
{
|
||||
if (clptr)
|
||||
if (clptr != NULL)
|
||||
return (ConFreq(clptr));
|
||||
return (DEFAULT_CONNECTFREQUENCY);
|
||||
}
|
||||
|
@ -169,7 +175,6 @@ int get_con_freq(struct Class *clptr)
|
|||
* - connection frequency
|
||||
* - maximum links
|
||||
* - max sendq
|
||||
- autojoin channel
|
||||
* output - NONE
|
||||
* side effects -
|
||||
* When adding a class, check to see if it is already present first.
|
||||
|
@ -178,15 +183,12 @@ int get_con_freq(struct Class *clptr)
|
|||
* if no present entry is found, then create a new one and add it in
|
||||
* immediately after the first one (class 0).
|
||||
*/
|
||||
void add_class(char *classname,
|
||||
int ping,
|
||||
int confreq,
|
||||
int maxli,
|
||||
long sendq)
|
||||
void
|
||||
add_class(char *classname, int ping, int confreq, int maxli, long sendq)
|
||||
{
|
||||
struct Class *t, *p;
|
||||
|
||||
if(!classname)
|
||||
if(classname == NULL)
|
||||
return;
|
||||
|
||||
t = find_class(classname);
|
||||
|
@ -220,19 +222,20 @@ void add_class(char *classname,
|
|||
* output - corresponding class pointer
|
||||
* side effects - NONE
|
||||
*/
|
||||
struct Class *find_class(char* classname)
|
||||
struct Class *
|
||||
find_class(char* classname)
|
||||
{
|
||||
struct Class *cltmp;
|
||||
|
||||
if(classname == NULL)
|
||||
{
|
||||
return(ClassList); /* return class 0 */
|
||||
}
|
||||
{
|
||||
return(ClassList); /* return class 0 */
|
||||
}
|
||||
|
||||
for (cltmp = ClassList; cltmp; cltmp = cltmp->next)
|
||||
if (!strcmp(ClassName(cltmp),classname))
|
||||
return cltmp;
|
||||
return ClassList;
|
||||
return (cltmp);
|
||||
return (ClassList);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -242,27 +245,28 @@ struct Class *find_class(char* classname)
|
|||
* output - NONE
|
||||
* side effects -
|
||||
*/
|
||||
void check_class()
|
||||
void
|
||||
check_class()
|
||||
{
|
||||
struct Class *cltmp, *cltmp2;
|
||||
|
||||
Debug((DEBUG_DEBUG, "Class check:"));
|
||||
|
||||
for (cltmp2 = cltmp = ClassList; cltmp; cltmp = cltmp2->next)
|
||||
{
|
||||
Debug((DEBUG_DEBUG,
|
||||
"ClassName %s Class %d : CF: %d PF: %d ML: %d LI: %d SQ: %ld",
|
||||
ClassName(cltmp),ClassType(cltmp), ConFreq(cltmp), PingFreq(cltmp),
|
||||
MaxLinks(cltmp), Links(cltmp), MaxSendq(cltmp)));
|
||||
if (MaxLinks(cltmp) < 0)
|
||||
{
|
||||
Debug((DEBUG_DEBUG,
|
||||
"ClassName %s Class %d : CF: %d PF: %d ML: %d LI: %d SQ: %ld",
|
||||
ClassName(cltmp),ClassType(cltmp), ConFreq(cltmp), PingFreq(cltmp),
|
||||
MaxLinks(cltmp), Links(cltmp), MaxSendq(cltmp)));
|
||||
if (MaxLinks(cltmp) < 0)
|
||||
{
|
||||
cltmp2->next = cltmp->next;
|
||||
if (Links(cltmp) <= 0)
|
||||
free_class(cltmp);
|
||||
}
|
||||
else
|
||||
cltmp2 = cltmp;
|
||||
cltmp2->next = cltmp->next;
|
||||
if (Links(cltmp) <= 0)
|
||||
free_class(cltmp);
|
||||
}
|
||||
else
|
||||
cltmp2 = cltmp;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -272,7 +276,8 @@ void check_class()
|
|||
* output - NONE
|
||||
* side effects -
|
||||
*/
|
||||
void initclass()
|
||||
void
|
||||
initclass()
|
||||
{
|
||||
ClassList = make_class();
|
||||
|
||||
|
@ -293,7 +298,8 @@ void initclass()
|
|||
* output - NONE
|
||||
* side effects - class report is done to this client
|
||||
*/
|
||||
void report_classes(struct Client *source_p)
|
||||
void
|
||||
report_classes(struct Client *source_p)
|
||||
{
|
||||
struct Class *cltmp;
|
||||
|
||||
|
@ -310,7 +316,8 @@ void report_classes(struct Client *source_p)
|
|||
* output - sendq for this client as found from its class
|
||||
* side effects - NONE
|
||||
*/
|
||||
long get_sendq(struct Client *client_p)
|
||||
long
|
||||
get_sendq(struct Client *client_p)
|
||||
{
|
||||
int sendq = DEFAULT_SENDQ, retc = BAD_CLIENT_CLASS;
|
||||
dlink_node *ptr;
|
||||
|
@ -318,19 +325,21 @@ long get_sendq(struct Client *client_p)
|
|||
struct ConfItem *aconf;
|
||||
|
||||
if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
|
||||
for (ptr = client_p->localClient->confs.head; ptr; ptr = ptr->next)
|
||||
{
|
||||
aconf = ptr->data;
|
||||
if(aconf == NULL)
|
||||
continue;
|
||||
{
|
||||
DLINK_FOREACH(ptr, client_p->localClient->confs.head)
|
||||
{
|
||||
aconf = ptr->data;
|
||||
if(aconf == NULL)
|
||||
continue;
|
||||
|
||||
if ( !(cl = aconf->c_class))
|
||||
continue;
|
||||
if ((cl = aconf->c_class) == NULL)
|
||||
continue;
|
||||
|
||||
if (ClassType(cl) > retc)
|
||||
sendq = MaxSendq(cl);
|
||||
}
|
||||
return sendq;
|
||||
if (ClassType(cl) > retc)
|
||||
sendq = MaxSendq(cl);
|
||||
}
|
||||
}
|
||||
return (sendq);
|
||||
}
|
||||
|
||||
|
||||
|
|
610
src/client.c
610
src/client.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: client.c,v 1.8 2002/09/13 16:30:04 fishwaldo Exp $
|
||||
* $Id: client.c,v 1.9 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
#include "stdinc.h"
|
||||
#include "config.h"
|
||||
|
@ -264,53 +264,52 @@ check_pings_list(dlink_list *list)
|
|||
int ping = 0; /* ping time value from client */
|
||||
dlink_node *ptr, *next_ptr;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
|
||||
{
|
||||
client_p = ptr->data;
|
||||
|
||||
/*
|
||||
** Note: No need to notify opers here. It's
|
||||
** already done when "FLAGS_DEADSOCKET" is set.
|
||||
*/
|
||||
if (client_p->flags & FLAGS_DEADSOCKET)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
client_p = ptr->data;
|
||||
/* Ignore it, its been exited already */
|
||||
continue;
|
||||
}
|
||||
if (IsPerson(client_p))
|
||||
{
|
||||
if(!IsExemptKline(client_p) &&
|
||||
GlobalSetOptions.idletime &&
|
||||
!IsOper(client_p) &&
|
||||
!IsIdlelined(client_p) &&
|
||||
((CurrentTime - client_p->user->last) > GlobalSetOptions.idletime))
|
||||
{
|
||||
struct ConfItem *aconf;
|
||||
|
||||
/*
|
||||
** Note: No need to notify opers here. It's
|
||||
** already done when "FLAGS_DEADSOCKET" is set.
|
||||
*/
|
||||
if (client_p->flags & FLAGS_DEADSOCKET)
|
||||
{
|
||||
/* Ignore it, its been exited already */
|
||||
continue;
|
||||
}
|
||||
if (IsPerson(client_p))
|
||||
{
|
||||
if(!IsExemptKline(client_p) &&
|
||||
GlobalSetOptions.idletime &&
|
||||
!IsOper(client_p) &&
|
||||
!IsIdlelined(client_p) &&
|
||||
((CurrentTime - client_p->user->last) > GlobalSetOptions.idletime))
|
||||
{
|
||||
struct ConfItem *aconf;
|
||||
aconf = make_conf();
|
||||
aconf->status = CONF_KILL;
|
||||
|
||||
aconf = make_conf();
|
||||
aconf->status = CONF_KILL;
|
||||
|
||||
DupString(aconf->host, client_p->host);
|
||||
DupString(aconf->passwd, "idle exceeder");
|
||||
DupString(aconf->user, client_p->username);
|
||||
aconf->port = 0;
|
||||
aconf->hold = CurrentTime + 60;
|
||||
add_temp_kline(aconf);
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
"Idle time limit exceeded for %s - temp k-lining",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
DupString(aconf->host, client_p->host);
|
||||
DupString(aconf->passwd, "idle exceeder");
|
||||
DupString(aconf->user, client_p->username);
|
||||
aconf->port = 0;
|
||||
aconf->hold = CurrentTime + 60;
|
||||
add_temp_kline(aconf);
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"Idle time limit exceeded for %s - temp k-lining",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, aconf->passwd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
(void)exit_client(client_p, client_p, &me, aconf->passwd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsRegistered(client_p))
|
||||
ping = CONNECTTIMEOUT;
|
||||
else
|
||||
ping = get_client_ping(client_p);
|
||||
if (!IsRegistered(client_p))
|
||||
ping = CONNECTTIMEOUT;
|
||||
else
|
||||
ping = get_client_ping(client_p);
|
||||
|
||||
if (ping < (CurrentTime - client_p->lasttime))
|
||||
{
|
||||
|
@ -337,25 +336,25 @@ check_pings_list(dlink_list *list)
|
|||
"Ping timeout: %d seconds",
|
||||
(int)(CurrentTime - client_p->lasttime));
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, scratch);
|
||||
continue;
|
||||
}
|
||||
else if ((client_p->flags & FLAGS_PINGSENT) == 0)
|
||||
{
|
||||
/*
|
||||
* if we havent PINGed the connection and we havent
|
||||
* heard from it in a while, PING it to make sure
|
||||
* it is still alive.
|
||||
*/
|
||||
client_p->flags |= FLAGS_PINGSENT;
|
||||
/* not nice but does the job */
|
||||
client_p->lasttime = CurrentTime - ping;
|
||||
sendto_one(client_p, "PING :%s", me.name);
|
||||
}
|
||||
}
|
||||
/* ping_timeout: */
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, scratch);
|
||||
continue;
|
||||
}
|
||||
else if ((client_p->flags & FLAGS_PINGSENT) == 0)
|
||||
{
|
||||
/*
|
||||
* if we havent PINGed the connection and we havent
|
||||
* heard from it in a while, PING it to make sure
|
||||
* it is still alive.
|
||||
*/
|
||||
client_p->flags |= FLAGS_PINGSENT;
|
||||
/* not nice but does the job */
|
||||
client_p->lasttime = CurrentTime - ping;
|
||||
sendto_one(client_p, "PING :%s", me.name);
|
||||
}
|
||||
}
|
||||
/* ping_timeout: */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -371,21 +370,20 @@ check_unknowns_list(dlink_list *list)
|
|||
dlink_node *ptr, *next_ptr;
|
||||
struct Client *client_p;
|
||||
|
||||
for(ptr = list->head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
|
||||
{
|
||||
client_p = ptr->data;
|
||||
|
||||
/*
|
||||
* Check UNKNOWN connections - if they have been in this state
|
||||
* for > 30s, close them.
|
||||
*/
|
||||
|
||||
if (client_p->firsttime ? ((CurrentTime - client_p->firsttime) > 30) : 0)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
client_p = ptr->data;
|
||||
|
||||
/*
|
||||
* Check UNKNOWN connections - if they have been in this state
|
||||
* for > 30s, close them.
|
||||
*/
|
||||
|
||||
if (client_p->firsttime ? ((CurrentTime - client_p->firsttime) > 30) : 0)
|
||||
{
|
||||
(void)exit_client(client_p, client_p, &me, "Connection timed out");
|
||||
}
|
||||
(void)exit_client(client_p, client_p, &me, "Connection timed out");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -399,160 +397,158 @@ void
|
|||
check_klines(void)
|
||||
{
|
||||
struct Client *client_p; /* current local client_p being examined */
|
||||
struct ConfItem *aconf = (struct ConfItem *)NULL;
|
||||
char *reason; /* pointer to reason string */
|
||||
dlink_node *ptr, *next_ptr;
|
||||
struct ConfItem *aconf = NULL;
|
||||
char *reason; /* pointer to reason string */
|
||||
dlink_node *ptr, *next_ptr;
|
||||
|
||||
for (ptr = lclient_list.head; ptr; ptr = next_ptr)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
client_p = ptr->data;
|
||||
|
||||
if (IsMe(client_p))
|
||||
continue;
|
||||
|
||||
/* if there is a returned struct ConfItem then kill it */
|
||||
if ((aconf = find_dline(&client_p->localClient->ip,
|
||||
client_p->localClient->aftype)))
|
||||
{
|
||||
if (aconf->status & CONF_EXEMPTDLINE)
|
||||
continue;
|
||||
|
||||
sendto_realops_flags(FLAGS_ALL||FLAGS_REMOTE, L_ALL,"DLINE active for %s",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
|
||||
if (ConfigFileEntry.kline_with_connection_closed &&
|
||||
ConfigFileEntry.kline_with_reason)
|
||||
{
|
||||
reason = "Connection closed";
|
||||
|
||||
if(IsPerson(client_p))
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name,
|
||||
aconf->passwd ? aconf->passwd : "D-lined");
|
||||
else
|
||||
sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ConfigFileEntry.kline_with_connection_closed)
|
||||
reason = "Connection closed";
|
||||
else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
|
||||
reason = aconf->passwd;
|
||||
else
|
||||
reason = "D-lined";
|
||||
|
||||
if(IsPerson(client_p))
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name, reason);
|
||||
else
|
||||
sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
|
||||
}
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, reason);
|
||||
continue; /* and go examine next fd/client_p */
|
||||
}
|
||||
|
||||
if (IsPerson(client_p))
|
||||
{
|
||||
if (ConfigFileEntry.glines &&
|
||||
(aconf = find_gkill(client_p, client_p->username)))
|
||||
{
|
||||
if (IsExemptKline(client_p))
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"GLINE over-ruled for %s, client is kline_exempt",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsExemptGline(client_p))
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"GLINE over-ruled for %s, client is gline_exempt",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
continue;
|
||||
}
|
||||
|
||||
sendto_realops_flags(FLAGS_ALL||FLAGS_REMOTE, L_ALL, "GLINE active for %s",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
|
||||
if(ConfigFileEntry.kline_with_connection_closed &&
|
||||
ConfigFileEntry.kline_with_reason)
|
||||
{
|
||||
reason = "Connection closed";
|
||||
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name,
|
||||
aconf->passwd ? aconf->passwd : "G-lined");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ConfigFileEntry.kline_with_connection_closed)
|
||||
reason = "Connection closed";
|
||||
else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
|
||||
reason = aconf->passwd;
|
||||
else
|
||||
reason = "G-lined";
|
||||
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name, reason);
|
||||
}
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, reason);
|
||||
/* and go examine next fd/client_p */
|
||||
continue;
|
||||
}
|
||||
else if((aconf = find_kill(client_p)))
|
||||
{
|
||||
/* if there is a returned struct ConfItem.. then kill it */
|
||||
if (IsExemptKline(client_p))
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"KLINE over-ruled for %s, client is kline_exempt",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
continue;
|
||||
}
|
||||
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL, "KLINE active for %s",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
|
||||
if(ConfigFileEntry.kline_with_connection_closed &&
|
||||
ConfigFileEntry.kline_with_reason)
|
||||
{
|
||||
reason = "Connection closed";
|
||||
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name,
|
||||
aconf->passwd ? aconf->passwd : "K-lined");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ConfigFileEntry.kline_with_connection_closed)
|
||||
reason = "Connection closed";
|
||||
else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
|
||||
reason = aconf->passwd;
|
||||
else
|
||||
reason = "K-lined";
|
||||
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name, reason);
|
||||
}
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, reason);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* also check the unknowns list for new dlines */
|
||||
for (ptr = unknown_list.head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
client_p = ptr->data;
|
||||
|
||||
if((aconf = find_dline(&client_p->localClient->ip,
|
||||
client_p->localClient->aftype)))
|
||||
if (IsMe(client_p))
|
||||
continue;
|
||||
|
||||
/* if there is a returned struct ConfItem then kill it */
|
||||
if ((aconf = find_dline_conf(&client_p->localClient->ip,
|
||||
client_p->localClient->aftype)) != NULL)
|
||||
{
|
||||
if (aconf->status & CONF_EXEMPTDLINE)
|
||||
continue;
|
||||
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,"DLINE active for %s",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
|
||||
if (ConfigFileEntry.kline_with_connection_closed &&
|
||||
ConfigFileEntry.kline_with_reason)
|
||||
{
|
||||
reason = "Connection closed";
|
||||
|
||||
if(IsPerson(client_p))
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name,
|
||||
aconf->passwd ? aconf->passwd : "D-lined");
|
||||
else
|
||||
sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ConfigFileEntry.kline_with_connection_closed)
|
||||
reason = "Connection closed";
|
||||
else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
|
||||
reason = aconf->passwd;
|
||||
else
|
||||
reason = "D-lined";
|
||||
|
||||
if(IsPerson(client_p))
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name, reason);
|
||||
else
|
||||
sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
|
||||
}
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, reason);
|
||||
continue; /* and go examine next fd/client_p */
|
||||
}
|
||||
|
||||
if (IsPerson(client_p))
|
||||
{
|
||||
if (ConfigFileEntry.glines &&
|
||||
(aconf = find_gkill(client_p, client_p->username)))
|
||||
{
|
||||
if (IsExemptKline(client_p))
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"GLINE over-ruled for %s, client is kline_exempt",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsExemptGline(client_p))
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"GLINE over-ruled for %s, client is gline_exempt",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
continue;
|
||||
}
|
||||
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL, "GLINE active for %s",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
|
||||
if(ConfigFileEntry.kline_with_connection_closed &&
|
||||
ConfigFileEntry.kline_with_reason)
|
||||
{
|
||||
reason = "Connection closed";
|
||||
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name,
|
||||
aconf->passwd ? aconf->passwd : "G-lined");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ConfigFileEntry.kline_with_connection_closed)
|
||||
reason = "Connection closed";
|
||||
else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
|
||||
reason = aconf->passwd;
|
||||
else
|
||||
reason = "G-lined";
|
||||
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name, reason);
|
||||
}
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, reason);
|
||||
/* and go examine next fd/client_p */
|
||||
continue;
|
||||
}
|
||||
else if((aconf = find_kill(client_p)) != NULL)
|
||||
{
|
||||
/* if there is a returned struct ConfItem.. then kill it */
|
||||
if (IsExemptKline(client_p))
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL,
|
||||
"KLINE over-ruled for %s, client is kline_exempt",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
continue;
|
||||
}
|
||||
|
||||
sendto_realops_flags(FLAGS_ALL, L_ALL, "KLINE active for %s",
|
||||
get_client_name(client_p, HIDE_IP));
|
||||
|
||||
if(ConfigFileEntry.kline_with_connection_closed &&
|
||||
ConfigFileEntry.kline_with_reason)
|
||||
{
|
||||
reason = "Connection closed";
|
||||
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name,
|
||||
aconf->passwd ? aconf->passwd : "K-lined");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ConfigFileEntry.kline_with_connection_closed)
|
||||
reason = "Connection closed";
|
||||
else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
|
||||
reason = aconf->passwd;
|
||||
else
|
||||
reason = "K-lined";
|
||||
|
||||
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, client_p->name, reason);
|
||||
}
|
||||
|
||||
(void)exit_client(client_p, client_p, &me, reason);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* also check the unknowns list for new dlines */
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, unknown_list.head)
|
||||
{
|
||||
client_p = ptr->data;
|
||||
|
||||
if((aconf = find_dline_conf(&client_p->localClient->ip,
|
||||
client_p->localClient->aftype)))
|
||||
{
|
||||
if(aconf->status & CONF_EXEMPTDLINE)
|
||||
continue;
|
||||
|
@ -574,20 +570,20 @@ check_klines(void)
|
|||
static void update_client_exit_stats(struct Client* client_p)
|
||||
{
|
||||
if (IsServer(client_p))
|
||||
{
|
||||
--Count.server;
|
||||
sendto_realops_flags(FLAGS_EXTERNAL|FLAGS_REMOTE, L_ALL,
|
||||
"Server %s split from %s",
|
||||
client_p->name, client_p->servptr->name);
|
||||
}
|
||||
{
|
||||
--Count.server;
|
||||
sendto_realops_flags(FLAGS_EXTERNAL, L_ALL,
|
||||
"Server %s split from %s",
|
||||
client_p->name, client_p->servptr->name);
|
||||
}
|
||||
else if (IsClient(client_p))
|
||||
{
|
||||
--Count.total;
|
||||
if (IsOper(client_p))
|
||||
--Count.oper;
|
||||
if (IsInvisible(client_p))
|
||||
--Count.invisi;
|
||||
}
|
||||
{
|
||||
--Count.total;
|
||||
if (IsOper(client_p))
|
||||
--Count.oper;
|
||||
if (IsInvisible(client_p))
|
||||
--Count.invisi;
|
||||
}
|
||||
|
||||
if(splitchecking && !splitmode)
|
||||
check_splitmode(NULL);
|
||||
|
@ -604,15 +600,15 @@ static void
|
|||
release_client_state(struct Client* client_p)
|
||||
{
|
||||
if (client_p->user != NULL)
|
||||
{
|
||||
free_user(client_p->user, client_p); /* try this here */
|
||||
}
|
||||
if (client_p->serv)
|
||||
{
|
||||
if (client_p->serv->user != NULL)
|
||||
free_user(client_p->serv->user, client_p);
|
||||
MyFree((char*) client_p->serv);
|
||||
}
|
||||
{
|
||||
free_user(client_p->user, client_p); /* try this here */
|
||||
}
|
||||
if (client_p->serv != NULL)
|
||||
{
|
||||
if (client_p->serv->user != NULL)
|
||||
free_user(client_p->serv->user, client_p);
|
||||
MyFree((char*) client_p->serv);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -625,7 +621,7 @@ release_client_state(struct Client* client_p)
|
|||
void
|
||||
remove_client_from_list(struct Client* client_p)
|
||||
{
|
||||
assert(NULL != client_p);
|
||||
assert(client_p != NULL);
|
||||
|
||||
if(client_p == NULL)
|
||||
return;
|
||||
|
@ -683,7 +679,8 @@ add_client_to_list(struct Client *client_p)
|
|||
/* Functions taken from +CSr31, paranoified to check that the client
|
||||
** isn't on a llist already when adding, and is there when removing -orabidoo
|
||||
*/
|
||||
void add_client_to_llist(struct Client **bucket, struct Client *client)
|
||||
void
|
||||
add_client_to_llist(struct Client **bucket, struct Client *client)
|
||||
{
|
||||
if (!client->lprev && !client->lnext)
|
||||
{
|
||||
|
@ -857,10 +854,10 @@ free_exited_clients(void *unused)
|
|||
dlink_node *ptr, *next;
|
||||
struct Client *target_p;
|
||||
|
||||
for(ptr = dead_list.head; ptr; ptr = next)
|
||||
DLINK_FOREACH_SAFE(ptr, next, dead_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
next = ptr->next;
|
||||
|
||||
if (ptr->data == NULL)
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
|
@ -972,32 +969,30 @@ static void exit_one_client(struct Client *client_p,
|
|||
source_p->vhost,
|
||||
comment);
|
||||
|
||||
for (lp = source_p->user->channel.head; lp; lp = next_lp)
|
||||
DLINK_FOREACH_SAFE(lp, next_lp, source_p->user->channel.head)
|
||||
{
|
||||
next_lp = lp->next;
|
||||
remove_user_from_channel(lp->data, source_p);
|
||||
remove_user_from_channel(lp->data, source_p);
|
||||
}
|
||||
|
||||
/* Should not be in any channels now */
|
||||
assert(source_p->user->channel.head == NULL);
|
||||
/* Should not be in any channels now */
|
||||
assert(source_p->user->channel.head == NULL);
|
||||
|
||||
/* Clean up invitefield */
|
||||
for (lp = source_p->user->invited.head; lp; lp = next_lp)
|
||||
/* Clean up invitefield */
|
||||
DLINK_FOREACH_SAFE(lp, next_lp, source_p->user->invited.head)
|
||||
{
|
||||
next_lp = lp->next;
|
||||
del_invite(lp->data, source_p);
|
||||
del_invite(lp->data, source_p);
|
||||
}
|
||||
|
||||
/* Clean up allow lists */
|
||||
del_all_accepts(source_p);
|
||||
/* Clean up allow lists */
|
||||
del_all_accepts(source_p);
|
||||
|
||||
add_history(source_p, 0);
|
||||
off_history(source_p);
|
||||
add_history(source_p, 0);
|
||||
off_history(source_p);
|
||||
|
||||
if (HasID(source_p))
|
||||
del_from_id_hash_table(source_p->user->id, source_p);
|
||||
if (HasID(source_p))
|
||||
del_from_id_hash_table(source_p->user->id, source_p);
|
||||
|
||||
/* again, this is all that is needed */
|
||||
/* again, this is all that is needed */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1099,18 +1094,19 @@ static void recurse_remove_clients(struct Client* source_p, const char* comment)
|
|||
** all necessary QUITs and SQUITs. source_p itself is still on the lists,
|
||||
** and its SQUITs have been sent except for the upstream one -orabidoo
|
||||
*/
|
||||
static void remove_dependents(struct Client* client_p,
|
||||
struct Client* source_p,
|
||||
struct Client* from,
|
||||
const char* comment,
|
||||
const char* comment1)
|
||||
static void
|
||||
remove_dependents(struct Client* client_p,
|
||||
struct Client* source_p,
|
||||
struct Client* from,
|
||||
const char* comment,
|
||||
const char* comment1)
|
||||
{
|
||||
struct Client *to;
|
||||
struct ConfItem *aconf;
|
||||
static char myname[HOSTLEN+1];
|
||||
dlink_node *ptr;
|
||||
|
||||
for(ptr = serv_list.head; ptr; ptr=ptr->next)
|
||||
DLINK_FOREACH(ptr, serv_list.head)
|
||||
{
|
||||
to = ptr->data;
|
||||
|
||||
|
@ -1172,15 +1168,16 @@ void dead_link(struct Client *client_p)
|
|||
SetDead(client_p); /* You are dead my friend */
|
||||
}
|
||||
|
||||
void exit_aborted_clients(void)
|
||||
void
|
||||
exit_aborted_clients(void)
|
||||
{
|
||||
dlink_node *ptr, *next;
|
||||
struct Client *target_p;
|
||||
char *notice;
|
||||
for(ptr = abort_list.head; ptr; ptr = next)
|
||||
|
||||
DLINK_FOREACH_SAFE(ptr, next, abort_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
next = ptr->next;
|
||||
if (ptr->data == NULL)
|
||||
{
|
||||
sendto_realops_flags(FLAGS_ALL|FLAGS_REMOTE, L_ALL,
|
||||
|
@ -1221,18 +1218,19 @@ void exit_aborted_clients(void)
|
|||
** CLIENT_EXITED if (client_p == source_p)
|
||||
** 0 if (client_p != source_p)
|
||||
*/
|
||||
int exit_client(
|
||||
struct Client* client_p, /* The local client originating the
|
||||
* exit or NULL, if this exit is
|
||||
* generated by this server for
|
||||
* internal reasons.
|
||||
* This will not get any of the
|
||||
* generated messages. */
|
||||
struct Client* source_p, /* Client exiting */
|
||||
struct Client* from, /* Client firing off this Exit,
|
||||
* never NULL! */
|
||||
const char* comment /* Reason for the exit */
|
||||
)
|
||||
int
|
||||
exit_client(
|
||||
struct Client* client_p, /* The local client originating the
|
||||
* exit or NULL, if this exit is
|
||||
* generated by this server for
|
||||
* internal reasons.
|
||||
* This will not get any of the
|
||||
* generated messages. */
|
||||
struct Client* source_p, /* Client exiting */
|
||||
struct Client* from, /* Client firing off this Exit,
|
||||
* never NULL! */
|
||||
const char* comment /* Reason for the exit */
|
||||
)
|
||||
{
|
||||
char comment1[HOSTLEN + HOSTLEN + 2];
|
||||
dlink_node *m;
|
||||
|
@ -1399,8 +1397,8 @@ int exit_client(
|
|||
*/
|
||||
|
||||
/* XXX one common Client list now */
|
||||
void count_local_client_memory(int *count,
|
||||
int *local_client_memory_used)
|
||||
void
|
||||
count_local_client_memory(int *count, int *local_client_memory_used)
|
||||
{
|
||||
*count = local_client_count;
|
||||
*local_client_memory_used = local_client_count *
|
||||
|
@ -1410,8 +1408,8 @@ void count_local_client_memory(int *count,
|
|||
/*
|
||||
* Count up remote client memory
|
||||
*/
|
||||
void count_remote_client_memory(int *count,
|
||||
int *remote_client_memory_used)
|
||||
void
|
||||
count_remote_client_memory(int *count, int *remote_client_memory_used)
|
||||
{
|
||||
*count = remote_client_count;
|
||||
*remote_client_memory_used = remote_client_count * sizeof(struct Client);
|
||||
|
@ -1444,12 +1442,13 @@ void count_remote_client_memory(int *count,
|
|||
* output - 1 if accept this message 0 if not
|
||||
* side effects - See if source is on target's allow list
|
||||
*/
|
||||
int accept_message(struct Client *source, struct Client *target)
|
||||
int
|
||||
accept_message(struct Client *source, struct Client *target)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
struct Client *target_p;
|
||||
|
||||
for(ptr = target->allow_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, target->allow_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
if(source == target_p)
|
||||
|
@ -1470,7 +1469,8 @@ int accept_message(struct Client *source, struct Client *target)
|
|||
* Walk through the target's accept list, remove if source is found,
|
||||
* Then walk through the source's on_accept_list remove target if found.
|
||||
*/
|
||||
void del_from_accept(struct Client *source, struct Client *target)
|
||||
void
|
||||
del_from_accept(struct Client *source, struct Client *target)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
dlink_node *ptr2;
|
||||
|
@ -1478,21 +1478,16 @@ void del_from_accept(struct Client *source, struct Client *target)
|
|||
dlink_node *next_ptr2;
|
||||
struct Client *target_p;
|
||||
|
||||
for (ptr = target->allow_list.head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, target->allow_list.head)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
|
||||
target_p = ptr->data;
|
||||
if(source == target_p)
|
||||
{
|
||||
dlinkDelete(ptr, &target->allow_list);
|
||||
free_dlink_node(ptr);
|
||||
|
||||
for (ptr2 = source->on_allow_list.head; ptr2;
|
||||
ptr2 = next_ptr2)
|
||||
DLINK_FOREACH_SAFE(ptr2, next_ptr2, source->on_allow_list.head)
|
||||
{
|
||||
next_ptr2 = ptr2->next;
|
||||
|
||||
target_p = ptr2->data;
|
||||
if (target == target_p)
|
||||
{
|
||||
|
@ -1512,23 +1507,22 @@ void del_from_accept(struct Client *source, struct Client *target)
|
|||
* side effects - Walk through given clients allow_list and on_allow_list
|
||||
* remove all references to this client
|
||||
*/
|
||||
void del_all_accepts(struct Client *client_p)
|
||||
void
|
||||
del_all_accepts(struct Client *client_p)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
dlink_node *next_ptr;
|
||||
struct Client *target_p;
|
||||
|
||||
for (ptr = client_p->allow_list.head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->allow_list.head)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
target_p = ptr->data;
|
||||
if(target_p != NULL)
|
||||
del_from_accept(target_p,client_p);
|
||||
}
|
||||
|
||||
for (ptr = client_p->on_allow_list.head; ptr; ptr = next_ptr)
|
||||
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head)
|
||||
{
|
||||
next_ptr = ptr->next;
|
||||
target_p = ptr->data;
|
||||
if(target_p != NULL)
|
||||
del_from_accept(client_p, target_p);
|
||||
|
@ -1564,7 +1558,7 @@ set_initial_nick(struct Client *client_p, struct Client *source_p,
|
|||
/* They have the nick they want now.. */
|
||||
*client_p->llname = '\0';
|
||||
|
||||
if (source_p->user)
|
||||
if (source_p->user != NULL)
|
||||
{
|
||||
strlcpy(buf, source_p->username, USERLEN);
|
||||
/*
|
||||
|
@ -1596,8 +1590,8 @@ set_initial_nick(struct Client *client_p, struct Client *source_p,
|
|||
* side effects - changes nick of a LOCAL user
|
||||
*
|
||||
*/
|
||||
int change_local_nick(struct Client *client_p, struct Client *source_p,
|
||||
char *nick)
|
||||
int
|
||||
change_local_nick(struct Client *client_p, struct Client *source_p, char *nick)
|
||||
{
|
||||
/*
|
||||
** Client just changing his/her nick. If he/she is
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: hostmask.c,v 1.4 2002/09/13 06:50:08 fishwaldo Exp $
|
||||
* $Id: hostmask.c,v 1.5 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -66,8 +66,12 @@ try_parse_v6_netmask(const char *text, struct irc_inaddr *addr, int *b)
|
|||
{
|
||||
const char *p;
|
||||
char c;
|
||||
int d[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }, dp = 0, nyble = 4, finsert =
|
||||
-1, bits = 0, deficit = 0;
|
||||
int d[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
int dp = 0;
|
||||
int nyble = 4;
|
||||
int finsert = -1;
|
||||
int bits = 128;
|
||||
int deficit = 0;
|
||||
short dc[8];
|
||||
|
||||
for (p = text; (c = *p); p++)
|
||||
|
@ -495,13 +499,37 @@ find_address_conf(const char *host, const char *user,
|
|||
return iconf;
|
||||
}
|
||||
|
||||
/* struct ConfItem* find_dline(struct irc_inaddr*, int)
|
||||
* Input: An address, an address family.
|
||||
* Output: The best matching D-line or exempt line.
|
||||
/*
|
||||
* find_kline_conf
|
||||
*
|
||||
* inputs - pointer to hostname
|
||||
* - pointer to username
|
||||
* - incoming IP and type (IPv4 vs. IPv6)
|
||||
* outut - pointer to kline conf if found NULL if not
|
||||
* side effects -
|
||||
*/
|
||||
struct ConfItem *
|
||||
find_kline_conf(const char *host, const char *user,
|
||||
struct irc_inaddr *ip, int aftype)
|
||||
{
|
||||
struct ConfItem *kconf;
|
||||
|
||||
/* Find the best K-line... -A1kmm */
|
||||
kconf = find_conf_by_address(host, ip, CONF_KILL, aftype, user);
|
||||
|
||||
/* If they are K-lined, return the K-line. Otherwise, return the
|
||||
* I-line. -A1kmm */
|
||||
return (kconf);
|
||||
}
|
||||
|
||||
/* struct ConfItem* find_dline_conf(struct irc_inaddr*, int)
|
||||
*
|
||||
* Input: An address, an address family.
|
||||
* Output: The best matching D-line or exempt line.
|
||||
* Side effects: None.
|
||||
*/
|
||||
struct ConfItem *
|
||||
find_dline(struct irc_inaddr *addr, int aftype)
|
||||
find_dline_conf(struct irc_inaddr *addr, int aftype)
|
||||
{
|
||||
struct ConfItem *eline;
|
||||
eline = find_conf_by_address(NULL, addr, CONF_EXEMPTDLINE | 1, aftype,
|
||||
|
@ -600,8 +628,8 @@ delete_one_address_conf(const char *address, struct ConfItem *aconf)
|
|||
arecl->next = arec->next;
|
||||
else
|
||||
atable[hv] = arec->next;
|
||||
aconf->flags |= CONF_ILLEGAL;
|
||||
if (!aconf->clients)
|
||||
aconf->status |= CONF_ILLEGAL;
|
||||
if (aconf->clients == 0)
|
||||
free_conf(aconf);
|
||||
MyFree(arec);
|
||||
return;
|
||||
|
@ -639,8 +667,8 @@ clear_out_address_conf(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
arec->aconf->flags |= CONF_ILLEGAL;
|
||||
if (!arec->aconf->clients)
|
||||
arec->aconf->status |= CONF_ILLEGAL;
|
||||
if (arec->aconf->clients == 0)
|
||||
free_conf(arec->aconf);
|
||||
MyFree(arec);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: ircd_parser.y,v 1.8 2002/09/17 07:42:16 fishwaldo Exp $
|
||||
* $Id: ircd_parser.y,v 1.9 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
%{
|
||||
|
@ -890,7 +890,7 @@ class_entry: CLASS
|
|||
|
||||
add_class(class_name_var,class_ping_time_var,
|
||||
class_number_per_ip_var, class_max_number_var,
|
||||
class_sendq_var);
|
||||
class_sendq_var );
|
||||
|
||||
MyFree(class_name_var);
|
||||
class_name_var = NULL;
|
||||
|
@ -1789,10 +1789,10 @@ exempt_ip: IP '=' QSTRING ';'
|
|||
|
||||
gecos_entry: GECOS
|
||||
{
|
||||
if(yy_aconf)
|
||||
if(yy_aconf != NULL)
|
||||
{
|
||||
free_conf(yy_aconf);
|
||||
yy_aconf = (struct ConfItem *)NULL;
|
||||
yy_aconf = NULL;
|
||||
}
|
||||
yy_aconf=make_conf();
|
||||
yy_aconf->status = CONF_XLINE;
|
||||
|
@ -1801,11 +1801,11 @@ gecos_entry: GECOS
|
|||
}
|
||||
'{' gecos_items '}' ';'
|
||||
{
|
||||
if(yy_aconf->host)
|
||||
if(yy_aconf->name != NULL)
|
||||
conf_add_x_conf(yy_aconf);
|
||||
else
|
||||
free_conf(yy_aconf);
|
||||
yy_aconf = (struct ConfItem *)NULL;
|
||||
yy_aconf = NULL;
|
||||
};
|
||||
|
||||
gecos_items: gecos_items gecos_item |
|
||||
|
@ -1816,9 +1816,8 @@ gecos_item: gecos_name | gecos_reason | gecos_action | error;
|
|||
|
||||
gecos_name: NAME '=' QSTRING ';'
|
||||
{
|
||||
MyFree(yy_aconf->host);
|
||||
DupString(yy_aconf->host, yylval.string);
|
||||
(void)collapse(yy_aconf->host);
|
||||
DupString(yy_aconf->name, yylval.string);
|
||||
collapse(yy_aconf->name);
|
||||
};
|
||||
|
||||
gecos_reason: REASON '=' QSTRING ';'
|
||||
|
|
71
src/match.c
71
src/match.c
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: match.c,v 1.3 2002/09/13 06:56:46 fishwaldo Exp $
|
||||
* $Id: match.c,v 1.4 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -208,6 +208,75 @@ int match_esc(const char *mask, const char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
comp_with_mask(void *addr, void *dest, u_int mask)
|
||||
{
|
||||
if (memcmp(addr, dest, mask / 8) == 0)
|
||||
{
|
||||
int n = mask / 8;
|
||||
int m = ((-1) << (8 - (mask % 8)));
|
||||
if (mask % 8 == 0 ||
|
||||
(((u_char *) addr)[n] & m) == (((u_char *) dest)[n] & m))
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* match_cidr()
|
||||
*
|
||||
* Input - mask, address
|
||||
* Ouput - 1 = Matched 0 = Did not match
|
||||
*/
|
||||
|
||||
int
|
||||
match_cidr(const char *s1, const char *s2)
|
||||
{
|
||||
struct irc_inaddr ipaddr, maskaddr;
|
||||
char address[NICKLEN + USERLEN + HOSTLEN + 6], mask[NICKLEN + USERLEN + HOSTLEN + 6], *ipmask, *ip, *len;
|
||||
int cidrlen, aftype;
|
||||
strcpy(mask, s1);
|
||||
strcpy(address, s2);
|
||||
|
||||
ipmask = strrchr(mask, '@');
|
||||
if(ipmask == NULL)
|
||||
return 0;
|
||||
|
||||
*ipmask++ = '\0';
|
||||
|
||||
ip = strrchr(address, '@');
|
||||
if(ip == NULL)
|
||||
return 0;
|
||||
*ip++ = '\0';
|
||||
|
||||
len = strrchr(ipmask, '/');
|
||||
if(len == NULL)
|
||||
return 0;
|
||||
|
||||
*len++ = '\0';
|
||||
|
||||
cidrlen = atoi(len);
|
||||
if(cidrlen == 0)
|
||||
return 0;
|
||||
|
||||
#ifdef IPV6
|
||||
if(strchr(ip, ':') && strchr(ipmask, ':'))
|
||||
aftype = AF_INET6;
|
||||
else
|
||||
#endif
|
||||
if(!strchr(ip, ':') && !strchr(ipmask, ':'))
|
||||
aftype = AF_INET;
|
||||
else
|
||||
return 0;
|
||||
|
||||
inetpton(aftype, ip, &ipaddr);
|
||||
inetpton(aftype, ipmask, &maskaddr);
|
||||
if(comp_with_mask(&IN_ADDR(ipaddr), &IN_ADDR(maskaddr), cidrlen) && match(mask, address))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* collapse()
|
||||
*
|
||||
* collapses a string containing multiple *'s.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: messages.tab,v 1.5 2002/09/13 16:30:04 fishwaldo Exp $
|
||||
* $Id: messages.tab,v 1.6 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
static char * replies[] = {
|
||||
|
@ -362,7 +362,7 @@ static char * replies[] = {
|
|||
/* 335 */ NULL,
|
||||
/* 336 */ NULL,
|
||||
/* 337 */ NULL,
|
||||
/* 338 */ NULL,
|
||||
/* 338 RPL_WHOISACTUALLY */ ":%s 338 %s :%s is actually %s@%s [%s]",
|
||||
/* 339 */ NULL,
|
||||
/* 340 */ NULL,
|
||||
/* 341 RPL_INVITING, */ ":%s 341 %s %s %s",
|
||||
|
@ -729,7 +729,7 @@ static char * replies[] = {
|
|||
/* 699 */ NULL,
|
||||
/* 700 */ NULL,
|
||||
/* 701 */ NULL,
|
||||
/* 702 RPL_MODLIST, */ ":%s 702 %s %s 0x%x %s",
|
||||
/* 702 RPL_MODLIST, */ ":%s 702 %s %s 0x%x %s %s",
|
||||
/* 703 RPL_ENDOFMODLIST, */ ":%s 703 %s :End of /MODLIST.",
|
||||
/* 704 RPL_HELPSTART, */ ":%s 704 %s %s :%s",
|
||||
/* 705 RPL_HELPTXT, */ ":%s 705 %s %s :%s",
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: parse.c,v 1.6 2002/09/13 16:30:04 fishwaldo Exp $
|
||||
* $Id: parse.c,v 1.7 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -240,7 +240,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
|
|||
{
|
||||
int ii = 0;
|
||||
|
||||
if( (s = strchr(ch, ' ')) )
|
||||
if((s = strchr(ch, ' ')) != NULL)
|
||||
*s++ = '\0';
|
||||
|
||||
mptr = hash_parse(ch);
|
||||
|
|
42
src/s_auth.c
42
src/s_auth.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_auth.c,v 1.5 2002/09/13 16:30:05 fishwaldo Exp $
|
||||
* $Id: s_auth.c,v 1.6 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -348,6 +348,21 @@ static int start_auth_query(struct AuthRequest* auth)
|
|||
* Output - NULL if no valid ident found, otherwise pointer to name
|
||||
* Side effects -
|
||||
*/
|
||||
/*
|
||||
* A few questions have been asked about this mess, obviously
|
||||
* it should have been commented better the first time.
|
||||
* The original idea was to remove all references to libc from ircd-hybrid.
|
||||
* Instead of having to write a replacement for sscanf(), I did a
|
||||
* rather gruseome parser here so we could remove this function call.
|
||||
* Note, that I had also removed a few floating point printfs as well (though
|
||||
* now we are still stuck with a few...)
|
||||
* Remember, we have a replacement ircd sprintf, we have bleeps fputs lib
|
||||
* it would have been nice to remove some unneeded code.
|
||||
* Oh well. If we don't remove libc stuff totally, then it would be
|
||||
* far cleaner to use sscanf()
|
||||
*
|
||||
* - Dianora
|
||||
*/
|
||||
static char* GetValidIdent(char *buf)
|
||||
{
|
||||
int remp = 0;
|
||||
|
@ -361,42 +376,33 @@ static char* GetValidIdent(char *buf)
|
|||
/* All this to get rid of a sscanf() fun. */
|
||||
remotePortString = buf;
|
||||
|
||||
colon1Ptr = strchr(remotePortString,':');
|
||||
if(!colon1Ptr)
|
||||
if((colon1Ptr = strchr(remotePortString,':')) == NULL)
|
||||
return 0;
|
||||
|
||||
*colon1Ptr = '\0';
|
||||
colon1Ptr++;
|
||||
colon2Ptr = strchr(colon1Ptr,':');
|
||||
if(!colon2Ptr)
|
||||
return 0;
|
||||
|
||||
if((colon2Ptr = strchr(colon1Ptr,':')) == NULL)
|
||||
return 0;
|
||||
*colon2Ptr = '\0';
|
||||
colon2Ptr++;
|
||||
commaPtr = strchr(remotePortString, ',');
|
||||
|
||||
if(!commaPtr)
|
||||
if((commaPtr = strchr(remotePortString, ',')) == NULL)
|
||||
return 0;
|
||||
|
||||
*commaPtr = '\0';
|
||||
commaPtr++;
|
||||
|
||||
remp = atoi(remotePortString);
|
||||
if(!remp)
|
||||
if((remp = atoi(remotePortString)) == 0)
|
||||
return 0;
|
||||
|
||||
locp = atoi(commaPtr);
|
||||
if(!locp)
|
||||
if((locp = atoi(commaPtr)) == 0)
|
||||
return 0;
|
||||
|
||||
/* look for USERID bordered by first pair of colons */
|
||||
if(!strstr(colon1Ptr, "USERID"))
|
||||
if(strstr(colon1Ptr, "USERID") == NULL)
|
||||
return 0;
|
||||
|
||||
colon3Ptr = strchr(colon2Ptr,':');
|
||||
if(!colon3Ptr)
|
||||
if((colon3Ptr = strchr(colon2Ptr,':')) == NULL)
|
||||
return 0;
|
||||
|
||||
*colon3Ptr = '\0';
|
||||
colon3Ptr++;
|
||||
return(colon3Ptr);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_bsd.c,v 1.6 2002/09/17 11:23:58 fishwaldo Exp $
|
||||
* $Id: s_bsd.c,v 1.7 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -170,7 +170,8 @@ void report_error(int level, const char* text, const char* who, int error)
|
|||
* output - returns true (1) if successful, false (0) otherwise
|
||||
* side effects -
|
||||
*/
|
||||
int set_sock_buffers(int fd, int size)
|
||||
int
|
||||
set_sock_buffers(int fd, int size)
|
||||
{
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*) &size, sizeof(size)) ||
|
||||
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*) &size, sizeof(size)))
|
||||
|
@ -186,7 +187,8 @@ int set_sock_buffers(int fd, int size)
|
|||
* side effects - disable_sock_options - if remote has any socket options set,
|
||||
* disable them
|
||||
*/
|
||||
int disable_sock_options(int fd)
|
||||
int
|
||||
disable_sock_options(int fd)
|
||||
{
|
||||
#if defined(IP_OPTIONS) && defined(IPPROTO_IP) && !defined(IPV6)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_OPTIONS, NULL, 0))
|
||||
|
|
196
src/s_conf.c
196
src/s_conf.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_conf.c,v 1.7 2002/09/17 07:08:56 fishwaldo Exp $
|
||||
* $Id: s_conf.c,v 1.8 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -229,9 +229,8 @@ det_confs_butmask(struct Client *client_p, int mask)
|
|||
dlink_node *link_next;
|
||||
struct ConfItem *aconf;
|
||||
|
||||
for (dlink = client_p->localClient->confs.head; dlink; dlink = link_next)
|
||||
DLINK_FOREACH_SAFE(dlink, link_next, client_p->localClient->confs.head)
|
||||
{
|
||||
link_next = dlink->next;
|
||||
aconf = dlink->data;
|
||||
|
||||
if ((aconf->status & mask) == 0)
|
||||
|
@ -498,7 +497,7 @@ verify_access(struct Client* client_p, const char* username)
|
|||
{
|
||||
struct ConfItem* aconf;
|
||||
struct ConfItem* gkill_conf;
|
||||
char non_ident[USERLEN + 1];
|
||||
char non_ident[USERLEN + 1];
|
||||
|
||||
if (IsGotId(client_p))
|
||||
{
|
||||
|
@ -704,7 +703,6 @@ find_or_add_ip(struct irc_inaddr *ip_in)
|
|||
* and number of ip#'s for that ip decremented.
|
||||
* if ip # count reaches 0, the IP_ENTRY is returned
|
||||
* to the free_ip_enties link list.
|
||||
* XXX: Broken for IPV6
|
||||
*/
|
||||
|
||||
void
|
||||
|
@ -744,28 +742,38 @@ remove_one_ip(struct irc_inaddr *ip_in)
|
|||
* side effects - hopefully, none
|
||||
*/
|
||||
|
||||
#ifndef IPV6
|
||||
static int
|
||||
hash_ip(struct irc_inaddr *addr)
|
||||
{
|
||||
#ifndef IPV6
|
||||
int hash;
|
||||
u_int32_t ip;
|
||||
|
||||
ip = ntohl(PIN_ADDR(addr));
|
||||
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
|
||||
return(hash);
|
||||
#else
|
||||
unsigned int hash = 0;
|
||||
char *ip = (char *) &PIN_ADDR(addr);
|
||||
|
||||
while (*ip)
|
||||
{
|
||||
hash = (hash << 4) - (hash + (unsigned char)*ip++);
|
||||
}
|
||||
|
||||
return(hash & (IP_HASH_SIZE - 1));
|
||||
#endif
|
||||
}
|
||||
#else /* IPV6 */
|
||||
static int
|
||||
hash_ip(struct irc_inaddr *addr)
|
||||
{
|
||||
int hash;
|
||||
u_int32_t *ip = (unsigned long *)&PIN_ADDR(addr);
|
||||
|
||||
if(IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ip))
|
||||
{
|
||||
hash = ((ip[3] >> 12) + ip[3]) & (IP_HASH_SIZE-1);
|
||||
return(hash);
|
||||
}
|
||||
|
||||
hash = ip[0] ^ ip[3];
|
||||
hash ^= hash >> 16;
|
||||
hash ^= hash >> 8;
|
||||
hash = hash & (IP_HASH_SIZE - 1);
|
||||
return(hash);
|
||||
}
|
||||
#endif /* IPV6 */
|
||||
|
||||
|
||||
/*
|
||||
* count_ip_hash
|
||||
|
@ -871,32 +879,32 @@ detach_conf(struct Client* client_p,struct ConfItem* aconf)
|
|||
if(aconf == NULL)
|
||||
return(-1);
|
||||
|
||||
for(ptr = client_p->localClient->confs.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, client_p->localClient->confs.head)
|
||||
{
|
||||
if (ptr->data == aconf)
|
||||
{
|
||||
if (ptr->data == aconf)
|
||||
{
|
||||
if ((aconf) && (ClassPtr(aconf)))
|
||||
{
|
||||
if (aconf->status & CONF_CLIENT_MASK)
|
||||
{
|
||||
if (ConfLinks(aconf) > 0)
|
||||
--ConfLinks(aconf);
|
||||
}
|
||||
if (ConfMaxLinks(aconf) == -1 && ConfLinks(aconf) == 0)
|
||||
{
|
||||
free_class(ClassPtr(aconf));
|
||||
ClassPtr(aconf) = NULL;
|
||||
}
|
||||
}
|
||||
if (aconf && !--aconf->clients && IsIllegal(aconf))
|
||||
{
|
||||
free_conf(aconf);
|
||||
}
|
||||
dlinkDelete(ptr, &client_p->localClient->confs);
|
||||
free_dlink_node(ptr);
|
||||
return(0);
|
||||
}
|
||||
if ((aconf) && (ClassPtr(aconf)))
|
||||
{
|
||||
if (aconf->status & CONF_CLIENT_MASK)
|
||||
{
|
||||
if (ConfLinks(aconf) > 0)
|
||||
--ConfLinks(aconf);
|
||||
}
|
||||
if (ConfMaxLinks(aconf) == -1 && ConfLinks(aconf) == 0)
|
||||
{
|
||||
free_class(ClassPtr(aconf));
|
||||
ClassPtr(aconf) = NULL;
|
||||
}
|
||||
}
|
||||
if (aconf && !--aconf->clients && IsIllegal(aconf))
|
||||
{
|
||||
free_conf(aconf);
|
||||
}
|
||||
dlinkDelete(ptr, &client_p->localClient->confs);
|
||||
free_dlink_node(ptr);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
@ -913,10 +921,11 @@ is_attached(struct Client *client_p, struct ConfItem *aconf)
|
|||
{
|
||||
dlink_node *ptr=NULL;
|
||||
|
||||
for (ptr = client_p->localClient->confs.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH(ptr, client_p->localClient->confs.head)
|
||||
{
|
||||
if (ptr->data == aconf)
|
||||
break;
|
||||
|
||||
}
|
||||
return((ptr != NULL) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
@ -937,33 +946,32 @@ attach_conf(struct Client *client_p,struct ConfItem *aconf)
|
|||
dlink_node *lp;
|
||||
|
||||
if (is_attached(client_p, aconf))
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
if (IsIllegal(aconf))
|
||||
{
|
||||
return(NOT_AUTHORIZED);
|
||||
}
|
||||
{
|
||||
return(NOT_AUTHORIZED);
|
||||
}
|
||||
|
||||
if ((aconf->status & CONF_OPERATOR) == 0)
|
||||
{
|
||||
if ((aconf->status & CONF_CLIENT) &&
|
||||
ConfLinks(aconf) >= ConfMaxLinks(aconf) && ConfMaxLinks(aconf) > 0)
|
||||
{
|
||||
if ((aconf->status & CONF_CLIENT) &&
|
||||
ConfLinks(aconf) >= ConfMaxLinks(aconf) && ConfMaxLinks(aconf) > 0)
|
||||
{
|
||||
if (!IsConfExemptLimits(aconf))
|
||||
{
|
||||
return(I_LINE_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
send(client_p->localClient->fd,
|
||||
"NOTICE FLINE :I: line is full, but you have an >I: line!\n",
|
||||
56, 0);
|
||||
SetExemptLimits(client_p);
|
||||
}
|
||||
|
||||
}
|
||||
if (!IsConfExemptLimits(aconf))
|
||||
{
|
||||
return(I_LINE_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
send(client_p->localClient->fd,
|
||||
"NOTICE FLINE :I: line is full, but you have an >I: line!\n",
|
||||
56, 0);
|
||||
SetExemptLimits(client_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(aconf->status & FLAGS2_RESTRICTED)
|
||||
SetRestricted(client_p);
|
||||
|
@ -992,7 +1000,7 @@ int
|
|||
attach_confs(struct Client* client_p, const char* name, int statmask)
|
||||
{
|
||||
struct ConfItem* tmp;
|
||||
int conf_counter = 0;
|
||||
int conf_counter = 0;
|
||||
|
||||
for (tmp = ConfigItemList; tmp; tmp = tmp->next)
|
||||
{
|
||||
|
@ -1106,13 +1114,13 @@ find_conf_name(dlink_list *list, const char* name, int statmask)
|
|||
dlink_node *ptr;
|
||||
struct ConfItem* aconf;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = ptr->next)
|
||||
{
|
||||
aconf = ptr->data;
|
||||
if ((aconf->status & statmask) && aconf->name &&
|
||||
(!irccmp(aconf->name, name) || match(aconf->name, name)))
|
||||
return(aconf);
|
||||
}
|
||||
DLINK_FOREACH(ptr, list->head)
|
||||
{
|
||||
aconf = ptr->data;
|
||||
if ((aconf->status & statmask) && aconf->name &&
|
||||
(!irccmp(aconf->name, name) || match(aconf->name, name)))
|
||||
return(aconf);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -1526,7 +1534,7 @@ int
|
|||
conf_connect_allowed(struct irc_inaddr *addr, int aftype)
|
||||
{
|
||||
IP_ENTRY *ip_found;
|
||||
struct ConfItem *aconf = find_dline(addr, aftype);
|
||||
struct ConfItem *aconf = find_dline_conf(addr,aftype);
|
||||
|
||||
/* DLINE exempt also gets you out of static limits/pacing... */
|
||||
if (aconf && (aconf->status & CONF_EXEMPTDLINE))
|
||||
|
@ -1562,9 +1570,10 @@ find_kill(struct Client* client_p)
|
|||
assert(client_p != NULL);
|
||||
if(client_p == NULL)
|
||||
return NULL;
|
||||
aconf = find_address_conf(client_p->host, client_p->username,
|
||||
&client_p->localClient->ip,
|
||||
client_p->localClient->aftype);
|
||||
|
||||
aconf = find_kline_conf(client_p->host, client_p->username,
|
||||
&client_p->localClient->ip,
|
||||
client_p->localClient->aftype);
|
||||
if (aconf == NULL)
|
||||
return aconf;
|
||||
if(aconf->status & CONF_KILL)
|
||||
|
@ -1616,10 +1625,9 @@ expire_tklines(dlink_list *tklist)
|
|||
dlink_node *kill_node;
|
||||
dlink_node *next_node;
|
||||
struct ConfItem *kill_ptr;
|
||||
for (kill_node = tklist->head; kill_node; kill_node = next_node)
|
||||
DLINK_FOREACH_SAFE(kill_node, next_node, tklist->head)
|
||||
{
|
||||
kill_ptr = kill_node->data;
|
||||
next_node = kill_node->next;
|
||||
|
||||
if (kill_ptr->hold <= CurrentTime)
|
||||
{
|
||||
|
@ -1810,20 +1818,22 @@ get_oper_name(struct Client *client_p)
|
|||
static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5];
|
||||
|
||||
if (MyConnect(client_p))
|
||||
{
|
||||
DLINK_FOREACH(cnode, client_p->localClient->confs.head)
|
||||
{
|
||||
for (cnode=client_p->localClient->confs.head; cnode; cnode=cnode->next)
|
||||
if (((struct ConfItem*)cnode->data)->status & CONF_OPERATOR)
|
||||
{
|
||||
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
|
||||
client_p->username, client_p->host,
|
||||
((struct ConfItem*)cnode->data)->name);
|
||||
return(buffer);
|
||||
}
|
||||
/* Probably should assert here for now. If there is an oper out there
|
||||
* with no oper{} conf attached, it would be good for us to know...
|
||||
*/
|
||||
assert(0); /* Oper without oper conf! */
|
||||
if (((struct ConfItem*)cnode->data)->status & CONF_OPERATOR)
|
||||
{
|
||||
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
|
||||
client_p->username, client_p->host,
|
||||
((struct ConfItem*)cnode->data)->name);
|
||||
return(buffer);
|
||||
}
|
||||
}
|
||||
/* Probably should assert here for now. If there is an oper out there
|
||||
* with no oper{} conf attached, it would be good for us to know...
|
||||
*/
|
||||
assert(0); /* Oper without oper conf! */
|
||||
}
|
||||
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
|
||||
client_p->username, client_p->host, client_p->servptr->name);
|
||||
return(buffer);
|
||||
|
@ -2332,10 +2342,6 @@ conf_add_d_conf(struct ConfItem *aconf)
|
|||
void
|
||||
conf_add_x_conf(struct ConfItem *aconf)
|
||||
{
|
||||
MyFree(aconf->user);
|
||||
aconf->user = NULL;
|
||||
aconf->name = aconf->host;
|
||||
aconf->host = (char *)NULL;
|
||||
aconf->next = x_conf;
|
||||
x_conf = aconf;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_gline.c,v 1.5 2002/09/13 16:30:05 fishwaldo Exp $
|
||||
* $Id: s_gline.c,v 1.6 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -97,16 +97,16 @@ find_is_glined(const char* host, const char* name)
|
|||
dlink_node *gline_node;
|
||||
struct ConfItem *kill_ptr;
|
||||
|
||||
for(gline_node = glines.head; gline_node; gline_node = gline_node->next)
|
||||
DLINK_FOREACH(gline_node, glines.head)
|
||||
{
|
||||
kill_ptr = gline_node->data;
|
||||
if( (kill_ptr->name && (!name || match(kill_ptr->name,name)))
|
||||
&&
|
||||
(kill_ptr->host && (!host || match(kill_ptr->host,host))))
|
||||
{
|
||||
kill_ptr = gline_node->data;
|
||||
if( (kill_ptr->name && (!name || match(kill_ptr->name,name)))
|
||||
&&
|
||||
(kill_ptr->host && (!host || match(kill_ptr->host,host))))
|
||||
{
|
||||
return(kill_ptr);
|
||||
}
|
||||
return(kill_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
return((struct ConfItem *)NULL);
|
||||
}
|
||||
|
@ -124,18 +124,18 @@ remove_gline_match(const char* user, const char* host)
|
|||
dlink_node *gline_node;
|
||||
struct ConfItem *kill_ptr;
|
||||
|
||||
for(gline_node = glines.head; gline_node; gline_node = gline_node->next)
|
||||
DLINK_FOREACH(gline_node, glines.head)
|
||||
{
|
||||
kill_ptr = gline_node->data;
|
||||
if(!irccmp(kill_ptr->host,host) && !irccmp(kill_ptr->name,user))
|
||||
{
|
||||
kill_ptr = gline_node->data;
|
||||
if(!irccmp(kill_ptr->host,host) && !irccmp(kill_ptr->name,user))
|
||||
{
|
||||
free_conf(kill_ptr);
|
||||
dlinkDelete(gline_node, &glines);
|
||||
free_dlink_node(gline_node);
|
||||
return 1;
|
||||
}
|
||||
free_conf(kill_ptr);
|
||||
dlinkDelete(gline_node, &glines);
|
||||
free_dlink_node(gline_node);
|
||||
return (1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -168,18 +168,17 @@ expire_glines()
|
|||
dlink_node *next_node;
|
||||
struct ConfItem *kill_ptr;
|
||||
|
||||
for(gline_node = glines.head; gline_node; gline_node = next_node)
|
||||
{
|
||||
kill_ptr = gline_node->data;
|
||||
next_node = gline_node->next;
|
||||
DLINK_FOREACH_SAFE(gline_node, next_node, glines.head)
|
||||
{
|
||||
kill_ptr = gline_node->data;
|
||||
|
||||
if(kill_ptr->hold <= CurrentTime)
|
||||
{
|
||||
free_conf(kill_ptr);
|
||||
dlinkDelete(gline_node, &glines);
|
||||
free_dlink_node(gline_node);
|
||||
}
|
||||
if(kill_ptr->hold <= CurrentTime)
|
||||
{
|
||||
free_conf(kill_ptr);
|
||||
dlinkDelete(gline_node, &glines);
|
||||
free_dlink_node(gline_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
139
src/s_log.c
139
src/s_log.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_log.c,v 1.3 2002/09/13 06:50:08 fishwaldo Exp $
|
||||
* $Id: s_log.c,v 1.4 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -87,7 +87,8 @@ static int
|
|||
open_log(const char* filename)
|
||||
{
|
||||
logFile = fbopen(filename, "a");
|
||||
if (logFile == NULL) {
|
||||
if (logFile == NULL)
|
||||
{
|
||||
#ifdef USE_SYSLOG
|
||||
syslog(LOG_ERR, "Unable to open log file: %s: %s",
|
||||
filename, strerror(errno));
|
||||
|
@ -121,7 +122,6 @@ ilog(int priority, const char* fmt, ...)
|
|||
assert(-1 < priority);
|
||||
if(fmt == NULL)
|
||||
return;
|
||||
assert(0 != fmt);
|
||||
|
||||
if (priority > logLevel)
|
||||
return;
|
||||
|
@ -215,9 +215,7 @@ log_user_exit(struct Client *source_p)
|
|||
(signed long) on_for / 3600,
|
||||
(signed long) (on_for % 3600)/60,
|
||||
(signed long) on_for % 60,
|
||||
source_p->name,
|
||||
source_p->username,
|
||||
source_p->host,
|
||||
source_p->name, source_p->username, source_p->host,
|
||||
source_p->localClient->sendK,
|
||||
source_p->localClient->receiveK);
|
||||
}
|
||||
|
@ -233,34 +231,31 @@ log_user_exit(struct Client *source_p)
|
|||
* -Taner
|
||||
*/
|
||||
if (IsPerson(source_p))
|
||||
{
|
||||
if (user_log_fb == NULL)
|
||||
{
|
||||
if (user_log_fb == NULL)
|
||||
{
|
||||
if( ConfigFileEntry.fname_userlog &&
|
||||
(user_log_fb = fbopen(ConfigFileEntry.fname_userlog, "r")) != NULL )
|
||||
{
|
||||
fbclose(user_log_fb);
|
||||
user_log_fb = fbopen(ConfigFileEntry.fname_userlog, "a");
|
||||
}
|
||||
}
|
||||
|
||||
if( user_log_fb != NULL )
|
||||
{
|
||||
ircsprintf(linebuf,
|
||||
"%s (%3ld:%02ld:%02ld): %s!%s@%s %d/%d\n",
|
||||
myctime(source_p->firsttime),
|
||||
(signed long) on_for / 3600,
|
||||
(signed long) (on_for % 3600)/60,
|
||||
(signed long) on_for % 60,
|
||||
source_p->name,
|
||||
source_p->username,
|
||||
source_p->host,
|
||||
source_p->localClient->sendK,
|
||||
source_p->localClient->receiveK);
|
||||
|
||||
fbputs(linebuf, user_log_fb);
|
||||
}
|
||||
if((ConfigFileEntry.fname_userlog[0] != '\0') &&
|
||||
(user_log_fb = fbopen(ConfigFileEntry.fname_userlog, "r")) != NULL )
|
||||
{
|
||||
fbclose(user_log_fb);
|
||||
user_log_fb = fbopen(ConfigFileEntry.fname_userlog, "a");
|
||||
}
|
||||
}
|
||||
if (user_log_fb != NULL)
|
||||
{
|
||||
ircsprintf(linebuf,
|
||||
"%s (%3ld:%02ld:%02ld): %s!%s@%s %d/%d\n",
|
||||
myctime(source_p->firsttime),
|
||||
(signed long) on_for / 3600,
|
||||
(signed long) (on_for % 3600)/60,
|
||||
(signed long) on_for % 60,
|
||||
source_p->name, source_p->username, source_p->host,
|
||||
source_p->localClient->sendK,
|
||||
source_p->localClient->receiveK);
|
||||
|
||||
fbputs(linebuf, user_log_fb);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -284,40 +279,78 @@ user_log_resync(void *notused)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* XXX log_oper and log_failed_oper should be combined in future */
|
||||
/*
|
||||
* log_oper
|
||||
*
|
||||
* inputs - pointer to client
|
||||
* inputs - pointer to client being opered up
|
||||
* output - none
|
||||
* side effects - FNAME_OPERLOG is written to, if its present
|
||||
* side effects - ConfigFileEntry.fname_operlog is written to, if its present
|
||||
*/
|
||||
|
||||
void
|
||||
log_oper( struct Client *source_p, char *name )
|
||||
log_oper(struct Client *source_p, char *name)
|
||||
{
|
||||
FBFILE *oper_fb;
|
||||
char linebuf[BUFSIZE];
|
||||
|
||||
if (!ConfigFileEntry.fname_operlog)
|
||||
return;
|
||||
if (ConfigFileEntry.fname_operlog[0] == '\0')
|
||||
return;
|
||||
|
||||
if (IsPerson(source_p))
|
||||
{
|
||||
if((oper_fb = fbopen(ConfigFileEntry.fname_operlog, "r")) != NULL)
|
||||
{
|
||||
if( (oper_fb = fbopen(ConfigFileEntry.fname_operlog, "r")) != NULL )
|
||||
{
|
||||
fbclose(oper_fb);
|
||||
oper_fb = fbopen(ConfigFileEntry.fname_operlog, "a");
|
||||
}
|
||||
|
||||
if(oper_fb != NULL)
|
||||
{
|
||||
ircsprintf(linebuf, "%s OPER (%s) by (%s!%s@%s)\n",
|
||||
myctime(CurrentTime), name,
|
||||
source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
|
||||
fbputs(linebuf,oper_fb);
|
||||
fbclose(oper_fb);
|
||||
}
|
||||
fbclose(oper_fb);
|
||||
oper_fb = fbopen(ConfigFileEntry.fname_operlog, "a");
|
||||
}
|
||||
|
||||
if(oper_fb != NULL)
|
||||
{
|
||||
ircsprintf(linebuf, "%s OPER (%s) by (%s!%s@%s)\n",
|
||||
myctime(CurrentTime), name,
|
||||
source_p->name, source_p->username,
|
||||
source_p->host);
|
||||
|
||||
fbputs(linebuf,oper_fb);
|
||||
fbclose(oper_fb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* log_failed_oper
|
||||
*
|
||||
* inputs - pointer to client that failed top oper up
|
||||
* output - none
|
||||
* side effects - ConfigFileEntry.fname_foperlog is written to, if its present
|
||||
*/
|
||||
|
||||
void
|
||||
log_failed_oper(struct Client *source_p, char *name)
|
||||
{
|
||||
FBFILE *oper_fb;
|
||||
char linebuf[BUFSIZE];
|
||||
|
||||
if (ConfigFileEntry.fname_foperlog[0] == '\0')
|
||||
return;
|
||||
|
||||
if (IsPerson(source_p))
|
||||
{
|
||||
if((oper_fb = fbopen(ConfigFileEntry.fname_foperlog, "r")) != NULL)
|
||||
{
|
||||
fbclose(oper_fb);
|
||||
oper_fb = fbopen(ConfigFileEntry.fname_foperlog, "a");
|
||||
}
|
||||
|
||||
if(oper_fb != NULL)
|
||||
{
|
||||
ircsprintf(linebuf, "%s FAILED OPER (%s) by (%s!%s@%s)\n",
|
||||
myctime(CurrentTime), name,
|
||||
source_p->name, source_p->username, source_p->host);
|
||||
|
||||
fbputs(linebuf,oper_fb);
|
||||
fbclose(oper_fb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_stats.c,v 1.3 2002/09/13 06:50:09 fishwaldo Exp $
|
||||
* $Id: s_stats.c,v 1.4 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -39,7 +39,8 @@
|
|||
static struct ServerStatistics ircst;
|
||||
struct ServerStatistics* ServerStats = &ircst;
|
||||
|
||||
void init_stats()
|
||||
void
|
||||
init_stats()
|
||||
{
|
||||
memset(&ircst, 0, sizeof(ircst));
|
||||
}
|
||||
|
@ -51,17 +52,19 @@ void init_stats()
|
|||
* output - NONE
|
||||
* side effects -
|
||||
*/
|
||||
void tstats(struct Client *source_p)
|
||||
void
|
||||
tstats(struct Client *source_p)
|
||||
{
|
||||
struct Client* target_p;
|
||||
struct ServerStatistics* sp;
|
||||
struct Client *target_p;
|
||||
struct ServerStatistics *sp;
|
||||
struct ServerStatistics tmp;
|
||||
dlink_node *ptr;
|
||||
|
||||
sp = &tmp;
|
||||
memcpy(sp, ServerStats, sizeof(struct ServerStatistics));
|
||||
|
||||
for(ptr = serv_list.head; ptr; ptr = ptr->next)
|
||||
sp->is_sv = dlink_list_length(&serv_list);
|
||||
DLINK_FOREACH(ptr, serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
@ -70,7 +73,6 @@ void tstats(struct Client *source_p)
|
|||
sp->is_sks += target_p->localClient->sendK;
|
||||
sp->is_skr += target_p->localClient->receiveK;
|
||||
sp->is_sti += CurrentTime - target_p->firsttime;
|
||||
sp->is_sv++;
|
||||
if (sp->is_sbs > 1023)
|
||||
{
|
||||
sp->is_sks += (sp->is_sbs >> 10);
|
||||
|
@ -83,7 +85,8 @@ void tstats(struct Client *source_p)
|
|||
}
|
||||
}
|
||||
|
||||
for(ptr = lclient_list.head; ptr; ptr = ptr->next)
|
||||
sp->is_cl = dlink_list_length(&lclient_list);
|
||||
DLINK_FOREACH(ptr, lclient_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
|
@ -92,7 +95,6 @@ void tstats(struct Client *source_p)
|
|||
sp->is_cks += target_p->localClient->sendK;
|
||||
sp->is_ckr += target_p->localClient->receiveK;
|
||||
sp->is_cti += CurrentTime - target_p->firsttime;
|
||||
sp->is_cl++;
|
||||
if (sp->is_cbs > 1023)
|
||||
{
|
||||
sp->is_cks += (sp->is_cbs >> 10);
|
||||
|
@ -106,10 +108,7 @@ void tstats(struct Client *source_p)
|
|||
|
||||
}
|
||||
|
||||
for(ptr = unknown_list.head; ptr; ptr = ptr->next)
|
||||
{
|
||||
sp->is_ni++;
|
||||
}
|
||||
sp->is_ni = dlink_list_length(&unknown_list);
|
||||
|
||||
sendto_one(source_p, ":%s %d %s :accepts %u refused %u",
|
||||
me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref);
|
||||
|
@ -119,16 +118,17 @@ void tstats(struct Client *source_p)
|
|||
me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni);
|
||||
sendto_one(source_p, ":%s %d %s :wrong direction %u empty %u",
|
||||
me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
|
||||
sendto_one(source_p, ":%s %d %s :numerics seen %u mode fakes %u",
|
||||
me.name, RPL_STATSDEBUG, source_p->name, sp->is_num, sp->is_fake);
|
||||
sendto_one(source_p, ":%s %d %s :numerics seen %u",
|
||||
me.name, RPL_STATSDEBUG, source_p->name, sp->is_num);
|
||||
sendto_one(source_p, ":%s %d %s :auth successes %u fails %u",
|
||||
me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
|
||||
sendto_one(source_p, ":%s %d %s :local connections %u udp packets %u",
|
||||
me.name, RPL_STATSDEBUG, source_p->name, sp->is_loc, sp->is_udp);
|
||||
sendto_one(source_p, ":%s %d %s :Client Server",
|
||||
me.name, RPL_STATSDEBUG, source_p->name);
|
||||
sendto_one(source_p, ":%s %d %s :connected %u %u",
|
||||
me.name, RPL_STATSDEBUG, source_p->name, sp->is_cl, sp->is_sv);
|
||||
|
||||
sendto_one(source_p, ":%s %d %s :connected %lu %lu",
|
||||
me.name, RPL_STATSDEBUG, source_p->name,
|
||||
dlink_list_length(&lclient_list),
|
||||
dlink_list_length(&serv_list));
|
||||
sendto_one(source_p, ":%s %d %s :bytes sent %d.%uK %d.%uK",
|
||||
me.name, RPL_STATSDEBUG, source_p->name,
|
||||
(int)sp->is_cks, sp->is_cbs, (int)sp->is_sks, sp->is_sbs);
|
||||
|
@ -136,7 +136,8 @@ void tstats(struct Client *source_p)
|
|||
me.name, RPL_STATSDEBUG, source_p->name,
|
||||
(int)sp->is_ckr, sp->is_cbr, (int)sp->is_skr, sp->is_sbr);
|
||||
sendto_one(source_p, ":%s %d %s :time connected %d %d",
|
||||
me.name, RPL_STATSDEBUG, source_p->name, (int)sp->is_cti, (int)sp->is_sti);
|
||||
me.name, RPL_STATSDEBUG, source_p->name, (int)sp->is_cti,
|
||||
(int)sp->is_sti);
|
||||
}
|
||||
|
||||
|
||||
|
|
35
src/send.c
35
src/send.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: send.c,v 1.7 2002/09/13 16:30:05 fishwaldo Exp $
|
||||
* $Id: send.c,v 1.8 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
|
@ -568,9 +568,8 @@ sendto_list_anywhere(struct Client *one, struct Client *from,
|
|||
dlink_node *ptr_next;
|
||||
struct Client *target_p;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, list->head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
target_p = ptr->data;
|
||||
|
||||
if (target_p->from == one)
|
||||
|
@ -651,9 +650,8 @@ sendto_server(struct Client *one, struct Client *source_p,
|
|||
linebuf_putmsg(&linebuf, format, &args, NULL);
|
||||
va_end(args);
|
||||
|
||||
for(ptr = serv_list.head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, serv_list.head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
client_p = ptr->data;
|
||||
|
||||
/* check against 'one' */
|
||||
|
@ -728,9 +726,8 @@ sendto_common_channels_local(struct Client *user, const char *pattern, ...)
|
|||
|
||||
if (user->user != NULL)
|
||||
{
|
||||
for (ptr = user->user->channel.head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, user->user->channel.head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
chptr = ptr->data;
|
||||
|
||||
sendto_list_local(&chptr->locchanops, &linebuf);
|
||||
|
@ -868,9 +865,8 @@ sendto_list_local(dlink_list *list, buf_head_t *linebuf_ptr)
|
|||
dlink_node *ptr_next;
|
||||
struct Client *target_p;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, list->head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
if ((target_p = ptr->data) == NULL)
|
||||
continue;
|
||||
|
||||
|
@ -910,16 +906,14 @@ sendto_list_remote(struct Client *one,
|
|||
dlink_node *ptr_next;
|
||||
struct Client *target_p;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, list->head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
if ((target_p = ptr->data) == NULL)
|
||||
continue;
|
||||
|
||||
if (MyConnect(target_p))
|
||||
continue;
|
||||
|
||||
|
||||
if (target_p->from == one->from) /* must skip the origin! */
|
||||
continue;
|
||||
|
||||
|
@ -993,9 +987,8 @@ sendto_match_butone(struct Client *one, struct Client *from,
|
|||
va_end(args);
|
||||
|
||||
/* scan the local clients */
|
||||
for(ptr = lclient_list.head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, lclient_list.head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
client_p = ptr->data;
|
||||
|
||||
if (client_p == one) /* must skip the origin !! */
|
||||
|
@ -1006,7 +999,7 @@ sendto_match_butone(struct Client *one, struct Client *from,
|
|||
}
|
||||
|
||||
/* Now scan servers */
|
||||
for (ptr = serv_list.head; ptr; ptr = ptr->next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, serv_list.head)
|
||||
{
|
||||
client_p = ptr->data;
|
||||
|
||||
|
@ -1077,7 +1070,8 @@ sendto_anywhere(struct Client *to, struct Client *from,
|
|||
linebuf_putmsg(&linebuf, pattern, &args, ":%s!%s@%s ", from->name,
|
||||
from->username, from->vhost);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if(IsCapable(to->from, CAP_UID))
|
||||
linebuf_putmsg(&linebuf, pattern, &args, ":%s ", ID(from));
|
||||
else
|
||||
|
@ -1119,9 +1113,8 @@ sendto_realops_flags(int flags, int level, const char *pattern, ...)
|
|||
send_format(nbuf, pattern, args);
|
||||
va_end(args);
|
||||
|
||||
for (ptr = oper_list.head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, oper_list.head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
client_p = ptr->data;
|
||||
|
||||
/* If we're sending it to opers and theyre an admin, skip.
|
||||
|
@ -1180,9 +1173,8 @@ sendto_wallops_flags(int flags, struct Client *source_p,
|
|||
|
||||
va_end(args);
|
||||
|
||||
for (ptr = oper_list.head; ptr; ptr = ptr_next)
|
||||
DLINK_FOREACH_SAFE(ptr, ptr_next, oper_list.head)
|
||||
{
|
||||
ptr_next = ptr->next;
|
||||
client_p = ptr->data;
|
||||
|
||||
if(client_p->umodes & flags)
|
||||
|
@ -1233,9 +1225,6 @@ ts_warn(const char *pattern, ...)
|
|||
ilog(L_CRIT, "%s", lbuf);
|
||||
} /* ts_warn() */
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* kill_client
|
||||
*
|
||||
|
|
144
src/tools.c
144
src/tools.c
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: tools.c,v 1.3 2002/09/13 06:50:09 fishwaldo Exp $
|
||||
* $Id: tools.c,v 1.4 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
*
|
||||
* When you update these functions make sure you update the ones in tools.h
|
||||
* as well!!!
|
||||
|
@ -58,12 +58,15 @@ dlinkAdd(void *data, dlink_node * m, dlink_list * list)
|
|||
{
|
||||
m->data = data;
|
||||
m->next = list->head;
|
||||
|
||||
/* Assumption: If list->tail != NULL, list->head != NULL */
|
||||
if (list->head != NULL)
|
||||
list->head->prev = m;
|
||||
else if (list->tail == NULL)
|
||||
list->tail = m;
|
||||
|
||||
list->head = m;
|
||||
list->length++;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -71,28 +74,34 @@ dlinkAddBefore(dlink_node *b, void *data, dlink_node *m, dlink_list *list)
|
|||
{
|
||||
/* Shortcut - if its the first one, call dlinkAdd only */
|
||||
if (b == list->head)
|
||||
{
|
||||
dlinkAdd(data, m, list);
|
||||
else {
|
||||
m->data = data;
|
||||
b->prev->next = m;
|
||||
m->prev = b->prev;
|
||||
b->prev = m;
|
||||
m->next = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
m->data = data;
|
||||
b->prev->next = m;
|
||||
m->prev = b->prev;
|
||||
b->prev = m;
|
||||
m->next = b;
|
||||
list->length++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dlinkAddTail(void *data, dlink_node *m, dlink_list *list)
|
||||
{
|
||||
m->data = data;
|
||||
m->next = NULL;
|
||||
m->prev = list->tail;
|
||||
/* Assumption: If list->tail != NULL, list->head != NULL */
|
||||
if (list->tail != NULL)
|
||||
list->tail->next = m;
|
||||
else if (list->head == NULL)
|
||||
list->head = m;
|
||||
list->tail = m;
|
||||
m->data = data;
|
||||
m->next = NULL;
|
||||
m->prev = list->tail;
|
||||
/* Assumption: If list->tail != NULL, list->head != NULL */
|
||||
if (list->tail != NULL)
|
||||
list->tail->next = m;
|
||||
else if (list->head == NULL)
|
||||
list->head = m;
|
||||
|
||||
list->tail = m;
|
||||
list->length++;
|
||||
}
|
||||
|
||||
/* Execution profiles show that this function is called the most
|
||||
|
@ -104,35 +113,21 @@ dlinkDelete(dlink_node *m, dlink_list *list)
|
|||
/* Assumption: If m->next == NULL, then list->tail == m
|
||||
* and: If m->prev == NULL, then list->head == m
|
||||
*/
|
||||
if (m->next)
|
||||
m->next->prev = m->prev;
|
||||
else
|
||||
list->tail = m->prev;
|
||||
if (m->prev)
|
||||
m->prev->next = m->next;
|
||||
else
|
||||
list->head = m->next;
|
||||
/* XXX - does this ever matter? */
|
||||
m->next = m->prev = NULL;
|
||||
if (m->next)
|
||||
m->next->prev = m->prev;
|
||||
else
|
||||
list->tail = m->prev;
|
||||
if (m->prev)
|
||||
m->prev->next = m->next;
|
||||
else
|
||||
list->head = m->next;
|
||||
|
||||
/* Set this to NULL does matter */
|
||||
m->next = m->prev = NULL;
|
||||
list->length--;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* dlink_list_length
|
||||
* inputs - pointer to a dlink_list
|
||||
* output - return the length (>=0) of a chain of links.
|
||||
* side effects -
|
||||
*/
|
||||
extern int dlink_list_length(dlink_list *list)
|
||||
{
|
||||
dlink_node *ptr;
|
||||
int count = 0;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = ptr->next)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
* dlinkFind
|
||||
* inputs - list to search
|
||||
|
@ -140,15 +135,16 @@ extern int dlink_list_length(dlink_list *list)
|
|||
* output - pointer to link or NULL if not found
|
||||
* side effects - Look for ptr in the linked listed pointed to by link.
|
||||
*/
|
||||
dlink_node *dlinkFind(dlink_list *list, void * data )
|
||||
dlink_node *
|
||||
dlinkFind(dlink_list *list, void * data )
|
||||
{
|
||||
dlink_node *ptr;
|
||||
|
||||
for (ptr = list->head; ptr; ptr = ptr->next)
|
||||
{
|
||||
if (ptr->data == data)
|
||||
return (ptr);
|
||||
}
|
||||
DLINK_FOREACH(ptr, list->head)
|
||||
{
|
||||
if (ptr->data == data)
|
||||
return (ptr);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -157,28 +153,52 @@ dlinkMoveList(dlink_list *from, dlink_list *to)
|
|||
{
|
||||
/* There are three cases */
|
||||
/* case one, nothing in from list */
|
||||
|
||||
if(from->head == NULL)
|
||||
return;
|
||||
if(from->head == NULL)
|
||||
return;
|
||||
|
||||
/* case two, nothing in to list */
|
||||
/* actually if to->head is NULL and to->tail isn't, thats a bug */
|
||||
|
||||
if(to->head == NULL) {
|
||||
to->head = from->head;
|
||||
to->tail = from->tail;
|
||||
from->head = from->tail = NULL;
|
||||
return;
|
||||
if(to->head == NULL)
|
||||
{
|
||||
to->head = from->head;
|
||||
to->tail = from->tail;
|
||||
from->head = from->tail = NULL;
|
||||
to->length = from->length;
|
||||
from->length = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* third case play with the links */
|
||||
|
||||
from->tail->next = to->head;
|
||||
from->head->prev = to->head->prev;
|
||||
to->head->prev = from->tail;
|
||||
to->head = from->head;
|
||||
from->head = from->tail = NULL;
|
||||
|
||||
from->tail->next = to->head;
|
||||
from->head->prev = to->head->prev;
|
||||
to->head->prev = from->tail;
|
||||
to->head = from->head;
|
||||
from->head = from->tail = NULL;
|
||||
to->length += from->length;
|
||||
from->length = 0;
|
||||
/* I think I got that right */
|
||||
}
|
||||
|
||||
dlink_node *
|
||||
dlinkFindDelete(dlink_list *list, void *data)
|
||||
{
|
||||
dlink_node *m;
|
||||
|
||||
DLINK_FOREACH(m, list->head)
|
||||
{
|
||||
if(m->data != data)
|
||||
continue;
|
||||
|
||||
if (m->next != NULL)
|
||||
m->next->prev = m->prev;
|
||||
else
|
||||
list->tail = m->prev;
|
||||
|
||||
m->next = m->prev = NULL;
|
||||
list->length--;
|
||||
return m;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile.in,v 1.2 2002/08/13 14:45:13 fishwaldo Exp $
|
||||
# $Id: Makefile.in,v 1.3 2002/09/19 05:41:11 fishwaldo Exp $
|
||||
|
||||
CC = @CC@
|
||||
INSTALL = @INSTALL@
|
||||
|
@ -32,23 +32,16 @@ localstatedir = @localstatedir@
|
|||
moduledir = @prefix@/modules
|
||||
automoduledir = @prefix@/modules/autoload
|
||||
|
||||
PROGS = viconf mkpasswd convertconf convertilines convertklines encspeed
|
||||
PROGS = viconf mkpasswd encspeed
|
||||
|
||||
mkpasswd_SOURCES = mkpasswd.c
|
||||
mkpasswd_OBJECTS = mkpasswd.o
|
||||
viconf_SOURCES = viconf.c
|
||||
viconf_OBJECTS = viconf.o
|
||||
convertconf_SOURCES = convertconf.c
|
||||
convertconf_OBJECTS = convertconf.o
|
||||
convertklines_SOURCES = convertklines.c
|
||||
convertklines_OBJECTS = convertklines.o
|
||||
convertilines_SOURCES = convertilines.c
|
||||
convertilines_OBJECTS = convertilines.o
|
||||
encspeed_SOURCES = encspeed.c
|
||||
encspeed_OBJECTS = encspeed.o
|
||||
|
||||
all_OBJECTS = $(viconf_OBJECTS) $(mkpasswd_OBJECTS) $(convertconf_OBJECTS)\
|
||||
$(convertklines_OBJECTS) $(encspeed_OBJECTS) $(convertilines_OBJECTS)
|
||||
all_OBJECTS = $(viconf_OBJECTS) $(mkpasswd_OBJECTS) $(encspeed_OBJECTS)
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
|
@ -62,23 +55,14 @@ mkpasswd: $(mkpasswd_OBJECTS)
|
|||
viconf: $(viconf_OBJECTS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o viconf $(viconf_OBJECTS) $(IRCDLIBS)
|
||||
|
||||
convertilines: convertilines.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o convertilines $(convertilines_OBJECTS) $(IRCDLIBS)
|
||||
|
||||
convertklines: convertklines.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o convertklines $(convertklines_OBJECTS) $(IRCDLIBS)
|
||||
|
||||
convertconf: convertconf.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o convertconf $(convertconf_OBJECTS) $(IRCDLIBS)
|
||||
|
||||
clean:
|
||||
$(RM) -f $(all_OBJECTS) convertconf encspeed viconf chkconf mkpasswd *~ core *.exe convertklines convertilines
|
||||
$(RM) -f $(all_OBJECTS) encspeed viconf chkconf mkpasswd *~ core *.exe
|
||||
|
||||
distclean: clean
|
||||
$(RM) -f Makefile
|
||||
|
||||
lint:
|
||||
lint -aacgprxhH $(CPPFLAGS) -DIRCD_PREFIX=\"@prefix@\" $(convertconf_SOURCES) $(convertklines_SOURCES) $(mkpasswd_SOURCES) $(viconf_SOURCES) $(encspeed_SOURCES) >>../lint.out
|
||||
lint -aacgprxhH $(CPPFLAGS) -DIRCD_PREFIX=\"@prefix@\" $(mkpasswd_SOURCES) $(viconf_SOURCES) $(encspeed_SOURCES) >>../lint.out
|
||||
|
||||
depend:
|
||||
|
||||
|
|
|
@ -1,825 +0,0 @@
|
|||
/************************************************************************
|
||||
* IRC - Internet Relay Chat, tools/convertconf.c
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 1, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: convertconf.c,v 1.2 2002/08/13 14:45:13 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "../include/config.h"
|
||||
#include "../include/setup.h"
|
||||
|
||||
#define CONFPATH ETCPATH "/.convertconf-example.conf"
|
||||
#define BUFSIZE 512
|
||||
|
||||
#define IS_LEAF 0
|
||||
#define IS_HUB 1
|
||||
|
||||
struct ConnectPair
|
||||
{
|
||||
struct ConnectPair* next; /* list node pointer */
|
||||
char* name; /* server name */
|
||||
char* host; /* host part of user@host */
|
||||
char* c_passwd;
|
||||
char* n_passwd;
|
||||
char* hub_mask;
|
||||
char* leaf_mask;
|
||||
int compressed;
|
||||
int lazylink;
|
||||
int port;
|
||||
char *class; /* Class of connection */
|
||||
};
|
||||
|
||||
static struct ConnectPair* base_ptr=NULL;
|
||||
|
||||
static void ConvertConf(FILE* file,FILE *out);
|
||||
static void usage(void);
|
||||
static char *getfield(char *);
|
||||
static void ReplaceQuotes(char *out, char *in);
|
||||
static void oldParseOneLine(FILE *out, char *in);
|
||||
static void PrintOutServers(FILE *out);
|
||||
static void PairUpServers(struct ConnectPair* );
|
||||
static void AddHubOrLeaf(int type,char* name,char* host);
|
||||
static void OperPrivsFromString(FILE* , char* );
|
||||
static int basic = 0;
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
FILE *in;
|
||||
FILE *out;
|
||||
char line[BUFSIZE];
|
||||
char *filein, *fileout;
|
||||
|
||||
if(argc < 3)
|
||||
usage();
|
||||
|
||||
if(argc > 3)
|
||||
{
|
||||
if((argv[1][0] == '-') && argv[1][1] && (argv[1][1] == 'b'))
|
||||
basic = 1;
|
||||
|
||||
filein = argv[2];
|
||||
fileout = argv[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
filein = argv[1];
|
||||
fileout = argv[2];
|
||||
}
|
||||
|
||||
#ifdef EFNET
|
||||
basic = 1;
|
||||
#endif
|
||||
|
||||
if ((in = fopen(filein, "r")) == NULL)
|
||||
{
|
||||
fprintf(stderr,"Can't open %s for reading\n", filein);
|
||||
usage();
|
||||
}
|
||||
|
||||
if ((out = fopen(fileout, "w")) == NULL)
|
||||
{
|
||||
fprintf(stderr,"Can't open %s for writing\n", fileout);
|
||||
usage();
|
||||
}
|
||||
|
||||
ConvertConf(in,out);
|
||||
|
||||
if(!basic && ((in = fopen(CONFPATH, "r")) == NULL))
|
||||
{
|
||||
fprintf(stderr, "Can't open %s for reading\n", CONFPATH);
|
||||
puts("You must use the example.conf in the ircd-hybrid-7 source to get the\n"
|
||||
"general {}; logging {}; channel {}; serverhide {}; modules {}; blocks.\n");
|
||||
}
|
||||
else if(!basic)
|
||||
{
|
||||
while (fgets(line, sizeof(line), in))
|
||||
fprintf(out, line);
|
||||
|
||||
puts("Adding the remaining missing blocks to your config..\n");
|
||||
}
|
||||
|
||||
puts("The config file has been converted however you MUST rearrange and check the config:\n"
|
||||
" o class blocks (Y:) must be before anything that uses then\n"
|
||||
" o auth blocks (I:) have NOT been converted, please use convertilines\n"
|
||||
" to convert them\n");
|
||||
if(!basic)
|
||||
puts(" o the general/channel/serverhide parts will need to be edited\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void usage()
|
||||
{
|
||||
fprintf(stderr,"convertconf [-b] ircd.conf.old ircd.conf.new\n");
|
||||
fprintf(stderr, " -b - this will run in 'basic' mode and not add extra blocks\n");
|
||||
fprintf(stderr, " such as general{}, channel{} etc. (Used for EFNet)\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
** ConvertConf()
|
||||
** Read configuration file.
|
||||
**
|
||||
*
|
||||
* Inputs - FILE* to config file to convert
|
||||
* - FILE* to output for new style conf
|
||||
*
|
||||
** returns -1, if file cannot be opened
|
||||
** 0, if file opened
|
||||
*/
|
||||
|
||||
#define MAXCONFLINKS 150
|
||||
|
||||
static void ConvertConf(FILE* file,FILE *out)
|
||||
{
|
||||
char line[BUFSIZE];
|
||||
char quotedLine[BUFSIZE];
|
||||
char* p;
|
||||
|
||||
while (fgets(line, sizeof(line), file))
|
||||
{
|
||||
if ((p = strchr(line, '\n')))
|
||||
*p = '\0';
|
||||
|
||||
ReplaceQuotes(quotedLine,line);
|
||||
|
||||
if (!*quotedLine || quotedLine[0] == '#' || quotedLine[0] == '\n' ||
|
||||
quotedLine[0] == ' ' || quotedLine[0] == '\t')
|
||||
continue;
|
||||
|
||||
if(quotedLine[0] == '.')
|
||||
{
|
||||
char *filename;
|
||||
char *back;
|
||||
|
||||
if(!strncmp(quotedLine+1,"include ",8))
|
||||
{
|
||||
if( (filename = strchr(quotedLine+8,'"')) )
|
||||
filename++;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Bad config line: %s", quotedLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
if( (back = strchr(filename,'"')) )
|
||||
*back = '\0';
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Bad config line: %s", quotedLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Could we test if it's conf line at all? -Vesa */
|
||||
if (quotedLine[1] == ':')
|
||||
oldParseOneLine(out,quotedLine);
|
||||
|
||||
}
|
||||
|
||||
PrintOutServers(out);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
/*
|
||||
* ReplaceQuotes
|
||||
* Inputs - input line to quote
|
||||
* Output - quoted line
|
||||
* Side Effects - All quoted chars in input are replaced
|
||||
* with quoted values in output, # chars replaced with '\0'
|
||||
* otherwise input is copied to output.
|
||||
*/
|
||||
static void ReplaceQuotes(char* quotedLine,char *inputLine)
|
||||
{
|
||||
char *in;
|
||||
char *out;
|
||||
static char quotes[] = {
|
||||
0, /* */
|
||||
0, /* a */
|
||||
'\b', /* b */
|
||||
0, /* c */
|
||||
0, /* d */
|
||||
0, /* e */
|
||||
'\f', /* f */
|
||||
0, /* g */
|
||||
0, /* h */
|
||||
0, /* i */
|
||||
0, /* j */
|
||||
0, /* k */
|
||||
0, /* l */
|
||||
0, /* m */
|
||||
'\n', /* n */
|
||||
0, /* o */
|
||||
0, /* p */
|
||||
0, /* q */
|
||||
'\r', /* r */
|
||||
0, /* s */
|
||||
'\t', /* t */
|
||||
0, /* u */
|
||||
'\v', /* v */
|
||||
0, /* w */
|
||||
0, /* x */
|
||||
0, /* y */
|
||||
0, /* z */
|
||||
0,0,0,0,0,0
|
||||
};
|
||||
|
||||
/*
|
||||
* Do quoting of characters and # detection.
|
||||
*/
|
||||
for (out = quotedLine,in = inputLine; *in; out++, in++)
|
||||
{
|
||||
if (*in == '\\')
|
||||
{
|
||||
in++;
|
||||
if(*in == '\\')
|
||||
*out = '\\';
|
||||
else if(*in == '#')
|
||||
*out = '#';
|
||||
else
|
||||
*out = quotes[ (unsigned int) (*in & 0x1F) ];
|
||||
}
|
||||
else if (*in == '#')
|
||||
{
|
||||
*out = '\0';
|
||||
return;
|
||||
}
|
||||
else
|
||||
*out = *in;
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* oldParseOneLine
|
||||
* Inputs - pointer to line to parse
|
||||
* - pointer to output to write
|
||||
* Output -
|
||||
* Side Effects - Parse one old style conf line.
|
||||
*/
|
||||
|
||||
static void oldParseOneLine(FILE *out,char* line)
|
||||
{
|
||||
char conf_letter;
|
||||
char* tmp;
|
||||
char* user_field=(char *)NULL;
|
||||
char* passwd_field=(char *)NULL;
|
||||
char* host_field=(char *)NULL;
|
||||
char* port_field=(char *)NULL;
|
||||
char* class_field=(char *)NULL;
|
||||
struct ConnectPair* pair;
|
||||
int sendq = 0;
|
||||
int restricted;
|
||||
|
||||
tmp = getfield(line);
|
||||
|
||||
conf_letter = *tmp;
|
||||
|
||||
restricted = 0;
|
||||
for (;;) /* Fake loop, that I can use break here --msa */
|
||||
{
|
||||
/* host field */
|
||||
if ((host_field = getfield(NULL)) == NULL)
|
||||
return;
|
||||
|
||||
/* pass field */
|
||||
if ((passwd_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
/* user field */
|
||||
if ((user_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
/* port field */
|
||||
if ((port_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
/* class field */
|
||||
if ((class_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
}
|
||||
if (!passwd_field)
|
||||
passwd_field = "";
|
||||
if (!user_field)
|
||||
user_field = "";
|
||||
if (!port_field)
|
||||
port_field = "";
|
||||
if (!class_field)
|
||||
class_field = "";
|
||||
switch( conf_letter )
|
||||
{
|
||||
case 'A':case 'a': /* Name, e-mail address of administrator */
|
||||
fprintf(out,"administrator {\n");
|
||||
if(host_field)
|
||||
fprintf(out,"\tname=\"%s\";\n", passwd_field);
|
||||
if(user_field)
|
||||
fprintf(out,"\tdescription=\"%s\";\n", user_field);
|
||||
if(passwd_field)
|
||||
fprintf(out,"\temail=\"%s\";\n", host_field);
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
case 'C':
|
||||
pair = (struct ConnectPair *)malloc(sizeof(struct ConnectPair));
|
||||
memset(pair,0,sizeof(struct ConnectPair));
|
||||
if(user_field)
|
||||
pair->name = strdup(user_field);
|
||||
if(host_field)
|
||||
pair->host = strdup(host_field);
|
||||
if(passwd_field)
|
||||
pair->c_passwd = strdup(passwd_field);
|
||||
if(port_field)
|
||||
pair->port = atoi(port_field);
|
||||
if(class_field)
|
||||
pair->class = strdup(class_field);
|
||||
PairUpServers(pair);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
fprintf(out,"exempt {\n");
|
||||
if(user_field)
|
||||
fprintf(out,"\tip=\"%s\";\n", user_field);
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'D': /* Deny lines (immediate refusal) */
|
||||
fprintf(out,"deny {\n");
|
||||
if(host_field)
|
||||
fprintf(out,"\tip=\"%s\";\n", host_field);
|
||||
if(passwd_field)
|
||||
fprintf(out,"\treason=\"%s\";\n", passwd_field);
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'H': /* Hub server line */
|
||||
case 'h':
|
||||
AddHubOrLeaf(IS_HUB,user_field,host_field);
|
||||
break;
|
||||
|
||||
/* We no longer have restricted connection in Hybrid 7 */
|
||||
case 'i':
|
||||
case 'I':
|
||||
break;
|
||||
|
||||
case 'K': /* Kill user line on irc.conf */
|
||||
case 'k':
|
||||
fprintf(out,"kill {\n");
|
||||
if(host_field)
|
||||
fprintf(out,"\tuser=\"%s@%s\";\n", user_field,host_field);
|
||||
if(passwd_field)
|
||||
fprintf(out,"\treason=\"%s\";\n", passwd_field);
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'L': /* guaranteed leaf server */
|
||||
case 'l':
|
||||
AddHubOrLeaf(IS_LEAF,user_field,host_field);
|
||||
break;
|
||||
|
||||
/* Me. Host field is name used for this host */
|
||||
/* and port number is the number of the port */
|
||||
case 'M':
|
||||
case 'm':
|
||||
fprintf(out,"serverinfo {\n");
|
||||
if(host_field)
|
||||
fprintf(out,"\tname=\"%s\";\n", host_field);
|
||||
if(passwd_field)
|
||||
fprintf(out,"\tvhost=\"%s\";\n", passwd_field);
|
||||
if(user_field)
|
||||
fprintf(out,"\tdescription=\"%s\";\n", user_field);
|
||||
if(port_field)
|
||||
fprintf(out,"\thub=yes;\n");
|
||||
else
|
||||
fprintf(out,"\thub=no;\n");
|
||||
/* Also print a default servername/netname */
|
||||
fprintf(out, "\tnetwork_name=\"EFNet\";\n");
|
||||
fprintf(out, "\tnetwork_desc=\"Eris Free Network\";\n");
|
||||
fprintf(out, "\tmax_clients=1024;\n");
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
pair = (struct ConnectPair *)malloc(sizeof(struct ConnectPair));
|
||||
memset(pair,0,sizeof(struct ConnectPair));
|
||||
if(user_field)
|
||||
pair->name = strdup(user_field);
|
||||
if(host_field)
|
||||
pair->host = strdup(host_field);
|
||||
if(passwd_field)
|
||||
pair->n_passwd = strdup(passwd_field);
|
||||
pair->lazylink = 1;
|
||||
if(port_field)
|
||||
pair->port = atoi(port_field);
|
||||
if(class_field)
|
||||
pair->class = strdup(class_field);
|
||||
PairUpServers(pair);
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
pair = (struct ConnectPair *)malloc(sizeof(struct ConnectPair));
|
||||
memset(pair,0,sizeof(struct ConnectPair));
|
||||
if(user_field)
|
||||
pair->name = strdup(user_field);
|
||||
if(host_field)
|
||||
pair->host = strdup(host_field);
|
||||
if(passwd_field)
|
||||
pair->n_passwd = strdup(passwd_field);
|
||||
if(port_field)
|
||||
pair->port = atoi(port_field);
|
||||
if(class_field)
|
||||
pair->class = strdup(class_field);
|
||||
PairUpServers(pair);
|
||||
break;
|
||||
|
||||
/* Operator. Line should contain at least */
|
||||
/* password and host where connection is */
|
||||
/* Local operators no longer exist */
|
||||
/* For now, I don't force locals to have */
|
||||
/* certain default flags. I probably */
|
||||
/* should if there is no port field */
|
||||
case 'o':
|
||||
case 'O':
|
||||
/* defaults */
|
||||
fprintf(out,"operator {\n");
|
||||
if(user_field)
|
||||
fprintf(out,"\tname=\"%s\";\n", user_field);
|
||||
if(host_field)
|
||||
{
|
||||
fprintf(out,"\tuser=\"%s\";\n", host_field);
|
||||
}
|
||||
if(passwd_field)
|
||||
fprintf(out,"\tpassword=\"%s\";\n", passwd_field);
|
||||
if(port_field)
|
||||
OperPrivsFromString(out,port_field);
|
||||
if(class_field)
|
||||
fprintf(out,"\tclass=\"%s\";\n", class_field);
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'P': /* listen port line */
|
||||
case 'p':
|
||||
fprintf(out,"listen {\n");
|
||||
/* What is the purpose of this field? */
|
||||
if(host_field && *host_field)
|
||||
fprintf(out,"\tname=\"%s\";\n", host_field);
|
||||
if(port_field)
|
||||
fprintf(out,"\tport=%d;\n", atoi(port_field));
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'Q': /* reserved nicks */
|
||||
case 'q':
|
||||
if(host_field && (*host_field != '#'))
|
||||
{
|
||||
fprintf(out,"resv {\n");
|
||||
fprintf(out,"\tname=\"%s\";\n", host_field);
|
||||
}
|
||||
else
|
||||
{
|
||||
puts("Cannot convert a channel quarantine, skipping");
|
||||
break;
|
||||
}
|
||||
if(passwd_field)
|
||||
fprintf(out,"\treason=\"%s\";\n", passwd_field);
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
case 'u':
|
||||
fprintf(out,"shared {\n");
|
||||
if(host_field)
|
||||
fprintf(out,"\tname=\"%s\";\n", host_field);
|
||||
#if 0
|
||||
if(passwd_field)
|
||||
fprintf(out,"\treason=\"%s\";\n", passwd_field);
|
||||
#endif
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'X': /* rejected gecos */
|
||||
case 'x':
|
||||
fprintf(out,"gecos {\n");
|
||||
if(host_field)
|
||||
fprintf(out,"\tname=\"%s\";\n", host_field);
|
||||
if(passwd_field)
|
||||
fprintf(out,"\treason=\"%s\";\n", passwd_field);
|
||||
if(port_field)
|
||||
{
|
||||
if (*user_field == '0')
|
||||
fprintf(out,"\taction=reject;\n");
|
||||
else if (*user_field == '1')
|
||||
fprintf(out,"\taction=warn;\n");
|
||||
else
|
||||
fprintf(out, "\taction=silent;\n");
|
||||
}
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
case 'y':
|
||||
fprintf(out,"class {\n");
|
||||
if(host_field)
|
||||
fprintf(out,"\tname=\"%s\";\n", host_field);
|
||||
if(passwd_field)
|
||||
{
|
||||
int ping_time;
|
||||
ping_time = atoi(passwd_field);
|
||||
fprintf(out,"\tping_time=%d;\n", ping_time );
|
||||
}
|
||||
if(user_field)
|
||||
{
|
||||
/* Note that connectfreq and number_per_ip set the same variable
|
||||
** when read by the ircd. They *ARE* interchangable, just both
|
||||
** exist for the user's benefit
|
||||
*/
|
||||
int number_per_ip;
|
||||
number_per_ip = atoi(user_field);
|
||||
fprintf(out,"\tnumber_per_ip=%d;\n", number_per_ip );
|
||||
}
|
||||
if(port_field)
|
||||
{
|
||||
int max_number;
|
||||
max_number = atoi(port_field);
|
||||
fprintf(out,"\tmax_number=%d;\n", max_number );
|
||||
}
|
||||
if(class_field)
|
||||
sendq = atoi(class_field);
|
||||
fprintf(out,"\tsendq=%d;\n", sendq);
|
||||
fprintf(out,"};\n\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Error in config file: %s", line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* PrintOutServers
|
||||
*
|
||||
* In - FILE pointer
|
||||
* Out - NONE
|
||||
* Side Effects - Print out connect configurations
|
||||
*/
|
||||
static void PrintOutServers(FILE* out)
|
||||
{
|
||||
struct ConnectPair* p;
|
||||
|
||||
for(p = base_ptr; p; p = p->next)
|
||||
{
|
||||
if(p->name && p->c_passwd && p->n_passwd && p->host)
|
||||
{
|
||||
fprintf(out,"connect {\n");
|
||||
fprintf(out,"\thost=\"%s\";\n", p->host);
|
||||
fprintf(out,"\tname=\"%s\";\n", p->name);
|
||||
fprintf(out,"\tsend_password=\"%s\";\n", p->c_passwd);
|
||||
fprintf(out,"\taccept_password=\"%s\";\n", p->n_passwd);
|
||||
fprintf(out,"\tport=%d;\n", p->port );
|
||||
|
||||
#if 0
|
||||
/* ZIP links are gone */
|
||||
if(p->compressed)
|
||||
fprintf(out,"\tcompressed=yes;\n");
|
||||
#endif
|
||||
#if 0
|
||||
if(p->lazylink)
|
||||
fprintf(out,"\tlazylink=yes;\n");
|
||||
#endif
|
||||
if(p->hub_mask)
|
||||
{
|
||||
fprintf(out,"\thub_mask=\"%s\";\n",p->hub_mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p->leaf_mask)
|
||||
fprintf(out,"\tleaf_mask=\"%s\";\n",p->leaf_mask);
|
||||
}
|
||||
|
||||
if(p->class)
|
||||
fprintf(out,"\tclass=\"%s\";\n", p->class );
|
||||
|
||||
fprintf(out,"};\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* PairUpServers
|
||||
*
|
||||
* In - pointer to ConnectPair
|
||||
* Out - none
|
||||
* Side Effects - Pair up C/N lines on servers into one output
|
||||
*/
|
||||
static void PairUpServers(struct ConnectPair* pair)
|
||||
{
|
||||
struct ConnectPair *p;
|
||||
|
||||
for(p = base_ptr; p; p = p->next )
|
||||
{
|
||||
if(p->name && pair->name )
|
||||
{
|
||||
if( !strcasecmp(p->name,pair->name) )
|
||||
{
|
||||
if(!p->n_passwd && pair->n_passwd)
|
||||
p->n_passwd = strdup(pair->n_passwd);
|
||||
|
||||
if(!p->c_passwd && pair->c_passwd)
|
||||
p->c_passwd = strdup(pair->c_passwd);
|
||||
|
||||
p->compressed |= pair->compressed;
|
||||
p->lazylink |= pair->lazylink;
|
||||
|
||||
if(pair->port)
|
||||
p->port = pair->port;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(base_ptr)
|
||||
{
|
||||
pair->next = base_ptr;
|
||||
base_ptr = pair;
|
||||
}
|
||||
else
|
||||
base_ptr = pair;
|
||||
}
|
||||
|
||||
/*
|
||||
* AddHubOrLeaf
|
||||
*
|
||||
* In - type either IS_HUB or IS_LEAF
|
||||
* - name of leaf or hub
|
||||
* - mask
|
||||
* Out - none
|
||||
* Side Effects - Pair up hub or leaf with connect configuration
|
||||
*/
|
||||
static void AddHubOrLeaf(int type,char* name,char* host)
|
||||
{
|
||||
struct ConnectPair* p;
|
||||
struct ConnectPair* pair;
|
||||
|
||||
for(p = base_ptr; p; p = p->next )
|
||||
{
|
||||
if(p->name && name )
|
||||
{
|
||||
if( !strcasecmp(p->name,name) )
|
||||
{
|
||||
if(type == IS_HUB)
|
||||
p->hub_mask = strdup(host);
|
||||
|
||||
if(type == IS_LEAF)
|
||||
p->leaf_mask = strdup(host);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pair = (struct ConnectPair *)malloc(sizeof(struct ConnectPair));
|
||||
memset(pair,0,sizeof(struct ConnectPair));
|
||||
|
||||
pair->name = strdup(name);
|
||||
|
||||
if(type == IS_HUB)
|
||||
{
|
||||
pair->hub_mask = strdup(host);
|
||||
}
|
||||
else if(type == IS_LEAF)
|
||||
{
|
||||
pair->leaf_mask = strdup(host);
|
||||
}
|
||||
|
||||
if(base_ptr)
|
||||
{
|
||||
pair->next = base_ptr;
|
||||
base_ptr = pair;
|
||||
}
|
||||
else
|
||||
base_ptr = pair;
|
||||
}
|
||||
|
||||
/*
|
||||
* field breakup for ircd.conf file.
|
||||
*/
|
||||
static char *getfield(char *newline)
|
||||
{
|
||||
static char *line = (char *)NULL;
|
||||
char *end, *field;
|
||||
|
||||
if (newline)
|
||||
line = newline;
|
||||
|
||||
if (line == (char *)NULL)
|
||||
return((char *)NULL);
|
||||
|
||||
field = line;
|
||||
if ((end = strchr(line,':')) == NULL)
|
||||
{
|
||||
line = (char *)NULL;
|
||||
if ((end = strchr(field,'\n')) == (char *)NULL)
|
||||
end = field + strlen(field);
|
||||
}
|
||||
else
|
||||
line = end + 1;
|
||||
*end = '\0';
|
||||
return(field);
|
||||
}
|
||||
|
||||
/* OperPrivsFromString
|
||||
*
|
||||
* inputs - privs as string
|
||||
* output - none
|
||||
* side effects -
|
||||
*/
|
||||
|
||||
static void OperPrivsFromString(FILE* out, char *privs)
|
||||
{
|
||||
while(*privs)
|
||||
{
|
||||
/* If the priv is lower case, it defaults to whatever=no; anyway, so we dont need this? --fl */
|
||||
if(*privs == 'O') /* allow global kill */
|
||||
{
|
||||
fprintf(out,"\tglobal_kill=yes;\n");
|
||||
}
|
||||
else if(*privs == 'o') /* disallow global kill */
|
||||
{
|
||||
fprintf(out,"\tglobal_kill=no;\n");
|
||||
}
|
||||
else if(*privs == 'U') /* allow unkline */
|
||||
{
|
||||
fprintf(out,"\tunkline=yes;\n");
|
||||
}
|
||||
else if(*privs == 'u') /* disallow unkline */
|
||||
{
|
||||
fprintf(out,"\tunkline=no;\n");
|
||||
}
|
||||
else if(*privs == 'R') /* allow remote squit/connect etc.*/
|
||||
{
|
||||
fprintf(out,"\tremote=yes;\n");
|
||||
}
|
||||
else if(*privs == 'r') /* disallow remote squit/connect etc.*/
|
||||
{
|
||||
fprintf(out,"\tremote=no;\n");
|
||||
}
|
||||
else if(*privs == 'N') /* allow +n see nick changes */
|
||||
{
|
||||
fprintf(out,"\tnick_changes=yes;\n");
|
||||
}
|
||||
else if(*privs == 'K') /* allow kill and kline privs */
|
||||
{
|
||||
fprintf(out,"\tkline=yes;\n");
|
||||
}
|
||||
else if(*privs == 'k') /* disallow kill and kline privs */
|
||||
{
|
||||
fprintf(out,"\tkline=no;\n");
|
||||
}
|
||||
else if(*privs == 'G') /* allow gline */
|
||||
{
|
||||
fprintf(out,"\tgline=yes;\n");
|
||||
}
|
||||
else if(*privs == 'g') /* disallow gline */
|
||||
{
|
||||
fprintf(out,"\tgline=no;\n");
|
||||
}
|
||||
else if(*privs == 'H') /* allow rehash */
|
||||
{
|
||||
fprintf(out,"\trehash=yes;\n");
|
||||
}
|
||||
else if(*privs == 'h') /* disallow rehash */
|
||||
{
|
||||
fprintf(out,"\trehash=no;\n");
|
||||
}
|
||||
else if(*privs == 'D')
|
||||
{
|
||||
fprintf(out,"\tdie=yes;\n");
|
||||
}
|
||||
else if(*privs == 'd')
|
||||
{
|
||||
fprintf(out,"\tdie=no;\n");
|
||||
}
|
||||
privs++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,614 +0,0 @@
|
|||
/* tools/convertilines.c
|
||||
* Copyright (c) 2002 Hybrid Development Team
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1.Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2.Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3.The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: convertilines.c,v 1.2 2002/08/13 14:45:13 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BUFSIZE 512
|
||||
|
||||
struct AuthBlock
|
||||
{
|
||||
struct AuthBlock *next;
|
||||
|
||||
char **hostname;
|
||||
int hostnum;
|
||||
|
||||
char *spoof;
|
||||
char *passwd;
|
||||
int class;
|
||||
|
||||
int restricted;
|
||||
int exceed_limit;
|
||||
int kline_exempt;
|
||||
int gline_exempt;
|
||||
int require_ident;
|
||||
int no_tilde;
|
||||
|
||||
/* indicates one of above */
|
||||
int special;
|
||||
int specialk;
|
||||
};
|
||||
|
||||
static struct AuthBlock *auth_spoof = NULL;
|
||||
static struct AuthBlock *auth_special = NULL;
|
||||
static struct AuthBlock *auth_passwd = NULL;
|
||||
static struct AuthBlock *auth_general = NULL;
|
||||
static struct AuthBlock *auth_restricted = NULL;
|
||||
|
||||
static void ConvertConf(FILE* file,FILE *out);
|
||||
static void set_flags(struct AuthBlock *, const char *, const char *);
|
||||
static void usage();
|
||||
static char *getfield(char *);
|
||||
static struct AuthBlock *find_matching_conf(struct AuthBlock *);
|
||||
static void ReplaceQuotes(char *out, char *in);
|
||||
static void oldParseOneLine(FILE *out, char *in);
|
||||
static void write_auth_entries(FILE *out);
|
||||
static void write_specific(FILE *out, struct AuthBlock *);
|
||||
static int match(struct AuthBlock *, struct AuthBlock *);
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
FILE *in;
|
||||
FILE *out;
|
||||
|
||||
if(argc < 3)
|
||||
usage();
|
||||
|
||||
if((in = fopen(argv[1],"r")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Can't open %s for reading\n", argv[1]);
|
||||
usage();
|
||||
}
|
||||
|
||||
if((out = fopen(argv[2],"w")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Can't open %s for writing\n", argv[2]);
|
||||
usage();
|
||||
}
|
||||
|
||||
ConvertConf(in, out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
fprintf(stderr, "convertilines conf.old conf.new\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* ConvertConf()
|
||||
* Read configuration file.
|
||||
*
|
||||
*
|
||||
* Inputs - FILE* to config file to convert
|
||||
* - FILE* to output for new style conf
|
||||
*
|
||||
*/
|
||||
|
||||
#define MAXCONFLINKS 150
|
||||
|
||||
static void ConvertConf(FILE* file, FILE *out)
|
||||
{
|
||||
char line[BUFSIZE];
|
||||
char quotedLine[BUFSIZE];
|
||||
char* p;
|
||||
|
||||
while (fgets(line, sizeof(line), file))
|
||||
{
|
||||
if ((p = strchr(line, '\n')))
|
||||
*p = '\0';
|
||||
|
||||
ReplaceQuotes(quotedLine,line);
|
||||
|
||||
if(!*quotedLine || quotedLine[0] == '#' || quotedLine[0] == '\n' ||
|
||||
quotedLine[0] == ' ' || quotedLine[0] == '\t')
|
||||
continue;
|
||||
|
||||
if(quotedLine[0] == '.')
|
||||
{
|
||||
char *filename;
|
||||
char *back;
|
||||
|
||||
if(!strncmp(quotedLine+1,"include ",8))
|
||||
{
|
||||
if( (filename = strchr(quotedLine+8,'"')) )
|
||||
filename++;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Bad config line: %s", quotedLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
if((back = strchr(filename,'"')))
|
||||
*back = '\0';
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Bad config line: %s", quotedLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Could we test if it's conf line at all? -Vesa */
|
||||
if (quotedLine[1] == ':')
|
||||
oldParseOneLine(out,quotedLine);
|
||||
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
write_auth_entries(out);
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
/*
|
||||
* ReplaceQuotes
|
||||
* Inputs - input line to quote
|
||||
* Output - quoted line
|
||||
* Side Effects - All quoted chars in input are replaced
|
||||
* with quoted values in output, # chars replaced with '\0'
|
||||
* otherwise input is copied to output.
|
||||
*/
|
||||
static void ReplaceQuotes(char* quotedLine,char *inputLine)
|
||||
{
|
||||
char *in;
|
||||
char *out;
|
||||
static char quotes[] = {
|
||||
0, /* */
|
||||
0, /* a */
|
||||
'\b', /* b */
|
||||
0, /* c */
|
||||
0, /* d */
|
||||
0, /* e */
|
||||
'\f', /* f */
|
||||
0, /* g */
|
||||
0, /* h */
|
||||
0, /* i */
|
||||
0, /* j */
|
||||
0, /* k */
|
||||
0, /* l */
|
||||
0, /* m */
|
||||
'\n', /* n */
|
||||
0, /* o */
|
||||
0, /* p */
|
||||
0, /* q */
|
||||
'\r', /* r */
|
||||
0, /* s */
|
||||
'\t', /* t */
|
||||
0, /* u */
|
||||
'\v', /* v */
|
||||
0, /* w */
|
||||
0, /* x */
|
||||
0, /* y */
|
||||
0, /* z */
|
||||
0,0,0,0,0,0
|
||||
};
|
||||
|
||||
/*
|
||||
* Do quoting of characters and # detection.
|
||||
*/
|
||||
for (out = quotedLine,in = inputLine; *in; out++, in++)
|
||||
{
|
||||
if (*in == '\\')
|
||||
{
|
||||
in++;
|
||||
if(*in == '\\')
|
||||
*out = '\\';
|
||||
else if(*in == '#')
|
||||
*out = '#';
|
||||
else
|
||||
*out = quotes[ (unsigned int) (*in & 0x1F) ];
|
||||
}
|
||||
else if (*in == '#')
|
||||
{
|
||||
*out = '\0';
|
||||
return;
|
||||
}
|
||||
else
|
||||
*out = *in;
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* oldParseOneLine
|
||||
* Inputs - pointer to line to parse
|
||||
* - pointer to output to write
|
||||
* Output -
|
||||
* Side Effects - Parse one old style conf line.
|
||||
*/
|
||||
|
||||
static void oldParseOneLine(FILE *out,char* line)
|
||||
{
|
||||
char conf_letter;
|
||||
char* tmp;
|
||||
char* host_field=(char *)NULL;
|
||||
char* passwd_field=(char *)NULL;
|
||||
char* user_field=(char *)NULL;
|
||||
char* port_field = NULL;
|
||||
char* classconf_field = NULL;
|
||||
int class_field = 0;
|
||||
|
||||
tmp = getfield(line);
|
||||
|
||||
conf_letter = *tmp;
|
||||
|
||||
for (;;) /* Fake loop, that I can use break here --msa */
|
||||
{
|
||||
/* host field */
|
||||
if ((host_field = getfield(NULL)) == NULL)
|
||||
return;
|
||||
|
||||
/* pass field */
|
||||
if ((passwd_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
/* user field */
|
||||
if ((user_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
/* port field */
|
||||
if ((port_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
/* class field */
|
||||
if ((classconf_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!passwd_field)
|
||||
passwd_field = "";
|
||||
if (!user_field)
|
||||
user_field = "";
|
||||
if (!port_field)
|
||||
port_field = "";
|
||||
if (classconf_field)
|
||||
class_field = atoi(classconf_field);
|
||||
|
||||
switch( conf_letter )
|
||||
{
|
||||
case 'i':
|
||||
case 'I':
|
||||
{
|
||||
struct AuthBlock *ptr;
|
||||
struct AuthBlock *tempptr;
|
||||
|
||||
tempptr = malloc(sizeof(struct AuthBlock));
|
||||
memset(tempptr, 0, sizeof(*tempptr));
|
||||
|
||||
if(conf_letter == 'i')
|
||||
{
|
||||
tempptr->restricted = 1;
|
||||
tempptr->specialk = 1;
|
||||
}
|
||||
|
||||
if(passwd_field && *passwd_field)
|
||||
tempptr->passwd = strdup(passwd_field);
|
||||
|
||||
tempptr->class = class_field;
|
||||
|
||||
set_flags(tempptr, user_field, host_field);
|
||||
|
||||
/* dont add specials/passworded ones to existing auth blocks */
|
||||
if((ptr = find_matching_conf(tempptr)))
|
||||
{
|
||||
int authindex;
|
||||
|
||||
authindex = ptr->hostnum;
|
||||
ptr->hostnum++;
|
||||
|
||||
ptr->hostname = realloc((void *)ptr->hostname, ptr->hostnum * sizeof(void *));
|
||||
|
||||
ptr->hostname[authindex] = strdup(tempptr->hostname[0]);
|
||||
|
||||
free(tempptr->hostname[0]);
|
||||
free(tempptr->hostname);
|
||||
free(tempptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = tempptr;
|
||||
|
||||
if(ptr->spoof)
|
||||
{
|
||||
ptr->next = auth_spoof;
|
||||
auth_spoof = ptr;
|
||||
}
|
||||
else if(ptr->special)
|
||||
{
|
||||
ptr->next = auth_special;
|
||||
auth_special = ptr;
|
||||
}
|
||||
else if(ptr->passwd)
|
||||
{
|
||||
ptr->next = auth_passwd;
|
||||
auth_passwd = ptr;
|
||||
}
|
||||
else if(ptr->specialk)
|
||||
{
|
||||
ptr->next = auth_restricted;
|
||||
auth_restricted = ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr->next = auth_general;
|
||||
auth_general = ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void write_auth_entries(FILE *out)
|
||||
{
|
||||
struct AuthBlock *ptr;
|
||||
|
||||
for(ptr = auth_spoof; ptr; ptr = ptr->next)
|
||||
write_specific(out, ptr);
|
||||
|
||||
for(ptr = auth_special; ptr; ptr = ptr->next)
|
||||
write_specific(out, ptr);
|
||||
|
||||
for(ptr = auth_passwd; ptr; ptr = ptr->next)
|
||||
write_specific(out, ptr);
|
||||
|
||||
for(ptr = auth_general; ptr; ptr = ptr->next)
|
||||
write_specific(out, ptr);
|
||||
|
||||
for(ptr = auth_restricted; ptr; ptr = ptr->next)
|
||||
write_specific(out, ptr);
|
||||
}
|
||||
|
||||
|
||||
static void write_specific(FILE *out, struct AuthBlock *ptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(out, "auth {\n");
|
||||
|
||||
for(i = 0; i < ptr->hostnum; i++)
|
||||
fprintf(out, "\tuser = \"%s\";\n", ptr->hostname[i]);
|
||||
|
||||
if(ptr->spoof)
|
||||
fprintf(out, "\tspoof = \"%s\";\n", ptr->spoof);
|
||||
|
||||
if(ptr->passwd)
|
||||
fprintf(out, "\tpassword = \"%s\";\n", ptr->passwd);
|
||||
|
||||
if(ptr->exceed_limit)
|
||||
fprintf(out, "\texceed_limit = yes;\n");
|
||||
|
||||
if(ptr->kline_exempt)
|
||||
fprintf(out, "\tkline_exempt = yes;\n");
|
||||
|
||||
if(ptr->gline_exempt)
|
||||
fprintf(out, "\tgline_exempt = yes;\n");
|
||||
|
||||
if(ptr->no_tilde)
|
||||
fprintf(out, "\tno_tilde = yes;\n");
|
||||
|
||||
if(ptr->require_ident)
|
||||
fprintf(out, "\thave_ident = yes;\n");
|
||||
|
||||
if(ptr->restricted)
|
||||
fprintf(out, "\trestricted = yes;\n");
|
||||
|
||||
fprintf(out, "\tclass = \"%d\";\n", ptr->class);
|
||||
fprintf(out, "}\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* field breakup for ircd.conf file.
|
||||
*/
|
||||
static char *getfield(char *newline)
|
||||
{
|
||||
static char *line = (char *)NULL;
|
||||
char *end, *field;
|
||||
|
||||
if (newline)
|
||||
line = newline;
|
||||
|
||||
if (line == (char *)NULL)
|
||||
return((char *)NULL);
|
||||
|
||||
field = line;
|
||||
if ((end = strchr(line,':')) == NULL)
|
||||
{
|
||||
line = (char *)NULL;
|
||||
if ((end = strchr(field,'\n')) == (char *)NULL)
|
||||
end = field + strlen(field);
|
||||
}
|
||||
else
|
||||
line = end + 1;
|
||||
*end = '\0';
|
||||
return(field);
|
||||
}
|
||||
|
||||
struct AuthBlock *find_matching_conf(struct AuthBlock *acptr)
|
||||
{
|
||||
struct AuthBlock *ptr;
|
||||
|
||||
for(ptr = auth_spoof; ptr; ptr = ptr->next)
|
||||
{
|
||||
if(match(ptr, acptr))
|
||||
return ptr;
|
||||
}
|
||||
|
||||
for(ptr = auth_special; ptr; ptr = ptr->next)
|
||||
{
|
||||
if(match(ptr, acptr))
|
||||
return ptr;
|
||||
}
|
||||
|
||||
for(ptr = auth_passwd; ptr; ptr = ptr->next)
|
||||
{
|
||||
if(match(ptr, acptr))
|
||||
return ptr;
|
||||
}
|
||||
|
||||
for(ptr = auth_restricted; ptr; ptr = ptr->next)
|
||||
{
|
||||
if(match(ptr, acptr))
|
||||
return ptr;
|
||||
}
|
||||
|
||||
for(ptr = auth_general; ptr; ptr = ptr->next)
|
||||
{
|
||||
if(match(ptr, acptr))
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int match(struct AuthBlock *ptr, struct AuthBlock *acptr)
|
||||
{
|
||||
if((ptr->class == acptr->class) &&
|
||||
(ptr->restricted == acptr->restricted) &&
|
||||
(ptr->require_ident == acptr->require_ident) &&
|
||||
(ptr->exceed_limit == acptr->exceed_limit) &&
|
||||
(ptr->kline_exempt == acptr->kline_exempt) &&
|
||||
(ptr->gline_exempt == acptr->gline_exempt) &&
|
||||
(ptr->no_tilde == acptr->no_tilde))
|
||||
{
|
||||
char *p1, *p2;
|
||||
|
||||
/* check the spoofs match.. */
|
||||
if(ptr->spoof)
|
||||
p1 = ptr->spoof;
|
||||
else
|
||||
p1 = "";
|
||||
|
||||
if(acptr->spoof)
|
||||
p2 = acptr->spoof;
|
||||
else
|
||||
p2 = "";
|
||||
|
||||
if(strcmp(p1, p2))
|
||||
return 0;
|
||||
|
||||
/* now check the passwords match.. */
|
||||
if(ptr->passwd)
|
||||
p1 = ptr->passwd;
|
||||
else
|
||||
p1 = "";
|
||||
|
||||
if(acptr->passwd)
|
||||
p2 = acptr->passwd;
|
||||
else
|
||||
p2 = "";
|
||||
|
||||
if(strcmp(p1, p2))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_flags(struct AuthBlock *ptr, const char *user_field, const char *host_field)
|
||||
{
|
||||
for(; *user_field; user_field++)
|
||||
{
|
||||
switch(*user_field)
|
||||
{
|
||||
case '=':
|
||||
if(host_field)
|
||||
ptr->spoof = strdup(host_field);
|
||||
|
||||
ptr->special = 1;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
ptr->no_tilde = 1;
|
||||
ptr->special = 1;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
ptr->require_ident = 1;
|
||||
ptr->specialk = 1;
|
||||
break;
|
||||
|
||||
case '^': /* is exempt from k/g lines */
|
||||
ptr->kline_exempt = 1;
|
||||
ptr->special = 1;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
ptr->exceed_limit = 1;
|
||||
ptr->special = 1;
|
||||
break;
|
||||
|
||||
case '_':
|
||||
ptr->gline_exempt = 1;
|
||||
ptr->special = 1;
|
||||
break;
|
||||
|
||||
case '!':
|
||||
case '$':
|
||||
case '%':
|
||||
case '&':
|
||||
case '<':
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
int authindex;
|
||||
authindex = ptr->hostnum;
|
||||
ptr->hostnum++;
|
||||
|
||||
ptr->hostname = realloc((void *)ptr->hostname, ptr->hostnum * sizeof(void *));
|
||||
|
||||
/* if the IP field contains something useful, use that */
|
||||
if(strcmp(host_field, "NOMATCH") && (*host_field != 'x') &&
|
||||
strcmp(host_field, "*") && !ptr->spoof)
|
||||
ptr->hostname[authindex] = strdup(host_field);
|
||||
else
|
||||
ptr->hostname[authindex] = strdup(user_field);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,305 +0,0 @@
|
|||
/************************************************************************
|
||||
* IRC - Internet Relay Chat, tools/convertklines.c
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 1, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: convertklines.c,v 1.2 2002/08/13 14:45:13 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BUFSIZE 512
|
||||
|
||||
static void ConvertConf(FILE* file,FILE *outkline, FILE *outdline);
|
||||
static void usage(void);
|
||||
static char *getfield(char *);
|
||||
static void ReplaceQuotes(char *out, char *in);
|
||||
static void parse(FILE *outkline, FILE *outdline, char *in);
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
FILE *in;
|
||||
FILE *outkline;
|
||||
FILE *outdline;
|
||||
|
||||
if(argc < 4)
|
||||
usage();
|
||||
|
||||
if (( in = fopen(argv[1],"r")) == NULL )
|
||||
{
|
||||
fprintf(stderr,"Can't open %s for reading\n", argv[1]);
|
||||
usage();
|
||||
}
|
||||
|
||||
if (( outkline = fopen(argv[2],"w")) == NULL )
|
||||
{
|
||||
fprintf(stderr,"Can't open %s for writing\n", argv[2]);
|
||||
usage();
|
||||
}
|
||||
|
||||
if(( outdline = fopen(argv[3], "w")) == NULL )
|
||||
{
|
||||
fprintf(stderr, "Can't open %s for writing\n", argv[3]);
|
||||
usage();
|
||||
}
|
||||
|
||||
ConvertConf(in, outkline, outdline);
|
||||
|
||||
fprintf(stderr, "The kline file has been converted and should be renamed to\n");
|
||||
fprintf(stderr, "the config.h options (normally kline.conf and dline.conf) and\n");
|
||||
fprintf(stderr, "placed in your etc/ dir\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void usage()
|
||||
{
|
||||
fprintf(stderr, "klines and dlines now go in separate files:\n");
|
||||
fprintf(stderr,"convertklines kline.conf.old kline.conf.new dline.conf.new\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ConvertConf()
|
||||
* Read configuration file.
|
||||
*
|
||||
*
|
||||
* inputs - FILE* to config file to convert
|
||||
* - FILE* to output for new klines
|
||||
* - FILE* to output for new dlines
|
||||
* outputs - -1 if the file cannot be opened
|
||||
* - 0 otherwise
|
||||
*/
|
||||
|
||||
static void ConvertConf(FILE* file, FILE *outkline, FILE *outdline)
|
||||
{
|
||||
char line[BUFSIZE];
|
||||
char quotedLine[BUFSIZE];
|
||||
char* p;
|
||||
|
||||
while (fgets(line, sizeof(line), file))
|
||||
{
|
||||
if ((p = strchr(line, '\n')))
|
||||
*p = '\0';
|
||||
|
||||
ReplaceQuotes(quotedLine,line);
|
||||
|
||||
if (!*quotedLine || quotedLine[0] == '#' || quotedLine[0] == '\n' ||
|
||||
quotedLine[0] == ' ' || quotedLine[0] == '\t')
|
||||
continue;
|
||||
|
||||
/* Could we test if it's conf line at all? -Vesa */
|
||||
if (quotedLine[1] == ':')
|
||||
{
|
||||
parse(outkline, outdline, quotedLine);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
/*
|
||||
* ReplaceQuotes
|
||||
* Inputs - input line to quote
|
||||
* Output - quoted line
|
||||
* Side Effects - All quoted chars in input are replaced
|
||||
* with quoted values in output, # chars replaced with '\0'
|
||||
* otherwise input is copied to output.
|
||||
*/
|
||||
static void ReplaceQuotes(char* quotedLine,char *inputLine)
|
||||
{
|
||||
char *in;
|
||||
char *out;
|
||||
static char quotes[] = {
|
||||
0, /* */
|
||||
0, /* a */
|
||||
'\b', /* b */
|
||||
0, /* c */
|
||||
0, /* d */
|
||||
0, /* e */
|
||||
'\f', /* f */
|
||||
0, /* g */
|
||||
0, /* h */
|
||||
0, /* i */
|
||||
0, /* j */
|
||||
0, /* k */
|
||||
0, /* l */
|
||||
0, /* m */
|
||||
'\n', /* n */
|
||||
0, /* o */
|
||||
0, /* p */
|
||||
0, /* q */
|
||||
'\r', /* r */
|
||||
0, /* s */
|
||||
'\t', /* t */
|
||||
0, /* u */
|
||||
'\v', /* v */
|
||||
0, /* w */
|
||||
0, /* x */
|
||||
0, /* y */
|
||||
0, /* z */
|
||||
0,0,0,0,0,0
|
||||
};
|
||||
|
||||
/*
|
||||
* Do quoting of characters and # detection.
|
||||
*/
|
||||
for (out = quotedLine,in = inputLine; *in; out++, in++)
|
||||
{
|
||||
if (*in == '\\')
|
||||
{
|
||||
in++;
|
||||
if(*in == '\\')
|
||||
*out = '\\';
|
||||
else if(*in == '#')
|
||||
*out = '#';
|
||||
else
|
||||
*out = quotes[ (unsigned int) (*in & 0x1F) ];
|
||||
}
|
||||
else if (*in == '#')
|
||||
{
|
||||
*out = '\0';
|
||||
return;
|
||||
}
|
||||
else
|
||||
*out = *in;
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* parse()
|
||||
* Inputs - pointer to line to parse
|
||||
* - pointer to output to write
|
||||
* Output -
|
||||
* Side Effects - Parse one old style conf line.
|
||||
*/
|
||||
|
||||
static void parse(FILE *outkline, FILE *outdline, char* line)
|
||||
{
|
||||
char conf_letter;
|
||||
char *tmp;
|
||||
char *user_field = NULL;
|
||||
char *passwd_field = NULL;
|
||||
char *host_field = NULL;
|
||||
char *operpasswd_field = NULL;
|
||||
|
||||
tmp = getfield(line);
|
||||
|
||||
conf_letter = *tmp;
|
||||
|
||||
for (;;) /* Fake loop, that I can use break here --msa */
|
||||
{
|
||||
/* host field */
|
||||
if ((host_field = getfield(NULL)) == NULL)
|
||||
return;
|
||||
|
||||
/* pass field */
|
||||
if ((passwd_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
else
|
||||
{
|
||||
/* if theres a password, try splitting the operreason out */
|
||||
char *p;
|
||||
|
||||
if((p = strchr(passwd_field, '|')))
|
||||
{
|
||||
*p++ = '\0';
|
||||
operpasswd_field = p;
|
||||
}
|
||||
else
|
||||
operpasswd_field = "";
|
||||
}
|
||||
|
||||
/* user field */
|
||||
if ((user_field = getfield(NULL)) == NULL)
|
||||
break;
|
||||
|
||||
/* what could possibly be after a userfield? */
|
||||
break;
|
||||
}
|
||||
|
||||
if (!passwd_field)
|
||||
{
|
||||
passwd_field = "";
|
||||
operpasswd_field = "";
|
||||
}
|
||||
|
||||
if (!user_field)
|
||||
user_field = "";
|
||||
|
||||
switch( conf_letter )
|
||||
{
|
||||
case 'd':
|
||||
fprintf(stderr, "exempt in old file, ignoring.\n");
|
||||
break;
|
||||
|
||||
case 'D': /* Deny lines (immediate refusal) */
|
||||
if(host_field && passwd_field)
|
||||
fprintf(outdline, "\"%s\",\"%s\",\"%s\",\"\",\"Unknown\",0\n",
|
||||
host_field, passwd_field, operpasswd_field);
|
||||
break;
|
||||
|
||||
case 'K': /* Kill user line on irc.conf */
|
||||
case 'k':
|
||||
if(host_field && passwd_field && user_field)
|
||||
fprintf(outkline, "\"%s\",\"%s\",\"%s\",\"%s\",\"\",\"Unknown\",0\n",
|
||||
user_field, host_field, passwd_field, operpasswd_field);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Error in config file: %s", line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* field breakup for ircd.conf file.
|
||||
*/
|
||||
static char *getfield(char *newline)
|
||||
{
|
||||
static char *line = NULL;
|
||||
char *end, *field;
|
||||
|
||||
if (newline)
|
||||
line = newline;
|
||||
|
||||
if (line == NULL)
|
||||
{
|
||||
fprintf(stderr, "returned null!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
field = line;
|
||||
|
||||
if ((end = strchr(line,':')) == NULL)
|
||||
{
|
||||
line = (char *)NULL;
|
||||
if ((end = strchr(field,'\n')) == NULL)
|
||||
end = field + strlen(field);
|
||||
}
|
||||
else
|
||||
line = end + 1;
|
||||
|
||||
*end = '\0';
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
|
Reference in a new issue