return;
connect_str = t_strdup_printf("CONNECT\t%s\t%u\n",
- net_ip2addr(&host->ip), host->port);
+ host->ip_str, host->port);
director_connection_send(conn, connect_str);
o_stream_uncork(conn->output);
conn->host->port != port)) {
i_error("Remote director thinks it's someone else "
"(connected to %s:%u, remote says it's %s:%u)",
- net_ip2addr(&conn->host->ip), conn->host->port,
+ conn->host->ip_str, conn->host->port,
net_ip2addr(&ip), port);
return FALSE;
}
dir->self_host) < 0) {
/* c) */
connect_str = t_strdup_printf("CONNECT\t%s\t%u\n",
- net_ip2addr(&conn->host->ip),
+ conn->host->ip_str,
conn->host->port);
director_connection_send(dir->left, connect_str);
} else {
} else if (weak) {
dir_debug("user refresh: %u weak update to %s ignored, "
"we recently changed it to %s",
- username_hash, net_ip2addr(&host->ip),
- net_ip2addr(&user->host->ip));
+ username_hash, host->ip_str,
+ user->host->ip_str);
host = user->host;
ret = TRUE;
} else if (user->host == host) {
and we should have as well. use the new host. */
dir_debug("user refresh: %u is nearly expired, "
"replacing host %s with %s", username_hash,
- net_ip2addr(&user->host->ip), net_ip2addr(&host->ip));
+ user->host->ip_str, host->ip_str);
ret = TRUE;
} else if (USER_IS_BEING_KILLED(user)) {
/* user is still being moved - ignore conflicting host updates
from other directors who don't yet know about the move. */
dir_debug("user refresh: %u is being moved, "
"preserve its host %s instead of replacing with %s",
- username_hash, net_ip2addr(&user->host->ip),
- net_ip2addr(&host->ip));
+ username_hash, user->host->ip_str, host->ip_str);
host = user->host;
} else {
/* non-weak user received a non-weak update with
str_printfa(str, "User hash %u "
"is being redirected to two hosts: %s and %s",
- username_hash, net_ip2addr(&user->host->ip),
- net_ip2addr(&host->ip));
+ username_hash, user->host->ip_str, host->ip_str);
str_printfa(str, " (old_ts=%ld", (long)user->timestamp);
if (!conn->handshake_received) {
this around the ring to the origin so it also knows it has
travelled through the ring. */
dir_debug("user refresh: %u Remote USER-WEAK from %s seen by the entire ring, ignoring",
- username_hash, net_ip2addr(&dir_host->ip));
+ username_hash, dir_host->ip_str);
weak_forward = TRUE;
}
host_tag = mail_host_get_tag(host);
if (strcmp(tag, host_tag) != 0) {
i_error("director(%s): Host %s changed tag from '%s' to '%s'",
- conn->name, net_ip2addr(&host->ip),
+ conn->name, host->ip_str,
host_tag, tag);
mail_host_set_tag(host, tag);
update = TRUE;
string_t *str = t_str_new(128);
str_printfa(str, "director(%s): Host %s is being updated before previous update had finished (",
- conn->name, net_ip2addr(&host->ip));
+ conn->name, host->ip_str);
if (host->down != down &&
host->last_updown_change > last_updown_change) {
/* our host has a newer change. preserve it. */
/* tell the "right" director about the "left" one */
director_update_send(dir, director_connection_get_host(conn),
t_strdup_printf("DIRECTOR\t%s\t%u\n",
- net_ip2addr(&conn->host->ip),
+ conn->host->ip_str,
conn->host->port));
/* this is our "left" side. */
return director_connection_assign_left(conn);
if (host->desynced_hosts_hash != hosts_hash) {
dir_debug("Ignore director %s stale SYNC request whose hosts don't match us "
"(seq=%u, remote hosts_hash=%u, my hosts_hash=%u)",
- net_ip2addr(&host->ip), seq, hosts_hash,
+ host->ip_str, seq, hosts_hash,
mail_hosts_hash(dir->mail_hosts));
host->desynced_hosts_hash = hosts_hash;
return FALSE;
changing rapidly. */
i_error("director(%s): Director %s SYNC request hosts don't match us - resending hosts "
"(seq=%u, remote hosts_hash=%u, my hosts_hash=%u)",
- conn->name, net_ip2addr(&host->ip), seq,
+ conn->name, host->ip_str, seq,
hosts_hash, mail_hosts_hash(dir->mail_hosts));
director_resend_hosts(dir);
return FALSE;
str_truncate(str, 0);
str_printfa(str, "DIRECTOR\t%s\t%u\n",
- net_ip2addr(&(*hostp)->ip), (*hostp)->port);
+ (*hostp)->ip_str, (*hostp)->port);
director_connection_send(conn, str_c(str));
}
}
const char *host_tag = mail_host_get_tag(host);
str_printfa(str, "HOST\t%s\t%u",
- net_ip2addr(&host->ip), host->vhost_count);
+ host->ip_str, host->vhost_count);
if (host_tag[0] != '\0' || send_updowns) {
str_append_c(str, '\t');
str_append_tabescaped(str, host_tag);
str_printfa(str, "USER\t%u\t%s\t%u",
user->username_hash,
- net_ip2addr(&user->host->ip),
+ user->host->ip_str,
user->timestamp);
if (user->weak)
str_append(str, "\tw");
host->ip = *ip;
host->ip_str = i_strdup(net_ip2addr(&host->ip));
host->port = port;
- host->name = i_strdup_printf("%s:%u", net_ip2addr(ip), port);
+ host->name = i_strdup_printf("%s:%u", host->ip_str, port);
array_append(&dir->dir_hosts, &host, 1);
(int)(ioloop_time - host->last_protocol_failure));
}
i_info("Connecting to %s:%u (as %s%s): %s",
- net_ip2addr(&host->ip), host->port,
+ host->ip_str, host->port,
net_ip2addr(&dir->self_ip), str_c(str), reason);
}
str = t_str_new(128);
str_printfa(str, "SYNC\t%s\t%u\t%u",
- net_ip2addr(&host->ip), host->port, seq);
+ host->ip_str, host->port, seq);
if (minor_version > 0 &&
director_connection_get_minor_version(dir->right) > 0) {
/* only minor_version>0 supports extra parameters */
added_host->dir->ring_change_counter++;
cmd = t_strdup_printf("DIRECTOR\t%s\t%u\n",
- net_ip2addr(&added_host->ip), added_host->port);
+ added_host->ip_str, added_host->port);
director_update_send(added_host->dir, src, cmd);
}
/* if our left or ride side gets removed, notify them first
before disconnecting. */
cmd = t_strdup_printf("DIRECTOR-REMOVE\t%s\t%u\n",
- net_ip2addr(&removed_host->ip),
- removed_host->port);
+ removed_host->ip_str, removed_host->port);
director_update_send_version(dir, src,
DIRECTOR_VERSION_RING_REMOVE, cmd);
str = t_str_new(128);
str_printfa(str, "HOST\t%s\t%u\t%u\t%s\t%u",
- net_ip2addr(&orig_src->ip), orig_src->port,
- orig_src->last_seq,
- net_ip2addr(&host->ip), host->vhost_count);
+ orig_src->ip_str, orig_src->port, orig_src->last_seq,
+ host->ip_str, host->vhost_count);
if (dir->ring_min_version >= DIRECTOR_VERSION_TAGS_V2) {
str_append_c(str, '\t');
str_append_tabescaped(str, host_tag);
dir->ring_min_version < DIRECTOR_VERSION_TAGS_V2) {
if (dir->ring_min_version < DIRECTOR_VERSION_TAGS) {
i_error("Ring has directors that don't support tags - removing host %s with tag '%s'",
- net_ip2addr(&host->ip), host_tag);
+ host->ip_str, host_tag);
} else {
i_error("Ring has directors that support mixed versions of tags - removing host %s with tag '%s'",
- net_ip2addr(&host->ip), host_tag);
+ host->ip_str, host_tag);
}
director_remove_host(dir, NULL, NULL, host);
return;
dir_debug("Updating host %s vhost_count=%u "
"down=%d last_updown_change=%ld (hosts_hash=%u)",
- net_ip2addr(&host->ip), host->vhost_count, host->down ? 1 : 0,
+ host->ip_str, host->vhost_count, host->down ? 1 : 0,
(long)host->last_updown_change,
mail_hosts_hash(dir->mail_hosts));
director_update_send(dir, src, t_strdup_printf(
"HOST-REMOVE\t%s\t%u\t%u\t%s\n",
- net_ip2addr(&orig_src->ip), orig_src->port,
- orig_src->last_seq, net_ip2addr(&host->ip)));
+ orig_src->ip_str, orig_src->port,
+ orig_src->last_seq, host->ip_str));
}
user_directory_remove_host(users, host);
director_update_send(dir, src, t_strdup_printf(
"HOST-FLUSH\t%s\t%u\t%u\t%s\n",
- net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq,
- net_ip2addr(&host->ip)));
+ orig_src->ip_str, orig_src->port, orig_src->last_seq,
+ host->ip_str));
user_directory_remove_host(users, host);
director_sync(dir);
}
i_assert(!user->weak);
director_update_send(dir, src, t_strdup_printf("USER\t%u\t%s\n",
- user->username_hash, net_ip2addr(&user->host->ip)));
+ user->username_hash, user->host->ip_str));
}
void director_update_user_weak(struct director *dir, struct director_host *src,
}
cmd = t_strdup_printf("USER-WEAK\t%s\t%u\t%u\t%u\t%s\n",
- net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq,
- user->username_hash, net_ip2addr(&user->host->ip));
+ orig_src->ip_str, orig_src->port, orig_src->last_seq,
+ user->username_hash, user->host->ip_str);
if (src != dir->self_host && dir->left != NULL && dir->right != NULL &&
director_connection_get_host(dir->left) ==
i_error("%s: Failed to flush user hash %u in host %s: %s",
ctx->socket_path,
ctx->username_hash,
- net_ip2addr(&ctx->host_ip),
- data);
+ net_ip2addr(&ctx->host_ip), data);
}
i_stream_unref(&is);
} else {
{
struct director_kill_context *ctx = user->kill_ctx;
struct var_expand_table tab[] = {
- { 'i', net_ip2addr(&user->host->ip), "ip" },
+ { 'i', user->host->ip_str, "ip" },
{ 'h', user->host->hostname, "host" },
{ '\0', NULL, NULL }
};
"FLUSH",
t_strdup_printf("%u", user->username_hash),
net_ip2addr(&ctx->old_host_ip),
- net_ip2addr(&user->host->ip),
+ user->host->ip_str,
ctx->old_host_down ? "down" : "up",
dec2str(ctx->old_host_vhost_count),
NULL
i_error("%s: Failed to flush user hash %u in host %s: %s",
ctx->socket_path,
user->username_hash,
- net_ip2addr(&user->host->ip),
+ user->host->ip_str,
error);
director_flush_user_continue(0, ctx);
return;
ctx->reply =
iostream_temp_create_named("/tmp", 0,
t_strdup_printf("flush response from %s",
- net_ip2addr(&user->host->ip)));
+ user->host->ip_str));
o_stream_set_no_error_handling(ctx->reply, TRUE);
program_client_set_output(ctx->pclient, ctx->reply);
ctx->callback_pending = TRUE;
old_host = user->host;
user->timestamp = ioloop_time;
dir_debug("User %u move forwarded: host is already %s",
- username_hash, net_ip2addr(&host->ip));
+ username_hash, host->ip_str);
} else {
/* user is looked up via the new host's tag, so if it's found
the old tag has to be the same. */
user->host->user_count++;
user->timestamp = ioloop_time;
dir_debug("User %u move started: host %s -> %s",
- username_hash, net_ip2addr(&old_host->ip),
- net_ip2addr(&host->ip));
+ username_hash, old_host->ip_str,
+ host->ip_str);
}
if (orig_src == NULL) {
}
director_update_send(dir, src, t_strdup_printf(
"USER-MOVE\t%s\t%u\t%u\t%u\t%s\n",
- net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq,
- user->username_hash, net_ip2addr(&user->host->ip)));
+ orig_src->ip_str, orig_src->port, orig_src->last_seq,
+ user->username_hash, user->host->ip_str));
/* kill the user only after sending the USER-MOVE, because the kill
may finish instantly. */
director_kill_user(dir, src, user, host->tag, old_host, FALSE);
}
str_truncate(cmd, 0);
str_printfa(cmd, "USER-KICK\t%s\t%u\t%u\t",
- net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq);
+ orig_src->ip_str, orig_src->port, orig_src->last_seq);
str_append_tabescaped(cmd, username);
str_append_c(cmd, '\n');
director_update_send_version(dir, src, DIRECTOR_VERSION_USER_KICK, str_c(cmd));
}
str_truncate(cmd, 0);
str_printfa(cmd, "USER-KICK-ALT\t%s\t%u\t%u\t",
- net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq);
+ orig_src->ip_str, orig_src->port, orig_src->last_seq);
str_append_tabescaped(cmd, field);
str_append_c(cmd, '\t');
str_append_tabescaped(cmd, value);
orig_src->last_seq++;
}
cmd = t_strdup_printf("USER-KICK-HASH\t%s\t%u\t%u\t%u\t%s\n",
- net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq,
+ orig_src->ip_str, orig_src->port, orig_src->last_seq,
username_hash, net_ip2addr(except_ip));
director_update_send_version(dir, src, DIRECTOR_VERSION_USER_KICK, cmd);
}
}
director_update_send(dir, src, t_strdup_printf(
"USER-KILLED-EVERYWHERE\t%s\t%u\t%u\t%u\n",
- net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq,
+ orig_src->ip_str, orig_src->port, orig_src->last_seq,
username_hash));
}
array_foreach(mail_hosts_get(conn->dir->mail_hosts), hostp) {
str_printfa(str, "%s\t%u\t%u\t",
- net_ip2addr(&(*hostp)->ip), (*hostp)->vhost_count,
+ (*hostp)->ip_str, (*hostp)->vhost_count,
(*hostp)->user_count);
str_append_tabescaped(str, mail_host_get_tag(*hostp));
str_printfa(str, "\t%c\t%ld", (*hostp)->down ? 'D' : 'U',
else if (ret > 0)
j++;
else {
- str_printfa(str, "%s\n",
- net_ip2addr(&orig_hosts[i]->ip));
+ str_printfa(str, "%s\n", orig_hosts[i]->ip_str);
i++;
}
}
for (; i < orig_hosts_count; i++)
- str_printfa(str, "%s\n", net_ip2addr(&orig_hosts[i]->ip));
+ str_printfa(str, "%s\n", orig_hosts[i]->ip_str);
str_append_c(str, '\n');
o_stream_nsend(conn->output, str_data(str), str_len(str));
time_t last_failed = I_MAX(host->last_network_failure,
host->last_protocol_failure);
str_printfa(str, "%s\t%u\t%s\t%"PRIdTIME_T"\t",
- net_ip2addr(&host->ip), host->port, type,
+ host->ip_str, host->port, type,
last_failed);
}
if (user == NULL)
str_append(str, "\t0");
else {
- str_printfa(str, "%s\t%u", net_ip2addr(&user->host->ip),
+ str_printfa(str, "%s\t%u", user->host->ip_str,
user->timestamp +
conn->dir->set->director_user_expire);
}
if (host == NULL)
str_append(str, "\t");
else
- str_printfa(str, "\t%s", net_ip2addr(&host->ip));
+ str_printfa(str, "\t%s", host->ip_str);
/* get host with default configuration */
host = mail_host_get_by_hash(conn->dir->orig_config_hosts,
if (host == NULL)
str_append(str, "\t\n");
else
- str_printfa(str, "\t%s\n", net_ip2addr(&host->ip));
+ str_printfa(str, "\t%s\n", host->ip_str);
o_stream_nsend(conn->output, str_data(str), str_len(str));
return DOVEADM_DIRECTOR_CMD_RET_OK;
}
o_stream_nsend_str(conn->output, t_strdup_printf(
"%u\t%u\t%s\n",
user->username_hash, expire_time,
- net_ip2addr(&user->host->ip)));
+ user->host->ip_str));
} T_END;
}
director_iterate_users_deinit(&iter);
struct mail_vhost *vhost;
struct md5_context md5_ctx, md5_ctx2;
unsigned char md5[MD5_RESULTLEN];
- const char *ip_str;
char num_str[MAX_INT_STRLEN];
unsigned int i, j;
if (host->down || host->tag != tag)
return;
- ip_str = net_ip2addr(&host->ip);
-
md5_init(&md5_ctx);
- md5_update(&md5_ctx, ip_str, strlen(ip_str));
+ md5_update(&md5_ctx, host->ip_str, strlen(host->ip_str));
for (i = 0; i < host->vhost_count; i++) {
md5_ctx2 = md5_ctx;
const char *updown = down ? "down" : "up";
i_info("%sHost %s changed %s "
"(vhost_count=%u last_updown_change=%ld)",
- log_prefix, net_ip2addr(&host->ip), updown,
+ log_prefix, host->ip_str, updown,
host->vhost_count, (long)host->last_updown_change);
host->down = down;
const char *log_prefix)
{
i_info("%sHost %s vhost count changed from %u to %u",
- log_prefix, net_ip2addr(&host->ip),
+ log_prefix, host->ip_str,
host->vhost_count, vhost_count);
host->vhost_count = vhost_count;