struct client_connection_tcp {
struct client_connection conn;
+ unsigned int minor_version;
int fd;
struct io *io;
struct istream *input;
bool preauthenticated:1;
bool authenticated:1;
bool io_setup:1;
- bool use_multiplex:1;
};
static void
doveadm_server_capture_logs();
}
+static void
+client_handle_options(struct client_connection_tcp *conn,
+ const char *const *options)
+{
+ for (unsigned int i = 0; options[i] != NULL; i++) {
+ if (strcmp(options[i], "log-passthrough") == 0) {
+ if (conn->log_out == NULL)
+ client_connection_log_passthrough(conn);
+ } else {
+ /* unknown option - ignore */
+ }
+ }
+}
+
static bool client_handle_command(struct client_connection_tcp *conn,
const char *const *args)
{
}
}
+ if (strcmp(cmd_name, "OPTION") == 0) {
+ client_handle_options(conn, args+3);
+ return TRUE;
+ }
+
if (!doveadm_client_is_allowed_command(conn->conn.set, cmd_name)) {
i_error("doveadm client isn't allowed to use command: %s",
cmd_name);
const char *line;
bool ok = TRUE;
int ret;
- unsigned int minor;
if (!conn->handshaked) {
if ((line = i_stream_read_next_line(conn->input)) == NULL) {
return;
}
if (!version_string_verify_full(line, "doveadm-server",
- DOVEADM_SERVER_PROTOCOL_VERSION_MAJOR, &minor)) {
+ DOVEADM_SERVER_PROTOCOL_VERSION_MAJOR,
+ &conn->minor_version)) {
i_error("doveadm client not compatible with this server "
"(mixed old and new binaries?)");
client_connection_tcp_destroy(&conn);
return;
}
- if (minor >= DOVEADM_PROTOCOL_MIN_VERSION_MULTIPLEX) {
+ if (conn->minor_version >= DOVEADM_PROTOCOL_MIN_VERSION_MULTIPLEX) {
/* send version reply */
o_stream_nsend_str(conn->output,
DOVEADM_CLIENT_PROTOCOL_VERSION_LINE"\n");
- conn->use_multiplex = TRUE;
}
client_connection_tcp_send_auth_handshake(conn);
conn->handshaked = TRUE;
if (!conn->io_setup) {
conn->io_setup = TRUE;
- if (conn->use_multiplex) {
+ if (conn->minor_version >= DOVEADM_PROTOCOL_MIN_VERSION_MULTIPLEX) {
struct ostream *os = conn->output;
conn->output = o_stream_create_multiplex(os, SIZE_MAX);
o_stream_set_name(conn->output, o_stream_get_name(os));
o_stream_set_no_error_handling(conn->output, TRUE);
o_stream_unref(&os);
+ }
+ if (conn->minor_version >= DOVEADM_PROTOCOL_MIN_VERSION_MULTIPLEX &&
+ conn->minor_version < DOVEADM_PROTOCOL_MIN_VERSION_LOG_PASSTHROUGH) {
+ /* Log passthrough supported by the client, but it's
+ not explicitly requested. */
client_connection_log_passthrough(conn);
}
doveadm_print_ostream = conn->output;
dest_r->ssl_ctx = src->ssl_ctx;
ssl_iostream_context_ref(dest_r->ssl_ctx);
}
+
+ dest_r->log_passthrough = src->log_passthrough;
}
static void doveadm_client_set_print_pending(struct doveadm_client *conn)
if (conn->conn.minor_version >= DOVEADM_PROTOCOL_MIN_VERSION_MULTIPLEX)
doveadm_client_start_multiplex(conn);
+ if (conn->set.log_passthrough &&
+ conn->conn.minor_version >= DOVEADM_PROTOCOL_MIN_VERSION_LOG_PASSTHROUGH)
+ o_stream_nsend_str(conn->conn.output, "\t\tOPTION\tlog-passthrough\n");
+
if (conn->delayed_cmd != NULL) {
o_stream_nsend_str(conn->conn.output, conn->delayed_cmd);
conn->delayed_cmd = NULL;