forked from bip/bip
1
0
Fork 0

Merge branch 'bip_use_notice'

Conflicts:

	src/bip.c
This commit is contained in:
Loc Gomez 2007-11-25 16:06:45 +01:00
commit a65ffa67fa
11 changed files with 171 additions and 131 deletions

3
TODO
View File

@ -46,4 +46,5 @@ FAQ:
- why is my vhost not used when I connect (one IP)
backlog_no_private
- backlog_no_private
- biplog.vim syntax file

View File

@ -187,6 +187,17 @@ The server port to connect to.
This section allows you to define the users allowed to connect to BIP and their
options. It may appear more than once in the configuration file.
.TP
\fBadmin\fP (default: \fBfalse\fP)
If a user has admin set to true, he'll become a bip administrator, which allows
him for example to RELOAD bip from IRC or to see the user configuration.
.TP
\fBbip_use_notice\fP (default: \fBfalse\fP)
If \fBbip_use_notice\fP is true, bip's notifications to the clients will be
send as notices instead of private messages. For example, this setting applies
to disconnection notifications or /BIP command replies.
.TP
\fBdefault_nick\fP
The default nick option for each \fBconnection section\fP where no \fBnick\fP
@ -210,11 +221,6 @@ The user name. It'll be used to authenticate to bip and in \fBlog_format\fP.
\fBpassword\fP
The password. It \fBMUST\fP be generated with \fBbimkpw\fP or it'll not work.
.TP
\fBadmin\fP (default: \fBfalse\fP)
If a user has admin set to true, he'll become a bip administrator, which allows
him for example to RELOAD bip from IRC or to see the user configuration.
.TP
\fBssl_check_mode\fP (default: \fBnone\fP)
Tells whether BIP should check the server SSL certificate and against what.

View File

