Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Zotov committed Jan 29, 2010
2 parents cd13106 + fe55f2c commit f6b1355
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
10 changes: 6 additions & 4 deletions libsparkle/LinkLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,13 @@ void LinkLayer::handleProtocolVersionReply(QByteArray &payload, SparkleNode* nod
if(!checkPacketExpection(node, "ProtocolVersionReply", JoinVersionRequest))
return;

const protocol_version_reply_t *ver = (const protocol_version_reply_t *) payload.data();
Log::debug("link: remote protocol version: %1") << ver->version;
const protocol_version_reply_t *reply = (const protocol_version_reply_t *) payload.data();
quint32 version = ntohl(reply->version);

if(ntohl(ver->version) != ProtocolVersion) {
Log::error("link: protocol version mismatch: got %1, expected %2") << ver->version << ProtocolVersion;
Log::debug("link: remote protocol version: %1") << version;

if(version != ProtocolVersion) {
Log::error("link: protocol version mismatch: got %1, expected %2") << version << ProtocolVersion;

cleanup();
emit joinFailed();
Expand Down
18 changes: 15 additions & 3 deletions libsparkle/SparkleNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "SparkleNode.h"
#include "Log.h"

SparkleNode::SparkleNode(Router &router, QHostAddress realIP, quint16 realPort) : QObject(&router), _router(router), _realIP(realIP), _phantomIP(realIP), _realPort(realPort), _phantomPort(realPort), authKeyPresent(false), keysNegotiated(false) {
SparkleNode::SparkleNode(Router &router, QHostAddress realIP, quint16 realPort) : QObject(&router), _router(router), _realIP(realIP), _realPort(realPort), _phantomPort(0), authKeyPresent(false), keysNegotiated(false) {
_mySessionKey.generate();

negotiationTimer.setSingleShot(true);
Expand All @@ -42,12 +42,12 @@ void SparkleNode::setSparkleMAC(const SparkleAddress& mac) {
}

void SparkleNode::setRealIP(const QHostAddress& ip) {
_realIP = _phantomIP = ip;
_realIP = ip;
_router.notifyNodeUpdated(this);
}

void SparkleNode::setRealPort(quint16 port) {
_realPort = _phantomPort = port;
_realPort = port;
_router.notifyNodeUpdated(this);
}

Expand All @@ -59,6 +59,18 @@ void SparkleNode::setPhantomPort(quint16 port) {
_phantomPort = port;
}

QHostAddress SparkleNode::phantomIP() const {
if(_phantomIP.isNull())
return _realIP;
return _phantomIP;
}

quint16 SparkleNode::phantomPort() const {
if(_phantomPort == 0)
return _realPort;
return _phantomPort;
}

void SparkleNode::setBehindNAT(bool behindNAT) {
this->behindNAT = behindNAT;
_router.notifyNodeUpdated(this);
Expand Down
4 changes: 2 additions & 2 deletions libsparkle/headers/SparkleNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class SparkleNode : public QObject
QHostAddress realIP() const { return _realIP; }
quint16 realPort() const { return _realPort; }

QHostAddress phantomIP() const { return _phantomIP; }
quint16 phantomPort() const { return _phantomPort; }
QHostAddress phantomIP() const;
quint16 phantomPort() const;

SparkleAddress sparkleMAC() const { return _sparkleMAC; }

Expand Down

0 comments on commit f6b1355

Please sign in to comment.