linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04565
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2615: Don't try ipv6 for nmdc
------------------------------------------------------------
revno: 2615
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Sat 2011-09-24 23:13:31 +0200
message:
Don't try ipv6 for nmdc
modified:
dcpp/AdcHub.h
dcpp/BufferedSocket.cpp
dcpp/BufferedSocket.h
dcpp/Client.cpp
dcpp/Client.h
dcpp/NmdcHub.h
dcpp/Pointer.h
dcpp/Socket.cpp
dcpp/Socket.h
dcpp/ThrottleManager.h
win32/HubListsDlg.cpp
win32/StringListDlg.cpp
win32/UploadPage.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/AdcHub.h'
--- dcpp/AdcHub.h 2011-08-11 13:02:19 +0000
+++ dcpp/AdcHub.h 2011-09-24 21:13:31 +0000
@@ -130,6 +130,7 @@
void unknownProtocol(uint32_t target, const string& protocol, const string& token);
bool secureAvail(uint32_t target, const string& protocol, const string& token);
+ virtual bool v4only() const { return false; }
virtual void on(Connecting) noexcept { fire(ClientListener::Connecting(), this); }
virtual void on(Connected) noexcept;
virtual void on(Line, const string& aLine) noexcept;
=== modified file 'dcpp/BufferedSocket.cpp'
--- dcpp/BufferedSocket.cpp 2011-09-21 17:51:13 +0000
+++ dcpp/BufferedSocket.cpp 2011-09-24 21:13:31 +0000
@@ -40,9 +40,9 @@
// Polling is used for tasks...should be fixed...
#define POLL_TIMEOUT 250
-BufferedSocket::BufferedSocket(char aSeparator) :
+BufferedSocket::BufferedSocket(char aSeparator, bool v4only) :
separator(aSeparator), mode(MODE_LINE), dataBytes(0), rollback(0), state(STARTING),
-disconnecting(false)
+disconnecting(false), v4only(v4only)
{
start();
@@ -74,7 +74,7 @@
mode = aMode;
}
-void BufferedSocket::setSocket(std::unique_ptr<Socket> s) {
+void BufferedSocket::setSocket(unique_ptr<Socket>&& s) {
dcassert(!sock.get());
sock = move(s);
}
@@ -89,7 +89,7 @@
void BufferedSocket::accept(const Socket& srv, bool secure, bool allowUntrusted) {
dcdebug("BufferedSocket::accept() %p\n", (void*)this);
- std::unique_ptr<Socket> s(secure ? CryptoManager::getInstance()->getServerSocket(allowUntrusted) : new Socket(Socket::TYPE_TCP));
+ unique_ptr<Socket> s(secure ? CryptoManager::getInstance()->getServerSocket(allowUntrusted) : new Socket(Socket::TYPE_TCP));
s->accept(srv);
@@ -106,7 +106,7 @@
void BufferedSocket::connect(const string& aAddress, const string& aPort, const string& localPort, NatRoles natRole, bool secure, bool allowUntrusted, bool proxy) {
dcdebug("BufferedSocket::connect() %p\n", (void*)this);
- std::unique_ptr<Socket> s(secure ? (natRole == NAT_SERVER ? CryptoManager::getInstance()->getServerSocket(allowUntrusted) : CryptoManager::getInstance()->getClientSocket(allowUntrusted)) : new Socket(Socket::TYPE_TCP));
+ unique_ptr<Socket> s(secure ? (natRole == NAT_SERVER ? CryptoManager::getInstance()->getServerSocket(allowUntrusted) : CryptoManager::getInstance()->getClientSocket(allowUntrusted)) : new Socket(Socket::TYPE_TCP));
s->setLocalIp4(SETTING(BIND_ADDRESS));
s->setLocalIp6(SETTING(BIND_ADDRESS6));
=== modified file 'dcpp/BufferedSocket.h'
--- dcpp/BufferedSocket.h 2011-08-11 13:02:19 +0000
+++ dcpp/BufferedSocket.h 2011-09-24 21:13:31 +0000
@@ -57,8 +57,8 @@
* @param sep Line separator
* @return An unconnected socket
*/
- static BufferedSocket* getSocket(char sep) {
- return new BufferedSocket(sep);
+ static BufferedSocket* getSocket(char sep, bool v4only = false) {
+ return new BufferedSocket(sep, v4only);
}
static void putSocket(BufferedSocket* aSock) {
@@ -141,7 +141,7 @@
InputStream* stream;
};
- BufferedSocket(char aSeparator);
+ BufferedSocket(char aSeparator, bool v4only);
virtual ~BufferedSocket();
@@ -162,6 +162,7 @@
std::unique_ptr<Socket> sock;
State state;
bool disconnecting;
+ bool v4only;
virtual int run();
@@ -177,7 +178,7 @@
bool checkEvents();
void checkSocket();
- void setSocket(std::unique_ptr<Socket> s);
+ void setSocket(std::unique_ptr<Socket>&& s);
void setOptions();
void shutdown();
void addTask(Tasks task, TaskData* data);
=== modified file 'dcpp/Client.cpp'
--- dcpp/Client.cpp 2011-08-11 13:02:19 +0000
+++ dcpp/Client.cpp 2011-09-24 21:13:31 +0000
@@ -32,7 +32,7 @@
Client::Client(const string& hubURL, char separator_, bool secure_) :
myIdentity(ClientManager::getInstance()->getMe(), 0),
reconnDelay(120), lastActivity(GET_TICK()), registered(false), autoReconnect(false),
- encoding(Text::systemCharset), state(STATE_DISCONNECTED), sock(0),
+ encoding(Text::systemCharset), state(STATE_DISCONNECTED), sock(NULL, &BufferedSocket::putSocket),
hubUrl(hubURL),separator(separator_),
secure(secure_), countType(COUNT_UNCOUNTED)
{
@@ -66,10 +66,7 @@
}
void Client::shutdown() {
- if(sock) {
- BufferedSocket::putSocket(sock);
- sock = 0;
- }
+ sock.reset();
}
void Client::reloadSettings(bool updateNick) {
@@ -96,7 +93,7 @@
void Client::connect() {
if(sock)
- BufferedSocket::putSocket(sock);
+ sock.reset();
setAutoReconnect(true);
setReconnDelay(120 + Util::rand(0, 60));
@@ -108,7 +105,7 @@
state = STATE_CONNECTING;
try {
- sock = BufferedSocket::getSocket(separator);
+ sock.reset(BufferedSocket::getSocket(separator, v4only()));
sock->addListener(this);
sock->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
} catch(const Exception& e) {
=== modified file 'dcpp/Client.h'
--- dcpp/Client.h 2011-08-11 13:02:19 +0000
+++ dcpp/Client.h 2011-09-24 21:13:31 +0000
@@ -136,7 +136,7 @@
STATE_DISCONNECTED, ///< Nothing in particular
} state;
- BufferedSocket* sock;
+ std::unique_ptr<BufferedSocket, void(*)(BufferedSocket*)> sock;
void updateCounts(bool aRemove);
void updateActivity() { lastActivity = GET_TICK(); }
@@ -154,6 +154,7 @@
virtual void on(Line, const string& aLine) noexcept;
virtual void on(Failed, const string&) noexcept;
+ virtual bool v4only() const = 0;
private:
Client(const Client&);
=== modified file 'dcpp/NmdcHub.h'
--- dcpp/NmdcHub.h 2011-04-13 19:16:51 +0000
+++ dcpp/NmdcHub.h 2011-09-24 21:13:31 +0000
@@ -120,6 +120,7 @@
void updateFromTag(Identity& id, const string& tag);
virtual string checkNick(const string& aNick);
+ virtual bool v4only() const { return true; }
// TimerManagerListener
virtual void on(Second, uint64_t aTick) noexcept;
=== modified file 'dcpp/Pointer.h'
--- dcpp/Pointer.h 2011-03-29 20:40:28 +0000
+++ dcpp/Pointer.h 2011-09-24 21:13:31 +0000
@@ -22,10 +22,15 @@
#include <boost/intrusive_ptr.hpp>
#include <boost/smart_ptr/detail/atomic_count.hpp>
+#include <memory>
+
#include "noexcept.h"
namespace dcpp {
+using std::unique_ptr;
+using std::forward;
+
template<typename T>
class intrusive_ptr_base
{
@@ -44,12 +49,36 @@
boost::detail::atomic_count ref;
};
-
struct DeleteFunction {
template<typename T>
void operator()(const T& p) const { delete p; }
};
+template<typename T>
+inline unique_ptr<T> make_unique()
+{
+ return unique_ptr<T>(new T);
+}
+
+template<typename T, typename A0>
+inline unique_ptr<T> make_unique(A0&& a0)
+{
+ return unique_ptr<T>(new T(forward<A0>(a0)));
+}
+
+template<typename T, typename A0, typename A1>
+inline unique_ptr<T> make_unique(A0 && a0, A1 && a1)
+{
+ return unique_ptr<T>(new T(forward<A0>(a0), forward<A1>(a1)));
+}
+
+template<typename T, typename A0, typename A1, typename A2>
+inline unique_ptr<T> make_unique(A0 && a0, A1 && a1, A2 && a2)
+{
+ return unique_ptr<T>(new T(forward<A0>(a0), forward<A1>(a1), forward<A2>(a2)));
+}
+
+
} // namespace dcpp
#endif // !defined(POINTER_H)
=== modified file 'dcpp/Socket.cpp'
--- dcpp/Socket.cpp 2011-09-21 17:51:13 +0000
+++ dcpp/Socket.cpp 2011-09-24 21:13:31 +0000
@@ -298,7 +298,7 @@
}
}
- if(!sock6.valid() && a->ai_family == AF_INET6) {
+ if(!sock6.valid() && a->ai_family == AF_INET6 && !v4only) {
create(*a);
if(ret != 0) {
((sockaddr_in6*)a->ai_addr)->sin6_port = ret;
@@ -328,7 +328,7 @@
for(auto ai = addr.get(); ai; ai = ai->ai_next) {
if((ai->ai_family == AF_INET && !sock4.valid()) ||
- (ai->ai_family == AF_INET6 && !sock6.valid()))
+ (ai->ai_family == AF_INET6 && !sock6.valid() && !v4only))
{
auto sock = create(*ai);
auto &localIp = ai->ai_family == AF_INET ? getLocalIp4() : getLocalIp6();
=== modified file 'dcpp/Socket.h'
--- dcpp/Socket.h 2011-09-04 15:20:46 +0000
+++ dcpp/Socket.h 2011-09-24 21:13:31 +0000
@@ -88,7 +88,7 @@
TYPE_UDP = IPPROTO_UDP
};
- explicit Socket(SocketType type) : type(type) { }
+ explicit Socket(SocketType type, bool v4only = false) : type(type), v4only(true) { }
virtual ~Socket() { }
@@ -197,6 +197,8 @@
SocketType type;
+ bool v4only;
+
class Stats {
public:
uint64_t totalDown;
=== modified file 'dcpp/ThrottleManager.h'
--- dcpp/ThrottleManager.h 2011-04-18 18:41:36 +0000
+++ dcpp/ThrottleManager.h 2011-09-24 21:13:31 +0000
@@ -55,7 +55,7 @@
static void setSetting(SettingsManager::IntSetting setting, int value);
- static const unsigned MAX_LIMIT = 1024 * 1024; // 1 GiB/s
+ static const int MAX_LIMIT = 1024 * 1024; // 1 GiB/s
private:
// stack up throttled read & write threads
=== modified file 'win32/HubListsDlg.cpp'
--- win32/HubListsDlg.cpp 2011-01-02 17:12:02 +0000
+++ win32/HubListsDlg.cpp 2011-09-24 21:13:31 +0000
@@ -63,6 +63,8 @@
case HELP_EDIT: return IDH_PUBLIC_HUB_LISTS_EDIT;
case HELP_REMOVE: return IDH_PUBLIC_HUB_LISTS_REMOVE;
}
+
+ return 0;
}
void HubListsDlg::add(const tstring& s) {
=== modified file 'win32/StringListDlg.cpp'
--- win32/StringListDlg.cpp 2011-05-04 19:32:00 +0000
+++ win32/StringListDlg.cpp 2011-09-24 21:13:31 +0000
@@ -94,6 +94,7 @@
case HELP_EDIT: return IDH_STRING_LIST_EDIT;
case HELP_REMOVE: return IDH_STRING_LIST_REMOVE;
}
+ return 0;
}
void StringListDlg::add(const tstring& s) {
=== modified file 'win32/UploadPage.cpp'
--- win32/UploadPage.cpp 2011-05-04 19:32:00 +0000
+++ win32/UploadPage.cpp 2011-09-24 21:13:31 +0000
@@ -96,7 +96,7 @@
// dummy grid so that the check-box doesn't fill the whole row.
CheckBoxPtr shareHidden = cur->addChild(Grid::Seed(1, 1))->addChild(CheckBox::Seed(T_("Share hidden files")));
items.push_back(Item(shareHidden, SettingsManager::SHARE_HIDDEN, PropPage::T_BOOL));
- auto last = items.back();
+
shareHidden->onClicked([=] { handleShareHiddenClicked(shareHidden, SettingsManager::SHARE_HIDDEN); });
shareHidden->setHelpId(IDH_SETTINGS_UPLOAD_SHAREHIDDEN);
}