summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2010-11-08 11:18:38 +0100
committerLinus Nordberg <linus@nordu.net>2010-11-08 11:18:38 +0100
commitf9b25cad24ec4e3e89e818457beb29cbe08eed0c (patch)
tree2bf1d08b12002b8e1136485c1c7d4bd6c7ec32df
parenteae90973cc8f0947067abb816c028826bbd911f5 (diff)
Don't ignore connection type configuration.
-rw-r--r--lib/conf.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/conf.c b/lib/conf.c
index 31ae6da..cedb84c 100644
--- a/lib/conf.c
+++ b/lib/conf.c
@@ -52,7 +52,6 @@ rs_context_read_config(struct rs_context *ctx, const char *config_file)
{
struct rs_realm *r = rs_malloc (ctx, sizeof(*r));
const char *typestr;
- enum rs_conn_type type;
if (!r)
return rs_err_ctx_push_fl (ctx, RSE_NOMEM, __FILE__, __LINE__, NULL);
@@ -65,16 +64,18 @@ rs_context_read_config(struct rs_context *ctx, const char *config_file)
r->name = strdup (cfg_title (cfg_config));
typestr = cfg_getstr (cfg_config, "type");
if (!strcmp (typestr, "UDP"))
- type = RS_CONN_TYPE_UDP;
+ r->type = RS_CONN_TYPE_UDP;
else if (!strcmp (typestr, "TCP"))
- type = RS_CONN_TYPE_TCP;
+ r->type = RS_CONN_TYPE_TCP;
else if (!strcmp (typestr, "TLS"))
- type = RS_CONN_TYPE_TLS;
+ r->type = RS_CONN_TYPE_TLS;
else if (!strcmp (typestr, "DTLS"))
- type = RS_CONN_TYPE_DTLS;
+ r->type = RS_CONN_TYPE_DTLS;
else
return rs_err_ctx_push_fl (ctx, RSE_CONFIG, __FILE__, __LINE__,
"%s: invalid connection type", typestr);
+
+ /* Add peers, one per server stanza. */
for (j = 0; j < cfg_size (cfg_config, "server"); j++)
{
struct rs_peer *p = _rs_peer_create (ctx, &r->peers);
@@ -83,7 +84,7 @@ rs_context_read_config(struct rs_context *ctx, const char *config_file)
NULL);
cfg_server = cfg_getnsec (cfg_config, "server", j);
- _rs_resolv (&p->addr, type, cfg_getstr (cfg_server, "hostname"),
+ _rs_resolv (&p->addr, r->type, cfg_getstr (cfg_server, "hostname"),
cfg_getstr (cfg_server, "service"));
p->secret = strdup (cfg_getstr (cfg_server, "secret"));
p->timeout = cfg_getint (cfg_server, "timeout");