Skip to content
Snippets Groups Projects
  1. Feb 23, 2020
    • Simon Tatham's avatar
      Auxiliary application: 'psocks', a simple SOCKS server. · 1b40d9f3
      Simon Tatham authored
      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.)
      1b40d9f3
Loading