]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
fetch(3): Add SOCKS5 support
authorkevans <kevans@FreeBSD.org>
Sat, 15 Feb 2020 18:03:16 +0000 (18:03 +0000)
committerkevans <kevans@FreeBSD.org>
Sat, 15 Feb 2020 18:03:16 +0000 (18:03 +0000)
commitbf579e30a4d54a2d7203cdb1d1689dde46db5db6
tree6eb1814e91a94f2cc998d66d964c7e993042cc4a
parent5708bc0dd247c433b35251c3aadf76f780cd1797
fetch(3): Add SOCKS5 support

This change adds SOCKS5 support to the library fetch(3) and updates the man
page.

Details: Within the fetch_connect() function, fetch(3) checks if the
SOCKS5_PROXY environment variable is set. If so, it connects to this host
rather than the end-host. It then initializes the SOCKS5 connection in
accordance with RFC 1928 and returns the resulting conn_t (file descriptor)
for usage by the regular FTP/HTTP handlers.

Design Decision: This change defaults all DNS resolutions through the proxy
by sending all IPs as hostnames. Going forward, another feature might be to
create another environmental variable to toggle resolutions through the
proxy or not..

One may set the SOCKS5_PROXY environment variable in any of the formats:

SOCKS5_PROXY=proxy.example.com
SOCKS5_PROXY=proxy.example.com:1080
SOCKS5_PROXY=192.0.2.0
SOCKS5_PROXY=198.51.100.0:1080
SOCKS5_PROXY=[2001:db8::1]
SOCKS5_PROXY=[2001:db8::2]:1080

Then perform a request with fetch(1).

(note by kevans)
I've since been informed that Void Linux/xbps has a fork of libfetch that
also implements SOCKS5. I may compare/contrast the two in the mid-to-near
future.

Submitted by: Farhan Khan <farhan farhan codes>
Differential Revision: https://reviews.freebsd.org/D18908
lib/libfetch/common.c
lib/libfetch/common.h
lib/libfetch/fetch.3