curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Supporting socks proxy via unix sockets

From: Timothe Litt <litt_at_acm.org>
Date: Fri, 15 Apr 2022 06:21:09 -0400


On 15-Apr-22 05:32, Daniel Stenberg via curl-users wrote:
> On Mon, 11 Apr 2022, Dan Fandrich via curl-users wrote:
>
>> My preference is still for the file: style triple-slash syntax
>> socks5h:///path/to/socks.sock but it sounds like that won't work
>> without changes to the URL parser. Given that a normal socks path
>> will never use the path portion of the URL, it means the host part
>> could be pretty flexible. So much so that the host part could be
>> completely ignored if a path of any sort exists in the URL (I'm not
>> suggesting we do that, though).
>
> Maybe we could require "localhost" as hostname and if the URL then has
> a path it means it is a unix-socket and not a "normal one"?
>
> Like this:
>
>   socks5h://localhost/path/to/socks.sock
>
For a somewhat magical approach:

    If the authority is localhost, use stat(2) to determine if the path
    is a unix socket (or pipe).

    If so, do an open and treat as a file.  Otherwise, do the
    socket/connect dance.

    This doesn't work if a webserver or other network agent maps a URI
    that happens to be the filesystem path to something else that
    provides a proxy service.  But that would take considerable (and
    somewhat perverse) effort.

For foolproof, but ugly: define protocols for local proxies - e.g.
socks5hu:, socks4u:, etc.

Or use port 0 to indicate a socket, and put the port in the path (e.g.
socks5:localhost:0/1088/path/to/socks.sock or
socks5:localhost:0//path/to/socks.sock)


Timothe Litt
ACM Distinguished Engineer
--------------------------
This communication may not represent the ACM or my employer's views,
if any, on the matters discussed.


-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-users
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2022-04-15