diff options
-rw-r--r-- | src/options.c | 3 | ||||
-rw-r--r-- | src/uanytun.c | 31 |
2 files changed, 16 insertions, 18 deletions
diff --git a/src/options.c b/src/options.c index 906e43e..2c018f1 100644 --- a/src/options.c +++ b/src/options.c @@ -277,6 +277,9 @@ int options_parse(options_t* opt, int argc, char* argv[]) if(ipv6_only) opt->resolv_addr_type_ = IPV6_ONLY; + if(!opt->log_targets_.first_) + string_list_add(&opt->log_targets_, "syslog:3,uanytun,daemon"); + #ifndef NO_CRYPT if(role) { if(!strcmp(role, "alice") || !strcmp(role, "server") || !strcmp(role, "left")) diff --git a/src/uanytun.c b/src/uanytun.c index ba64bc7..e7f2312 100644 --- a/src/uanytun.c +++ b/src/uanytun.c @@ -351,26 +351,21 @@ int main(int argc, char* argv[]) exit(ret); } string_list_element_t* tmp = opt.log_targets_.first_; - if(!tmp) { - log_add_target("syslog:3,uanytun,daemon"); - } - else { - while(tmp) { - ret = log_add_target(tmp->string_); - if(ret) { - switch(ret) { - case -2: fprintf(stderr, "memory error on log_add_target, exitting\n"); break; - case -3: fprintf(stderr, "unknown log target: '%s', exitting\n", tmp->string_); break; - case -4: fprintf(stderr, "this log target is only allowed once: '%s', exitting\n", tmp->string_); break; - default: fprintf(stderr, "syntax error near: '%s', exitting\n", tmp->string_); break; - } - - options_clear(&opt); - log_close(); - exit(ret); + while(tmp) { + ret = log_add_target(tmp->string_); + if(ret) { + switch(ret) { + case -2: fprintf(stderr, "memory error on log_add_target, exitting\n"); break; + case -3: fprintf(stderr, "unknown log target: '%s', exitting\n", tmp->string_); break; + case -4: fprintf(stderr, "this log target is only allowed once: '%s', exitting\n", tmp->string_); break; + default: fprintf(stderr, "syntax error near: '%s', exitting\n", tmp->string_); break; } - tmp = tmp->next_; + + options_clear(&opt); + log_close(); + exit(ret); } + tmp = tmp->next_; } log_printf(NOTICE, "just started..."); |