[spot-on-development] SF.net SVN: spot-on:[1307] branches/0.x/Kernel
Brought to you by:
textfield
|
From: <tex...@us...> - 2013-06-16 16:48:06
|
Revision: 1307
http://sourceforge.net/p/spot-on/code/1307
Author: textfield
Date: 2013-06-16 16:47:59 +0000 (Sun, 16 Jun 2013)
Log Message:
-----------
A workaround for proxies.
Modified Paths:
--------------
branches/0.x/Kernel/spot-on-neighbor.cc
branches/0.x/Kernel/spot-on-neighbor.h
Modified: branches/0.x/Kernel/spot-on-neighbor.cc
===================================================================
--- branches/0.x/Kernel/spot-on-neighbor.cc 2013-06-16 15:11:03 UTC (rev 1306)
+++ branches/0.x/Kernel/spot-on-neighbor.cc 2013-06-16 16:47:59 UTC (rev 1307)
@@ -48,6 +48,7 @@
s_dbId += 1;
setSocketDescriptor(socketDescriptor);
m_address = peerAddress();
+ m_ipAddress = m_address.toString();
m_externalAddress = new spoton_external_address(this);
m_id = std::numeric_limits<qint64>::min();
m_lastReadTime = QDateTime::currentDateTime();
@@ -104,10 +105,11 @@
s_dbId += 1;
setProxy(proxy);
m_address = QHostAddress(ipAddress);
+ m_ipAddress = ipAddress;
if(m_address.isNull())
- if(!ipAddress.isEmpty())
- QHostInfo::lookupHost(ipAddress,
+ if(!m_ipAddress.isEmpty())
+ QHostInfo::lookupHost(m_ipAddress,
this, SLOT(slotHostFound(const QHostInfo &)));
m_address.setScopeId(scopeId);
@@ -470,6 +472,22 @@
void spoton_neighbor::slotConnected(void)
{
+ if(proxy().type() != QNetworkProxy::NoProxy)
+ {
+ /*
+ ** The local address is the address of the proxy. Unfortunately,
+ ** we do not have network interfaces that have such an address. Hence,
+ ** m_networkInterface will always be zero.
+ */
+
+ QHostAddress address(m_ipAddress);
+
+ if(address.protocol() == QAbstractSocket::IPv4Protocol)
+ setLocalAddress(QHostAddress("127.0.0.1"));
+ else
+ setLocalAddress(QHostAddress("::1"));
+ }
+
m_keepAliveTimer.start();
m_lastReadTime = QDateTime::currentDateTime();
@@ -2298,6 +2316,7 @@
if(!address.isNull())
{
m_address = address;
+ m_ipAddress = m_address.toString();
break;
}
}
Modified: branches/0.x/Kernel/spot-on-neighbor.h
===================================================================
--- branches/0.x/Kernel/spot-on-neighbor.h 2013-06-16 15:11:03 UTC (rev 1306)
+++ branches/0.x/Kernel/spot-on-neighbor.h 2013-06-16 16:47:59 UTC (rev 1307)
@@ -69,6 +69,7 @@
QDateTime m_lastReadTime;
QHostAddress m_address;
QNetworkInterface *m_networkInterface;
+ QString m_ipAddress;
QTimer m_externalAddressDiscovererTimer;
QTimer m_keepAliveTimer;
QTimer m_lifetime;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|