Move config dump to stderr and verbose > 4

This commit is contained in:
yrutschle 2019-02-08 22:45:16 +01:00
parent 848b107f2b
commit 7baf7f724c
3 changed files with 76 additions and 71 deletions

View File

@ -1,5 +1,5 @@
/* Generated by conf2struct (https://www.rutschle.net/tech/conf2struct/README)
* on Sun Feb 3 11:11:15 2019. */
* on Fri Feb 8 22:36:20 2019. */
#define _GNU_SOURCE
#include <string.h>
@ -334,105 +334,108 @@ int sslhcfg_parse_file(const char* filename, struct sslhcfg_item* cfg, const cha
return sslhcfg_parser(config_lookup(&c, "/"), cfg, errmsg);
}
static void indent(int depth)
static void indent(FILE* out, int depth)
{
int i;
for (i = 0; i < depth; i++)
printf(" ");
fprintf(out, " ");
}
static void sslhcfg_protocols_print(
static void sslhcfg_protocols_fprint(
FILE* out,
struct sslhcfg_protocols_item* sslhcfg_protocols,
int depth)
{
int i;
indent(depth);
printf("name: %s\n", sslhcfg_protocols->name);
indent(depth);
printf("host: %s\n", sslhcfg_protocols->host);
indent(depth);
printf("port: %s\n", sslhcfg_protocols->port);
indent(depth);
printf("service: %s\n", sslhcfg_protocols->service);
indent(depth);
printf("fork: %d\n", sslhcfg_protocols->fork);
indent(depth);
printf("log_level: %d\n", sslhcfg_protocols->log_level);
indent(depth);
printf("keepalive: %d\n", sslhcfg_protocols->keepalive);
indent(depth);
printf("sni_hostnames [%d]:\n", sslhcfg_protocols->sni_hostnames_len);
indent(out, depth);
fprintf(out, "name: %s\n", sslhcfg_protocols->name);
indent(out, depth);
fprintf(out, "host: %s\n", sslhcfg_protocols->host);
indent(out, depth);
fprintf(out, "port: %s\n", sslhcfg_protocols->port);
indent(out, depth);
fprintf(out, "service: %s\n", sslhcfg_protocols->service);
indent(out, depth);
fprintf(out, "fork: %d\n", sslhcfg_protocols->fork);
indent(out, depth);
fprintf(out, "log_level: %d\n", sslhcfg_protocols->log_level);
indent(out, depth);
fprintf(out, "keepalive: %d\n", sslhcfg_protocols->keepalive);
indent(out, depth);
fprintf(out, "sni_hostnames [%d]:\n", sslhcfg_protocols->sni_hostnames_len);
for (i = 0; i < sslhcfg_protocols->sni_hostnames_len; i++) {
indent(depth+1);
printf("%d:\t%s\n", i, sslhcfg_protocols->sni_hostnames[i]);
indent(out, depth+1);
fprintf(out, "%d:\t%s\n", i, sslhcfg_protocols->sni_hostnames[i]);
}
indent(depth);
printf("alpn_protocols [%d]:\n", sslhcfg_protocols->alpn_protocols_len);
indent(out, depth);
fprintf(out, "alpn_protocols [%d]:\n", sslhcfg_protocols->alpn_protocols_len);
for (i = 0; i < sslhcfg_protocols->alpn_protocols_len; i++) {
indent(depth+1);
printf("%d:\t%s\n", i, sslhcfg_protocols->alpn_protocols[i]);
indent(out, depth+1);
fprintf(out, "%d:\t%s\n", i, sslhcfg_protocols->alpn_protocols[i]);
}
indent(depth);
printf("regex_patterns [%d]:\n", sslhcfg_protocols->regex_patterns_len);
indent(out, depth);
fprintf(out, "regex_patterns [%d]:\n", sslhcfg_protocols->regex_patterns_len);
for (i = 0; i < sslhcfg_protocols->regex_patterns_len; i++) {
indent(depth+1);
printf("%d:\t%s\n", i, sslhcfg_protocols->regex_patterns[i]);
indent(out, depth+1);
fprintf(out, "%d:\t%s\n", i, sslhcfg_protocols->regex_patterns[i]);
}
indent(depth);
printf("minlength: %d\n", sslhcfg_protocols->minlength);
indent(out, depth);
fprintf(out, "minlength: %d\n", sslhcfg_protocols->minlength);
}
static void sslhcfg_listen_print(
static void sslhcfg_listen_fprint(
FILE* out,
struct sslhcfg_listen_item* sslhcfg_listen,
int depth)
{
int i;
indent(depth);
printf("host: %s\n", sslhcfg_listen->host);
indent(depth);
printf("port: %s\n", sslhcfg_listen->port);
indent(depth);
printf("keepalive: %d\n", sslhcfg_listen->keepalive);
indent(out, depth);
fprintf(out, "host: %s\n", sslhcfg_listen->host);
indent(out, depth);
fprintf(out, "port: %s\n", sslhcfg_listen->port);
indent(out, depth);
fprintf(out, "keepalive: %d\n", sslhcfg_listen->keepalive);
}
void sslhcfg_print(
void sslhcfg_fprint(
FILE* out,
struct sslhcfg_item* sslhcfg,
int depth)
{
int i;
indent(depth);
printf("verbose: %d\n", sslhcfg->verbose);
indent(depth);
printf("foreground: %d\n", sslhcfg->foreground);
indent(depth);
printf("inetd: %d\n", sslhcfg->inetd);
indent(depth);
printf("numeric: %d\n", sslhcfg->numeric);
indent(depth);
printf("transparent: %d\n", sslhcfg->transparent);
indent(depth);
printf("timeout: %d\n", sslhcfg->timeout);
indent(depth);
printf("user: %s\n", sslhcfg->user);
indent(depth);
printf("pidfile: %s\n", sslhcfg->pidfile);
indent(depth);
printf("chroot: %s\n", sslhcfg->chroot);
indent(depth);
printf("syslog_facility: %s\n", sslhcfg->syslog_facility);
indent(depth);
printf("on_timeout: %s\n", sslhcfg->on_timeout);
indent(out, depth);
fprintf(out, "verbose: %d\n", sslhcfg->verbose);
indent(out, depth);
fprintf(out, "foreground: %d\n", sslhcfg->foreground);
indent(out, depth);
fprintf(out, "inetd: %d\n", sslhcfg->inetd);
indent(out, depth);
fprintf(out, "numeric: %d\n", sslhcfg->numeric);
indent(out, depth);
fprintf(out, "transparent: %d\n", sslhcfg->transparent);
indent(out, depth);
fprintf(out, "timeout: %d\n", sslhcfg->timeout);
indent(out, depth);
fprintf(out, "user: %s\n", sslhcfg->user);
indent(out, depth);
fprintf(out, "pidfile: %s\n", sslhcfg->pidfile);
indent(out, depth);
fprintf(out, "chroot: %s\n", sslhcfg->chroot);
indent(out, depth);
fprintf(out, "syslog_facility: %s\n", sslhcfg->syslog_facility);
indent(out, depth);
fprintf(out, "on_timeout: %s\n", sslhcfg->on_timeout);
indent(depth);
printf("listen [%d]:\n", sslhcfg->listen_len);
indent(out, depth);
fprintf(out, "listen [%d]:\n", sslhcfg->listen_len);
for (int i = 0; i < sslhcfg->listen_len; i++) {
sslhcfg_listen_print(&sslhcfg->listen[i], depth+1);
sslhcfg_listen_fprint(out, &sslhcfg->listen[i], depth+1);
}
indent(depth);
printf("protocols [%d]:\n", sslhcfg->protocols_len);
indent(out, depth);
fprintf(out, "protocols [%d]:\n", sslhcfg->protocols_len);
for (int i = 0; i < sslhcfg->protocols_len; i++) {
sslhcfg_protocols_print(&sslhcfg->protocols[i], depth+1);
sslhcfg_protocols_fprint(out, &sslhcfg->protocols[i], depth+1);
}
}

View File

@ -1,5 +1,5 @@
/* Generated by conf2struct (https://www.rutschle.net/tech/conf2struct/README)
* on Sun Feb 3 11:11:15 2019. */
* on Fri Feb 8 22:36:20 2019. */
#ifndef C2S_SSLHCFG_H
#define C2S_SSLHCFG_H
@ -64,7 +64,8 @@ int sslhcfg_parse_file(
struct sslhcfg_item* sslhcfg,
const char** errmsg);
void sslhcfg_print(
void sslhcfg_fprint(
FILE* out,
struct sslhcfg_item *sslhcfg,
int depth);

View File

@ -258,7 +258,8 @@ int main(int argc, char *argv[])
memset(&cfg, 0, sizeof(cfg));
sslhcfg_cl_parse(argc, argv, &cfg);
sslhcfg_print(&cfg, 0);
if (cfg.verbose > 3)
sslhcfg_fprint(stderr, &cfg, 0);
config_resolve_listen(&addr_listen);
config_protocols();
config_sanity_check(&cfg);