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 modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (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
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Classified Ads. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #ifndef NODE_H
22 #define NODE_H
23 #include <QObject>
24 #include "../util/hash.h"
25 #include <time.h>
26 #include <QHostAddress> // for Q_IPV6ADDR
27 class Hash ;
28 
29 extern Q_IPV6ADDR KNullIpv6Addr ;
30 
39 class Node : public QObject {
40  Q_OBJECT
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 ;
141  bool setIpAddrWithChecks(const QHostAddress& aAddress) ;
145  QVariant asQVariant() const ;
150  static Node* fromQVariant(const QVariantMap& aJSonAsQVariant,
151  const bool aIsInitialGreeting ) ;
152 
153 private:
161  quint32 iIPv4Addr ;
163  Q_IPV6ADDR iIPv6Addr ;
165  QString* iDnsName ;
167  QString* iTorAddr ;
176 } ;
177 #endif
void setLastConnectTime(const time_t aTime)
QString * iTorAddr
Definition: node.h:167
time_t lastConnectTime(void) const
int iListenPort
Definition: node.h:157
Node is a peer in network.
Definition: node.h:39
bool canReceiveIncoming(void) const
void setPort(const int aPort)
const Hash & nodeFingerPrint(void) const
void setGoodNodeListTime(const time_t aTime)
void setIpv6Addr(const Q_IPV6ADDR &aAddr)
Node(const Hash &aNodeFingerPrint, const int aListenPort)
time_t goodNodeListTime(void) const
Q_IPV6ADDR iIPv6Addr
Definition: node.h:163
time_t iLastConnectTime
Definition: node.h:173
const Hash iNodeFingerPrint
Definition: node.h:155
Q_IPV6ADDR KNullIpv6Addr
time_t iTimeOfGoodNodeList
Definition: node.h:171
Hash is class that carries 160-bit digest.
Definition: hash.h:37
QString DNSAddr(void) const
QString TORAddr(void) const
quint32 iIPv4Addr
Definition: node.h:161
void setCanReceiveIncoming(const bool aYesItCan)
int port(void) const
bool setIpAddrWithChecks(const QHostAddress &aAddress)
bool iCanReceiveIncoming
Definition: node.h:169
void setTORAddr(const QString &aAddr)
time_t iTimeOfLastContact
Definition: node.h:159
void setIpv4Addr(const quint32 aAddr)
QVariant asQVariant() const
void setDNSAddr(const QString &aAddr)
static Node * fromQVariant(const QVariantMap &aJSonAsQVariant, const bool aIsInitialGreeting)
QString * iDnsName
Definition: node.h:165
void setLastMutualConnectTime(const time_t aTime)
quint32 ipv4Addr(void) const
time_t iLastMutualConnectTime
Definition: node.h:175
Q_IPV6ADDR ipv6Addr(void) const
time_t lastMutualConnectTime(void) const