From 8388551b678cf44110b0ef9bf5ac70d3020dacb3 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 21 Oct 2022 03:35:58 -0500 Subject: [PATCH] Add netcat -n to prevent DNS lookup. --- toys/net/netcat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toys/net/netcat.c b/toys/net/netcat.c index f51cca6a..74eb94a9 100644 --- a/toys/net/netcat.c +++ b/toys/net/netcat.c @@ -6,7 +6,7 @@ * fix -t, xconnect * netcat -L zombies -USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uU[!tlL][!Lw][!46U]", TOYFLAG_BIN)) +USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUn[!tlL][!Lw][!46U]", TOYFLAG_BIN)) USE_NETCAT(OLDTOY(nc, netcat, TOYFLAG_USR|TOYFLAG_BIN)) config NETCAT @@ -23,6 +23,7 @@ config NETCAT -f Use FILENAME (ala /dev/ttyS0) instead of network -l Listen for one incoming connection, then exit -L Listen and background each incoming connection (server mode) + -n No DNS lookup -p Local port number -q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet -s Local source address @@ -108,7 +109,7 @@ void netcat_main(void) if (!ll) { if (FLAG(U)) sockfd = usock(toys.optargs[0], type, 1); else sockfd = xconnectany(xgetaddrinfo(toys.optargs[0], toys.optargs[1], - family, type, 0, 0)); + family, type, 0, AI_NUMERICHOST*!!FLAG(n))); // We have a connection. Disarm timeout and start poll/send loop. alarm(0); -- 2.39.2