git ssb

0+

cel / sslh



Commit f02ce3821c018719536971dbb1bc1ed1517530a2

clarify no space after -F (issue 108)

Yves Rutschlé committed on 11/6/2016, 7:44:47 PM
Parent: b4cb91043812c7ff6fb13d369a65288adb6fbc8a

Files changed

common.cchanged
common.hchanged
probe.cchanged
probe.hchanged
sslh-main.cchanged
sslh.podchanged
common.cView
@@ -36,9 +36,8 @@
3636 int probing_timeout = 2;
3737 int inetd = 0;
3838 int foreground = 0;
3939 int background = 0;
40-int transparent = 0;
4140 int numeric = 0;
4241 const char *user_name, *pid_file;
4342
4443 struct addrinfo *addr_listen = NULL; /* what addresses do we listen to? */
@@ -236,9 +235,9 @@
236235 CHECK_RES_RETURN(res, "getpeername");
237236
238237 for (a = cnx->proto->saddr; a; a = a->ai_next) {
239238 /* When transparent, make sure both connections use the same address family */
240- if (transparent && a->ai_family != from.ai_addr->sa_family)
239+ if (cnx->proto->transparent && a->ai_family != from.ai_addr->sa_family)
241240 continue;
242241 if (verbose)
243242 fprintf(stderr, "connecting to %s family %d len %d\n",
244243 sprintaddr(buf, sizeof(buf), a),
@@ -249,9 +248,9 @@
249248 if (fd == -1) {
250249 log_message(LOG_ERR, "forward to %s failed:socket: %s\n",
251250 cnx->proto->description, strerror(errno));
252251 } else {
253- if (transparent) {
252+ if (cnx->proto->transparent) {
254253 res = bind_peer(fd, fd_from);
255254 CHECK_RES_RETURN(res, "bind_peer");
256255 }
257256 res = connect(fd, a->ai_addr, a->ai_addrlen);
common.hView
@@ -112,10 +112,9 @@
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,
117- background, transparent, numeric;
116+extern int probing_timeout, verbose, inetd, foreground, background, numeric;
118117 extern struct sockaddr_storage addr_ssl, addr_ssh, addr_openvpn;
119118 extern struct addrinfo *addr_listen;
120119 extern const char* USAGE_STRING;
121120 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 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 }
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 }
5858 };
5959
6060 static struct proto *protocols;
6161 static char* on_timeout = "ssh";
probe.hView
@@ -23,8 +23,9 @@
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 */
2728
2829 /* function to probe that protocol; parameters are buffer and length
2930 * containing the data to probe, and a pointer to the protocol structure */
3031 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\n" \
52+"-F: use configuration file (warning: no space between -F and file name!)\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,13 +60,16 @@
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+
6467 static struct option const_options[] = {
6568 { "inetd", no_argument, &inetd, 1 },
6669 { "foreground", no_argument, &foreground, 1 },
6770 { "background", no_argument, &background, 1 },
68- { "transparent", no_argument, &transparent, 1 },
71+ { "transparent", no_argument, &g_transparent, 1 },
6972 { "numeric", no_argument, &numeric, 1 },
7073 { "verbose", no_argument, &verbose, 1 },
7174 { "user", required_argument, 0, 'u' },
7275 { "config", optional_argument, 0, 'F' },
@@ -122,16 +125,18 @@
122125 struct proto *p;
123126
124127 for (p = get_first_protocol(); p; p = p->next) {
125128 fprintf(stderr,
126- "%s addr: %s. libwrap service: %s log_level: %d family %d %d [%s]\n",
129+ "%s addr: %s. libwrap service: %s log_level: %d family %d %d [%s%s]\n",
127130 p->description,
128131 sprintaddr(buf, sizeof(buf), p->saddr),
129132 p->service,
130133 p->log_level,
131134 p->saddr->ai_family,
132135 p->saddr->ai_addr->sa_family,
133- p->keepalive ? "keepalive" : "");
136+ p->keepalive ? "keepalive " : "",
137+ p->transparent ? "transparent" : ""
138+ );
134139 }
135140 fprintf(stderr, "listening on:\n");
136141 for (a = addr_listen; a; a = a->ai_next) {
137142 fprintf(stderr,
@@ -306,8 +311,9 @@
306311 )) {
307312 p->description = name;
308313 config_setting_lookup_string(prot, "service", &(p->service));
309314 config_setting_lookup_bool(prot, "keepalive", &p->keepalive);
315+ config_setting_lookup_bool(prot, "transparent", &p->transparent);
310316
311317 if (config_setting_lookup_int(prot, "log_level", &p->log_level) == CONFIG_FALSE) {
312318 p->log_level = 1;
313319 }
@@ -375,9 +381,9 @@
375381 config_lookup_bool(&config, "verbose", &verbose);
376382 config_lookup_bool(&config, "inetd", &inetd);
377383 config_lookup_bool(&config, "foreground", &foreground);
378384 config_lookup_bool(&config, "numeric", &numeric);
379- config_lookup_bool(&config, "transparent", &transparent);
385+ config_lookup_bool(&config, "transparent", &g_transparent);
380386
381387 if (config_lookup_int(&config, "timeout", (int *)&timeout) == CONFIG_TRUE) {
382388 probing_timeout = timeout;
383389 }
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,14 +77,17 @@
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> has 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+
8790 =item B<-t> I<num>, B<--timeout> I<num>
8891
8992 Timeout before forwarding the connection to the timeout
9093 protocol (which should usually be SSH). Default is 2s.

Built with git-ssb-web