- change default nick in sample file

- fix nick desync between client and server
- fix possible null deference
This commit is contained in:
nohar 2006-06-08 18:55:26 +00:00
parent e7a10369c3
commit f80cdd85e0
5 changed files with 53 additions and 22 deletions

View File

@ -1,3 +1,8 @@
2006-03-08 Arnaud Cornet <arnaud.cornet@gmail.com>
* samples/bip.conf: change default nick in sample file
* src/irc.c: fix nick desync between client and server
2006-03-08 Arnaud Cornet <arnaud.cornet@gmail.com>
* bip: release 0.5.2

3
TODO
View File

@ -8,3 +8,6 @@
- use gnutls
- MODE #channel and WHO #channel on join
11:23 < KiBi> Un /away truc chose automatique quand plus aucun client n'est
attaché.
- in english: automatic command when no more client is connected

View File

@ -72,7 +72,7 @@ network {
user {
# The name in bip of the user
# This is used by bip only
name = "nohar";
name = "bip4ever";
# this user's password (md5(md5("tata"))) with seed - generated by bipmkpw
password = "3880f2b39b3b9cb507b052b695d2680859bfc327";
@ -94,12 +94,12 @@ user {
# In "ca" mode, it's a directory of a standard openssl store; you must
# put PEM objects (certificates, CRLs...) with .pem extension and run
# `c_rehash .' in it
ssl_check_store = "/home/nohar/.bip/trustedcerts.txt";
ssl_check_store = "/home/bip4ever/.bip/trustedcerts.txt";
# These will be the default for each connections
default_nick = "nohar";
default_user = "nohar";
default_realname = "nohar";
default_nick = "bip4ever";
default_user = "bip4ever";
default_realname = "bip4ever";
# A user can have mutiple connections to irc networks.
# define a connection:

View File

@ -568,7 +568,7 @@ static int check_event_read(fd_set *fds, connection_t *cn)
if (!FD_ISSET(cn->handle, fds))
return 0;
mylog(LOG_DEBUGVERB, "Read positif sur fd %d (state %d)", cn->handle,
mylog(LOG_DEBUGVERB, "Read positif on fd %d (state %d)", cn->handle,
cn->connected);
/* notify caller to make it check for a new client */
@ -587,14 +587,14 @@ static int check_event_read(fd_set *fds, connection_t *cn)
cn->handle);
return 1;
}
if (!cn->incoming_lines)
cn->incoming_lines = list_new(NULL);
data_find_lines(cn);
if (list_is_empty(cn->incoming_lines))
return 0;
mylog(LOG_DEBUGVERB, "newlines sur fd %d (state %d)", cn->handle,
mylog(LOG_DEBUGVERB, "newlines on fd %d (state %d)", cn->handle,
cn->connected);
return 1;
}
@ -617,7 +617,7 @@ static int check_event_write(fd_set *fds, connection_t *cn, int *nc)
return connection_timedout(cn);
}
mylog(LOG_DEBUGVERB, "Write positif sur fd %d (state %d)",
mylog(LOG_DEBUGVERB, "Write positif on fd %d (state %d)",
cn->handle, cn->connected);
if (cn_is_new(cn)) {
@ -771,7 +771,7 @@ list_t *wait_event(list_t *cn_list, int *msec, int *nc)
*/
if (cn_is_connected(cn)) {
FD_SET(cn->handle, &fds_read);
mylog(LOG_DEBUGVERB, "Test read sur fd %d %d:%d",
mylog(LOG_DEBUGVERB, "Test read on fd %d %d:%d",
cn->handle, cn->connected,
cn_is_connected(cn));
}
@ -782,7 +782,7 @@ list_t *wait_event(list_t *cn_list, int *msec, int *nc)
if (!cn_is_connected(cn) || cn_want_write(cn)) {
FD_SET(cn->handle, &fds_write);
mylog(LOG_DEBUGVERB, "Test write sur fd %d %d:%d",
mylog(LOG_DEBUGVERB, "Test write on fd %d %d:%d",
cn->handle, cn->connected,
cn_is_connected(cn));
}

View File

@ -100,6 +100,7 @@ char *nick_from_ircmask(char *mask)
char *nick = mask;
char *ret;
size_t len;
while (*nick && *nick != '!')
nick++;
if (!*nick)
@ -190,7 +191,7 @@ static int irc_001(struct link_server *server, struct line *line)
if (LINK(server)->s_state == IRCS_WAS_CONNECTED)
LINK(server)->s_state = IRCS_RECONNECTING;
else
else
LINK(server)->s_state = IRCS_CONNECTING;
if (line->elemc != 3)
@ -296,10 +297,23 @@ static void irc_server_join(struct link_server *s)
static void irc_server_connected(struct link_server *server)
{
int i;
char *initmask;
LINK(server)->s_state = IRCS_CONNECTED;
irc_server_join(server);
log_connected(LINK(server)->log);
/* Tell already connected clients what the nick is */
initmask = make_irc_mask(server->nick, server->irc_mask);
/* we change nick on client */
for (i = 0; i < LINK(server)->l_clientc; i++) {
struct link_client *ic = LINK(server)->l_clientv[i];
WRITE_LINE1(CONN(ic), initmask, "NICK", server->nick);
}
free(initmask);
/* basic helper for nickserv and co */
if (LINK(server)->on_connect_send) {
ssize_t len = strlen(LINK(server)->on_connect_send) + 2;
char *str = malloc(len + 1);
@ -744,12 +758,10 @@ static int irc_cli_startup(struct link_client *ic, struct line *line,
if (!LINK(ic))
mylog(LOG_ERROR, "Invalid credentials (user:%s connection:%s)",
user, connname);
free(user);
free(connname);
free(pass);
free(ic->init_pass);
ic->init_pass = NULL;
init_nick = ic->init_nick;
@ -1075,7 +1087,7 @@ static int irc_dispatch_trust_client(struct link_client *ic, struct line *line)
if (strcmp(line->elemv[0], "BIP") == 0 &&
strcmp(line->elemv[1], "TRUST") == 0)
r = adm_trust(ic, line);
return r;
}
#endif
@ -1230,9 +1242,11 @@ int irc_dispatch(struct link_any *l, struct line *line, list_t *linkl)
static int origin_is_me(struct line *l, struct link_server *server)
{
char *nick;
if (!l->origin)
return 0;
char *nick = nick_from_ircmask(l->origin);
nick = nick_from_ircmask(l->origin);
if (strcmp(nick, server->nick) == 0) {
free(nick);
return 1;
@ -1266,7 +1280,8 @@ static int irc_join(struct link_server *server, struct line *line)
* JOIN */
if (!channel)
return ERR_PROTOCOL;
if (!line->origin)
return ERR_PROTOCOL;
s_nick = nick_from_ircmask(line->origin);
nick = calloc(sizeof(struct nick), 1);
@ -1301,7 +1316,7 @@ static int irc_333(struct link_server *server, struct line *line)
struct channel *channel;
if (line->elemc != 5)
return ERR_PROTOCOL;
channel = hash_get(&server->channels, line->elemv[2]);
/* we can get topic info reply for chans we're not on */
if (!channel)
@ -1457,6 +1472,8 @@ static int irc_part(struct link_server *server, struct line *line)
return OK_COPY;
}
if (!line->origin)
return ERR_PROTOCOL;
s_nick = nick_from_ircmask(line->origin);
nick = hash_get(&channel->nicks, s_nick);
if (!nick) {
@ -1641,7 +1658,7 @@ static int irc_topic(struct link_server *server, struct line *line)
if (line->elemc != 3)
return ERR_PROTOCOL;
channel = hash_get(&server->channels, line->elemv[1]);
/* we can't get topic message for chans we're not on */
if (!channel)
@ -1696,7 +1713,7 @@ static int irc_kick(struct link_server *server, struct line *line)
channel_free(channel);
return OK_COPY;
}
hash_remove(&channel->nicks, nick->name);
nick_free(nick);
log_kick(LINK(server)->log, line->origin, line->elemv[1],
@ -1736,6 +1753,9 @@ static int irc_nick(struct link_server *server, struct line *line)
if (line->elemc != 2)
return ERR_PROTOCOL;
if (!line->origin)
return ERR_PROTOCOL;
s_nick = nick_from_ircmask(line->origin);
if (strcmp(s_nick, server->nick) == 0) {
@ -1786,7 +1806,10 @@ static int irc_generic_quit(struct link_server *server, struct line *line)
if (line->elemc != 2 && line->elemc != 1)
return ERR_PROTOCOL;
if (!line->origin)
return ERR_PROTOCOL;
s_nick = nick_from_ircmask(line->origin);
for (hash_it_init(&server->channels, &hi); hash_it_item(&hi);
hash_it_next(&hi)) {
channel = hash_it_item(&hi);
@ -1795,7 +1818,7 @@ static int irc_generic_quit(struct link_server *server, struct line *line)
continue;
hash_remove(&channel->nicks, s_nick);
nick_free(nick);
log_quit(LINK(server)->log, line->origin, channel->name,
line->elemc == 2 ? line->elemv[1] : NULL);
}