@ -85,6 +85,11 @@ user {
# He'll be able to RELOAD bip and see all users' configuration (except pass)
admin = true;
# When bip_use_notice is true, bip will send internal messages like
# disconnection notifications or /BIP commands replies as notices
# instead of private messages. The default is false.
#bip_use_notice = true;
# SSL certificates checking mode for user:
# - "none" to accept anything;
# - "basic" to accept if the certificate is contained in the store;

View File

@ -77,7 +77,7 @@ syn keyword bipUKeyword contained nextgroup=bipNumericV backlog_lines
syn keyword bipUKeyword contained nextgroup=bipBoolV admin
\ no_backlog always_backlog bl_msg_only blreset_on_talk
\ backlog_no_timestamp backlog log_system backlog_reset_on_talk
\ backlog_msg_only backlog_always
\ backlog_msg_only backlog_always bip_use_notice
" Connection block (level 2)
syn region bipConnection contained matchgroup=Macro

261
src/bip.c
View File

@ -54,7 +54,7 @@ static void conf_die(char *fmt, ...);
int adm_trust(struct link_client *ic, struct line *line);
#endif
static char *get_tuple_value(list_t *tuple_l, int lex);
void adm_reply(struct link_client *ic, char *str);
void bip_notify(struct link_client *ic, char *fmt, ...);
void adm_list_connections(struct link_client *ic, struct user *bu);
static void hash_binary(char *hex, unsigned char **password, unsigned int *seed)
@ -274,6 +274,7 @@ void rlimit_cpu_reached(int i)
(void)i;
mylog(LOG_WARN, "This process has reached the CPU time usage limit. "
"It means bip will be killed by the Operating System soon.");
#warning CODEME warn all users via bip_notify
}
void rlimit_bigfile_reached(int i)
@ -282,6 +283,7 @@ void rlimit_bigfile_reached(int i)
mylog(LOG_WARN, "A file has reached the max size this process is "
"allowed to create. The file will not be written correctly, "
"an error message should follow. This is not fatal.");
#warning CODEME warn all users via bip_notify ?
}
void bad_quit(int i)
@ -526,6 +528,7 @@ static int add_user(bip_t *bip, list_t *data)
u->backlog_lines = DEFAULT_BACKLOG_LINES;
u->backlog_no_timestamp = DEFAULT_BACKLOG_NO_TIMESTAMP;
u->blreset_on_talk = DEFAULT_BLRESET_ON_TALK;
u->bip_use_notice = DEFAULT_BIP_USE_NOTICE;
} else {
FREE(u->name);
FREE(u->password);
@ -576,7 +579,9 @@ static int add_user(bip_t *bip, list_t *data)
case LEX_BLRESET_ON_TALK:
u->blreset_on_talk = t->ndata;
break;
case LEX_BIP_USE_NOTICE:
u->bip_use_notice = t->ndata;
break;
case LEX_CONNECTION:
r = add_connection(bip, u, t->pdata);
free(t->pdata);
@ -873,7 +878,6 @@ int main(int argc, char **argv)
signal(SIGQUIT, bad_quit);
signal(SIGTERM, bad_quit);
signal(SIGXFSZ, rlimit_bigfile_reached);
/* TODO handle SIGXCPU => soft CPU limit reached */
signal(SIGXCPU, rlimit_cpu_reached);
conf_log_root = NULL;
@ -1024,21 +1028,14 @@ void adm_print_connection(struct link_client *ic, struct link *lnk,
char buf[RET_STR_LEN + 1];
int t_wrote = 0;
if (!bu) {
if (!bu)
bu = lnk->user;
snprintf(buf, RET_STR_LEN, "%s's links:", bu->name);
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
}
snprintf(buf, RET_STR_LEN, "* %s to %s as \"%s\" (%s!%s) :",
lnk->name, lnk->network->name,
bip_notify(ic, "* %s to %s as \"%s\" (%s!%s) :", lnk->name,
lnk->network->name,
(lnk->realname ? lnk->realname : bu->default_realname),
(lnk->connect_nick ? lnk->connect_nick : bu->default_nick),
(lnk->username ? lnk->username : bu->default_username)
);
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
(lnk->username ? lnk->username : bu->default_username));
t_wrote = snprintf(buf, RET_STR_LEN, " Options:");
if (t_wrote >= RET_STR_LEN)
@ -1086,38 +1083,30 @@ void adm_print_connection(struct link_client *ic, struct link *lnk,
noroom: /* that means the line is larger that RET_STR_LEN. We're not likely to
even read such a long line */
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
// TODO: on_connect_send
// TODO : check channels struct
t_wrote = snprintf(buf, RET_STR_LEN, " Channels:");
t_wrote = snprintf(buf, RET_STR_LEN, " Channels (* with key, ` no backlog)");
if (t_wrote >= RET_STR_LEN)
goto noroomchan;
for (hash_it_init(&lnk->chan_infos, &lit); hash_it_item(&lit);
hash_it_next(&lit)) {
struct channel *ch = hash_it_item(&lit);
struct chan_info *ch = hash_it_item(&lit);
if (ch->key) {
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN
- t_wrote, " *%s", ch->name);
if (t_wrote >= RET_STR_LEN)
goto noroomchan;
} else {
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN
- t_wrote, " %s", ch->name);
if (t_wrote >= RET_STR_LEN)
goto noroomchan;
}
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, " %s%s%s",
ch->name, (ch->key ? "*" : ""),
(ch->backlog ? "" : "`"));
if (t_wrote > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
t_wrote = 0;
}
}
noroomchan:
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
t_wrote = snprintf(buf, RET_STR_LEN, " Status: ");
if (t_wrote >= RET_STR_LEN)
@ -1177,29 +1166,35 @@ noroomchan:
}
noroomstatus:
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
}
void adm_list_all_links(struct link_client *ic)
{
list_iterator_t it;
bip_notify(ic, "-- All links");
for (list_it_init(&_bip->link_list, &it); list_it_item(&it);
list_it_next(&it)) {
struct link *l = list_it_item(&it);
if (l)
adm_print_connection(ic, l, NULL);
}
bip_notify(ic, "-- End of All links");
}
void adm_list_all_connections(struct link_client *ic)
{
hash_iterator_t it;
bip_notify(ic, "-- All connections");
for (hash_it_init(&_bip->users, &it); hash_it_item(&it);
hash_it_next(&it)) {
struct user *u = hash_it_item(&it);
if (u)
adm_list_connections(ic, u);
}
bip_notify(ic, "-- End of All connections");
}
void adm_info_user(struct link_client *ic, char *name)
@ -1208,15 +1203,16 @@ void adm_info_user(struct link_client *ic, char *name)
char buf[RET_STR_LEN + 1];
int t_wrote = 0;
bip_notify(ic, "-- User '%s' info", name);
u = hash_get(&_bip->users, name);
if (!u) {
adm_reply(ic, "Unknown user");
bip_notify(ic, "Unknown user");
return;
}
//t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, "");
//buf[RET_STR_LEN] = 0;
//adm_reply(ic, buf);
//bip_notify(ic, buf);
//t_wrote = 0;
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, "user: %s",
@ -1232,37 +1228,28 @@ void adm_info_user(struct link_client *ic, char *name)
noroom:
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
t_wrote = 0;
#ifdef HAVE_LIBSSL
snprintf(buf, RET_STR_LEN, "SSL check mode '%s', stored into '%s'",
bip_notify(ic, "SSL check mode '%s', stored into '%s'",
checkmode2text(u->ssl_check_mode), u->ssl_check_store);
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
#endif
snprintf(buf, RET_STR_LEN, "Defaults nick: %s, user: %s, realname: %s",
bip_notify(ic, "Defaults nick: %s, user: %s, realname: %s",
u->default_nick, u->default_username, u->default_realname);
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
if (u->backlog) {
snprintf(buf, RET_STR_LEN, "Backlog enabled, lines: %d, "
"no timestamp: %s, messages only: %s",
u->backlog_lines,
bool2text(u->backlog_no_timestamp),
bool2text(u->bl_msg_only));
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
snprintf(buf, RET_STR_LEN, "always backlog: %s, "
"reset on talk: %s",
bool2text(u->always_backlog),
bool2text(u->blreset_on_talk));
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, "Backlog enabled, lines: %d, no timestamp: %s,"
" messages only: %s", u->backlog_lines,
bool2text(u->backlog_no_timestamp),
bool2text(u->bl_msg_only));
bip_notify(ic, "always backlog: %s, reset on talk: %s",
bool2text(u->always_backlog),
bool2text(u->blreset_on_talk));
} else {
adm_reply(ic, "Backlog disabled");
bip_notify(ic, "Backlog disabled");
}
adm_list_connections(ic, u);
bip_notify(ic, "-- End of User '%s' info", name);
}
void adm_list_users(struct link_client *ic)
@ -1274,7 +1261,7 @@ void adm_list_users(struct link_client *ic)
c = CONN(ic);
adm_reply(ic, "bip user list:");
bip_notify(ic, "-- User list");
for (hash_it_init(&_bip->users, &it); hash_it_item(&it);
hash_it_next(&it)) {
struct user *u = hash_it_item(&it);
@ -1291,7 +1278,7 @@ void adm_list_users(struct link_client *ic)
struct link *lnk = hash_it_item(&lit);
if (first) {
first = 0;
}else {
} else {
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN
- t_wrote, ",");
if (t_wrote >= RET_STR_LEN)
@ -1305,15 +1292,15 @@ void adm_list_users(struct link_client *ic)
goto noroom;
if (t_wrote > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
t_wrote = 0;
}
}
noroom:
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
}
adm_reply(ic, "End of bip user list");
bip_notify(ic, "-- End of User list");
}
void adm_list_networks(struct link_client *ic)
@ -1324,7 +1311,7 @@ void adm_list_networks(struct link_client *ic)
c = CONN(ic);
adm_reply(ic, "bip network list (* means SSL):");
bip_notify(ic, "-- Network list (* means SSL):");
for (hash_it_init(&_bip->networks, &it); hash_it_item(&it);
hash_it_next(&it)) {
struct network *n = hash_it_item(&it);
@ -1355,15 +1342,15 @@ void adm_list_networks(struct link_client *ic)
goto noroom;
if (t_wrote > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
t_wrote = 0;
}
}
noroom:
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, buf);
}
adm_reply(ic, "End of bip network list");
bip_notify(ic, "-- End of Network list");
}
void adm_list_connections(struct link_client *ic, struct user *bu)
@ -1374,12 +1361,10 @@ void adm_list_connections(struct link_client *ic, struct user *bu)
c = CONN(ic);
if (!bu) {
adm_reply(ic, "Your connections:");
bip_notify(ic, "-- Your connections:");
bu = LINK(ic)->user;
} else {
snprintf(buf, RET_STR_LEN, "%s's connections:", bu->name);
buf[RET_STR_LEN] = 0;
adm_reply(ic, buf);
bip_notify(ic, "-- User %s's connections:", bu->name);
}
for (hash_it_init(&bu->connections, &it); hash_it_item(&it);
@ -1387,7 +1372,7 @@ void adm_list_connections(struct link_client *ic, struct user *bu)
struct link *lnk= hash_it_item(&it);
adm_print_connection(ic, lnk, bu);
}
adm_reply(ic, "End of bip connection list");
bip_notify(ic, "-- End of Connection list");
}
#ifdef HAVE_LIBSSL
@ -1534,22 +1519,36 @@ int adm_trust(struct link_client *ic, struct line *line)
}
#endif
void adm_reply(struct link_client *ic, char *str)
void _bip_notify(struct link_client *ic, char *fmt, va_list ap)
{
char *nick;
char str[4096];
if (LINK(ic)->l_server)
nick = LINK(ic)->l_server->nick;
else
nick = LINK(ic)->prev_nick;
WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG", nick, str);
vsnprintf(str, 4095, fmt, ap);
str[4095] = 0;
WRITE_LINE2(CONN(ic), P_IRCMASK, (LINK(ic)->user->bip_use_notice ?
"NOTICE" : "PRIVMSG"), nick, str);
}
void bip_notify(struct link_client *ic, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
_bip_notify(ic, fmt, ap);
va_end(ap);
}
extern struct link_client *reloading_client;
void adm_blreset(struct link_client *ic)
{
log_reinit_all(LINK(ic)->log);
adm_reply(ic, "backlog resetted for this network.");
bip_notify(ic, "backlog resetted for this network.");
}
void adm_follow_nick(struct link_client *ic, char *val)
@ -1557,10 +1556,10 @@ void adm_follow_nick(struct link_client *ic, char *val)
struct link *link = LINK(ic);
if (strncasecmp(val, "TRUE", 4) == 0) {
link->follow_nick = 1;
adm_reply(ic, "follow_nick is now true.");
bip_notify(ic, "follow_nick is now true.");
} else {
link->follow_nick = 0;
adm_reply(ic, "follow_nick is now false.");
bip_notify(ic, "follow_nick is now false.");
}
}
@ -1569,29 +1568,55 @@ void adm_ignore_first_nick(struct link_client *ic, char *val)
struct link *link = LINK(ic);
if (strncasecmp(val, "TRUE", 4) == 0) {
link->ignore_first_nick = 1;
adm_reply(ic, "ignore_first_nick is now true.");
bip_notify(ic, "ignore_first_nick is now true.");
} else {
link->ignore_first_nick = 0;
adm_reply(ic, "ignore_first_nick is now false.");
bip_notify(ic, "ignore_first_nick is now false.");
}
}
void adm_on_connect_send(struct link_client *ic, char *val)
void set_on_connect_send(struct link_client *ic, char *val)
{
struct link *link = LINK(ic);
char *s;
if (val != NULL) {
list_add_last(&link->on_connect_send, strdup(val));
adm_reply(ic, "added to on_connect_send.");
bip_notify(ic, "added to on_connect_send.");
} else {
s = list_remove_last(&link->on_connect_send);
if (s)
free(s);
adm_reply(ic, "on_connect_send cleared.");
bip_notify(ic, "on_connect_send cleared.");
}
}
void adm_on_connect_send(struct link_client *ic, struct line *line,
unsigned int privmsg)
{
char buf[4096];
int t_wrote = 0;
unsigned int i;
if (!line) {
set_on_connect_send(ic, NULL);
return;
}
if (line->elemc < 3)
return;
for (i = privmsg + 2; i < line->elemc; i++) {
if (t_wrote)
t_wrote += snprintf(buf, 4095 - t_wrote, " %s",
line->elemv[i]);
else
t_wrote = snprintf(buf, 4095, "%s", line->elemv[i]);
}
buf[4095] = 0;
set_on_connect_send(ic, buf);
}
void adm_away_nick(struct link_client *ic, char *val)
{
struct link *link = LINK(ic);
@ -1601,37 +1626,37 @@ void adm_away_nick(struct link_client *ic, char *val)
}
if (val != NULL) {
link->away_nick = strdup(val);
adm_reply(ic, "away_nick set.");
bip_notify(ic, "away_nick set.");
} else {
adm_reply(ic, "away_nick cleared.");
bip_notify(ic, "away_nick cleared.");
}
}
void adm_bip_help(struct link_client *ic, int admin)
{
if (admin) {
adm_reply(ic, "/BIP RELOAD # Re-read bip configuration "
bip_notify(ic, "/BIP RELOAD # Re-read bip configuration "
"and apply changes. /!\\ VERY UNSTABLE !");
adm_reply(ic, "/BIP INFO user <username> # show a user's "
bip_notify(ic, "/BIP INFO user <username> # show a user's "
"configuration");
adm_reply(ic, "/BIP LIST networks|users|connections|all_links"
bip_notify(ic, "/BIP LIST networks|users|connections|all_links"
"|all_connections");
} else {
adm_reply(ic, "/BIP LIST networks|connections");
}
adm_reply(ic, "/BIP JUMP # jump to next server (in same network)");
adm_reply(ic, "/BIP BLRESET # reset backlog (this connection only)");
} else {
bip_notify(ic, "/BIP LIST networks|connections");
}
bip_notify(ic, "/BIP JUMP # jump to next server (in same network)");
bip_notify(ic, "/BIP BLRESET # reset backlog (this connection only)");
#ifdef HAVE_LIBSSL
adm_reply(ic, "/BIP TRUST # trust this server certificate");
bip_notify(ic, "/BIP TRUST # trust this server certificate");
#endif
adm_reply(ic, "/BIP HELP # show this help...");
adm_reply(ic, "## Temporary changes for this connection:");
adm_reply(ic, "/BIP FOLLOW_NICK|IGNORE_FIRST_NICK TRUE|FALSE");
adm_reply(ic, "/BIP ON_CONNECT_SEND <str> # Adds a string to "
bip_notify(ic, "/BIP HELP # show this help...");
bip_notify(ic, "## Temporary changes for this connection:");
bip_notify(ic, "/BIP FOLLOW_NICK|IGNORE_FIRST_NICK TRUE|FALSE");
bip_notify(ic, "/BIP ON_CONNECT_SEND <str> # Adds a string to "
"send on connect");
adm_reply(ic, "/BIP ON_CONNECT_SEND # Clears on_connect_send");
adm_reply(ic, "/BIP AWAY_NICK <nick> # Set away nick");
adm_reply(ic, "/BIP AWAY_NICK # clear away nick");
bip_notify(ic, "/BIP ON_CONNECT_SEND # Clears on_connect_send");
bip_notify(ic, "/BIP AWAY_NICK <nick> # Set away nick");
bip_notify(ic, "/BIP AWAY_NICK # clear away nick");
}
int adm_bip(struct link_client *ic, struct line *line, unsigned int privmsg)
@ -1645,15 +1670,15 @@ int adm_bip(struct link_client *ic, struct line *line, unsigned int privmsg)
LINK(ic)->user->name);
if (strcasecmp(line->elemv[privmsg + 1], "RELOAD") == 0) {
if (!admin) {
adm_reply(ic, "You're not allowed to reload bip");
bip_notify(ic, "-- You're not allowed to reload bip");
return OK_FORGET;
}
adm_reply(ic, "Reloading...");
bip_notify(ic, "-- Bip has been set to reload shortly");
reloading_client = ic;
sighup = 1;
} else if (strcasecmp(line->elemv[privmsg + 1], "LIST") == 0) {
if (line->elemc != privmsg + 3) {
adm_reply(ic, "LIST command needs one argument");
bip_notify(ic, "-- LIST command needs one argument");
return OK_FORGET;
}
@ -1673,12 +1698,11 @@ int adm_bip(struct link_client *ic, struct line *line, unsigned int privmsg)
"all_links") == 0) {
adm_list_all_links(ic);
} else {
adm_reply(ic, "Invalid LIST request");
bip_notify(ic, "-- Invalid LIST request");
}
} else if (strcasecmp(line->elemv[privmsg + 1], "INFO") == 0) {
if (line->elemc < privmsg + 3) {
adm_reply(ic, "INFO command needs at least one "
"argument");
bip_notify(ic, "-- INFO command needs at least one argument");
return OK_FORGET;
}
@ -1687,8 +1711,8 @@ int adm_bip(struct link_client *ic, struct line *line, unsigned int privmsg)
if (line->elemc == privmsg + 4) {
adm_info_user(ic, line->elemv[privmsg + 3]);
} else {
adm_reply(ic, "/BIP INFO user needs one "
"argument");
bip_notify(ic, "-- INFO USER command needs one"
" argument");
}
#if 0
TODO
@ -1697,12 +1721,12 @@ int adm_bip(struct link_client *ic, struct line *line, unsigned int privmsg)
if (line->elemc == privmsg + 4) {
adm_info_network(ic, line->elemv[privmsg + 3]);
} else {
adm_reply(ic, "/BIP INFO network needs one "
bip_notify(ic, "/BIP INFO network needs one "
"argument");
}
#endif
} else {
adm_reply(ic, "Invalid INFO request");
bip_notify(ic, "-- Invalid INFO request");
}
} else if (strcasecmp(line->elemv[privmsg + 1], "JUMP") == 0) {
if (LINK(ic)->l_server) {
@ -1710,35 +1734,33 @@ int adm_bip(struct link_client *ic, struct line *line, unsigned int privmsg)
"jumpin' jumpin'");
connection_close(CONN(LINK(ic)->l_server));
}
adm_reply(ic, "Jumping to next server");
bip_notify(ic, "-- Jumping to next server");
} else if (strcasecmp(line->elemv[privmsg + 1], "BLRESET") == 0) {
adm_blreset(ic);
} else if (strcasecmp(line->elemv[privmsg + 1], "HELP") == 0) {
adm_bip_help(ic, admin);
} else if (strcasecmp(line->elemv[privmsg + 1], "FOLLOW_NICK") == 0) {
if (line->elemc != privmsg + 3) {
adm_reply(ic, "FOLLOW_NICK command needs one argument");
bip_notify(ic, "-- FOLLOW_NICK command needs one argument");
return OK_FORGET;
}
adm_follow_nick(ic, line->elemv[privmsg + 2]);
} else if (strcasecmp(line->elemv[privmsg + 1],
"IGNORE_FIRST_NICK") == 0) {
if (line->elemc != privmsg + 3) {
adm_reply(ic, "IGNORE_FIRST_NICK command needs one "
"argument");
bip_notify(ic, "-- IGNORE_FIRST_NICK command needs one argument");
return OK_FORGET;
}
adm_ignore_first_nick(ic, line->elemv[privmsg + 2]);
} else if (strcasecmp(line->elemv[privmsg + 1],
"ON_CONNECT_SEND") == 0) {
if (line->elemc == privmsg + 2) {
adm_on_connect_send(ic, NULL);
} else if (line->elemc == privmsg + 3) {
// TODO: on connect send should not be limited to one word
adm_on_connect_send(ic, line->elemv[privmsg + 2]);
adm_on_connect_send(ic, NULL, 0);
} else if (line->elemc >= privmsg + 3) {
adm_on_connect_send(ic, line, privmsg);
} else {
adm_reply(ic, "/BIP ON_CONNECT_SEND needs zero or one "
"argument");
bip_notify(ic, "-- ON_CONNECT_SEND command needs at "
"least one argument");
}
} else if (strcasecmp(line->elemv[privmsg + 1], "AWAY_NICK") == 0) {
if (line->elemc == privmsg + 2) {
@ -1746,16 +1768,15 @@ int adm_bip(struct link_client *ic, struct line *line, unsigned int privmsg)
} else if (line->elemc == privmsg + 3) {
adm_away_nick(ic, line->elemv[privmsg + 2]);
} else {
adm_reply(ic, "/BIP AWAY_NICK needs zero or one "
"argument");
bip_notify(ic, "-- AWAY_NICK command needs zero or one"
" argument");
}
#ifdef HAVE_LIBSSL
} else if (strcasecmp(line->elemv[privmsg + 1], "TRUST") == 0) {
/* TODO : warn the user of results */
return adm_trust(ic, line);
#endif
} else {
adm_reply(ic, "Unknown command.");
bip_notify(ic, "Unknown command.");
}
return OK_FORGET;
}

