|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|