mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-13 07:37:15 +03:00
update c2f output
This commit is contained in:
parent
d2b64c7f38
commit
5b309a9b97
559
sslh-conf.c
559
sslh-conf.c
@ -1,5 +1,5 @@
|
||||
/* Generated by conf2struct (https://www.rutschle.net/tech/conf2struct/README)
|
||||
* on Sat Jan 12 21:31:24 2019. */
|
||||
* on Sun Jan 27 18:51:35 2019. */
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
@ -9,19 +9,15 @@
|
||||
|
||||
static void sslhcfg_protocols_init(struct sslhcfg_protocols_item* cfg) {
|
||||
memset(cfg, 0, sizeof(*cfg));
|
||||
cfg->name = "";
|
||||
cfg->host = "";
|
||||
cfg->port = "";
|
||||
cfg->service = NULL;
|
||||
cfg->fork = 0;
|
||||
cfg->log_level = 1;
|
||||
cfg->keepalive = 0;
|
||||
cfg->minlength = 0;
|
||||
cfg->maxlength = 0;
|
||||
}
|
||||
|
||||
static void sslhcfg_listen_init(struct sslhcfg_listen_item* cfg) {
|
||||
memset(cfg, 0, sizeof(*cfg));
|
||||
cfg->host = "";
|
||||
cfg->port = "";
|
||||
cfg->keepalive = 0;
|
||||
}
|
||||
|
||||
@ -33,9 +29,6 @@ static void sslhcfg_init(struct sslhcfg_item* cfg) {
|
||||
cfg->numeric = 0;
|
||||
cfg->transparent = 0;
|
||||
cfg->timeout = 5;
|
||||
cfg->user = NULL;
|
||||
cfg->pidfile = NULL;
|
||||
cfg->chroot = NULL;
|
||||
cfg->syslog_facility = "auth";
|
||||
cfg->on_timeout = "ssh";
|
||||
}
|
||||
@ -148,6 +141,18 @@ static int sslhcfg_protocols_parser(
|
||||
sslhcfg_protocols->regex_patterns[i] = config_setting_get_string(s);
|
||||
}
|
||||
}
|
||||
if (config_setting_lookup(cfg, "minlength")) {
|
||||
if (config_setting_lookup_int(cfg, "minlength", &sslhcfg_protocols->minlength) == CONFIG_FALSE) {
|
||||
*errmsg = "Parsing of option \"minlength\" failed";
|
||||
return 0;
|
||||
} ;
|
||||
}
|
||||
if (config_setting_lookup(cfg, "maxlength")) {
|
||||
if (config_setting_lookup_int(cfg, "maxlength", &sslhcfg_protocols->maxlength) == CONFIG_FALSE) {
|
||||
*errmsg = "Parsing of option \"maxlength\" failed";
|
||||
return 0;
|
||||
} ;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -378,6 +383,10 @@ static void sslhcfg_protocols_print(
|
||||
indent(depth+1);
|
||||
printf("%d:\t%s\n", i, sslhcfg_protocols->regex_patterns[i]);
|
||||
}
|
||||
indent(depth);
|
||||
printf("minlength: %d\n", sslhcfg_protocols->minlength);
|
||||
indent(depth);
|
||||
printf("maxlength: %d\n", sslhcfg_protocols->maxlength);
|
||||
}
|
||||
|
||||
static void sslhcfg_listen_print(
|
||||
@ -565,30 +574,30 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_listen->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_listen_item* group;
|
||||
|
||||
/* No search for override */
|
||||
if (!found) {
|
||||
cfg->listen_len++;
|
||||
cfg->listen = realloc(cfg->listen, cfg->listen_len * sizeof(*cfg->listen));
|
||||
group = & cfg->listen [cfg->listen_len - 1];
|
||||
} else {
|
||||
group = & cfg->listen [found];
|
||||
}
|
||||
|
||||
sslhcfg_listen_init(group);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_listen->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_listen->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--listen %s: Illegal argument\n", sslhcfg_listen->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_listen_item* group;
|
||||
|
||||
/* No search for override */ if (found == -1) {
|
||||
cfg->listen_len++;
|
||||
cfg->listen = realloc(cfg->listen, cfg->listen_len * sizeof(*cfg->listen));
|
||||
group = & cfg->listen [cfg->listen_len - 1];
|
||||
} else {
|
||||
group = & cfg->listen [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_listen_init(group);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_listen->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_listen->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
#define MAX_MATCH 10
|
||||
for (cl_i = 0; cl_i < sslhcfg_ssh->count; cl_i++) {
|
||||
@ -604,39 +613,40 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_ssh->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strcmp(cfg->protocols [i].name, "ssh")) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 3;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "ssh", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_ssh->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_ssh->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--ssh %s: Illegal argument\n", sslhcfg_ssh->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strncmp(cfg->protocols [i].name, "ssh",
|
||||
3)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 3;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "ssh", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_ssh->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_ssh->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
#define MAX_MATCH 10
|
||||
for (cl_i = 0; cl_i < sslhcfg_tls->count; cl_i++) {
|
||||
@ -652,39 +662,40 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_tls->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strcmp(cfg->protocols [i].name, "tls")) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 3;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "tls", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_tls->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_tls->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--tls %s: Illegal argument\n", sslhcfg_tls->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strncmp(cfg->protocols [i].name, "tls",
|
||||
3)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 3;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "tls", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_tls->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_tls->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
#define MAX_MATCH 10
|
||||
for (cl_i = 0; cl_i < sslhcfg_openvpn->count; cl_i++) {
|
||||
@ -700,39 +711,40 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_openvpn->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strcmp(cfg->protocols [i].name, "openvpn")) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 7;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "openvpn", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_openvpn->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_openvpn->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--openvpn %s: Illegal argument\n", sslhcfg_openvpn->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strncmp(cfg->protocols [i].name, "openvpn",
|
||||
7)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 7;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "openvpn", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_openvpn->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_openvpn->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
#define MAX_MATCH 10
|
||||
for (cl_i = 0; cl_i < sslhcfg_tinc->count; cl_i++) {
|
||||
@ -748,39 +760,40 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_tinc->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strcmp(cfg->protocols [i].name, "openvpn")) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 7;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "openvpn", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_tinc->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_tinc->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--tinc %s: Illegal argument\n", sslhcfg_tinc->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strncmp(cfg->protocols [i].name, "openvpn",
|
||||
7)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 7;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "openvpn", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_tinc->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_tinc->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
#define MAX_MATCH 10
|
||||
for (cl_i = 0; cl_i < sslhcfg_xmpp->count; cl_i++) {
|
||||
@ -796,39 +809,40 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_xmpp->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strcmp(cfg->protocols [i].name, "xmpp")) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 4;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "xmpp", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_xmpp->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_xmpp->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--xmpp %s: Illegal argument\n", sslhcfg_xmpp->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strncmp(cfg->protocols [i].name, "xmpp",
|
||||
4)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 4;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "xmpp", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_xmpp->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_xmpp->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
#define MAX_MATCH 10
|
||||
for (cl_i = 0; cl_i < sslhcfg_http->count; cl_i++) {
|
||||
@ -844,39 +858,40 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_http->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strcmp(cfg->protocols [i].name, "http")) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 4;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "http", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_http->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_http->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--http %s: Illegal argument\n", sslhcfg_http->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strncmp(cfg->protocols [i].name, "http",
|
||||
4)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 4;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "http", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_http->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_http->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
#define MAX_MATCH 10
|
||||
for (cl_i = 0; cl_i < sslhcfg_adb->count; cl_i++) {
|
||||
@ -892,39 +907,40 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_adb->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strcmp(cfg->protocols [i].name, "adb")) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 3;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "adb", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_adb->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_adb->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--adb %s: Illegal argument\n", sslhcfg_adb->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strncmp(cfg->protocols [i].name, "adb",
|
||||
3)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 3;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "adb", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_adb->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_adb->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
#define MAX_MATCH 10
|
||||
for (cl_i = 0; cl_i < sslhcfg_socks5->count; cl_i++) {
|
||||
@ -940,39 +956,40 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
|
||||
exit(1);
|
||||
}
|
||||
res = regexec(&preg, sslhcfg_socks5->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
|
||||
if (!res) {
|
||||
int param_len, i, found = 0;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strcmp(cfg->protocols [i].name, "socks5")) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 6;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "socks5", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_socks5->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_socks5->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
} else {
|
||||
if (res) {
|
||||
fprintf(stderr, "--socks5 %s: Illegal argument\n", sslhcfg_socks5->sval [cl_i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int param_len, i, found = -1;
|
||||
struct sslhcfg_protocols_item* group;
|
||||
|
||||
for (i = 0; i < cfg->protocols_len; i++) {
|
||||
if (!strncmp(cfg->protocols [i].name, "socks5",
|
||||
6)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
cfg->protocols_len++;
|
||||
cfg->protocols = realloc(cfg->protocols, cfg->protocols_len * sizeof(*cfg->protocols));
|
||||
group = & cfg->protocols [cfg->protocols_len - 1];
|
||||
} else {
|
||||
group = & cfg->protocols [found];
|
||||
}
|
||||
|
||||
|
||||
sslhcfg_protocols_init(group);
|
||||
param_len = 6;
|
||||
group->name = calloc(1, param_len + 1);
|
||||
memcpy(group->name, "socks5", param_len);
|
||||
param_len = pmatch[1].rm_eo - pmatch[1].rm_so;
|
||||
group->host = calloc(1, param_len + 1);
|
||||
memcpy(group->host, sslhcfg_socks5->sval [cl_i]+pmatch[1].rm_so, param_len);
|
||||
param_len = pmatch[2].rm_eo - pmatch[2].rm_so;
|
||||
group->port = calloc(1, param_len + 1);
|
||||
memcpy(group->port, sslhcfg_socks5->sval [cl_i]+pmatch[2].rm_so, param_len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Generated by conf2struct (https://www.rutschle.net/tech/conf2struct/README)
|
||||
* on Sat Jan 12 21:31:24 2019. */
|
||||
* on Sun Jan 27 18:51:35 2019. */
|
||||
|
||||
#ifndef C2S_SSLHCFG_H
|
||||
#define C2S_SSLHCFG_H
|
||||
@ -31,6 +31,8 @@ struct sslhcfg_protocols_item {
|
||||
const char** alpn_protocols;
|
||||
size_t regex_patterns_len;
|
||||
const char** regex_patterns;
|
||||
int minlength;
|
||||
int maxlength;
|
||||
T_PROBE* probe;
|
||||
struct addrinfo* saddr;
|
||||
void* data;
|
||||
|
@ -80,6 +80,9 @@ config: {
|
||||
type: "array",
|
||||
element_type: "string"
|
||||
},
|
||||
{ name: "minlength"; type: "int"; default: 0 },
|
||||
{ name: "maxlength"; type: "int"; default: 0 },
|
||||
|
||||
|
||||
# Runtime data
|
||||
{ name: "probe"; type: "runtime"; c_type: "T_PROBE*" },
|
||||
|
Loading…
x
Reference in New Issue
Block a user