kiesel / wormhole

Client/server interaction between guest and host system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Netcat

thekid opened this issue · comments

I had to change the following in net-invoke.sh in order to make the client side work:

-nc -l 127.0.0.1 5115 | while read -r -a 'RARG' ; do
+nc -p 5115 -l 127.0.0.1 | while read -r -a 'RARG' ; do

Using netcat on Cygwin:

$ nc -h 2>&1|head -3
[v1.10]
connect to somewhere:   nc [-options] hostname port[s] [ports] ...
listen for inbound:     nc -l -p port [-options] [hostname] [port]

Atfer a bit of research, the nc -l [ip] [port] syntax seems to come from the BSD netcat variant, while nl -p [port] -l [ip] is the Linux one.

http://www.freebsd.org/cgi/man.cgi?nc
http://man.cx/netcat

I am on Cygwin, too. I see a different output:

$ nc -h 2>&1|head -3
usage: nc [-46CDdhklnrtUuvz] [-I length] [-i interval] [-O length]
          [-P proxy_username] [-p source_port] [-s source] [-T ToS]
          [-V rtable] [-w timeout] [-X proxy_protocol]

This seems to be the BSD variant, right? I just updated all the Cygwin stuff, no difference here.

On my other machine (Cygwin), I also get the output you've posted above, and the manpage is titled "NC(1), BSD General Commands Manual, nc — arbitrary TCP and UDP connections and listens".

On a Gentoo machine though I can see the Linux variant, with the [v1.10] in the help output. Its manpage is titled "NC(1), General Commands Manual, nc - TCP/IP swiss army knife".

Seems at some point Cygwin started using the first.

Best yet, there's no compatible way to write the command so it works with both versions. Try the Linux version to listen to ports with the BSD version:

$ nc -l -p 1234 127.0.0.1
nc: cannot use -p and -l

Blergh... the only thing left is to grep the help output for ^[v in its first line, I guess.

So maybe this would work portably:

(nc -p 5115 -l 127.0.0.1 || nc -l 127.0.0.1 5115)  | while read -r -a 'RARG' ; do

I incorporated this change; it works on this box - can you please try?

Thanks, will do so on Monday