summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-04-01 22:28:31 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-04-01 22:28:31 +0200
commitbd781685508ae5096f864ba969824e299c7f327c (patch)
tree574d91e2dcbc61a7bb9096d6a46dd3b6f70825c5 /src/config.c
parent14d6915f098c6d51a6e879b81f70d9b9dba0b867 (diff)
downloadfastd-bd781685508ae5096f864ba969824e299c7f327c.tar
fastd-bd781685508ae5096f864ba969824e299c7f327c.zip
Require port with peer specfication, remove default port
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/config.c b/src/config.c
index 5acdc21..8534fe2 100644
--- a/src/config.c
+++ b/src/config.c
@@ -340,33 +340,24 @@ void fastd_configure(fastd_context *ctx, fastd_config *conf, int argc, char *con
if (arg[0] == '[') {
charptr = strchr(arg, ']');
- if (!charptr || (charptr[1] != ':' && charptr[1] != '\0'))
+ if (!charptr || (charptr[1] != ':'))
exit_error(ctx, "invalid peer address `%s'", arg);
addrstr = strndup(arg+1, charptr-arg-1);
-
- if (charptr[1] == ':')
- charptr++;
- else
- charptr = NULL;
+ charptr++;
}
else {
charptr = strchr(arg, ':');
- if (charptr)
- addrstr = strndup(arg, charptr-arg);
- else
- addrstr = strdup(arg);
- }
+ if (!charptr)
+ exit_error(ctx, "invalid peer address `%s'", arg);
- if (charptr) {
- l = strtol(charptr+1, &endptr, 10);
- if (*endptr || l < 0 || l > 65535)
- exit_error(ctx, "invalid peer port `%s'", charptr+1);
- }
- else {
- l = 1337; /* default port */
+ addrstr = strndup(arg, charptr-arg);
}
+ l = strtol(charptr+1, &endptr, 10);
+ if (*endptr || l < 0 || l > 65535)
+ exit_error(ctx, "invalid peer port `%s'", charptr+1);
+
if (arg[0] == '[') {
peer->address.in6.sin6_family = AF_INET6;
if (inet_pton(AF_INET6, addrstr, &peer->address.in6.sin6_addr) != 1)