|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct rspamd_server { |
|
|
struct rspamd_server { |
|
|
struct upstream up; |
|
|
struct upstream up; |
|
|
struct in_addr addr; |
|
|
|
|
|
guint16 client_port; |
|
|
guint16 client_port; |
|
|
guint16 controller_port; |
|
|
guint16 controller_port; |
|
|
gchar *name; |
|
|
gchar *name; |
|
|
|
|
|
|
|
|
guint16 controller_port, GError **err) |
|
|
guint16 controller_port, GError **err) |
|
|
{ |
|
|
{ |
|
|
struct rspamd_server *new; |
|
|
struct rspamd_server *new; |
|
|
struct hostent *hent; |
|
|
|
|
|
gint nlen, i; |
|
|
gint nlen, i; |
|
|
|
|
|
|
|
|
g_assert (client != NULL); |
|
|
g_assert (client != NULL); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
new = &client->servers[client->servers_num]; |
|
|
new = &client->servers[client->servers_num]; |
|
|
|
|
|
|
|
|
if (*host != '/') { |
|
|
|
|
|
/* Try to resolve */ |
|
|
|
|
|
if (!inet_aton (host, &new->addr)) { |
|
|
|
|
|
/* Try to call gethostbyname */ |
|
|
|
|
|
hent = gethostbyname (host); |
|
|
|
|
|
if (hent == NULL) { |
|
|
|
|
|
if (*err == NULL) { |
|
|
|
|
|
*err = g_error_new (G_RSPAMD_ERROR, 1, "Cannot resolve: %s", host); |
|
|
|
|
|
} |
|
|
|
|
|
return FALSE; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
memcpy (&new->addr, hent->h_addr, sizeof (struct in_addr)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
new->client_port = port; |
|
|
new->client_port = port; |
|
|
new->controller_port = controller_port; |
|
|
new->controller_port = controller_port; |
|
|
new->host = g_strdup (host); |
|
|
new->host = g_strdup (host); |