Classes used in rrnat - each namespace is in a separate directory
- Netfilter
- Conntrack - create new conntrack
- Listener - listen for incoming packets through QUEUE
- Status - get connection status for a client
- Client
- Connection - connection to server
- Control - control client functions like shutdown
- Packet - packet definition
- Server
- Listener - client connection listener
- Connection - connection to client
- ClientManager - client availability manager
- Router - route packets to next available client
namespace Netfilter
{
class Conntrack
{
Conntrack(const boost::asio::ip::tcp::endpoint& orig_src, const boost::asio::ip::tcp::endpoint& orig_dst,
const boost::asio::ip::tcp::endpoint& new_src, const boost::asio::ip::tcp::endpoint& new_dst);
};
class Listener
{
Listener(boost::asio::io_service& io);
Listener(boost::asio::io_service& io,
std::function<void(const boost::asio::ip::tcp::endpoint&, const boost::asio::ip::tcp::endpoint&)>);
void setCallback(std::function<void(const boost::asio::ip::tcp::endpoint&, const boost::asio::ip::tcp::endpoint&)>);
};
class Status
{
Status();
Status(const boost::asio::ip::address& addr);
unsigned int getConnections() const;
void setAddr(const boost::asio::ip::address& addr);
};
}
For the server daemon, the main running classes are Server::Router and Server::ClientManager. Server::Router will call upon a Server::ClientManager to determine the next available client, and uses Netfilter::Conntrack and Netfilter::Listener to detect and route new connections to that client. Server::ClientManager uses Server::Listener to listen for clients, along with Netfilter::Status to determine the connections going to each client. It uses Client::Packet as a data transfer mechanism to communicate with clients.
For the client daemon, the main running classes are Client::Connection and Client::Control. Client::Connection will connect to a server and perform the necessary authentication, and Client::Control will interpret commands sent from the server, such as shutting down the client.
Parse configuration (Boost::Program_Options)
Create io_service
Initialise Server::ClientManager with settings from configuration
List of allowed IPs
Refresh interval
Connection thresholds
Set up Server::Listener
Set up timers using io_service
Initialise Server::Router passing created Server::ClientManager
Set up Netfilter::Listener and Netfilter::Conntrack
Optional: set up signals
Run io_service
Parse configuration (Boost::Program_Options)
Create io_service
Initialise Client::Control
Initialise Client::Connection passing created Client::Control
Connect to server
Authenticate against server
Schedule io_service jobs
Run io_service
https://git.netfilter.org/libnetfilter_conntrack/tree/utils/conntrack_create_nat.c http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference/posix__stream_descriptor.html