Skip to content

Commit 1b40d9f

Browse files
committed
Auxiliary application: 'psocks', a simple SOCKS server.
This is built more or less entirely out of pieces I already had. The SOCKS server code is provided by the dynamic forwarding code in portfwd.c. When that accepts a connection request, it wants to talk to an SSH ConnectionLayer, which is already a trait with interchangeable implementations - so I just provide one of my own which only supports the lportfwd_open() method. And that in turn returns an SshChannel object, with a special trait implementation all of whose methods just funnel back to an ordinary Socket. Result: you get a Socket-to-Socket SOCKS implementation with no SSH anywhere, and even a minimal amount of need to _pretend_ internally to be an SSH implementation. Additional features include the ability to log all the traffic in the form of diagnostics to standard error, or log each direction of each connection separately to a file, or for anything more general, to log each direction of each connection through a pipe to a subcommand that can filter out whatever you think are the interesting parts. Also, you can spawn a subcommand after the SOCKS server is set up, and terminate automatically when that subcommand does - e.g. you might use this to wrap the execution of a single SOCKS-using program. This is a modernisation of a diagnostic utility I've had kicking around out-of-tree for a long time. With all of last year's refactorings, it now becomes feasible to keep it in-tree without needing huge amounts of scaffolding. Also, this version runs on Windows, which is more than the old one did. (On Windows I haven't implemented the subprocess parts, although there's no reason I _couldn't_.) As well as diagnostic uses, this may also be useful in some situations as a thing to forward ports to: PuTTY doesn't currently support reverse dynamic port forwarding (in which the remote listening port acts as a SOCKS server), but you could get the same effect by forwarding a remote port to a local instance of this. (Although, of course, that's nothing you couldn't achieve using any other SOCKS server.)
1 parent 5a9bfca commit 1b40d9f

File tree

6 files changed

+870
-2
lines changed

6 files changed

+870
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
/psusan
4141
/osxlaunch
4242
/uppity
43+
/psocks
4344
/unix/PuTTY.app
4445
/unix/Pterm.app
4546
/fuzzterm

Recipe

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,22 @@ uppity : [UT] uxserver SSHSERVER UXMISC uxsignal uxnoise uxgss uxnogtk
411411
psusan : [UT] uxpsusan SSHSERVER UXMISC uxsignal uxnoise nogss uxnogtk
412412
+ uxpty uxsftpserver ux_x11 uxagentsock procnet uxcliloop
413413

414+
PSOCKS = psocks portfwd conf sshutils logging proxy nocproxy timing callback
415+
+ time tree234 version errsock be_misc norand MISC
416+
psocks : [C] PSOCKS winsocks wincons winproxy winnet winmisc winselcli
417+
+ winhsock winhandl winmiscs winnohlp wincliloop LIBS
418+
psocks : [UT] PSOCKS uxsocks uxcons uxproxy uxnet uxmisc uxpoll uxsel uxnogtk
419+
+ uxpeer uxfdsock uxcliloop uxsignal
420+
414421
# ----------------------------------------------------------------------
415422
# On Windows, provide a means of removing local test binaries that we
416423
# aren't going to actually ship. (I prefer this to not building them
417424
# in the first place, so that we find out about build breakage early.)
418425
!begin vc
419426
cleantestprogs:
420-
-del $(BUILDDIR)testcrypt.exe
427+
-del $(BUILDDIR)testcrypt.exe $(BUILDDIR)psocks.exe
421428
!end
422429
!begin clangcl
423430
cleantestprogs:
424-
-rm -f $(BUILDDIR)testcrypt.exe
431+
-rm -f $(BUILDDIR)testcrypt.exe $(BUILDDIR)psocks.exe
425432
!end

0 commit comments

Comments
 (0)