Browse Source

[Feature] Use controller port by default when connecting to local IP

tags/1.7.0
Vsevolod Stakhov 6 years ago
parent
commit
ee86574d47
1 changed files with 21 additions and 7 deletions
  1. 21
    7
      src/client/rspamc.c

+ 21
- 7
src/client/rspamc.c View File

@@ -1594,13 +1594,6 @@ rspamc_process_input (struct event_base *ev_base, struct rspamc_command *cmd,

p = strrchr (p, ':');

if (p != NULL) {
port = strtoul (p + 1, NULL, 10);
}
else {
port = cmd->is_controller ? DEFAULT_CONTROL_PORT : DEFAULT_PORT;
}

if (!hostbuf) {
if (p != NULL) {
hostbuf = g_malloc (p - connect_str + 1);
@@ -1611,6 +1604,27 @@ rspamc_process_input (struct event_base *ev_base, struct rspamc_command *cmd,
}
}

if (p != NULL) {
port = strtoul (p + 1, NULL, 10);
}
else {
/*
* If we connect to localhost, 127.0.0.1 or ::1, then try controller
* port first
*/

if (strcmp (hostbuf, "localhost") == 0 ||
strcmp (hostbuf, "127.0.0.1") == 0 ||
strcmp (hostbuf, "::1") == 0 ||
strcmp (hostbuf, "[::1]") == 0) {
port = DEFAULT_CONTROL_PORT;
}
else {
port = cmd->is_controller ? DEFAULT_CONTROL_PORT : DEFAULT_PORT;
}

}

conn = rspamd_client_init (ev_base, hostbuf, port, timeout, key);

if (conn != NULL) {

Loading…
Cancel
Save