Skip to content

Commit

Permalink
add --anyprot command line option (fix #272)
Browse files Browse the repository at this point in the history
  • Loading branch information
yrutschle committed Jul 18, 2020
1 parent ac85635 commit d7cf824
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
26 changes: 24 additions & 2 deletions sslh-conf.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Generated by conf2struct (https://www.rutschle.net/tech/conf2struct/README)
* on Fri Jul 17 21:57:49 2020.
* on Sat Jul 18 17:26:18 2020.
# conf2struct: generate libconf parsers that read to structs
# Copyright (C) 2018-2019 Yves Rutschle
Expand Down Expand Up @@ -312,6 +312,7 @@ struct arg_file* sslhcfg_conffile;
struct arg_str* sslhcfg_http;
struct arg_str* sslhcfg_adb;
struct arg_str* sslhcfg_socks5;
struct arg_str* sslhcfg_anyprot;
struct arg_end* sslhcfg_end;


Expand Down Expand Up @@ -777,6 +778,14 @@ static struct config_desc table_sslhcfg[] = {
},
{ 0 }
};
static struct compound_cl_target sslhcfg_anyprot_targets [] = {
{ & table_sslhcfg_protocols[0], 0, .value.def_string = "anyprot" },
{ & table_sslhcfg_protocols[1], 1, .value.def_string = "0" },
{ & table_sslhcfg_protocols[2], 2, .value.def_string = "0" },
{ & table_sslhcfg_protocols[6], 0, .value.def_int = 1 },
{ 0 }
};

static struct compound_cl_target sslhcfg_socks5_targets [] = {
{ & table_sslhcfg_protocols[0], 0, .value.def_string = "socks5" },
{ & table_sslhcfg_protocols[1], 1, .value.def_string = "0" },
Expand Down Expand Up @@ -961,6 +970,18 @@ static struct compound_cl_arg compound_cl_args[] = {
.override_const = "socks5",
},

{ /* arg: anyprot */
.regex = "(.+):(\\w+)",
.arg_cl = & sslhcfg_anyprot,
.base_entry = & table_sslhcfg [12],
.targets = sslhcfg_anyprot_targets,


.override_desc = & table_sslhcfg_protocols [0],
.override_matchindex = 0,
.override_const = "anyprot",
},

{ 0 }
};

Expand Down Expand Up @@ -1474,6 +1495,7 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg)
sslhcfg_http = arg_strn(NULL, "http", "<host:port>", 0, 10, "Set up HTTP (plain) target"),
sslhcfg_adb = arg_strn(NULL, "adb", "<host:port>", 0, 10, "Set up ADB (Android Debug) target"),
sslhcfg_socks5 = arg_strn(NULL, "socks5", "<host:port>", 0, 10, "Set up socks5 target"),
sslhcfg_anyprot = arg_strn(NULL, "anyprot", "<host:port>", 0, 10, "Set up default target"),
sslhcfg_end = arg_end(10)

};
Expand All @@ -1482,7 +1504,7 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg)
nerrors = arg_parse(argc, argv, argtable);
if (nerrors) {
arg_print_errors(stdout, sslhcfg_end, "sslhcfg");
arg_print_syntax(stdout, argtable, "\\n");
arg_print_syntax(stdout, argtable, "\n");
arg_print_glossary(stdout, argtable, " %-25s\t%s\n");
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion sslh-conf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Generated by conf2struct (https://www.rutschle.net/tech/conf2struct/README)
* on Fri Jul 17 21:57:49 2020.
* on Sat Jul 18 17:26:18 2020.
# conf2struct: generate libconf parsers that read to structs
# Copyright (C) 2018-2019 Yves Rutschle
Expand Down
11 changes: 11 additions & 0 deletions sslhconf.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,16 @@ cl_groups: (
{ path: "port"; value: "$2" },
{ path: "log_level"; value: 1 }
);
},
{ name: "anyprot"; pattern: "(.+):(\w+)"; description: "Set up default target";
list: "protocols";
override: "name";
argdesc: "<host:port>";
targets: (
{ path: "name"; value: "anyprot" },
{ path: "host"; value: "$1" },
{ path: "port"; value: "$2" },
{ path: "log_level"; value: 1 }
);
}
)

0 comments on commit d7cf824

Please sign in to comment.