Classified ads
node.h
Go to the documentation of this file.
1 /* -*-C++-*-
2  Classified Ads is Copyright (c) Antti Jarvinen 2013.
3 
4  This file is part of Classified Ads.
5 
6  Classified Ads is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with Classified Ads; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 
22 #ifndef NODE_H
23 #define NODE_H
24 #include <QObject>
25 #include "../util/hash.h"
26 #include <time.h>
27 #include <QHostAddress> // for Q_IPV6ADDR
28 class Hash ;
29 
30 extern Q_IPV6ADDR KNullIpv6Addr ;
31 
40 class Node {
41 
42 public:
43 
51  Node(const Hash &aNodeFingerPrint,
52  const int aListenPort) ;
56  ~Node() ;
60  void setIpv4Addr(const quint32 aAddr) ;
64  void setIpv6Addr(const Q_IPV6ADDR &aAddr) ;
68  quint32 ipv4Addr(void) const ;
72  Q_IPV6ADDR ipv6Addr(void) const ;
76  QString DNSAddr(void) const ;
80  void setDNSAddr(const QString& aAddr) ;
84  QString TORAddr(void) const ;
88  void setTORAddr(const QString& aAddr) ;
92  void setPort(const int aPort) ;
96  int port(void) const ;
97 
101  void setGoodNodeListTime(const time_t aTime) ;
105  time_t goodNodeListTime(void) const ;
109  const Hash& nodeFingerPrint(void) const ;
113  void setLastConnectTime(const time_t aTime) ;
117  time_t lastConnectTime(void) const ;
121  void setLastMutualConnectTime(const time_t aTime) ;
125  time_t lastMutualConnectTime(void) const ;
126 
130  void setCanReceiveIncoming(const bool aYesItCan) ;
134  bool canReceiveIncoming(void) const ;
142  bool setIpAddrWithChecks(const QHostAddress& aAddress) ;
146  QVariant asQVariant() const ;
151  static Node* fromQVariant(const QVariantMap& aJSonAsQVariant,
152  const bool aIsInitialGreeting ) ;
153 
154 private:
162  quint32 iIPv4Addr ;
164  Q_IPV6ADDR iIPv6Addr ;
166  QString* iDnsName ;
168  QString* iTorAddr ;
177 } ;
178 #endif
void setLastConnectTime(const time_t aTime)
const Hash & nodeFingerPrint(void) const
QString * iTorAddr
Definition: node.h:168
int iListenPort
Definition: node.h:158
Node is a peer in network.
Definition: node.h:40
void setPort(const int aPort)
int port(void) const
void setGoodNodeListTime(const time_t aTime)
void setIpv6Addr(const Q_IPV6ADDR &aAddr)
Node(const Hash &aNodeFingerPrint, const int aListenPort)
Q_IPV6ADDR iIPv6Addr
Definition: node.h:164
time_t iLastConnectTime
Definition: node.h:174
const Hash iNodeFingerPrint
Definition: node.h:156
Q_IPV6ADDR KNullIpv6Addr
time_t iTimeOfGoodNodeList
Definition: node.h:172
Hash is class that carries 160-bit digest.
Definition: hash.h:38
QString TORAddr(void) const
QString DNSAddr(void) const
quint32 iIPv4Addr
Definition: node.h:162
void setCanReceiveIncoming(const bool aYesItCan)
QVariant asQVariant() const
time_t goodNodeListTime(void) const
Q_IPV6ADDR ipv6Addr(void) const
time_t lastConnectTime(void) const
bool setIpAddrWithChecks(const QHostAddress &aAddress)
bool iCanReceiveIncoming
Definition: node.h:170
time_t lastMutualConnectTime(void) const
void setTORAddr(const QString &aAddr)
quint32 ipv4Addr(void) const
time_t iTimeOfLastContact
Definition: node.h:160
void setIpv4Addr(const quint32 aAddr)
bool canReceiveIncoming(void) const
void setDNSAddr(const QString &aAddr)
static Node * fromQVariant(const QVariantMap &aJSonAsQVariant, const bool aIsInitialGreeting)
QString * iDnsName
Definition: node.h:166
void setLastMutualConnectTime(const time_t aTime)
time_t iLastMutualConnectTime
Definition: node.h:176