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(line, "doveadm-server",
- DOVEADM_SERVER_PROTOCOL_VERSION_MAJOR)) {
+ if (!version_string_verify_full(line, "doveadm-server",
+ DOVEADM_SERVER_PROTOCOL_VERSION_MAJOR, &minor)) {
i_error("doveadm client not compatible with this server "
"(mixed old and new binaries?)");
client_connection_destroy(&conn);
return;
}
+ if (minor > 0) {
+ /* send version reply */
+ o_stream_nsend_str(conn->output,
+ DOVEADM_CLIENT_PROTOCOL_VERSION_LINE"\n");
+ conn->use_multiplex = TRUE;
+ }
conn->handshaked = TRUE;
}
if (!conn->authenticated) {
}
o_stream_nsend(conn->output, "+\n", 2);
conn->authenticated = TRUE;
+ doveadm_print_ostream = conn->output;
}
if (!conn->io_setup) {
client_connection_send_auth_handshake(conn, listen_fd);
client_connection_set_proctitle(conn, "");
- doveadm_print_ostream = conn->output;
return conn;
}
struct doveadm_settings *set;
int fd;
+ unsigned int minor;
+
struct io *io;
struct istream *input;
struct ostream *output;
if (!conn->handshaked || !conn->authenticated) {
while((line = i_stream_read_next_line(conn->input)) != NULL) {
+ if (strncmp(line, "VERSION\t", 8) == 0) {
+ if (!version_string_verify_full(line, "doveadm-client",
+ DOVEADM_SERVER_PROTOCOL_VERSION_MAJOR,
+ &conn->minor)) {
+ i_error("doveadm server not compatible with this client"
+ "(mixed old and new binaries?)");
+ server_connection_destroy(&conn);
+ }
+ continue;
+ }
if (strcmp(line, "+") == 0) {
server_connection_authenticated(conn);
break;
int server_connection_create(struct doveadm_server *server,
struct server_connection **conn_r)
{
-#define DOVEADM_SERVER_HANDSHAKE "VERSION\tdoveadm-server\t1\t0\n"
struct server_connection *conn;
pool_t pool;
conn->fd = doveadm_connect_with_default_port(server->name,
doveadm_settings->doveadm_port);
net_set_nonblock(conn->fd, TRUE);
- conn->io = io_add(conn->fd, IO_READ, server_connection_input, conn);
conn->input = i_stream_create_fd(conn->fd, MAX_INBUF_SIZE);
+ conn->io = io_add_istream(conn->input, server_connection_input, conn);
conn->output = o_stream_create_fd(conn->fd, (size_t)-1);
o_stream_set_flush_callback(conn->output, server_connection_output, conn);
o_stream_set_no_error_handling(conn->output, TRUE);
conn->state = SERVER_REPLY_STATE_DONE;
- o_stream_nsend_str(conn->output, DOVEADM_SERVER_HANDSHAKE);
+ o_stream_nsend_str(conn->output, DOVEADM_SERVER_PROTOCOL_VERSION_LINE"\n");
*conn_r = conn;
return 0;