Classified ads
|
This is node-specific part of the datamodel. More...
#include <nodemodel.h>
Signals | |
void | error (MController::CAErrorSituation aError, const QString &aExplanation) |
Signals inherited from ModelBase | |
void | error (MController::CAErrorSituation aError, const QString &aExplanation) |
Public Member Functions | |
NodeModel (MController *aController, const Model &aModel) | |
~NodeModel () | |
virtual Hash & | nodeFingerPrint () |
virtual int | listenPortOfThisNode () |
virtual void | setListenPortOfThisNode (int port) |
virtual const QSslCertificate & | nodeCert () const |
virtual const QSslKey & | nodeKey () const |
virtual QByteArray * | getNextItemToSend (Connection &aConnection) |
virtual Node * | nodeByHash (const Hash &aHash) |
virtual QList< HostConnectQueueItem > | getHotAddresses () |
QList< Node * > * | getHotNodes (int aMaxNodes) |
virtual bool | nodeGreetingReceived (Node &aNode, bool aWasInitialGreeting=false) |
virtual QList< Node * > * | getNodesAfterHash (const Hash &aHash, unsigned aMaxNodes, int aMaxInactivityMinutes=-1) |
bool | updateNodeLastConnectTimeInDb (Node &aNode) |
virtual bool | updateNodeLastMutualConnectTimeInDb (const Hash &aNodeFp, quint32 aTime) |
virtual QList< Node * > * | getNodesBeforeHash (const Hash &aHash, unsigned aMaxNodes) |
virtual void | closeOldestInactiveConnection () |
QString | dataDir () |
virtual void | addNodeFromBroadcast (const Hash &aNodeFingerPrint, const QHostAddress &aAddr, int aPort) |
virtual bool | addNodeToConnectionWishList (Node *aNode) |
virtual bool | addNodeToConnectionWishList (const Hash &aNode) |
virtual Node * | nextConnectionWishListItem () |
virtual bool | isNodeAlreadyConnected (const Node &aNode) const |
virtual bool | isNodeAlreadyConnected (const Hash &aHash) const |
virtual Hash | bucketEndHash (const Hash &aFingerPrintOfNodeAsking) |
virtual void | setDnsName (QString aName) |
virtual QString | getDnsName () |
virtual void | offerNodeToRecentlyFailedList (const Hash &aFailedNodeHash) |
Public Member Functions inherited from ModelBase | |
ModelBase (QString aDataTableName, unsigned aMaxRowsToKeep) | |
~ModelBase () | |
bool | setTimeLastReference (const Hash &aObjectFingerPrint, quint32 aTimeWhenLastReferenced) |
unsigned | getMaxRowsToKeep () |
void | setMaxRowsToKeep (unsigned aRows) |
void | truncateDataTableToMaxRows (void) |
void | updateDbTableRowCount () |
Protected Member Functions | |
bool | insertNodeToDb (Node &aNode) |
bool | updateNodeInDb (Node &aNode) |
void | retrieveListOfHotConnections () |
void | timerEvent (QTimerEvent *event) |
Private Member Functions | |
bool | openOrCreateSSLCertificate () |
bool | saveSslCertToDb (const QByteArray &aCert) |
bool | saveSslKeyToDb (const QByteArray &aKey) |
bool | loadSslCertFromDb () |
bool | loadSslKeyFromDb () |
void | deleteOldestConnectedNode () |
void | countNodes () |
Q_IPV6ADDR | ipv6AddrFromUints (quint32 aLeastSignificant, quint32 aLessSignificant, quint32 aMoreSignificant, quint32 aMostSignificant) const |
void | removeNodeFromRecentlyFailedList (const Hash &aConnectedHostFingerPrint) |
Private Attributes | |
MController * | iController |
Hash * | iFingerPrintOfThisNode |
QSslCertificate * | iThisNodeCert |
QSslKey * | iThisNodeKey |
QList< HostConnectQueueItem > | iHotAddresses |
const Model & | iModel |
QString | iDataDir |
QList< Node * > | iConnectionWishList |
QList< QPair< Hash, unsigned > > | iRecentlyFailedNodes |
int | iTimerId |
Additional Inherited Members | |
Public Types inherited from MNodeModelProtocolInterface | |
typedef struct MNodeModelProtocolInterface::HostConnectQueueItemStructure | HostConnectQueueItem |
Protected Attributes inherited from ModelBase | |
QString | iDataTableName |
unsigned | iMaxRowsToKeep |
unsigned | iCurrentDbTableRowCount |
This is node-specific part of the datamodel.
This is node-specific part of the datamodel ; this handled storage and handling of data that is directly related to nodes themselves. Node is a peer in network.
NodeModel::NodeModel | ( | MController * | aController, |
const Model & | aModel | ||
) |
NodeModel::~NodeModel | ( | ) |
|
virtual |
method for adding node reference from broadcast. this needs difference in handling because in IPv4 network this typically contains private addr space addresses that we don't want to permanently store nor give to others as node-references.
For making connections inside LANs of organisations having NATs and firewalls and whatnot this might still be a handy feature.
Implements MNodeModelProtocolInterface.
|
virtual |
method for adding a node to connection-wishlist. network connector engine will then later pick them up. nodemodel will take ownership of the node and delete the object later.
Implements MNodeModelProtocolInterface.
|
virtual |
method for adding a node to connection-wishlist. network connector engine will then later pick them up.
Implements MNodeModelProtocolInterface.
Important method regarding churn here. This is called from Connection class and this method is used to determine what content belongs to same bucket with the node that is being served by that Connection. Content in the same bucket with the node is then sent over to node ; to keep the content alive in the network.
Intent here is find bucket size where we have approximately 20 live nodes in a bucket. If size of nodes alive in network is less than 20, returned hash is same as the one given in argument, methods using the value must then implement something like "send all data".
This is done so that we order the recently-seen nodes by hash value of the node, then start from the fingerprint of the node that is asking, and from that point we count to 20. The fingerprint of the node at position 20 is the end of the bucket. The fingerprint of the node that asks is the start.
aFingerPrintOfNodeAsking | fingerprint of node that wants to have its bucket filled |
Implements MNodeModelProtocolInterface.
|
virtual |
method that picks up a connection that may be closed with smallest amount of hassle..
method also works a bit conditionally, it may be that if there is for instance a lot of connections from same subnet with us, it will not close any connection..
Implements MNodeModelProtocolInterface.
|
private |
internal book-keeping
QString NodeModel::dataDir | ( | ) |
Method that returns path of directory where datafiles are kept
|
private |
prevent db table from overflowing
|
signal |
|
virtual |
called from settings dialog and own node construction
Implements MNodeModelProtocolInterface.
|
virtual |
method for getting node-connection prospects. lock() must be called by caller. This does not return addresses of nodes that are already connected-to. And this does not return address of this same node. Idea is to use this method internally to fish out some addresses that might be worth connecting.
Implements MNodeModelProtocolInterface.
|
virtual |
method for getting node-connection prospects with idea that we make node-greetings out of those and send to neighboring node. This may and will also return address of this node and this may and will also return addresses of nodes currently connected ; it makes sense to give others list of addresses that are known to be online.
aMaxNodes | max number of nodes to return |
Implements MNodeModelProtocolInterface.
|
virtual |
Method that network connections use to request for more stuff to send to peers
aConnection | is the connection in question |
Implements MNodeModelProtocolInterface.
|
virtual |
Method for getting node-connection prospects around a given hash. This is used to obtain nodes that might contain content with hash-value near hash-values of nodes.
aHash | is hash where to start returning |
aMaxNodes | max number of nodes to return |
aMaxInactivityMinutes | leave out nodes that have last activity time older than this many minutes, if negative value specified, just include all. |
Implements MNodeModelProtocolInterface.
|
virtual |
We'll try to maintain the connections in hash-space in ring-like structure where each node is connected to the adjacent node, "adjacency" means that nodes whose hash-values are closest to ours, are our adjacent nodes. For this purpose have methods for retrieving list of nodes just before us in the ring and later list of nodes just after us in the ring.
Implements MNodeModelProtocolInterface.
|
protected |
|
private |
|
virtual |
method for checking if a node is already connected. This will try matching against hash and network addresses.
Implements MNodeModelProtocolInterface.
|
virtual |
Method for checking if a node is already connected. This version checks only hash, not addresses.
Implements MNodeModelProtocolInterface.
|
virtual |
TCP listen port number method
Implements MNodeModelProtocolInterface.
|
private |
|
private |
|
virtual |
method for getting one node from wishlist. caller is obliged to delete the node returned.
Implements MNodeModelProtocolInterface.
Method for getting node details by hash
aHash | tells which node to retrieve |
Implements MNodeModelProtocolInterface.
|
virtual |
getter for ssl certificate of SSL sock
Implements MNodeModelProtocolInterface.
|
virtual |
returns fingerprint of this node
Implements MNodeModelProtocolInterface.
|
virtual |
From MModelProtocolInterface.
Method related to node database handling ; generic node reference update method, that is used also to update reference of this node (self). NodeModel must be locked before this is used.
Practically this is called on 2 occasions: one is a new connection to peer, there peer sends node greeing as the first thing. This may trigger other things inside datamodel.
Second possibility is that we've asked for node references (around some hash) and then we'll receive.
aNode | is the node that had its ref sent |
aWasInitialGreeting | is true if this call was due to initial node greeting sent just as first time after connect |
Implements MNodeModelProtocolInterface.
|
virtual |
getter for ssl certificate of SSL sock
Implements MNodeModelProtocolInterface.
|
virtual |
used to offer node to list of recently failed connections. this model maintains a list of such nodes and tries to not immediately re-connect a recently failed node
Implements MNodeModelProtocolInterface.
|
private |
opens the node cert that is for network traffic
|
private |
|
protected |
|
private |
|
private |
|
virtual |
called from settings dialog
Implements MNodeModelProtocolInterface.
|
virtual |
Setting of TCP listen port number method
Implements MNodeModelProtocolInterface.
|
protected |
for periodical stuff inside datamodel
|
protected |
method for updating existing node in db table
aNode | is the node to update |
|
virtual |
this is like updateNodeInDb but updates only the time of last connect
Implements MNodeModelProtocolInterface.
|
virtual |
method for updating last mutual connect time of a node
Implements MNodeModelProtocolInterface.
|
private |
|
private |
|
private |
|
private |
set by method openOrCreateSSLCertificate
|
private |
|
private |
|
private |
this variable holds list of nodes that we've tried to connect and failed. purpose of this is that we don't immediately try again
|
private |
set by method openOrCreateSSLCertificate
|
private |
set by method openOrCreateSSLCertificate
|
private |
periodical timer