# error DIRECTOR_CONNECTION_PONG_TIMEOUT_MSECS is too low
#endif
-#define CMD_IS_USER_HANDSHAKE(args) \
- (str_array_length(args) > 2)
+#define CMD_IS_USER_HANDSHAKE(minor_version, args) \
+ ((minor_version) < DIRECTOR_VERSION_HANDSHAKE_U_CMD && \
+ str_array_length(args) > 2)
#define DIRECTOR_OPT_CONSISTENT_HASHING "consistent-hashing"
struct user *user;
bool forced;
- /* NOTE: if more parameters are added, update also
- CMD_IS_USER_HANDSHAKE() macro */
if (str_array_length(args) != 2 ||
str_to_uint(args[0], &username_hash) < 0 ||
net_addr2ip(args[1], &ip) < 0) {
return director_cmd_host_hand_start(conn, args) ? 1 : -1;
}
- if (conn->in && strcmp(cmd, "USER") == 0 && CMD_IS_USER_HANDSHAKE(args))
+ if (conn->in &&
+ (strcmp(cmd, "U") == 0 ||
+ (strcmp(cmd, "USER") == 0 &&
+ CMD_IS_USER_HANDSHAKE(conn->minor_version, args))))
return director_handshake_cmd_user(conn, args) ? 1 : -1;
/* both get DONE */
i_assert(conn->version_received);
- while ((user = director_iterate_users_next(conn->user_iter)) != NULL) {
- str_truncate(str, 0);
+ /* with new versions use "U" for sending the handshake users, because
+ otherwise their parameters may look identical and can't be
+ distinguished. */
+ if (director_connection_get_minor_version(conn) >= DIRECTOR_VERSION_HANDSHAKE_U_CMD)
+ str_append(str, "U\t");
+ else
str_append(str, "USER\t");
+ size_t cmd_prefix_len = str_len(str);
+ while ((user = director_iterate_users_next(conn->user_iter)) != NULL) {
+ str_truncate(str, cmd_prefix_len);
str_append(str, dec2str_buf(dec_buf, user->username_hash));
str_append_c(str, '\t');
str_append(str, user->host->ip_str);
#define DIRECTOR_VERSION_NAME "director"
#define DIRECTOR_VERSION_MAJOR 1
-#define DIRECTOR_VERSION_MINOR 8
+#define DIRECTOR_VERSION_MINOR 9
/* weak users supported in protocol */
#define DIRECTOR_VERSION_WEAK_USERS 1
#define DIRECTOR_VERSION_TAGS_V2 7
/* user-kick-alt supported */
#define DIRECTOR_VERSION_USER_KICK_ALT 8
+/* Users are sent as "U" command in handshake */
+#define DIRECTOR_VERSION_HANDSHAKE_U_CMD 9
/* Minimum time between even attempting to communicate with a director that
failed due to a protocol error. */