source:
npl/overig/netcat_openbsd/patches/0005-send-crlf.patch
@
30f002a
Last change on this file since 30f002a was c5c522c, checked in by , 8 years ago | |
---|---|
|
|
File size: 3.0 KB |
-
nc.1
From: Aron Xu <aron@debian.org> Date: Mon, 13 Feb 2012 14:57:45 +0800 Subject: send crlf --- nc.1 | 6 ++++-- netcat.c | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/nc.1 b/nc.1 index b7014a2..af44976 100644
a b 34 34 .Sh SYNOPSIS 35 35 .Nm nc 36 36 .Bk -words 37 .Op Fl 46 DdhklnrStUuvz37 .Op Fl 46CDdhklnrStUuvz 38 38 .Op Fl I Ar length 39 39 .Op Fl i Ar interval 40 40 .Op Fl O Ar length … … to use IPv4 addresses only. 98 98 Forces 99 99 .Nm 100 100 to use IPv6 addresses only. 101 .It Fl C 102 Send CRLF as line-ending. 101 103 .It Fl D 102 104 Enable debugging on the socket. 103 105 .It Fl d … … More complicated examples can be built up when the user knows the format 355 357 of requests required by the server. 356 358 As another example, an email may be submitted to an SMTP server using: 357 359 .Bd -literal -offset indent 358 $ nc localhost 25 \*(Lt\*(Lt EOF360 $ nc [\-C] localhost 25 \*(Lt\*(Lt EOF 359 361 HELO host.example.com 360 362 MAIL FROM:\*(Ltuser@host.example.com\*(Gt 361 363 RCPT TO:\*(Ltuser2@host.example.com\*(Gt -
netcat.c
diff --git a/netcat.c b/netcat.c index fdaca44..4f4d2bf 100644
a b 111 111 #define CONNECTION_TIMEOUT 2 112 112 113 113 /* Command Line Options */ 114 int Cflag = 0; /* CRLF line-ending */ 114 115 int dflag; /* detached, no stdin */ 115 116 unsigned int iflag; /* Interval Flag */ 116 117 int jflag; /* use jumbo frames if we can */ … … main(int argc, char *argv[]) 180 181 sv = NULL; 181 182 182 183 while ((ch = getopt(argc, argv, 183 "46 DdhI:i:jklnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) {184 "46CDdhI:i:jklnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) { 184 185 switch (ch) { 185 186 case '4': 186 187 family = AF_INET; … … main(int argc, char *argv[]) 309 310 if (Tflag < 0 || Tflag > 255 || errstr || errno) 310 311 errx(1, "illegal tos value %s", optarg); 311 312 break; 313 case 'C': 314 Cflag = 1; 315 break; 312 316 default: 313 317 usage(1); 314 318 } … … readwrite(int nfd) 906 910 else if (n == 0) { 907 911 goto shutdown_wr; 908 912 } else { 909 if (atomicio(vwrite, nfd, buf, n) != n) 910 return; 913 if ((Cflag) && (buf[n-1]=='\n')) { 914 if (atomicio(vwrite, nfd, buf, n-1) != (n-1)) 915 return; 916 if (atomicio(vwrite, nfd, "\r\n", 2) != 2) 917 return; 918 } 919 else { 920 if (atomicio(vwrite, nfd, buf, n) != n) 921 return; 922 } 911 923 } 912 924 } 913 925 else if (pfd[1].revents & POLLHUP) { … … help(void) 1139 1151 fprintf(stderr, "\tCommand Summary:\n\ 1140 1152 \t-4 Use IPv4\n\ 1141 1153 \t-6 Use IPv6\n\ 1154 \t-C Send CRLF as line-ending\n\ 1142 1155 \t-D Enable the debug socket option\n\ 1143 1156 \t-d Detach from stdin\n\ 1144 1157 \t-h This help text\n\ … … void 1172 1185 usage(int ret) 1173 1186 { 1174 1187 fprintf(stderr, 1175 "usage: nc [-46 DdhjklnrStUuvz] [-I length] [-i interval] [-O length]\n"1188 "usage: nc [-46CDdhjklnrStUuvz] [-I length] [-i interval] [-O length]\n" 1176 1189 "\t [-P proxy_username] [-p source_port] [-s source] [-T toskeyword]\n" 1177 1190 "\t [-V rtable] [-w timeout] [-X proxy_protocol]\n" 1178 1191 "\t [-x proxy_address[:port]] [destination] [port]\n");
Note: See TracBrowser
for help on using the repository browser.