{
gboolean ret = FALSE;
- if (inet_pton (AF_INET6, src, &target->addr.s6.sin6_addr) == 1) {
+ if (src[0] == '/' || src[0] == '.') {
+ target->af = AF_UNIX;
+ target->slen = sizeof (target->addr.su);
+ rspamd_strlcpy (target->addr.su.sun_path, src,
+ sizeof (target->addr.su.sun_path));
+#ifdef FREEBSD
+ target->addr.su.sun_len = SUN_LEN (addr);
+#endif
+ }
+ else if (inet_pton (AF_INET6, src, &target->addr.s6.sin6_addr) == 1) {
target->af = AF_INET6;
target->slen = sizeof (target->addr.s6);
ret = TRUE;
guint *max_addrs,
guint *priority,
gchar **name,
- guint default_port)
+ guint default_port,
+ rspamd_mempool_t *pool)
{
gchar *err_str, portbuf[8];
const gchar *cur_tok, *cur_port;
addr_cnt ++;
}
- *addr = g_new (rspamd_inet_addr_t, addr_cnt);
+ if (pool == NULL) {
+ *addr = g_new (rspamd_inet_addr_t, addr_cnt);
+ }
+ else {
+ *addr = rspamd_mempool_alloc (pool, addr_cnt *
+ sizeof (rspamd_inet_addr_t));
+ }
cur = res;
addr_cnt = 0;
/* Restore errno */
if (name != NULL) {
- *name = g_strdup (tokens[0]);
+ if (pool == NULL) {
+ *name = g_strdup (tokens[0]);
+ }
+ else {
+ *name = rspamd_mempool_strdup (pool, tokens[0]);
+ }
}
errno = saved_errno;
return TRUE;
guint *max_addrs,
guint *priority,
gchar **name,
- guint default_port)
+ guint default_port,
+ rspamd_mempool_t *pool)
{
gchar **tokens;
gboolean ret;
}
ret = rspamd_parse_host_port_priority_strv (tokens, addr, max_addrs,
- priority, name, default_port);
+ priority, name, default_port, pool);
g_strfreev (tokens);
rspamd_inet_addr_t **addr,
guint *max_addrs,
gchar **name,
- guint default_port)
+ guint default_port,
+ rspamd_mempool_t *pool)
{
return rspamd_parse_host_port_priority (str, addr, max_addrs, NULL,
- name, default_port);
+ name, default_port, pool);
}
#define ADDR_H_
#include "config.h"
+#include "mem_pool.h"
/**
* Union that is used for storing sockaddrs
gboolean rspamd_parse_host_port_priority_strv (gchar **tokens,
rspamd_inet_addr_t **addr, guint *max_addrs, guint *priority,
- gchar **name, guint default_port);
+ gchar **name, guint default_port, rspamd_mempool_t *pool);
/**
* Parse host[:port[:priority]] line
*/
gboolean rspamd_parse_host_port_priority (const gchar *str,
rspamd_inet_addr_t **addr, guint *max_addrs,
- guint *priority, gchar **name, guint default_port);
+ guint *priority, gchar **name, guint default_port,
+ rspamd_mempool_t *pool);
/**
* Parse host:port line
*/
gboolean rspamd_parse_host_port (const gchar *str,
rspamd_inet_addr_t **addr, guint *max_addrs,
- gchar **name, guint default_port);
+ gchar **name, guint default_port, rspamd_mempool_t *pool);
#endif /* ADDR_H_ */
up->addrs.count = default_max_addresses;
if (!rspamd_parse_host_port_priority (str, &up->addrs.addr,
&up->addrs.count, &up->weight,
- &up->name, def_port)) {
+ &up->name, def_port, NULL)) {
g_slice_free1 (sizeof (*up), up);
return FALSE;
}