2015-12-06 23:32:18 -06:00
|
|
|
--- apps/nc/netcat.c.orig Sun Dec 6 22:05:45 2015
|
|
|
|
+++ apps/nc/netcat.c Sun Dec 6 23:23:15 2015
|
2015-10-14 15:53:11 +09:00
|
|
|
@@ -57,6 +57,10 @@
|
|
|
|
#include <tls.h>
|
|
|
|
#include "atomicio.h"
|
|
|
|
|
|
|
|
+#ifndef IPV6_TCLASS
|
|
|
|
+#define IPV6_TCLASS -1
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#define PORT_MAX 65535
|
|
|
|
#define UNIX_DG_TMP_SOCKET_SIZE 19
|
2015-12-06 23:32:18 -06:00
|
|
|
|
|
|
|
@@ -92,9 +96,13 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
int Dflag; /* sodebug */
|
|
|
|
int Iflag; /* TCP receive buffer size */
|
|
|
|
int Oflag; /* TCP send buffer size */
|
|
|
|
+#ifdef TCP_MD5SIG
|
|
|
|
int Sflag; /* TCP MD5 signature option */
|
|
|
|
+#endif
|
|
|
|
int Tflag = -1; /* IP Type of Service */
|
|
|
|
+#ifdef SO_RTABLE
|
|
|
|
int rtableid = -1;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
int usetls; /* use TLS */
|
|
|
|
char *Cflag; /* Public cert file */
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -144,7 +152,7 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
struct servent *sv;
|
|
|
|
socklen_t len;
|
|
|
|
struct sockaddr_storage cliaddr;
|
|
|
|
- char *proxy;
|
|
|
|
+ char *proxy = NULL;
|
|
|
|
const char *errstr, *proxyhost = "", *proxyport = NULL;
|
|
|
|
struct addrinfo proxyhints;
|
|
|
|
char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -245,12 +253,14 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
case 'u':
|
|
|
|
uflag = 1;
|
|
|
|
break;
|
|
|
|
+#ifdef SO_RTABLE
|
|
|
|
case 'V':
|
|
|
|
rtableid = (int)strtonum(optarg, 0,
|
|
|
|
RT_TABLEID_MAX, &errstr);
|
|
|
|
if (errstr)
|
|
|
|
errx(1, "rtable %s: %s", errstr, optarg);
|
|
|
|
break;
|
|
|
|
+#endif
|
|
|
|
case 'v':
|
|
|
|
vflag = 1;
|
|
|
|
break;
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -283,9 +293,11 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
errx(1, "TCP send window %s: %s",
|
|
|
|
errstr, optarg);
|
|
|
|
break;
|
|
|
|
+#ifdef TCP_MD5SIG
|
|
|
|
case 'S':
|
|
|
|
Sflag = 1;
|
|
|
|
break;
|
|
|
|
+#endif
|
|
|
|
case 'T':
|
|
|
|
errstr = NULL;
|
|
|
|
errno = 0;
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -309,9 +321,11 @@
|
2015-10-23 16:17:45 -07:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
+#ifdef SO_RTABLE
|
2015-11-22 04:55:22 -06:00
|
|
|
if (rtableid >= 0)
|
|
|
|
if (setrtable(rtableid) == -1)
|
|
|
|
err(1, "setrtable");
|
2015-10-23 16:17:45 -07:00
|
|
|
+#endif
|
2015-11-22 04:55:22 -06:00
|
|
|
|
|
|
|
if (family == AF_UNIX) {
|
2015-10-23 16:17:45 -07:00
|
|
|
if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1)
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -791,7 +805,10 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
remote_connect(const char *host, const char *port, struct addrinfo hints)
|
|
|
|
{
|
|
|
|
struct addrinfo *res, *res0;
|
|
|
|
- int s, error, on = 1;
|
|
|
|
+ int s, error;
|
|
|
|
+#ifdef SO_BINDANY
|
|
|
|
+ int on = 1;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
if ((error = getaddrinfo(host, port, &hints, &res)))
|
|
|
|
errx(1, "getaddrinfo: %s", gai_strerror(error));
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -806,8 +823,10 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
if (sflag || pflag) {
|
|
|
|
struct addrinfo ahints, *ares;
|
|
|
|
|
|
|
|
+#ifdef SO_BINDANY
|
|
|
|
/* try SO_BINDANY, but don't insist */
|
|
|
|
setsockopt(s, SOL_SOCKET, SO_BINDANY, &on, sizeof(on));
|
|
|
|
+#endif
|
|
|
|
memset(&ahints, 0, sizeof(struct addrinfo));
|
|
|
|
ahints.ai_family = res0->ai_family;
|
|
|
|
ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -876,7 +895,10 @@
|
2015-09-13 19:06:29 -05:00
|
|
|
local_listen(char *host, char *port, struct addrinfo hints)
|
|
|
|
{
|
|
|
|
struct addrinfo *res, *res0;
|
|
|
|
- int s, ret, x = 1;
|
|
|
|
+ int s;
|
|
|
|
+#ifdef SO_REUSEPORT
|
2015-09-13 19:15:34 -05:00
|
|
|
+ int ret, x = 1;
|
2015-09-13 19:06:29 -05:00
|
|
|
+#endif
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* Allow nodename to be null. */
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -898,9 +920,11 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
res0->ai_protocol)) < 0)
|
|
|
|
continue;
|
|
|
|
|
2015-09-13 18:57:29 -05:00
|
|
|
+#ifdef SO_REUSEPORT
|
2015-09-13 11:56:41 -05:00
|
|
|
ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
|
|
|
|
if (ret == -1)
|
2015-09-13 18:57:29 -05:00
|
|
|
err(1, NULL);
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
set_common_sockopts(s, res0->ai_family);
|
|
|
|
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -1340,11 +1364,13 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
{
|
|
|
|
int x = 1;
|
|
|
|
|
|
|
|
+#ifdef TCP_MD5SIG
|
|
|
|
if (Sflag) {
|
|
|
|
if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG,
|
|
|
|
&x, sizeof(x)) == -1)
|
|
|
|
err(1, NULL);
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
if (Dflag) {
|
|
|
|
if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
|
|
|
|
&x, sizeof(x)) == -1)
|
2015-12-06 23:32:18 -06:00
|
|
|
@@ -1519,15 +1545,19 @@
|
2015-09-13 11:56:41 -05:00
|
|
|
\t-P proxyuser\tUsername for proxy authentication\n\
|
|
|
|
\t-p port\t Specify local port for remote connects\n\
|
|
|
|
\t-R CAfile CA bundle\n\
|
|
|
|
- \t-r Randomize remote ports\n\
|
|
|
|
- \t-S Enable the TCP MD5 signature option\n\
|
|
|
|
- \t-s source Local source address\n\
|
|
|
|
+ \t-r Randomize remote ports\n"
|
|
|
|
+#ifdef TCP_MD5SIG
|
|
|
|
+ "\t-S Enable the TCP MD5 signature option\n"
|
|
|
|
+#endif
|
|
|
|
+ "\t-s source Local source address\n\
|
|
|
|
\t-T keyword TOS value or TLS options\n\
|
|
|
|
\t-t Answer TELNET negotiation\n\
|
|
|
|
\t-U Use UNIX domain socket\n\
|
|
|
|
- \t-u UDP mode\n\
|
|
|
|
- \t-V rtable Specify alternate routing table\n\
|
|
|
|
- \t-v Verbose\n\
|
|
|
|
+ \t-u UDP mode\n"
|
|
|
|
+#ifdef SO_RTABLE
|
|
|
|
+ "\t-V rtable Specify alternate routing table\n"
|
|
|
|
+#endif
|
|
|
|
+ "\t-v Verbose\n\
|
|
|
|
\t-w timeout Timeout for connects and final net reads\n\
|
|
|
|
\t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\
|
|
|
|
\t-x addr[:port]\tSpecify proxy address and port\n\
|