Expand description
Connect to relays via a proxy.
This code is here for two reasons:
- To connect via external pluggable transports (for which we use SOCKS to build our connections).
- To support users who are behind a firewall that requires them to use a SOCKS proxy to connect.
Supports SOCKS4/4a/5 and HTTP CONNECT proxies.
Re-exportsยง
use std::net::IpAddr;๐use std::net::SocketAddr;๐use std::sync::Arc;๐use base64ct::Base64;๐use base64ct::Encoding;๐use futures::io::AsyncBufReadExt;๐use futures::io::BufReader;๐use futures::AsyncReadExt;๐use futures::AsyncWriteExt;๐use httparse;๐use safelog::Sensitive;๐use tor_linkspec::PtTargetAddr;๐use tor_rtcompat::NetStreamProvider;๐use tor_socksproto::Handshake as _;๐use tor_socksproto::SocksAddr;๐use tor_socksproto::SocksAuth;๐use tor_socksproto::SocksClientHandshake;๐use tor_socksproto::SocksCmd;๐use tor_socksproto::SocksRequest;๐use tor_socksproto::SocksStatus;๐use tor_socksproto::SocksVersion;๐use tracing::trace;๐use super::TransportImplHelper;๐use async_trait::async_trait;๐use safelog::sensitive as sv;๐use tor_error::bad_api_usage;๐use tor_linkspec::ChannelMethod;๐use tor_linkspec::HasChanMethod;๐use tor_linkspec::OwnedChanTarget;๐use tor_proto::peer::PeerAddr;๐
Structsยง
- External
Proxy Plugin - An object that connects to a Tor bridge via an external pluggable transport that provides a proxy.
Enumsยง
- Protocol
- Information about what proxy protocol to use, and how to use it.
- Proxy
Error - An error that occurs while negotiating a connection with a proxy.
Constantsยง
- MAX_
HTTP_ ๐HEADER_ BYTES - Maximum number of bytes allowed in HTTP response headers from proxy.
- NO_ADDR ๐
- An address to use when told to connect to โno address.โ
Functionsยง
- build_
http_ ๐connect_ request - Build HTTP CONNECT request string with optional Basic auth.
- connect_
via_ ๐proxy - Open a connection to
targetvia the proxy atproxy, using the protocol atprotocol. - do_
http_ ๐connect_ handshake - Perform HTTP CONNECT proxy handshake (RFC 7231, RFC 7617 for Basic auth).
- do_
socks_ ๐handshake - Perform SOCKS proxy handshake.
- encode_
settings ๐ - Encode the PT settings from
ITin a format that a pluggable transport can use. - format_
connect_ ๐target - Format target address for HTTP CONNECT request line and Host header.
- parse_
http_ ๐connect_ response - Parse HTTP CONNECT response and extract status code.
- send_
http_ ๐connect_ request - Send HTTP CONNECT request to proxy.
- settings_
to_ protocol - Transform a string into a representation that can be sent as SOCKS authentication.