Some fixes
This commit is contained in:
parent
c6b81401db
commit
01aa19f354
@ -549,8 +549,6 @@ void chat_put_r(char *data, char *buf)
|
|||||||
owner = TRUE;
|
owner = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Syslog('c', "IBC: process command, in channel %s and we are %sthe owner",
|
|
||||||
usr_list[i].channel, owner ? "":"not ");
|
|
||||||
}
|
}
|
||||||
if (strncasecmp(msg, "/help", 5) == 0) {
|
if (strncasecmp(msg, "/help", 5) == 0) {
|
||||||
chat_help(pid, owner);
|
chat_help(pid, owner);
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
extern int internet; /* Internet status */
|
extern int internet; /* Internet status */
|
||||||
time_t scfg_time = (time_t)0; /* Servers config time */
|
time_t scfg_time = (time_t)0; /* Servers config time */
|
||||||
time_t now; /* Current time */
|
time_t now; /* Current time */
|
||||||
ban_list *banned = NULL; /* Banned users */
|
|
||||||
nick_list *nicknames = NULL; /* Known nicknames */
|
|
||||||
int callchg = FALSE; /* Is call state changed */
|
int callchg = FALSE; /* Is call state changed */
|
||||||
int srvchg = FALSE; /* Is serverlist changed */
|
int srvchg = FALSE; /* Is serverlist changed */
|
||||||
int usrchg = FALSE; /* Is userlist changed */
|
int usrchg = FALSE; /* Is userlist changed */
|
||||||
@ -169,8 +167,8 @@ void dump_ncslist(void)
|
|||||||
for (i = 0; i < MAXIBC_SRV; i++) {
|
for (i = 0; i < MAXIBC_SRV; i++) {
|
||||||
if (strlen(srv_list[i].server)) {
|
if (strlen(srv_list[i].server)) {
|
||||||
if (! first) {
|
if (! first) {
|
||||||
Syslog('+', "IBC: Idx Server Router Hops Users Connect time");
|
Syslog('+', "IBC: Idx Server Router Hops User Connect time");
|
||||||
Syslog('+', "IBC: --- ------------------------- ------------------------- ----- ----- --------------------");
|
Syslog('+', "IBC: --- ------------------------- ------------------------- ---- ---- --------------------");
|
||||||
first = TRUE;
|
first = TRUE;
|
||||||
}
|
}
|
||||||
snprintf(temp1, 25, "%s", srv_list[i].server);
|
snprintf(temp1, 25, "%s", srv_list[i].server);
|
||||||
@ -179,7 +177,7 @@ void dump_ncslist(void)
|
|||||||
localtime_r(&tnow, &ptm);
|
localtime_r(&tnow, &ptm);
|
||||||
snprintf(buf, 21, "%02d-%s-%04d %02d:%02d:%02d", ptm.tm_mday, mon[ptm.tm_mon], ptm.tm_year+1900,
|
snprintf(buf, 21, "%02d-%s-%04d %02d:%02d:%02d", ptm.tm_mday, mon[ptm.tm_mon], ptm.tm_year+1900,
|
||||||
ptm.tm_hour, ptm.tm_min, ptm.tm_sec);
|
ptm.tm_hour, ptm.tm_min, ptm.tm_sec);
|
||||||
Syslog('+', "IBC: %3d %-25s %-25s %5d %5d %s", i, temp1, temp2, srv_list[i].hops, srv_list[i].users, buf);
|
Syslog('+', "IBC: %3d %-25s %-25s %4d %4d %s", i, temp1, temp2, srv_list[i].hops, srv_list[i].users, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! first) {
|
if (! first) {
|
||||||
@ -1149,6 +1147,7 @@ int command_server(char *hostname, char *parameters)
|
|||||||
* If the user is one of our own and has set a channel topic, send it.
|
* If the user is one of our own and has set a channel topic, send it.
|
||||||
*/
|
*/
|
||||||
for (j = 0; j < MAXIBC_USR; j++) {
|
for (j = 0; j < MAXIBC_USR; j++) {
|
||||||
|
if (strlen(usr_list[j].server)) {
|
||||||
snprintf(p, 512, "USER %s@%s %s\r\n", usr_list[j].name, usr_list[j].server, usr_list[j].realname);
|
snprintf(p, 512, "USER %s@%s %s\r\n", usr_list[j].name, usr_list[j].server, usr_list[j].realname);
|
||||||
send_msg(i, p);
|
send_msg(i, p);
|
||||||
if (strcmp(usr_list[j].name, usr_list[j].nick)) {
|
if (strcmp(usr_list[j].name, usr_list[j].nick)) {
|
||||||
@ -1161,6 +1160,7 @@ int command_server(char *hostname, char *parameters)
|
|||||||
send_msg(i, p);
|
send_msg(i, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
free(p);
|
free(p);
|
||||||
for (j = 0; j < MAXIBC_CHN; j++) {
|
for (j = 0; j < MAXIBC_CHN; j++) {
|
||||||
if (strlen(chn_list[j].topic) && (strcmp(chn_list[j].server, CFG.myfqdn) == 0)) {
|
if (strlen(chn_list[j].topic) && (strcmp(chn_list[j].server, CFG.myfqdn) == 0)) {
|
||||||
@ -1288,7 +1288,7 @@ int command_quit(int slot, char *hostname, char *parameters)
|
|||||||
int command_nick(int slot, char *hostname, char *parameters)
|
int command_nick(int slot, char *hostname, char *parameters)
|
||||||
{
|
{
|
||||||
char *p, *nick, *name, *server, *realname;
|
char *p, *nick, *name, *server, *realname;
|
||||||
int i, found;
|
int i, found, nickerror = FALSE;
|
||||||
|
|
||||||
nick = strtok(parameters, " \0");
|
nick = strtok(parameters, " \0");
|
||||||
name = strtok(NULL, " \0");
|
name = strtok(NULL, " \0");
|
||||||
@ -1300,7 +1300,25 @@ int command_nick(int slot, char *hostname, char *parameters)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check nickname syntax, max 9 characters, first is alpha, rest alpha or digits.
|
||||||
|
*/
|
||||||
if (strlen(nick) > 9) {
|
if (strlen(nick) > 9) {
|
||||||
|
nickerror = TRUE;
|
||||||
|
}
|
||||||
|
if (! nickerror) {
|
||||||
|
if (! isalpha(nick[0]))
|
||||||
|
nickerror = TRUE;
|
||||||
|
}
|
||||||
|
if (! nickerror) {
|
||||||
|
for (i = 1; i < strlen(nick); i++) {
|
||||||
|
if (! isalnum(nick[i])) {
|
||||||
|
nickerror = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nickerror) {
|
||||||
p = calloc(81, sizeof(char));
|
p = calloc(81, sizeof(char));
|
||||||
snprintf(p, 81, "402 %s: Erroneous nickname\r\n", nick);
|
snprintf(p, 81, "402 %s: Erroneous nickname\r\n", nick);
|
||||||
send_msg(slot, p);
|
send_msg(slot, p);
|
||||||
@ -1308,8 +1326,6 @@ int command_nick(int slot, char *hostname, char *parameters)
|
|||||||
return 402;
|
return 402;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: check 1st char is alpha, rest alpha/digit
|
|
||||||
|
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
for (i = 0; i < MAXIBC_USR; i++) {
|
for (i = 0; i < MAXIBC_USR; i++) {
|
||||||
if ((strcmp(usr_list[i].name, nick) == 0) || (strcmp(usr_list[i].nick, nick) == 0)) {
|
if ((strcmp(usr_list[i].name, nick) == 0) || (strcmp(usr_list[i].nick, nick) == 0)) {
|
||||||
@ -1752,6 +1768,8 @@ void ibc_init(void)
|
|||||||
{
|
{
|
||||||
memset(&ncs_list, 0, sizeof(ncs_list));
|
memset(&ncs_list, 0, sizeof(ncs_list));
|
||||||
memset(&srv_list, 0, sizeof(srv_list));
|
memset(&srv_list, 0, sizeof(srv_list));
|
||||||
|
memset(&usr_list, 0, sizeof(usr_list));
|
||||||
|
memset(&chn_list, 0, sizeof(chn_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1763,12 +1781,12 @@ void ibc_shutdown(void)
|
|||||||
|
|
||||||
Syslog('r', "IBC: start shutdown connections");
|
Syslog('r', "IBC: start shutdown connections");
|
||||||
|
|
||||||
|
p = calloc(512, sizeof(char));
|
||||||
for (i = 0; i < MAXIBC_USR; i++) {
|
for (i = 0; i < MAXIBC_USR; i++) {
|
||||||
if (strcmp(usr_list[i].server, CFG.myfqdn) == 0) {
|
if (strcmp(usr_list[i].server, CFG.myfqdn) == 0) {
|
||||||
/*
|
/*
|
||||||
* Our user, still connected
|
* Our user, still connected
|
||||||
*/
|
*/
|
||||||
p = calloc(512, sizeof(char));
|
|
||||||
if (strlen(usr_list[i].channel) && strcmp(usr_list[i].channel, "#sysop")) {
|
if (strlen(usr_list[i].channel) && strcmp(usr_list[i].channel, "#sysop")) {
|
||||||
/*
|
/*
|
||||||
* In a channel
|
* In a channel
|
||||||
@ -1778,11 +1796,9 @@ void ibc_shutdown(void)
|
|||||||
}
|
}
|
||||||
snprintf(p, 512, "QUIT %s@%s System shutdown\r\n", usr_list[i].nick, usr_list[i].server);
|
snprintf(p, 512, "QUIT %s@%s System shutdown\r\n", usr_list[i].nick, usr_list[i].server);
|
||||||
broadcast((char *)"foobar", p);
|
broadcast((char *)"foobar", p);
|
||||||
free(p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p = calloc(512, sizeof(char));
|
|
||||||
for (i = 0; i < MAXIBC_NCS; i++) {
|
for (i = 0; i < MAXIBC_NCS; i++) {
|
||||||
if (strlen(ncs_list[i].server) && ncs_list[i].state == NCS_CONNECT) {
|
if (strlen(ncs_list[i].server) && ncs_list[i].state == NCS_CONNECT) {
|
||||||
snprintf(p, 512, "SQUIT %s System shutdown\r\n", ncs_list[i].myname);
|
snprintf(p, 512, "SQUIT %s System shutdown\r\n", ncs_list[i].myname);
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#define MAXIBC_NCS 20 /* Maximum Neighbour ChatServers */
|
#define MAXIBC_NCS 50 /* Maximum Neighbour ChatServers */
|
||||||
#define MAXIBC_SRV 100 /* Maximum Servers in chatnetwork */
|
#define MAXIBC_SRV 200 /* Maximum Servers in chatnetwork */
|
||||||
#define MAXIBC_USR 100 /* Maximum Users in chatnetwork */
|
#define MAXIBC_USR 500 /* Maximum Users in chatnetwork */
|
||||||
#define MAXIBC_CHN 100 /* Maximum Channels in chatnetwork */
|
#define MAXIBC_CHN 200 /* Maximum Channels in chatnetwork */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,27 +93,27 @@ _chn_list chn_list[MAXIBC_CHN];
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Database with banned users
|
* Database with banned users (not yet in use)
|
||||||
*/
|
*/
|
||||||
typedef struct _ban_list {
|
//typedef struct _ban_rec {
|
||||||
struct _ban_list *next;
|
// char server[64]; /* Users server */
|
||||||
char name[10]; /* Users name */
|
// char name[10]; /* Users name */
|
||||||
char server[64]; /* Users server */
|
// char channel[21]; /* Users banned channel */
|
||||||
char channel[21]; /* Users banned channel */
|
// time_t kicked; /* Users banned time */
|
||||||
time_t kicked; /* Users banned time */
|
//} _ban_list;
|
||||||
} ban_list;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Database with nicknames
|
* Database with nicknames (not yet in use)
|
||||||
*/
|
*/
|
||||||
typedef struct _nick_list {
|
//typedef struct _nick_rec {
|
||||||
struct _nick_list *next;
|
// char server[64]; /* Originating server */
|
||||||
char nick[10]; /* Nickname */
|
// char nick[10]; /* Nickname */
|
||||||
char server[64]; /* Originating server */
|
// time_t lastused; /* Last used time */
|
||||||
time_t lastused; /* Last used time */
|
//} _nick_list;
|
||||||
} nick_list;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int add_user(char *, char *, char *);
|
int add_user(char *, char *, char *);
|
||||||
|
Reference in New Issue
Block a user