Ctrlproxy 3.0.6 UNRELEASED
+ IMPROVEMENTS
+
+ * Add report-time-offset setting.
+
+ BUG FIXES
+
+ * Don't "forget" listener password.
+
Ctrlproxy 3.0.5 2007-12-07
IMPROVEMENTS
} else if (run_server_filter(n, l, FROM_SERVER)) {
if (!strcmp(l->args[0], "PRIVMSG") &&
n->global->config->report_time == REPORT_TIME_ALWAYS)
- l = line_prefix_time(l, time(NULL));
+ l = line_prefix_time(l, time(NULL)+n->global->config->report_time_offset);
clients_send(n->clients, l, NULL);
}
!g_strcasecmp(l.args[0], "NOTICE"))) {
g_assert(l.origin);
if (s->global->config->report_time == REPORT_TIME_ALWAYS)
- line_prefix_time(&l, time(NULL));
+ line_prefix_time(&l, time(NULL)+s->global->config->report_time_offset);
clients_send(s->clients, &l, c);
}
admin_out(h, "Sending backlog for network '%s'", n->info.name);
linestack_send(n->linestack, lm, NULL, admin_get_client(h),
- TRUE, n->global->config->report_time != REPORT_TIME_NEVER);
+ TRUE, n->global->config->report_time != REPORT_TIME_NEVER,
+ n->global->config->report_time_offset);
g_hash_table_replace(markers, n, linestack_get_marker(n->linestack));
linestack_send_object(n->linestack, args[1], lm, NULL,
admin_get_client(h), TRUE,
- n->global->config->report_time != REPORT_TIME_NEVER);
+ n->global->config->report_time != REPORT_TIME_NEVER,
+ n->global->config->report_time_offset);
g_hash_table_replace(markers, n, linestack_get_marker(n->linestack));
}
return TRUE;
}
+static char *report_time_offset_get(admin_handle h)
+{
+ struct global *g = admin_get_global(h);
+
+ return g_strdup_printf("%d", g->config->report_time_offset);
+}
+
+static gboolean report_time_offset_set(admin_handle h, const char *value)
+{
+ struct global *g = admin_get_global(h);
+
+ g->config->report_time_offset = atoi(value);
+
+ return TRUE;
+}
+
/**
* Table of administration settings that can be
* viewed and changed using the SET command.
{ "max_who_age", max_who_age_get, max_who_age_set },
{ "motd-file", motd_file_get, motd_file_set },
{ "report-time", report_time_get, report_time_set },
+ { "report-time-offset", report_time_offset_get, report_time_offset_set },
{ "replication", replication_get, replication_set },
{ NULL, NULL, NULL }
};
return ctx->ops->insert_line(ctx, l, state);
}
-static gboolean send_line(struct line *l, time_t t, void *_client)
+struct send_line_privdata {
+ int time_offset;
+ struct client *client;
+};
+
+static gboolean send_line(struct line *l, time_t t, void *_privdata)
{
- struct client *c = _client;
- return client_send_line(c, l);
+ struct send_line_privdata *privdata = _privdata;
+ return client_send_line(privdata->client, l);
}
-static gboolean send_line_timed(struct line *l, time_t t, void *_client)
+static gboolean send_line_timed(struct line *l, time_t t, void *_privdata)
{
- struct client *c = _client;
+ struct send_line_privdata *privdata = _privdata;
if ((!g_strcasecmp(l->args[0], "PRIVMSG") ||
!g_strcasecmp(l->args[0], "NOTICE")) &&
l->argc > 2) {
- struct line *nl = line_prefix_time(l, t);
+ struct line *nl = line_prefix_time(l, t+privdata->time_offset);
gboolean ret;
- ret = client_send_line(c, nl);
+ ret = client_send_line(privdata->client, nl);
free_line(nl);
return ret;
} else {
- return client_send_line(c, l);
+ return client_send_line(privdata->client, l);
}
}
-static gboolean send_line_timed_dataonly(struct line *l, time_t t, void *_client)
+static gboolean send_line_timed_dataonly(struct line *l, time_t t, void *_privdata)
{
- struct client *c = _client;
+ struct send_line_privdata *privdata = _privdata;
gboolean ret;
struct line *nl;
if (l->argc <= 2)
return TRUE;
- nl = line_prefix_time(l, t);
- ret = client_send_line(c, nl);
+ nl = line_prefix_time(l, t+privdata->time_offset);
+ ret = client_send_line(privdata->client, nl);
free_line(nl);
return ret;
}
-static gboolean send_line_dataonly(struct line *l, time_t t, void *_client)
+static gboolean send_line_dataonly(struct line *l, time_t t, void *_privdata)
{
- struct client *c = _client;
+ struct send_line_privdata *privdata = _privdata;
if (g_strcasecmp(l->args[0], "PRIVMSG") != 0 &&
g_strcasecmp(l->args[0], "NOTICE") != 0)
if (l->argc <= 2)
return TRUE;
- return client_send_line(c, l);
+ return client_send_line(privdata->client, l);
}
-gboolean linestack_send(struct linestack_context *ctx, struct linestack_marker *mf, struct linestack_marker *mt, struct client *c, gboolean dataonly, gboolean timed)
+gboolean linestack_send(struct linestack_context *ctx, struct linestack_marker *mf, struct linestack_marker *mt, struct client *c, gboolean dataonly, gboolean timed, int time_offset)
{
+ struct send_line_privdata privdata;
linestack_traverse_fn trav_fn;
+ privdata.client = c;
+ privdata.time_offset = time_offset;
+
if (dataonly) {
if (timed)
trav_fn = send_line_timed_dataonly;
trav_fn = send_line;
}
- return linestack_traverse(ctx, mf, mt, trav_fn, c);
+ return linestack_traverse(ctx, mf, mt, trav_fn, &privdata);
}
-gboolean linestack_send_object(struct linestack_context *ctx, const char *obj, struct linestack_marker *mf, struct linestack_marker *mt, struct client *c, gboolean dataonly, gboolean timed)
+gboolean linestack_send_object(struct linestack_context *ctx, const char *obj, struct linestack_marker *mf, struct linestack_marker *mt, struct client *c, gboolean dataonly, gboolean timed, int time_offset)
{
+ struct send_line_privdata privdata;
linestack_traverse_fn trav_fn;
+
+ privdata.client = c;
+ privdata.time_offset = time_offset;
+
if (dataonly) {
if (timed)
trav_fn = send_line_timed_dataonly;
trav_fn = send_line;
}
- return linestack_traverse_object(ctx, obj, mf, mt, trav_fn, c);
+ return linestack_traverse_object(ctx, obj, mf, mt, trav_fn, &privdata);
}
static gboolean replay_line(struct line *l, time_t t, void *state)
struct linestack_marker *to, /* Can be NULL for 'now' */
struct client *,
gboolean dataonly,
- gboolean timed);
+ gboolean timed,
+ int time_offset);
G_MODULE_EXPORT gboolean linestack_send_object (
struct linestack_context *,
struct linestack_marker *to, /* Can be NULL for 'now' */
struct client *,
gboolean dataonly,
- gboolean timed);
+ gboolean timed,
+ int time_offset);
G_MODULE_EXPORT gboolean linestack_replay (
struct linestack_context *,
free_network_state(ns);
linestack_send(c->network->linestack, lm, NULL, c, FALSE,
- c->network->global->config->report_time != REPORT_TIME_NEVER);
+ c->network->global->config->report_time != REPORT_TIME_NEVER,
+ c->network->global->config->report_time_offset);
}
static gboolean log_data(struct network *n, const struct line *l, enum data_direction dir, void *userdata)
free_network_state(ns);
linestack_send(c->network->linestack, m, NULL, c, FALSE,
- c->network->global->config->report_time != REPORT_TIME_NEVER);
+ c->network->global->config->report_time != REPORT_TIME_NEVER,
+ c->network->global->config->report_time_offset);
}
static const struct replication_backend backends[] = {
"replication",
"linestack",
"report-time",
+ "report-time-offset",
"motd-file",
"default-client-charset",
"learn-nickserv",
break;
}
+ if (cfg->report_time_offset != 0 ||
+ g_key_file_has_key(cfg->keyfile, "global", "report-time-offset", NULL))
+ g_key_file_set_integer(cfg->keyfile, "global", "report-time-offset", cfg->report_time_offset);
+
config_save_networks(configuration_dir, cfg->networks);
config_save_listeners(cfg, configuration_dir);
g_free(setting);
}
+ cfg->report_time_offset = 0;
+ if (g_key_file_has_key(kf, "global", "report-time-offset", NULL)) {
+ cfg->report_time_offset = g_key_file_get_integer(kf, "global", "report-time-offset", NULL);
+ }
+
if (g_key_file_has_key(kf, "global", "motd-file", NULL))
cfg->motd_file = g_key_file_get_string(kf, "global", "motd-file", NULL);
else
REPORT_TIME_NEVER,
REPORT_TIME_REPLICATION
} report_time;
+ int report_time_offset;
int max_who_age;
GKeyFile *keyfile;
GList *listeners;