git ssb

0+

cel / sslh



Commit 067f5d76462e26cdbcb898425cc35453f21df232

Revert "clarify no space after -F (issue 108)"

This reverts commit f02ce3821c018719536971dbb1bc1ed1517530a2.

That commit accidently imported code that broke transparent
proxying.
Yves Rutschle committed on 1/8/2017, 11:54:34 AM
Parent: 718fe0e2e9f339a022d9bc13285017fdd76a32e1

Files changed

common.cchanged
common.hchanged
probe.cchanged
probe.hchanged
sslh-main.cchanged
sslh.podchanged
common.cView
@@ -36,8 +36,9 @@
3636 int probing_timeout = 2;
3737 int inetd = 0;
3838 int foreground = 0;
3939 int background = 0;
40+int transparent = 0;
4041 int numeric = 0;
4142 const char *user_name, *pid_file;
4243
4344 struct addrinfo *addr_listen = NULL; /* what addresses do we listen to? */
@@ -235,9 +236,9 @@
235236 CHECK_RES_RETURN(res, "getpeername");
236237
237238 for (a = cnx->proto->saddr; a; a = a->ai_next) {
238239 /* When transparent, make sure both connections use the same address family */
239- if (cnx->proto->transparent && a->ai_family != from.ai_addr->sa_family)
240+ if (transparent && a->ai_family != from.ai_addr->sa_family)
240241 continue;
241242 if (verbose)
242243 fprintf(stderr, "connecting to %s family %d len %d\n",
243244 sprintaddr(buf, sizeof(buf), a),
@@ -248,9 +249,9 @@
248249 if (fd == -1) {
249250 log_message(LOG_ERR, "forward to %s failed:socket: %s\n",
250251 cnx->proto->description, strerror(errno));
251252 } else {
252- if (cnx->proto->transparent) {
253+ if (transparent) {
253254 res = bind_peer(fd, fd_from);
254255 CHECK_RES_RETURN(res, "bind_peer");
255256 }
256257 res = connect(fd, a->ai_addr, a->ai_addrlen);
common.hView
@@ -112,9 +112,10 @@
112112
113113 int defer_write(struct queue *q, void* data, int data_size);
114114 int flush_deferred(struct queue *q);
115115
116-extern int probing_timeout, verbose, inetd, foreground, background, numeric;
116+extern int probing_timeout, verbose, inetd, foreground,
117+ background, transparent, numeric;
117118 extern struct sockaddr_storage addr_ssl, addr_ssh, addr_openvpn;
118119 extern struct addrinfo *addr_listen;
119120 extern const char* USAGE_STRING;
120121 extern const char* user_name, *pid_file;
probe.cView
@@ -44,18 +44,18 @@
4444
4545 /* Table of protocols that have a built-in probe
4646 */
4747 static struct proto builtins[] = {
48- /* description service saddr log_level keepalive transparent probe */
49- { "ssh", "sshd", NULL, 1, 0, 0, is_ssh_protocol},
50- { "openvpn", NULL, NULL, 1, 0, 0, is_openvpn_protocol },
51- { "tinc", NULL, NULL, 1, 0, 0, is_tinc_protocol },
52- { "xmpp", NULL, NULL, 1, 0, 0, is_xmpp_protocol },
53- { "http", NULL, NULL, 1, 0, 0, is_http_protocol },
54- { "ssl", NULL, NULL, 1, 0, 0, is_tls_protocol },
55- { "tls", NULL, NULL, 1, 0, 0, is_tls_protocol },
56- { "adb", NULL, NULL, 1, 0, 0, is_adb_protocol },
57- { "anyprot", NULL, NULL, 1, 0, 0, is_true }
48+ /* description service saddr log_level keepalive probe */
49+ { "ssh", "sshd", NULL, 1, 0, is_ssh_protocol},
50+ { "openvpn", NULL, NULL, 1, 0, is_openvpn_protocol },
51+ { "tinc", NULL, NULL, 1, 0, is_tinc_protocol },
52+ { "xmpp", NULL, NULL, 1, 0, is_xmpp_protocol },
53+ { "http", NULL, NULL, 1, 0, is_http_protocol },
54+ { "ssl", NULL, NULL, 1, 0, is_tls_protocol },
55+ { "tls", NULL, NULL, 1, 0, is_tls_protocol },
56+ { "adb", NULL, NULL, 1, 0, is_adb_protocol },
57+ { "anyprot", NULL, NULL, 1, 0, is_true }
5858 };
5959
6060 static struct proto *protocols;
6161 static char* on_timeout = "ssh";
probe.hView
@@ -23,9 +23,8 @@
2323 int log_level; /* 0: No logging of connection
2424 * 1: Log incoming connection
2525 */
2626 int keepalive; /* 0: No keepalive ; 1: Set Keepalive for this connection */
27- int transparent; /* 0: opaque proxy ; 1: transparent proxy */
2827
2928 /* function to probe that protocol; parameters are buffer and length
3029 * containing the data to probe, and a pointer to the protocol structure */
3130 T_PROBE* probe;
sslh-main.cView
@@ -38,9 +38,9 @@
3838
3939 const char* USAGE_STRING =
4040 "sslh " VERSION "\n" \
4141 "usage:\n" \
42-"\tsslh [-v] [-i] [-V] [-f] [-n] [--transparent] [-F<file>]\n"
42+"\tsslh [-v] [-i] [-V] [-f] [-n] [--transparent] [-F <file>]\n"
4343 "\t[-t <timeout>] [-P <pidfile>] -u <username> -p <add> [-p <addr> ...] \n" \
4444 "%s\n\n" /* Dynamically built list of builtin protocols */ \
4545 "\t[--on-timeout <addr>]\n" \
4646 "-v: verbose\n" \
@@ -48,9 +48,9 @@
4848 "-f: foreground\n" \
4949 "-n: numeric output\n" \
5050 "-u: specify under which user to run\n" \
5151 "--transparent: behave as a transparent proxy\n" \
52-"-F: use configuration file (warning: no space between -F and file name!)\n" \
52+"-F: use configuration file\n" \
5353 "--on-timeout: connect to specified address upon timeout (default: ssh address)\n" \
5454 "-t: seconds to wait before connecting to --on-timeout address.\n" \
5555 "-p: address and port to listen on.\n Can be used several times to bind to several addresses.\n" \
5656 "--[ssh,ssl,...]: where to connect connections from corresponding protocol.\n" \
@@ -60,16 +60,13 @@
6060
6161 /* Constants for options that have no one-character shorthand */
6262 #define OPT_ONTIMEOUT 257
6363
64-/* Global setting for transparent proxying */
65-int g_transparent = 0;
66-
6764 static struct option const_options[] = {
6865 { "inetd", no_argument, &inetd, 1 },
6966 { "foreground", no_argument, &foreground, 1 },
7067 { "background", no_argument, &background, 1 },
71- { "transparent", no_argument, &g_transparent, 1 },
68+ { "transparent", no_argument, &transparent, 1 },
7269 { "numeric", no_argument, &numeric, 1 },
7370 { "verbose", no_argument, &verbose, 1 },
7471 { "user", required_argument, 0, 'u' },
7572 { "config", optional_argument, 0, 'F' },
@@ -125,18 +122,16 @@
125122 struct proto *p;
126123
127124 for (p = get_first_protocol(); p; p = p->next) {
128125 fprintf(stderr,
129- "%s addr: %s. libwrap service: %s log_level: %d family %d %d [%s%s]\n",
126+ "%s addr: %s. libwrap service: %s log_level: %d family %d %d [%s]\n",
130127 p->description,
131128 sprintaddr(buf, sizeof(buf), p->saddr),
132129 p->service,
133130 p->log_level,
134131 p->saddr->ai_family,
135132 p->saddr->ai_addr->sa_family,
136- p->keepalive ? "keepalive " : "",
137- p->transparent ? "transparent" : ""
138- );
133+ p->keepalive ? "keepalive" : "");
139134 }
140135 fprintf(stderr, "listening on:\n");
141136 for (a = addr_listen; a; a = a->ai_next) {
142137 fprintf(stderr,
@@ -311,9 +306,8 @@
311306 )) {
312307 p->description = name;
313308 config_setting_lookup_string(prot, "service", &(p->service));
314309 config_setting_lookup_bool(prot, "keepalive", &p->keepalive);
315- config_setting_lookup_bool(prot, "transparent", &p->transparent);
316310
317311 if (config_setting_lookup_int(prot, "log_level", &p->log_level) == CONFIG_FALSE) {
318312 p->log_level = 1;
319313 }
@@ -381,9 +375,9 @@
381375 config_lookup_bool(&config, "verbose", &verbose);
382376 config_lookup_bool(&config, "inetd", &inetd);
383377 config_lookup_bool(&config, "foreground", &foreground);
384378 config_lookup_bool(&config, "numeric", &numeric);
385- config_lookup_bool(&config, "transparent", &g_transparent);
379+ config_lookup_bool(&config, "transparent", &transparent);
386380
387381 if (config_lookup_int(&config, "timeout", (int *)&timeout) == CONFIG_TRUE) {
388382 probing_timeout = timeout;
389383 }
sslh.podView
@@ -5,9 +5,9 @@
55 sslh - protocol demultiplexer
66
77 =head1 SYNOPSIS
88
9-sslh [B<-F>I<config file>] [ B<-t> I<num> ] [B<--transparent>] [B<-p> I<listening address> [B<-p> I<listening address> ...] [B<--ssl> I<target address for SSL>] [B<--tls> I<target address for TLS>] [B<--ssh> I<target address for SSH>] [B<--openvpn> I<target address for OpenVPN>] [B<--http> I<target address for HTTP>] [B<--xmpp> I<target address for XMPP>] [B<--tinc> I<target address for TINC>] [B<--anyprot> I<default target address>] [B<--on-timeout> I<protocol name>] [B<-u> I<username>] [B<-P> I<pidfile>] [-v] [-i] [-V] [-f] [-n]
9+sslh [B<-F> I<config file>] [ B<-t> I<num> ] [B<--transparent>] [B<-p> I<listening address> [B<-p> I<listening address> ...] [B<--ssl> I<target address for SSL>] [B<--tls> I<target address for TLS>] [B<--ssh> I<target address for SSH>] [B<--openvpn> I<target address for OpenVPN>] [B<--http> I<target address for HTTP>] [B<--xmpp> I<target address for XMPP>] [B<--tinc> I<target address for TINC>] [B<--anyprot> I<default target address>] [B<--on-timeout> I<protocol name>] [B<-u> I<username>] [B<-P> I<pidfile>] [-v] [-i] [-V] [-f] [-n]
1010
1111 =head1 DESCRIPTION
1212
1313 B<sslh> accepts connections on specified ports, and forwards
@@ -77,17 +77,14 @@
7777 =head1 OPTIONS
7878
7979 =over 4
8080
81-=item B<-F>I<filename>, B<--config> I<filename>
81+=item B<-F> I<filename>, B<--config> I<filename>
8282
8383 Uses I<filename> as configuration file. If other
8484 command-line options are specified, they will override the
8585 configuration file's settings.
8686
87-When using the shorthand version, make sure there should be
88-no space between B<-F> and the I<filename>.
89-
9087 =item B<-t> I<num>, B<--timeout> I<num>
9188
9289 Timeout before forwarding the connection to the timeout
9390 protocol (which should usually be SSH). Default is 2s.

Built with git-ssb-web