netcat-openbsd/verbose-numeric-port.patch
Tomáš Chvátal ffb1f958b4 Accepting request 648974 from home:scarabeus_iv:branches:network:utilities
- Update to 1.195 release matching with debian
- Added new patches:
  * broadcast-support.patch
  * build-without-TLS-support.patch
  * destination-port-list.patch
  * use-flags-to-specify-listen-address.patch
- Refreshed patches:
  * connect-timeout.patch
  * dccp-support.patch
  * get-sev-by-name.patch
  * misc-failures-and-features.patch
  * port-to-linux-with-libsd.patch
  * quit-timer.patch
  * send-crlf.patch
  * serialized-handling-multiple-clients.patch
  * set-TCP-MD5SIG-correctly-for-client-connections.patch
  * udp-scan-timeout.patch
  * verbose-numeric-port.patch
- Drop patch compile-without-TLS-support.patch, renamed

OBS-URL: https://build.opensuse.org/request/show/648974
OBS-URL: https://build.opensuse.org/package/show/network:utilities/netcat-openbsd?expand=0&rev=18
2018-11-14 13:18:05 +00:00

66 lines
1.5 KiB
Diff

From: Aron Xu <aron@debian.org>
Date: Mon, 13 Feb 2012 15:38:15 +0800
Subject: verbose numeric port
---
netcat.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
--- a/netcat.c
+++ b/netcat.c
@@ -43,6 +43,7 @@
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <arpa/telnet.h>
+#include <arpa/inet.h>
#ifdef __linux__
# include <linux/in6.h>
#endif
@@ -689,6 +690,21 @@ main(int argc, char *argv[])
}
if (s < 0)
err(1, NULL);
+
+ if (vflag && (family != AF_UNIX)) {
+ char* local;
+ if (family == AF_INET)
+ local = "0.0.0.0";
+ else if (family == AF_INET6)
+ local = "::";
+ else
+ local = "unknown";
+ fprintf(stderr, "Listening on [%s] (family %d, port %d)\n",
+ host ?: local,
+ family,
+ *uport);
+ }
+
if (uflag && kflag) {
/*
* For UDP and -k, don't connect the socket,
@@ -708,20 +724,19 @@ main(int argc, char *argv[])
*/
int rv;
char buf[2048];
- struct sockaddr_storage z;
- len = sizeof(z);
+ len = sizeof(cliaddr);
rv = recvfrom(s, buf, sizeof(buf), MSG_PEEK,
- (struct sockaddr *)&z, &len);
+ (struct sockaddr *)&cliaddr, &len);
if (rv < 0)
err(1, "recvfrom");
- rv = connect(s, (struct sockaddr *)&z, len);
+ rv = connect(s, (struct sockaddr *)&cliaddr, len);
if (rv < 0)
err(1, "connect");
if (vflag)
- report_connect((struct sockaddr *)&z, len, NULL);
+ report_connect((struct sockaddr *)&cliaddr, len, NULL);
# if defined(TLS)
readwrite(s, NULL);