Qt DNS P2P Code
Status: Planning
Brought to you by:
pikeaero
December 7th, 2010 QtDNSP2P http://sourceforge.net/projects/qtdnsp2p It's designed to be a cross platform P2P DNS experimentation platform that will allow experimenting with various trust based models, and various P2P topologies in order to evaluate real world issues such as latency, enemy infiltration, and so on. It utilizes a MySQL database backend in order to facilitate real-time data monitoring and potentially controlling by external applications. The object oriented design is intended to allow a developer to reconfigure the P2P model and data models with relative ease comparing to an application that is tightly bound to a particular mode of operation. QtDNSP2P is an object oriented, cross platform, C++ framework utilizing a cipher stream protected protocol between peers base on an RSA public key exchange. Coding Standards ---------------- - 4 spaces per tab. - Preserve tab characters. - Horstmann coding style. - Positive logic nesting. Requirements ------------ Qt 4.x + dev headers. MySQL (or similar) Build ----- cd easyzlib qmake-qt4 make cd .. cd qca-2.0.3 qmake-qt4 make sudo make install cd .. cd cryptplugins qmake-qt4 make cd .. qmake-qt4 make Install ------- sudo mkdir /etc/qtdnsp2p sudo mkdir /etc/qtdnsp2p/plugins sudo cp cryptoplugins/*/*.so /etc/qtdnsp2p/plugins/ Database -------- Currently hard coded to use QMYSQL backend. File qtdnsp2p.sql contains the schema. Use something like "mysql -u root -p < qtdnsp2p.sql" to prime the database. These two tables control the instantiation of listener and connector objects during bootstrap: tbl_listeners - manages listeners. tbl_connectors - manages outbound connectors. These tables are intended to be somewhat dynamic: tbl_key - storage for public and private keys tbl_nodes - nodes of interest Setup ----- ** TODO: Simplify this *** In mysql client, connect to database and modify tbl_connectors and tbl_listeners to suite your boostrap environment. tbl_connectors descripts which peers to initially try to peer with. tbl_listeners describes how many and what ports to start listeners on. Now you can also use ++bootstrap <addr>:<port> to add a bootstrap peer --help for up to date listing of command line options. Session ------- Once a socket is created, either by a connector or by a listener, a session is instantiated and the socket is passed to the new session instance for handling the connection. Currently two types of sessions are supported, those which have to do with establishing trust and routing, and those that have to do with resolving DNS queries. A session runs as an independent thread of execution, and is destroyed once the socket connection is severed. Secure / Insecure Stream Protocol --------------------------------- The stream communication is implemented as a cargo metaphore whereby the cargo map dictionary is serialized into a known location in the packet stream. In order for secure stream to start, the peers must initiate a public key exchange, challenge handshake, and stream cipher negatioation to select an agreeable stream cypher from the available plugins. Once secure stream begins, the packet handler begins passing input and output streams through whichever stream cipher plugin was agreed on. Peer Cipher Stream Handshake ---------------------------- '>' & '<' = cleartext ')' & '(' = ciphertext '+' = packet cargo Peer A connects to peer B: A >>>>>>>>>>> (tcp open) >>>>>>>>>>>>>>>>> B A >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> B + ConnectionRequest + Status(OK) + A's Public Key + A's Prefered Cipher A <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< B + ConnectionReply + Status(OK) + B's Public Key + B's Prefered Cipher /* TODO: expand on the cipher negotiation protocol */ /* Once stream is secure, we establish a session and get to work... */ A )))))))))))))))))))))))))))))))))))))))) B + SessionRequest + Status(OK) + <parcel-data> A (((((((((((((((((((((((((((((((((((((((( B + SessionReply + Status(OK) + <parcel-data> ETC.. A (((((((((((((((((((((((((((((((((((((((( B + SessionDisconnect + Status(<reason>) /* B may initiate tcp close at this point */ A )))))))))))))))))))))))))))))))))))))))) B + ReplyDisconnect + Status(OK) A <<<<<<<<<<<< (tcp close) <<<<<<<<<<<<<<< B