- change default nick in sample file
- fix nick desync between client and server - fix possible null deference
This commit is contained in:
parent
e7a10369c3
commit
f80cdd85e0
@ -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>
|
2006-03-08 Arnaud Cornet <arnaud.cornet@gmail.com>
|
||||||
|
|
||||||
* bip: release 0.5.2
|
* bip: release 0.5.2
|
||||||
|
3
TODO
3
TODO
@ -8,3 +8,6 @@
|
|||||||
|
|
||||||
- use gnutls
|
- use gnutls
|
||||||
- MODE #channel and WHO #channel on join
|
- 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
|
||||||
|
@ -72,7 +72,7 @@ network {
|
|||||||
user {
|
user {
|
||||||
# The name in bip of the user
|
# The name in bip of the user
|
||||||
# This is used by bip only
|
# This is used by bip only
|
||||||
name = "nohar";
|
name = "bip4ever";
|
||||||
# this user's password (md5(md5("tata"))) with seed - generated by bipmkpw
|
# this user's password (md5(md5("tata"))) with seed - generated by bipmkpw
|
||||||
password = "3880f2b39b3b9cb507b052b695d2680859bfc327";
|
password = "3880f2b39b3b9cb507b052b695d2680859bfc327";
|
||||||
|
|
||||||
@ -94,12 +94,12 @@ user {
|
|||||||
# In "ca" mode, it's a directory of a standard openssl store; you must
|
# In "ca" mode, it's a directory of a standard openssl store; you must
|
||||||
# put PEM objects (certificates, CRLs...) with .pem extension and run
|
# put PEM objects (certificates, CRLs...) with .pem extension and run
|
||||||
# `c_rehash .' in it
|
# `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
|
# These will be the default for each connections
|
||||||
default_nick = "nohar";
|
default_nick = "bip4ever";
|
||||||
default_user = "nohar";
|
default_user = "bip4ever";
|
||||||
default_realname = "nohar";
|
default_realname = "bip4ever";
|
||||||
|
|
||||||
# A user can have mutiple connections to irc networks.
|
# A user can have mutiple connections to irc networks.
|
||||||
# define a connection:
|
# define a connection:
|
||||||
|
@ -568,7 +568,7 @@ static int check_event_read(fd_set *fds, connection_t *cn)
|
|||||||
if (!FD_ISSET(cn->handle, fds))
|
if (!FD_ISSET(cn->handle, fds))
|
||||||
return 0;
|
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);
|
cn->connected);
|
||||||
|
|
||||||
/* notify caller to make it check for a new client */
|
/* notify caller to make it check for a new client */
|
||||||
@ -594,7 +594,7 @@ static int check_event_read(fd_set *fds, connection_t *cn)
|
|||||||
if (list_is_empty(cn->incoming_lines))
|
if (list_is_empty(cn->incoming_lines))
|
||||||
return 0;
|
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);
|
cn->connected);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -617,7 +617,7 @@ static int check_event_write(fd_set *fds, connection_t *cn, int *nc)
|
|||||||
return connection_timedout(cn);
|
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);
|
cn->handle, cn->connected);
|
||||||
|
|
||||||
if (cn_is_new(cn)) {
|
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)) {
|
if (cn_is_connected(cn)) {
|
||||||
FD_SET(cn->handle, &fds_read);
|
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->handle, cn->connected,
|
||||||
cn_is_connected(cn));
|
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)) {
|
if (!cn_is_connected(cn) || cn_want_write(cn)) {
|
||||||
FD_SET(cn->handle, &fds_write);
|
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->handle, cn->connected,
|
||||||
cn_is_connected(cn));
|
cn_is_connected(cn));
|
||||||
}
|
}
|
||||||
|
31
src/irc.c
31
src/irc.c
@ -100,6 +100,7 @@ char *nick_from_ircmask(char *mask)
|
|||||||
char *nick = mask;
|
char *nick = mask;
|
||||||
char *ret;
|
char *ret;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
while (*nick && *nick != '!')
|
while (*nick && *nick != '!')
|
||||||
nick++;
|
nick++;
|
||||||
if (!*nick)
|
if (!*nick)
|
||||||
@ -296,10 +297,23 @@ static void irc_server_join(struct link_server *s)
|
|||||||
|
|
||||||
static void irc_server_connected(struct link_server *server)
|
static void irc_server_connected(struct link_server *server)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
char *initmask;
|
||||||
LINK(server)->s_state = IRCS_CONNECTED;
|
LINK(server)->s_state = IRCS_CONNECTED;
|
||||||
irc_server_join(server);
|
irc_server_join(server);
|
||||||
log_connected(LINK(server)->log);
|
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) {
|
if (LINK(server)->on_connect_send) {
|
||||||
ssize_t len = strlen(LINK(server)->on_connect_send) + 2;
|
ssize_t len = strlen(LINK(server)->on_connect_send) + 2;
|
||||||
char *str = malloc(len + 1);
|
char *str = malloc(len + 1);
|
||||||
@ -744,12 +758,10 @@ static int irc_cli_startup(struct link_client *ic, struct line *line,
|
|||||||
if (!LINK(ic))
|
if (!LINK(ic))
|
||||||
mylog(LOG_ERROR, "Invalid credentials (user:%s connection:%s)",
|
mylog(LOG_ERROR, "Invalid credentials (user:%s connection:%s)",
|
||||||
user, connname);
|
user, connname);
|
||||||
|
|
||||||
free(user);
|
free(user);
|
||||||
free(connname);
|
free(connname);
|
||||||
free(pass);
|
free(pass);
|
||||||
|
|
||||||
|
|
||||||
free(ic->init_pass);
|
free(ic->init_pass);
|
||||||
ic->init_pass = NULL;
|
ic->init_pass = NULL;
|
||||||
init_nick = ic->init_nick;
|
init_nick = ic->init_nick;
|
||||||
@ -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)
|
static int origin_is_me(struct line *l, struct link_server *server)
|
||||||
{
|
{
|
||||||
|
char *nick;
|
||||||
|
|
||||||
if (!l->origin)
|
if (!l->origin)
|
||||||
return 0;
|
return 0;
|
||||||
char *nick = nick_from_ircmask(l->origin);
|
nick = nick_from_ircmask(l->origin);
|
||||||
if (strcmp(nick, server->nick) == 0) {
|
if (strcmp(nick, server->nick) == 0) {
|
||||||
free(nick);
|
free(nick);
|
||||||
return 1;
|
return 1;
|
||||||
@ -1266,7 +1280,8 @@ static int irc_join(struct link_server *server, struct line *line)
|
|||||||
* JOIN */
|
* JOIN */
|
||||||
if (!channel)
|
if (!channel)
|
||||||
return ERR_PROTOCOL;
|
return ERR_PROTOCOL;
|
||||||
|
if (!line->origin)
|
||||||
|
return ERR_PROTOCOL;
|
||||||
s_nick = nick_from_ircmask(line->origin);
|
s_nick = nick_from_ircmask(line->origin);
|
||||||
|
|
||||||
nick = calloc(sizeof(struct nick), 1);
|
nick = calloc(sizeof(struct nick), 1);
|
||||||
@ -1457,6 +1472,8 @@ static int irc_part(struct link_server *server, struct line *line)
|
|||||||
return OK_COPY;
|
return OK_COPY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!line->origin)
|
||||||
|
return ERR_PROTOCOL;
|
||||||
s_nick = nick_from_ircmask(line->origin);
|
s_nick = nick_from_ircmask(line->origin);
|
||||||
nick = hash_get(&channel->nicks, s_nick);
|
nick = hash_get(&channel->nicks, s_nick);
|
||||||
if (!nick) {
|
if (!nick) {
|
||||||
@ -1736,6 +1753,9 @@ static int irc_nick(struct link_server *server, struct line *line)
|
|||||||
if (line->elemc != 2)
|
if (line->elemc != 2)
|
||||||
return ERR_PROTOCOL;
|
return ERR_PROTOCOL;
|
||||||
|
|
||||||
|
if (!line->origin)
|
||||||
|
return ERR_PROTOCOL;
|
||||||
|
|
||||||
s_nick = nick_from_ircmask(line->origin);
|
s_nick = nick_from_ircmask(line->origin);
|
||||||
|
|
||||||
if (strcmp(s_nick, server->nick) == 0) {
|
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)
|
if (line->elemc != 2 && line->elemc != 1)
|
||||||
return ERR_PROTOCOL;
|
return ERR_PROTOCOL;
|
||||||
|
|
||||||
|
if (!line->origin)
|
||||||
|
return ERR_PROTOCOL;
|
||||||
s_nick = nick_from_ircmask(line->origin);
|
s_nick = nick_from_ircmask(line->origin);
|
||||||
|
|
||||||
for (hash_it_init(&server->channels, &hi); hash_it_item(&hi);
|
for (hash_it_init(&server->channels, &hi); hash_it_item(&hi);
|
||||||
hash_it_next(&hi)) {
|
hash_it_next(&hi)) {
|
||||||
channel = hash_it_item(&hi);
|
channel = hash_it_item(&hi);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user