A Net::Proxy object represents a proxy that accepts connections and then relays the data transfered between the source and the destination.

The goal of this module is to abstract the different methods used to connect from the proxy to the destination.

A proxy is a program that transfer data across a network boundary between a client and a server. Net::Proxy introduces the concept of "connectors" (implemented as Net::Proxy::Connector subclasses), which abstract the server part (connected to the client) and the client part (connected to the server) of the proxy.

This architecture makes it easy to implement specific techniques to cross a given network boundary, possibly by using a proxy on one side of the network fence, and a reverse-proxy on the other side of the fence.

This method initialises all the registered Net::Proxy objects and then loops on all the sockets ready for reading, passing the data through the various Net::Proxy::Connector objets to handle the specifics of each connection.

If $max_connections is given, the proxy will stop after having fully processed that many connections. Otherwise, this method does not return.

There is a single parameter that all connectors accept: hook. Given a code reference, the code reference will be called when data is received on the corresponding socket.

The code reference should have the following signature:

sub callback {
my ($dataref, $sock, $connector) = @_;
...
}

$dataref is a reference to the chunk of data received, $sock is a reference to the socket that received the data, and $connector is the Net::Proxy::Connector object that created the socket. This allows someone to eventually store data in a stash stored in the connector, so as to share data between sockets.

Please report any bugs or feature requests to bug-net-proxy@rt.cpan.org, or through the web interface at http://rt.cpan.org/. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

Implement a Net::Proxy::Connector::starttls connector that can upgrade upgrade a connection to SSL transparently, even if the client or server doesn't support STARTTLS.

Martin Werthmöller provided a full implementation of a connector that can handle IMAP connections and upgrade them to TLS if the client sends a STARTTLS command. My implementation will split this in two parts Net::Proxy::Connector::ssl and Net::Proxy::Connector::starttls, that inherits from the former.