Indy has its own proxy components that do what you are asking for. Look at the TIdMappedPortTCP
and TIdHTTPProxyServer
components as starting places.
TIdMappedPortTCP
is a general-purpose proxy that just passes raw data back and forth. You can use its OnConnect
event to dynamically configure the target Host/Port for that connection (such as by reading it from the client), or you can set its MappedHost
and MappedPort
properties statically for all connections. You can use its OnExecute
and OnOutboundData
events to modify data as it passes through the proxy, if needed.
TIdHTTPProxyServer
is a specialized proxy only for HTTP-based proxying, where the client uses the HTTP GET
, POST
, HEAD
, and CONNECT
verbs, specifying absolute URLs to the target Host/Port, and then passes HTTP headers and data back and forth as needed (CONNECT
is commonly used for proxying an SSL/TLS connection through a firewall).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…