add backlog option to channels.
This commit is contained in:
parent
45e9688c45
commit
2090349f9c
@ -5,6 +5,8 @@
|
||||
debug info...
|
||||
* src/bip: add ssl_check_mode option to the connection block (requested
|
||||
by Trou) + die if ssl_check_mode is unset while the network is SSL.
|
||||
* src: add backlog option to channels, allowing to disable backlog on
|
||||
a per channel basis
|
||||
|
||||
|
||||
2007-09-25 Loïc Gomez <opensource@kyoshiro.org>
|
||||
|
@ -315,6 +315,11 @@ The channel name (#bip, &bip, ...).
|
||||
\fBkey\fP
|
||||
The channel key if needed.
|
||||
|
||||
.TP
|
||||
\fBbacklog\fP (default: \fBtrue\fP)
|
||||
Enable or disable backlogging of this particular channel.
|
||||
Setting this to true will NOT enable the backlog system, see the User section.
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
bip, bipmkpw
|
||||
|
@ -136,6 +136,10 @@ user {
|
||||
name = "iiens"; # used by bip only
|
||||
network = "iiens"; # which ircnet to connect to
|
||||
|
||||
# You can precise ssl_check_mode here, if you want a different
|
||||
# behavior than the one defined in the parent user {}.
|
||||
#ssl_check_mode = "none";
|
||||
|
||||
# If you have multiple IP addresses, you can set the one you
|
||||
# want bip to use here. See manpage for more information.
|
||||
|
||||
@ -166,6 +170,11 @@ user {
|
||||
name = "#elite_UnDeRgR0uNd";
|
||||
key = "sikiour";
|
||||
};
|
||||
channel {
|
||||
name = "#huge(28)_activity";
|
||||
# disable backlogging of this channel.
|
||||
backlog = false;
|
||||
};
|
||||
};
|
||||
|
||||
# another connection (optionnal)
|
||||
|
@ -69,12 +69,12 @@ syn keyword bipNKeyword contained nextgroup=bipBoolV ssl
|
||||
" User block (level 1)
|
||||
syn region bipUser contained matchgroup=Macro start=/user\s*{\s*/
|
||||
\ end=/};/
|
||||
\ contains=bipUKeyword,bipUBool,bipConnection,bipComment,bipEndError,bipWhite
|
||||
\ contains=bipUKeyword,bipConnection,bipComment,bipEndError,bipWhite
|
||||
syn keyword bipUKeyword contained nextgroup=bipStringV password name
|
||||
\ default_nick default_user default_realname ssl_check_store
|
||||
\ ssl_check_mode
|
||||
syn keyword bipUKeyword contained nextgroup=bipNumericV backlog_lines
|
||||
syn keyword bipUBool contained nextgroup=bipBoolV admin
|
||||
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
|
||||
@ -96,6 +96,7 @@ syn region bipChannel contained matchgroup=Macro
|
||||
\ start=/channel\s*{\s*/ end=/};/
|
||||
\ contains=bipCKeyword,bipComment,bipEndError,bipWhite
|
||||
syn keyword bipCKeyword contained nextgroup=bipStringV name key
|
||||
syn keyword bipCKeyword contained nextgroup=bipBoolV backlog
|
||||
|
||||
" Server elements (lvl 2)
|
||||
syn region bipServer contained matchgroup=Macro
|
||||
|
36
src/bip.c
36
src/bip.c
@ -357,7 +357,7 @@ static int add_network(bip_t *bip, list_t *data)
|
||||
|
||||
static int add_connection(bip_t *bip, struct user *user, list_t *data)
|
||||
{
|
||||
struct tuple *t;
|
||||
struct tuple *t, *t2;
|
||||
struct link *l;
|
||||
struct chan_info *ci;
|
||||
char *name = get_tuple_value(data, LEX_NAME);
|
||||
@ -373,7 +373,11 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
|
||||
list_add_last(&bip->link_list, l);
|
||||
l->user = user;
|
||||
l->log = log_new(user, name);
|
||||
#ifdef HAVE_LIBSSL
|
||||
l->ssl_check_mode = user->ssl_check_mode;
|
||||
l->ssl_check_store = user->ssl_check_store;
|
||||
l->untrusted_certs = sk_X509_new_null();
|
||||
#endif
|
||||
} else {
|
||||
#warning "CODEME (user switch..)"
|
||||
l->network = NULL;
|
||||
@ -412,9 +416,22 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
|
||||
break;
|
||||
case LEX_CHANNEL:
|
||||
ci = calloc(sizeof(struct chan_info), 1);
|
||||
ci->backlog = 1;
|
||||
|
||||
ci->name = get_tuple_value(t->pdata, LEX_NAME);
|
||||
ci->key = get_tuple_value(t->pdata, LEX_KEY);
|
||||
while ((t2 = list_remove_first(t->pdata))) {
|
||||
switch (t2->type) {
|
||||
case LEX_NAME:
|
||||
MOVE_STRING(ci->name, t2->pdata);
|
||||
break;
|
||||
case LEX_KEY:
|
||||
MOVE_STRING(ci->key, t2->pdata);
|
||||
break;
|
||||
case LEX_BACKLOG:
|
||||
ci->backlog = t2->ndata;
|
||||
break;
|
||||
}
|
||||
}
|
||||
list_free(t->pdata);
|
||||
|
||||
hash_insert(&l->chan_infos, ci->name, ci);
|
||||
list_add_last(&l->chan_infos_order, ci);
|
||||
@ -589,9 +606,10 @@ static int add_user(bip_t *bip, list_t *data)
|
||||
static int validate_config(bip_t *bip)
|
||||
{
|
||||
/* nick username realname or default_{nick,username,realname} in user */
|
||||
hash_iterator_t it, sit;
|
||||
hash_iterator_t it, sit, cit;
|
||||
struct user *user;
|
||||
struct link *link;
|
||||
struct chan_info *ci;
|
||||
int r = 1;
|
||||
|
||||
for (hash_it_init(&bip->users, &it); (user = hash_it_item(&it));
|
||||
@ -618,6 +636,16 @@ static int validate_config(bip_t *bip)
|
||||
|
||||
//conf_die("user: ... net: ... can i has nick/user/rael");
|
||||
r = 0;
|
||||
|
||||
for (hash_it_init(&link->chan_infos, &cit);
|
||||
(ci = hash_it_item(&cit));
|
||||
hash_it_next(&cit)) {
|
||||
if (!ci->name)
|
||||
conf_die("user %s, connection "
|
||||
"%s: channel must have"
|
||||
"a name.", user->name,
|
||||
link->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,6 +205,7 @@ channel:
|
||||
cha_command:
|
||||
LEX_NAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NAME, $3); }
|
||||
| LEX_KEY LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_KEY, $3); }
|
||||
| LEX_BACKLOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_BACKLOG, $3); }
|
||||
|
||||
server:
|
||||
{ $$ = list_new(NULL); }
|
||||
|
@ -2274,6 +2274,7 @@ void bip_tick(bip_t *bip)
|
||||
struct link_client *ic = list_it_item(&li);
|
||||
ic->logging_timer++;
|
||||
if (ic->logging_timer > LOGGING_TIMEOUT) {
|
||||
if (CONN(ic))
|
||||
list_remove(&bip->conn_list, CONN(ic));
|
||||
irc_close((struct link_any *)ic);
|
||||
list_it_remove(&li);
|
||||
|
@ -206,6 +206,7 @@ struct log;
|
||||
struct chan_info {
|
||||
char *name;
|
||||
char *key;
|
||||
int backlog;
|
||||
};
|
||||
|
||||
#define chan_info_new() calloc(sizeof(struct chan_info), 1)
|
||||
|
17
src/log.c
17
src/log.c
@ -718,6 +718,8 @@ char *log_beautify(log_t *logdata, char *buf, char *dest)
|
||||
char *ret;
|
||||
int out;
|
||||
int done;
|
||||
struct link *l;
|
||||
struct chan_info *ci;
|
||||
|
||||
if (!buf)
|
||||
fatal("BUG log_beautify not called correctly!");
|
||||
@ -732,6 +734,21 @@ char *log_beautify(log_t *logdata, char *buf, char *dest)
|
||||
return _log_wrap(dest, buf);
|
||||
lots = p - sots;
|
||||
p++;
|
||||
|
||||
if (!logdata->user)
|
||||
fatal("log_beautify: no user associated to logdata");
|
||||
if (!logdata->network)
|
||||
fatal("log_beautify: no network id associated to logdata");
|
||||
l = hash_get(&logdata->user->connections, logdata->network);
|
||||
if (!l)
|
||||
fatal("log_beautify: no connection associated to logdata");
|
||||
ci = hash_get(&l->chan_infos, dest);
|
||||
if (ci && !ci->backlog) {
|
||||
mylog(LOG_DEBUG, "Skipping unwanted channel %s for backlog",
|
||||
dest);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strncmp(p, "-!-", 3) == 0) {
|
||||
if (logdata->user->bl_msg_only)
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user