New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add `--no-shutdown` option. #151

Closed
wants to merge 1 commit into
base: master
from
Jump to file or symbol
Failed to load files and symbols.
+17 −1
Diff settings

Always

Just for now

Add `--no-shutdown` option.

This option solves issue #142. It prevents Ncat from putting the connection in
half-duplex mode after seeing EOF on stdin. This emulates the behavior of
OpenBSD-netcat's `-d` option. The `-d` option itself prevents a bug affecting
some versions of that program in which the sender closes the connection
prematurely upon receiving a FIN packet from a receiver.
  • Loading branch information...
adsr committed Jun 4, 2015
commit 0a34908e2f642abc17da4cc2fbdf2d3bd39359c4
View
@@ -775,6 +775,19 @@
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--no-shutdown</option> (Do not shutdown into half-duplex mode)
<indexterm><primary><option>--no-shutdown</option> (Ncat option)</primary></indexterm>
</term>
<listitem>
<para>If this option is passed, Ncat will not invoke shutdown on a
socket aftering seeing EOF on stdin. This is provided for
backward-compatibility with OpenBSD netcat, which exhibits this
behavior when executed with its '-d' option.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-t</option>,
View
@@ -168,6 +168,7 @@ void options_init(void)
o.keepopen = 0;
o.sendonly = 0;
o.recvonly = 0;
o.noshutdown = 0;
o.telnet = 0;
o.linedelay = 0;
o.chat = 0;
View
@@ -161,6 +161,7 @@ struct options {
int keepopen;
int sendonly;
int recvonly;
int noshutdown;
int telnet;
int linedelay;
int chat;
View
@@ -393,7 +393,7 @@ static int ncat_listen_stream(int proto)
receiving anything, we can quit here. */
return 0;
}
shutdown_sockets(SHUT_WR);
if (!o.noshutdown) shutdown_sockets(SHUT_WR);
}
if (rc < 0)
return 1;
View
@@ -286,6 +286,7 @@ int main(int argc, char *argv[])
{"source-port", required_argument, NULL, 'p'},
{"source", required_argument, NULL, 's'},
{"send-only", no_argument, &o.sendonly, 1},
{"no-shutdown", no_argument, &o.noshutdown,1},
{"broker", no_argument, NULL, 0},
{"chat", no_argument, NULL, 0},
{"talk", no_argument, NULL, 0},
ProTip! Use n and p to navigate between commits in a pull request.