Skip to content

Commit

Permalink
relax address matching rule so it matches more than just 'localhost'
Browse files Browse the repository at this point in the history
  • Loading branch information
yrutschle committed Mar 11, 2019
1 parent b529069 commit e528f51
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
38 changes: 19 additions & 19 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 Sun Mar 10 09:52:17 2019. */
* on Mon Mar 11 22:19:38 2019. */

#define _GNU_SOURCE
#include <string.h>
Expand Down Expand Up @@ -571,13 +571,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_listen->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_listen->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
Expand Down Expand Up @@ -610,13 +610,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_ssh->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_ssh->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
Expand Down Expand Up @@ -661,13 +661,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_tls->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_tls->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
Expand Down Expand Up @@ -711,13 +711,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_openvpn->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_openvpn->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
Expand Down Expand Up @@ -761,13 +761,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_tinc->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_tinc->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
Expand Down Expand Up @@ -811,13 +811,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_xmpp->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_xmpp->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
Expand Down Expand Up @@ -860,13 +860,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_http->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_http->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
Expand Down Expand Up @@ -909,13 +909,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_adb->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_adb->sval [cl_i], MAX_MATCH, &pmatch[0], 0);
Expand Down Expand Up @@ -958,13 +958,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) {
for (cl_i = 0; cl_i < sslhcfg_socks5->count; cl_i++) {
regex_t preg;
regmatch_t pmatch[MAX_MATCH];
int res = regcomp(&preg, "(\\w+):(\\w+)", REG_EXTENDED);
int res = regcomp(&preg, "(.+):(\\w+)", REG_EXTENDED);
if (res) {
int errlen = regerror(res, &preg, NULL, 0);
char* errmsg = malloc(errlen);
regerror(res, &preg, errmsg, errlen);

fprintf(stderr, "(\\w+):(\\w+): %s\n", errmsg);
fprintf(stderr, "(.+):(\\w+): %s\n", errmsg);
exit(1);
}
res = regexec(&preg, sslhcfg_socks5->sval [cl_i], MAX_MATCH, &pmatch[0], 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 Sun Mar 10 09:52:17 2019. */
* on Mon Mar 11 22:19:38 2019. */

#ifndef C2S_SSLHCFG_H
#define C2S_SSLHCFG_H
Expand Down
18 changes: 9 additions & 9 deletions sslhconf.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ config: {
# This may not be the right abstraction at all and way too
# sslh-centric
cl_groups: (
{ name: "listen"; pattern: "(\w+):(\w+)"; description: "Listen on host:port";
{ name: "listen"; pattern: "(.+):(\w+)"; description: "Listen on host:port";
short: "p"; argdesc: "<host:port>";
list: "listen";
# no override, this just adds to the list (and thus can be specified several times)
Expand All @@ -110,7 +110,7 @@ cl_groups: (
{ path: "port"; value: "$2" }
);
},
{ name: "ssh"; pattern: "(\w+):(\w+)"; description: "Set up ssh target";
{ name: "ssh"; pattern: "(.+):(\w+)"; description: "Set up ssh target";
list: "protocols"; # List name that we're defining with this command line option
override: "name"; # Field in the group to override. If not found in list, add an item
# (it's mandatory to have that field as one of the targets
Expand All @@ -124,7 +124,7 @@ cl_groups: (
{ path: "tfo_ok"; value: 1 }
);
},
{ name: "tls"; pattern: "(\w+):(\w+)"; description: "Set up TLS/SSL target";
{ name: "tls"; pattern: "(.+):(\w+)"; description: "Set up TLS/SSL target";
list: "protocols";
override: "name";
argdesc: "<host:port>";
Expand All @@ -135,7 +135,7 @@ cl_groups: (
{ path: "tfo_ok"; value: 1 }
);
},
{ name: "openvpn"; pattern: "(\w+):(\w+)"; description: "Set up OpenVPN target";
{ name: "openvpn"; pattern: "(.+):(\w+)"; description: "Set up OpenVPN target";
list: "protocols";
override: "name";
argdesc: "<host:port>";
Expand All @@ -146,7 +146,7 @@ cl_groups: (
{ path: "tfo_ok"; value: 1 }
);
},
{ name: "tinc"; pattern: "(\w+):(\w+)"; description: "Set up tinc target";
{ name: "tinc"; pattern: "(.+):(\w+)"; description: "Set up tinc target";
list: "protocols";
override: "name";
argdesc: "<host:port>";
Expand All @@ -157,7 +157,7 @@ cl_groups: (
{ path: "tfo_ok"; value: 1 }
);
},
{ name: "xmpp"; pattern: "(\w+):(\w+)"; description: "Set up XMPP target";
{ name: "xmpp"; pattern: "(.+):(\w+)"; description: "Set up XMPP target";
list: "protocols";
override: "name";
argdesc: "<host:port>";
Expand All @@ -167,7 +167,7 @@ cl_groups: (
{ path: "port"; value: "$2" }
);
},
{ name: "http"; pattern: "(\w+):(\w+)"; description: "Set up HTTP (plain) target";
{ name: "http"; pattern: "(.+):(\w+)"; description: "Set up HTTP (plain) target";
list: "protocols";
override: "name";
argdesc: "<host:port>";
Expand All @@ -177,7 +177,7 @@ cl_groups: (
{ path: "port"; value: "$2" }
);
},
{ name: "adb"; pattern: "(\w+):(\w+)"; description: "Set up ADB (Android Debug) target";
{ name: "adb"; pattern: "(.+):(\w+)"; description: "Set up ADB (Android Debug) target";
list: "protocols";
override: "name";
argdesc: "<host:port>";
Expand All @@ -187,7 +187,7 @@ cl_groups: (
{ path: "port"; value: "$2" }
);
},
{ name: "socks5"; pattern: "(\w+):(\w+)"; description: "Set up socks5 target";
{ name: "socks5"; pattern: "(.+):(\w+)"; description: "Set up socks5 target";
list: "protocols";
override: "name";
argdesc: "<host:port>";
Expand Down

0 comments on commit e528f51

Please sign in to comment.