View File

@ -20,5 +20,6 @@ int adm_trust(struct link_client *ic, struct line *line);
int adm_bip(struct link_client *ic, struct line *line, unsigned int privmsg);
int ssl_check_trust(struct link_client *ic);
void adm_blreset(struct link_client *ic);
void bip_notify(struct link_client *ic, char *fmt, ...);
#endif

View File

@ -80,7 +80,7 @@ struct tuple *tuple_l_new(int type, void *p)
%}
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN LEX_BIP_USE_NOTICE
%union {
int number;
@ -138,6 +138,8 @@ usr_command:
| LEX_PASSWORD LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_PASSWORD,
$3); }
| LEX_ADMIN LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_ADMIN, $3); }
| LEX_BIP_USE_NOTICE LEX_EQ LEX_BOOL {
$$ = tuple_i_new(LEX_BIP_USE_NOTICE, $3); }
| LEX_SSL_CHECK_MODE LEX_EQ LEX_STRING { $$ = tuple_s_new(
LEX_SSL_CHECK_MODE, $3); }
| LEX_SSL_CHECK_STORE LEX_EQ LEX_STRING { $$ = tuple_s_new(

View File

@ -25,5 +25,6 @@
#define DEFAULT_LOG_SYNC_INTERVAL 5
#define DEFAULT_LOG_LEVEL LOG_INFO
#define DEFAULT_LOG_FORMAT "%u/%n/%Y-%m/%c.%d.log"
#define DEFAULT_BIP_USE_NOTICE 0
#endif /* DEFAULTS_H */

View File

@ -939,8 +939,7 @@ static void irc_notify_disconnection(struct link_server *is)
c->name, is->nick,
"Server disconnected, reconnecting");
}
WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG", is->nick,
"Server disconnected, reconnecting");
bip_notify(ic, "Server disconnected, reconnecting");
}
}
@ -1092,7 +1091,9 @@ static int irc_dispatch_client(bip_t *bip, struct link_client *ic,
LINK(ic)->l_server->nick)
write_line(CONN(LINK(ic)->l_server), str);
else if (LINK(ic)->l_server->nick)
WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG",
WRITE_LINE2(CONN(ic), P_IRCMASK,
(LINK(ic)->user->bip_use_notice ?
"NOTICE" : "PRIVMSG"),
LINK(ic)->l_server->nick,
":Not connected please try again "
"later...\r\n");

View File

@ -69,6 +69,7 @@ struct user {
unsigned char *password;
unsigned int seed;
int admin;
int bip_use_notice;
/* common link options */

View File

@ -99,6 +99,7 @@ list_t *parse_conf(FILE *file)
"on_connect_send" { return LEX_ON_CONNECT_SEND; }
"no_client_away_msg" { return LEX_NO_CLIENT_AWAY_MSG; }
"pid_file" { return LEX_PID_FILE; }
"bip_use_notice" { return LEX_BIP_USE_NOTICE; }
\"[^"]*\" {
size_t len = strlen(yytext) - 2;
yylval.string = malloc(len + 1);