123
last_failed = I_MAX(host->last_network_failure,
124
host->last_protocol_failure);
119
125
str_printfa(str, "%s\t%u\t%s\t%lu\n",
120
126
net_ip2addr(&host->ip), host->port, type,
121
(unsigned long)host->last_failed);
127
(unsigned long)last_failed);
123
129
str_append_c(str, '\n');
124
130
o_stream_send(conn->output, str_data(str), str_len(str));
134
doveadm_cmd_director_add(struct doveadm_connection *conn, const char *line)
136
const char *const *args;
137
struct director_host *host;
139
unsigned int port = conn->dir->self_port;
141
args = t_strsplit_tab(line);
142
if (args[0] == NULL ||
143
net_addr2ip(line, &ip) < 0 ||
144
(args[1] != NULL && str_to_uint(args[1], &port) < 0)) {
145
i_error("doveadm sent invalid DIRECTOR-ADD parameters");
149
if (director_host_lookup(conn->dir, &ip, port) == NULL) {
150
host = director_host_add(conn->dir, &ip, port);
151
director_notify_ring_added(host, conn->dir->self_host);
153
o_stream_send(conn->output, "OK\n", 3);
158
doveadm_cmd_director_remove(struct doveadm_connection *conn, const char *line)
160
const char *const *args;
161
struct director_host *host;
163
unsigned int port = 0;
165
args = t_strsplit_tab(line);
166
if (args[0] == NULL ||
167
net_addr2ip(line, &ip) < 0 ||
168
(args[1] != NULL && str_to_uint(args[1], &port) < 0)) {
169
i_error("doveadm sent invalid DIRECTOR-REMOVE parameters");
174
director_host_lookup(conn->dir, &ip, port) :
175
director_host_lookup_ip(conn->dir, &ip);
177
o_stream_send_str(conn->output, "NOTFOUND\n");
179
director_ring_remove(host, conn->dir->self_host);
180
o_stream_send(conn->output, "OK\n", 3);
128
186
doveadm_cmd_host_set(struct doveadm_connection *conn, const char *line)
130
188
struct director *dir = conn->dir;
133
191
struct ip_addr ip;
134
192
unsigned int vhost_count = -1U;
136
args = t_strsplit(line, "\t");
194
args = t_strsplit_tab(line);
137
195
if (args[0] == NULL ||
138
196
net_addr2ip(args[0], &ip) < 0 ||
139
197
(args[1] != NULL && str_to_uint(args[1], &vhost_count) < 0)) {
223
281
string_t *str = t_str_new(256);
225
283
if (str_to_uint(line, &username_hash) < 0)
226
username_hash = user_directory_get_username_hash(line);
284
username_hash = user_directory_get_username_hash(conn->dir->users, line);
228
286
/* get user's current host */
229
287
user = user_directory_lookup(conn->dir->users, username_hash);
296
354
struct mail_host *host;
297
355
struct ip_addr ip;
299
args = t_strsplit(line, "\t");
357
args = t_strsplit_tab(line);
300
358
if (args[0] == NULL || args[1] == NULL ||
301
359
net_addr2ip(args[1], &ip) < 0) {
302
360
i_error("doveadm sent invalid USER-MOVE parameters: %s", line);
311
369
if (str_to_uint(args[0], &username_hash) < 0)
312
username_hash = user_directory_get_username_hash(line);
370
username_hash = user_directory_get_username_hash(conn->dir->users, line);
313
371
user = user_directory_lookup(conn->dir->users, username_hash);
314
372
if (user != NULL && user->kill_state != USER_KILL_STATE_NONE) {
315
373
o_stream_send_str(conn->output, "TRYAGAIN\n");
360
418
doveadm_cmd_host_list_removed(conn);
361
419
else if (strcmp(cmd, "DIRECTOR-LIST") == 0)
362
420
doveadm_cmd_director_list(conn);
421
else if (strcmp(cmd, "DIRECTOR-ADD") == 0)
422
doveadm_cmd_director_add(conn, args);
423
else if (strcmp(cmd, "DIRECTOR-REMOVE") == 0)
424
doveadm_cmd_director_remove(conn, args);
363
425
else if (strcmp(cmd, "HOST-SET") == 0)
364
426
ret = doveadm_cmd_host_set(conn, args);
365
427
else if (strcmp(cmd, "HOST-REMOVE") == 0)