From: <arn...@us...> - 2006-09-18 21:43:01
|
Revision: 650 http://svn.sourceforge.net/dcplusplus/?rev=650&view=rev Author: arnetheduck Date: 2006-09-18 14:40:58 -0700 (Mon, 18 Sep 2006) Log Message: ----------- Connection fixes, other small stuff Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ClientManager.h dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/ConnectionManager.h dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/FavoriteManager.cpp dcplusplus/trunk/client/FavoriteManager.h dcplusplus/trunk/client/QueueItem.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/SSLSocket.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h dcplusplus/trunk/client/Socket.cpp dcplusplus/trunk/client/Socket.h dcplusplus/trunk/client/Speaker.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/User.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/windows/MainFrm.cpp dcplusplus/trunk/yassl/README dcplusplus/trunk/yassl/include/buffer.hpp dcplusplus/trunk/yassl/include/cert_wrapper.hpp dcplusplus/trunk/yassl/include/crypto_wrapper.hpp dcplusplus/trunk/yassl/include/factory.hpp dcplusplus/trunk/yassl/include/handshake.hpp dcplusplus/trunk/yassl/include/lock.hpp dcplusplus/trunk/yassl/include/log.hpp dcplusplus/trunk/yassl/include/openssl/ssl.h dcplusplus/trunk/yassl/include/socket_wrapper.hpp dcplusplus/trunk/yassl/include/timer.hpp dcplusplus/trunk/yassl/include/yassl_error.hpp dcplusplus/trunk/yassl/include/yassl_imp.hpp dcplusplus/trunk/yassl/include/yassl_int.hpp dcplusplus/trunk/yassl/include/yassl_types.hpp dcplusplus/trunk/yassl/mySTL/algorithm.hpp dcplusplus/trunk/yassl/mySTL/helpers.hpp dcplusplus/trunk/yassl/mySTL/list.hpp dcplusplus/trunk/yassl/mySTL/memory.hpp dcplusplus/trunk/yassl/mySTL/pair.hpp dcplusplus/trunk/yassl/mySTL/stdexcept.hpp dcplusplus/trunk/yassl/mySTL/vector.hpp dcplusplus/trunk/yassl/src/buffer.cpp dcplusplus/trunk/yassl/src/cert_wrapper.cpp dcplusplus/trunk/yassl/src/crypto_wrapper.cpp dcplusplus/trunk/yassl/src/handshake.cpp dcplusplus/trunk/yassl/src/lock.cpp dcplusplus/trunk/yassl/src/log.cpp dcplusplus/trunk/yassl/src/socket_wrapper.cpp dcplusplus/trunk/yassl/src/ssl.cpp dcplusplus/trunk/yassl/src/template_instnt.cpp dcplusplus/trunk/yassl/src/timer.cpp dcplusplus/trunk/yassl/src/yassl.cpp dcplusplus/trunk/yassl/src/yassl_error.cpp dcplusplus/trunk/yassl/src/yassl_imp.cpp dcplusplus/trunk/yassl/src/yassl_int.cpp dcplusplus/trunk/yassl/taocrypt/include/aes.hpp dcplusplus/trunk/yassl/taocrypt/include/algebra.hpp dcplusplus/trunk/yassl/taocrypt/include/arc4.hpp dcplusplus/trunk/yassl/taocrypt/include/asn.hpp dcplusplus/trunk/yassl/taocrypt/include/block.hpp dcplusplus/trunk/yassl/taocrypt/include/blowfish.hpp dcplusplus/trunk/yassl/taocrypt/include/coding.hpp dcplusplus/trunk/yassl/taocrypt/include/des.hpp dcplusplus/trunk/yassl/taocrypt/include/dh.hpp dcplusplus/trunk/yassl/taocrypt/include/dsa.hpp dcplusplus/trunk/yassl/taocrypt/include/error.hpp dcplusplus/trunk/yassl/taocrypt/include/file.hpp dcplusplus/trunk/yassl/taocrypt/include/hash.hpp dcplusplus/trunk/yassl/taocrypt/include/hmac.hpp dcplusplus/trunk/yassl/taocrypt/include/integer.hpp dcplusplus/trunk/yassl/taocrypt/include/kernelc.hpp dcplusplus/trunk/yassl/taocrypt/include/md2.hpp dcplusplus/trunk/yassl/taocrypt/include/md4.hpp dcplusplus/trunk/yassl/taocrypt/include/md5.hpp dcplusplus/trunk/yassl/taocrypt/include/misc.hpp dcplusplus/trunk/yassl/taocrypt/include/modarith.hpp dcplusplus/trunk/yassl/taocrypt/include/modes.hpp dcplusplus/trunk/yassl/taocrypt/include/pwdbased.hpp dcplusplus/trunk/yassl/taocrypt/include/random.hpp dcplusplus/trunk/yassl/taocrypt/include/ripemd.hpp dcplusplus/trunk/yassl/taocrypt/include/rsa.hpp dcplusplus/trunk/yassl/taocrypt/include/runtime.hpp dcplusplus/trunk/yassl/taocrypt/include/sha.hpp dcplusplus/trunk/yassl/taocrypt/include/twofish.hpp dcplusplus/trunk/yassl/taocrypt/include/type_traits.hpp dcplusplus/trunk/yassl/taocrypt/include/types.hpp dcplusplus/trunk/yassl/taocrypt/src/aes.cpp dcplusplus/trunk/yassl/taocrypt/src/aestables.cpp dcplusplus/trunk/yassl/taocrypt/src/algebra.cpp dcplusplus/trunk/yassl/taocrypt/src/arc4.cpp dcplusplus/trunk/yassl/taocrypt/src/asn.cpp dcplusplus/trunk/yassl/taocrypt/src/bftables.cpp dcplusplus/trunk/yassl/taocrypt/src/blowfish.cpp dcplusplus/trunk/yassl/taocrypt/src/coding.cpp dcplusplus/trunk/yassl/taocrypt/src/des.cpp dcplusplus/trunk/yassl/taocrypt/src/dh.cpp dcplusplus/trunk/yassl/taocrypt/src/dsa.cpp dcplusplus/trunk/yassl/taocrypt/src/file.cpp dcplusplus/trunk/yassl/taocrypt/src/hash.cpp dcplusplus/trunk/yassl/taocrypt/src/integer.cpp dcplusplus/trunk/yassl/taocrypt/src/md2.cpp dcplusplus/trunk/yassl/taocrypt/src/md4.cpp dcplusplus/trunk/yassl/taocrypt/src/md5.cpp dcplusplus/trunk/yassl/taocrypt/src/misc.cpp dcplusplus/trunk/yassl/taocrypt/src/random.cpp dcplusplus/trunk/yassl/taocrypt/src/ripemd.cpp dcplusplus/trunk/yassl/taocrypt/src/rsa.cpp dcplusplus/trunk/yassl/taocrypt/src/sha.cpp dcplusplus/trunk/yassl/taocrypt/src/template_instnt.cpp dcplusplus/trunk/yassl/taocrypt/src/tftables.cpp dcplusplus/trunk/yassl/taocrypt/src/twofish.cpp Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/Example.xml 2006-09-18 21:40:58 UTC (rev 650) @@ -563,7 +563,7 @@ <String Name="SystemLog">System Log</String> <String Name="Tag">Tag</String> <String Name="TargetFilenameTooLong">Target filename too long</String> - <String Name="TcpPortBusy">Unable to open TCP port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP port</String> + <String Name="TcpPortBusy">Unable to open TCP/TLS port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP/TLS port</String> <String Name="Tib">TiB</String> <String Name="Time">Time</String> <String Name="TimeLeft">Time left</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/changelog.txt 2006-09-18 21:40:58 UTC (rev 650) @@ -4,7 +4,11 @@ * Removed the possibility to download files without TTH * Removed the possibility to read *.DcLst files (no TTH, no i18n support) * Files with no TTH no longer show up in search and directory listings -* Fixed support for uncompressed files.xml +* Sources in the queue with no TTH support will no longer appear +* Files without TTH in the queue will be removed (finish downloads with an older version) +* [ADC] Fixed support for uncompressed files.xml as well as proper files.xml.bz2 support +* Some socket code cleanup +* Removed broken nick save code -- 0.695 2006-09-10 -- * PM popup/ignore options updated, in nmdc a hub is any nick which hasn't sent a hello or myinfo, and a bot is a nick with myinfo Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -431,6 +431,10 @@ } } +void ClientManager::on(Load, SimpleXML&) throw() { + users.insert(make_pair(getMe()->getCID(), getMe())); +} + void ClientManager::on(TimerManagerListener::Minute, u_int32_t /* aTick */) throw() { Lock l(cs); @@ -449,43 +453,6 @@ } } -void ClientManager::save() { - Lock l(cs); - - try { - string tmp; - - File ff(getUsersFile() + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE); - BufferedOutputStream<false> f(&ff); - - f.write(SimpleXML::utf8Header); - f.write(LIT("<Users Version=\"1\">\r\n")); - for(UserIter i = users.begin(); i != users.end(); ++i) { - User::Ptr& p = i->second; - if(p->isSet(User::SAVE_NICK) && !p->getCID().isZero() && !p->getFirstNick().empty()) { - f.write(LIT("\t<User CID=\"")); - f.write(p->getCID().toBase32()); - f.write(LIT("\" Nick=\"")); - f.write(SimpleXML::escape(p->getFirstNick(), tmp, true)); - f.write(LIT("\"/>\r\n")); - } - } - - f.write("</Users>\r\n"); - f.flush(); - ff.close(); - File::deleteFile(getUsersFile()); - File::renameFile(getUsersFile() + ".tmp", getUsersFile()); - - } catch(const FileException&) { - // ... - } -} - -void ClientManager::on(Save, SimpleXML*) throw() { - save(); -} - User::Ptr& ClientManager::getMe() { if(!me) { Lock l(cs); @@ -509,29 +476,6 @@ return CID(tiger.finalize()); } -void ClientManager::on(Load, SimpleXML*) throw() { - users.insert(make_pair(getMe()->getCID(), getMe())); - - try { - SimpleXML xml; - xml.fromXML(File(getUsersFile(), File::READ, File::OPEN).read()); - if(xml.findChild("Users") && xml.getChildAttrib("Version") == "1") { - xml.stepIn(); - while(xml.findChild("User")) { - const string& cid = xml.getChildAttrib("CID"); - const string& nick = xml.getChildAttrib("Nick"); - if(cid.length() != 39 || nick.empty()) - continue; - User::Ptr p(new User(CID(cid))); - p->setFirstNick(xml.getChildData()); - users.insert(make_pair(p->getCID(), p)); - } - } - } catch(const Exception& e) { - dcdebug("Error loading Users.xml: %s\n", e.getError().c_str()); - } -} - void ClientManager::on(Failed, Client* client, const string&) throw() { FavoriteManager::getInstance()->removeUserCommand(client->getHubUrl()); fire(ClientManagerListener::ClientDisconnected(), client); Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ClientManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -96,7 +96,6 @@ CID getMyCID(); const CID& getMyPID(); - void save(); private: typedef HASH_MAP<string, User::Ptr> LegacyMap; typedef LegacyMap::iterator LegacyIter; @@ -133,13 +132,10 @@ TimerManager::getInstance()->removeListener(this); } - string getUsersFile() { return Util::getConfigPath() + "Users.xml"; } - void updateCachedIp(); // SettingsManagerListener - virtual void on(Load, SimpleXML*) throw(); - virtual void on(Save, SimpleXML*) throw(); + virtual void on(Load, SimpleXML&); // ClientListener virtual void on(Connected, Client* c) throw() { fire(ClientManagerListener::ClientConnected(), c); } Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -31,7 +31,7 @@ #include "UserConnection.h" -ConnectionManager::ConnectionManager() : port(0), securePort(0), floodCounter(0), server(0), secureServer(0), shuttingDown(false) { +ConnectionManager::ConnectionManager() : floodCounter(0), server(0), secureServer(0), shuttingDown(false) { TimerManager::getInstance()->addListener(this); features.push_back(UserConnection::FEATURE_MINISLOTS); @@ -44,50 +44,19 @@ adcFeatures.push_back("AD" + UserConnection::FEATURE_ADC_BZIP); } -// @todo clean this up -void ConnectionManager::listen() throw(Exception){ - unsigned short lastPort = (unsigned short)SETTING(TCP_PORT); - - if(lastPort == 0) - lastPort = (unsigned short)Util::rand(1025, 32000); - - unsigned short firstPort = lastPort; - +void ConnectionManager::listen() throw(SocketException){ disconnect(); + unsigned short port = static_cast<unsigned short>(SETTING(TCP_PORT)); - while(true) { - try { - server = new Server(false, lastPort, SETTING(BIND_ADDRESS)); - port = lastPort; - break; - } catch(const Exception&) { - short newPort = (short)((lastPort == 32000) ? 1025 : lastPort + 1); - if(!SettingsManager::getInstance()->isDefault(SettingsManager::TCP_PORT) || (firstPort == newPort)) { - throw Exception("Could not find a suitable free port"); - } - lastPort = newPort; - } - } + server = new Server(false, port, SETTING(BIND_ADDRESS)); if(!CryptoManager::getInstance()->TLSOk()) { return; } - lastPort = (unsigned short)SETTING(TLS_PORT); - firstPort = lastPort; - while(true) { - try { - secureServer = new Server(true, lastPort, SETTING(BIND_ADDRESS)); - securePort = lastPort; - break; - } catch(const Exception&) { - short newPort = (short)((lastPort == 32000) ? 1025 : lastPort + 1); - if(!SettingsManager::getInstance()->isDefault(SettingsManager::TCP_PORT) || (firstPort == newPort)) { - throw Exception("Could not find a suitable free port"); - } - lastPort = newPort; - } - } + port = static_cast<unsigned short>(SETTING(TLS_PORT)); + + secureServer = new Server(true, port, SETTING(BIND_ADDRESS)); } /** @@ -252,9 +221,9 @@ static const u_int32_t FLOOD_TRIGGER = 20000; static const u_int32_t FLOOD_ADD = 2000; -ConnectionManager::Server::Server(bool secure_, short port, const string& ip /* = "0.0.0.0" */) : secure(secure_), die(false) { +ConnectionManager::Server::Server(bool secure_, short aPort, const string& ip /* = "0.0.0.0" */) : port(0), secure(secure_), die(false) { sock.create(); - sock.bind(port, ip); + port = sock.bind(aPort, ip); sock.listen(); start(); @@ -345,6 +314,14 @@ } } +void ConnectionManager::disconnect() throw() { + delete server; + delete secureServer; + + server = secureServer = 0; +} + + void ConnectionManager::on(AdcCommand::SUP, UserConnection* aSource, const AdcCommand& cmd) throw() { if(aSource->getState() != UserConnection::STATE_SUPNICK) { // Already got this once, ignore...@todo fix support updates @@ -359,6 +336,11 @@ string feat = i->substr(2); if(feat == UserConnection::FEATURE_ADC_BASE) { baseOk = true; + // ADC clients must support all these... + aSource->setFlag(UserConnection::FLAG_SUPPORTS_ADCGET); + aSource->setFlag(UserConnection::FLAG_SUPPORTS_MINISLOTS); + aSource->setFlag(UserConnection::FLAG_SUPPORTS_TTHF); + aSource->setFlag(UserConnection::FLAG_SUPPORTS_TTHL); // For compatibility with older clients... aSource->setFlag(UserConnection::FLAG_SUPPORTS_XML_BZLIST); } else if(feat == UserConnection::FEATURE_ZLIB_GET) { Modified: dcplusplus/trunk/client/ConnectionManager.h =================================================================== --- dcplusplus/trunk/client/ConnectionManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ConnectionManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -33,6 +33,8 @@ #include "ConnectionManagerListener.h" +class SocketException; + class ConnectionQueueItem { public: typedef ConnectionQueueItem* Ptr; @@ -110,27 +112,23 @@ void shutdown(); /** Find a suitable port to listen on, and start doing it */ - void listen() throw(Exception); - void disconnect() throw() { - delete server; - delete secureServer; + void listen() throw(SocketException); + void disconnect() throw(); - server = secureServer = 0; - port = securePort = 0; - } - - unsigned short getPort() { return port; } - unsigned short getSecurePort() { return securePort; } + unsigned short getPort() { return static_cast<unsigned short>(server->getPort()); } + unsigned short getSecurePort() { return static_cast<unsigned short>(secureServer->getPort()); } private: class Server : public Thread { public: Server(bool secure_, short port, const string& ip = "0.0.0.0"); + short getPort() { return port; } virtual ~Server() { die = true; join(); } private: virtual int run() throw(); Socket sock; + short port; bool secure; bool die; }; @@ -138,8 +136,6 @@ friend class Server; CriticalSection cs; - unsigned short port; - unsigned short securePort; /** All ConnectionQueueItems */ ConnectionQueueItem::List downloads; Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -49,7 +49,7 @@ const string DownloadManager::USER_LIST_NAME_BZ = "files.xml.bz2"; Download::Download() throw() : file(NULL), -crcCalc(NULL), tth(NULL), treeValid(false) { +crcCalc(NULL), treeValid(false) { } Download::Download(QueueItem* qi) throw() : @@ -63,7 +63,7 @@ setFlag(Download::FLAG_RESUME); } -AdcCommand Download::getCommand(bool zlib, bool tthf) { +AdcCommand Download::getCommand(bool zlib) { AdcCommand cmd(AdcCommand::CMD_GET); if(isSet(FLAG_TREE_DOWNLOAD)) { cmd.addParam("tthl"); @@ -72,15 +72,15 @@ } else { cmd.addParam("file"); } - if(tthf) { + if(isSet(FLAG_PARTIAL_LIST) || isSet(FLAG_USER_LIST)) { + cmd.addParam(Util::toAdcFile(getSource())); + } else { cmd.addParam("TTH/" + getTTH().toBase32()); - } else { - cmd.addParam(Util::toAdcFile(getSource())); } cmd.addParam(Util::toString(getPos())); cmd.addParam(Util::toString(getSize() - getPos())); - if(zlib && getSize() != -1 && BOOLSETTING(COMPRESS_TRANSFERS)) { + if(zlib && BOOLSETTING(COMPRESS_TRANSFERS)) { cmd.addParam("ZL1"); } @@ -91,7 +91,7 @@ TimerManager::getInstance()->addListener(this); } -~DownloadManager::DownloadManager() throw() { +DownloadManager::~DownloadManager() throw() { TimerManager::getInstance()->removeListener(this); while(true) { { @@ -246,7 +246,7 @@ } void DownloadManager::addConnection(UserConnection::Ptr conn) { - if(!conn->isSet(UserConnection::FLAG_SUPPORTS_TTHF)) { + if(!conn->isSet(UserConnection::FLAG_SUPPORTS_TTHF) || !conn->isSet(UserConnection::FLAG_SUPPORTS_ADCGET)) { // Can't download from these... QueueManager::getInstance()->removeSource(conn->getUser(), QueueItem::Source::FLAG_NO_TTHF); removeConnection(conn); @@ -333,7 +333,7 @@ downloads.push_back(d); } - aConn->send(d->getCommand(aConn->isSet(UserConnection::FLAG_SUPPORTS_ZLIB_GET), !d->isSet(Download::FLAG_USER_LIST))); + aConn->send(d->getCommand(aConn->isSet(UserConnection::FLAG_SUPPORTS_ZLIB_GET))); } class DummyOutputStream : public OutputStream { @@ -498,10 +498,10 @@ string target = d->getDownloadTarget(); File::ensureDirectory(target); if(d->isSet(Download::FLAG_USER_LIST)) { - if(!aSource->isSet(UserConnection::FLAG_NMDC) || aSource->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST)) { + if(aSource->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST)) { target += ".xml.bz2"; } else { - target += ".DcLst"; + target += ".xml"; } } Modified: dcplusplus/trunk/client/DownloadManager.h =================================================================== --- dcplusplus/trunk/client/DownloadManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/DownloadManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -90,7 +90,7 @@ TigerTree& getTigerTree() { return tt; } string& getPFS() { return pfs; } /** @internal */ - AdcCommand getCommand(bool zlib, bool tthf); + AdcCommand getCommand(bool zlib); typedef CalcOutputStream<CRC32Filter, true> CrcOS; GETSET(string, source, Source); Modified: dcplusplus/trunk/client/FavoriteManager.cpp =================================================================== --- dcplusplus/trunk/client/FavoriteManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/FavoriteManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -125,7 +125,6 @@ void FavoriteManager::addFavoriteUser(User::Ptr& aUser) { Lock l(cs); if(users.find(aUser->getCID()) == users.end()) { - aUser->setFlag(User::SAVE_NICK); StringList urls = ClientManager::getInstance()->getHubs(aUser->getCID()); StringList nicks = ClientManager::getInstance()->getNicks(aUser->getCID()); @@ -345,7 +344,6 @@ xml.addTag("Users"); xml.stepIn(); for(FavoriteMap::iterator j = users.begin(); j != users.end(); ++j) { - j->second.getUser()->setFlag(User::SAVE_NICK); xml.addTag("User"); xml.addChildAttrib("LastSeen", j->second.getLastSeen()); xml.addChildAttrib("GrantSlot", j->second.isSet(FavoriteUser::FLAG_GRANTSLOT)); @@ -418,7 +416,7 @@ if(xml.findChild("Favorites")) { xml.stepIn(); - load(&xml); + load(xml); xml.stepOut(); } } catch(const Exception& e) { @@ -426,37 +424,37 @@ } } -void FavoriteManager::load(SimpleXML* aXml) { +void FavoriteManager::load(SimpleXML& aXml) { dontSave = true; - aXml->resetCurrentChild(); - if(aXml->findChild("Hubs")) { - aXml->stepIn(); - while(aXml->findChild("Hub")) { + aXml.resetCurrentChild(); + if(aXml.findChild("Hubs")) { + aXml.stepIn(); + while(aXml.findChild("Hub")) { FavoriteHubEntry* e = new FavoriteHubEntry(); - e->setName(aXml->getChildAttrib("Name")); - e->setConnect(aXml->getBoolChildAttrib("Connect")); - e->setDescription(aXml->getChildAttrib("Description")); - e->setNick(aXml->getChildAttrib("Nick")); - e->setPassword(aXml->getChildAttrib("Password")); - e->setServer(aXml->getChildAttrib("Server")); - e->setUserDescription(aXml->getChildAttrib("UserDescription")); - e->setBottom((u_int16_t)aXml->getIntChildAttrib("Bottom") ); - e->setTop((u_int16_t)aXml->getIntChildAttrib("Top")); - e->setRight((u_int16_t)aXml->getIntChildAttrib("Right")); - e->setLeft((u_int16_t)aXml->getIntChildAttrib("Left")); + e->setName(aXml.getChildAttrib("Name")); + e->setConnect(aXml.getBoolChildAttrib("Connect")); + e->setDescription(aXml.getChildAttrib("Description")); + e->setNick(aXml.getChildAttrib("Nick")); + e->setPassword(aXml.getChildAttrib("Password")); + e->setServer(aXml.getChildAttrib("Server")); + e->setUserDescription(aXml.getChildAttrib("UserDescription")); + e->setBottom((u_int16_t)aXml.getIntChildAttrib("Bottom") ); + e->setTop((u_int16_t)aXml.getIntChildAttrib("Top")); + e->setRight((u_int16_t)aXml.getIntChildAttrib("Right")); + e->setLeft((u_int16_t)aXml.getIntChildAttrib("Left")); favoriteHubs.push_back(e); } - aXml->stepOut(); + aXml.stepOut(); } - aXml->resetCurrentChild(); - if(aXml->findChild("Users")) { - aXml->stepIn(); - while(aXml->findChild("User")) { + aXml.resetCurrentChild(); + if(aXml.findChild("Users")) { + aXml.stepIn(); + while(aXml.findChild("User")) { User::Ptr u; - const string& cid = aXml->getChildAttrib("CID"); - const string& nick = aXml->getChildAttrib("Nick"); - const string& hubUrl = aXml->getChildAttrib("URL"); + const string& cid = aXml.getChildAttrib("CID"); + const string& nick = aXml.getChildAttrib("Nick"); + const string& hubUrl = aXml.getChildAttrib("URL"); if(cid.length() != 39) { if(nick.empty() || hubUrl.empty()) @@ -469,35 +467,34 @@ } FavoriteMap::iterator i = users.insert(make_pair(u->getCID(), FavoriteUser(u, nick, hubUrl))).first; - if(aXml->getBoolChildAttrib("GrantSlot")) + if(aXml.getBoolChildAttrib("GrantSlot")) i->second.setFlag(FavoriteUser::FLAG_GRANTSLOT); - i->second.setLastSeen((u_int32_t)aXml->getIntChildAttrib("LastSeen")); - i->second.setDescription(aXml->getChildAttrib("UserDescription")); + i->second.setLastSeen((u_int32_t)aXml.getIntChildAttrib("LastSeen")); + i->second.setDescription(aXml.getChildAttrib("UserDescription")); - i->second.getUser()->setFlag(User::SAVE_NICK); } - aXml->stepOut(); + aXml.stepOut(); } - aXml->resetCurrentChild(); - if(aXml->findChild("UserCommands")) { - aXml->stepIn(); - while(aXml->findChild("UserCommand")) { - addUserCommand(aXml->getIntChildAttrib("Type"), aXml->getIntChildAttrib("Context"), - 0, aXml->getChildAttrib("Name"), aXml->getChildAttrib("Command"), aXml->getChildAttrib("Hub")); + aXml.resetCurrentChild(); + if(aXml.findChild("UserCommands")) { + aXml.stepIn(); + while(aXml.findChild("UserCommand")) { + addUserCommand(aXml.getIntChildAttrib("Type"), aXml.getIntChildAttrib("Context"), + 0, aXml.getChildAttrib("Name"), aXml.getChildAttrib("Command"), aXml.getChildAttrib("Hub")); } - aXml->stepOut(); + aXml.stepOut(); } //Favorite download to dirs - aXml->resetCurrentChild(); - if(aXml->findChild("FavoriteDirs")) { - aXml->stepIn(); - while(aXml->findChild("Directory")) { - string virt = aXml->getChildAttrib("Name"); - string d(aXml->getChildData()); + aXml.resetCurrentChild(); + if(aXml.findChild("FavoriteDirs")) { + aXml.stepIn(); + while(aXml.findChild("Directory")) { + string virt = aXml.getChildAttrib("Name"); + string d(aXml.getChildData()); FavoriteManager::getInstance()->addFavoriteDir(d, virt); } - aXml->stepOut(); + aXml.stepOut(); } dontSave = false; Modified: dcplusplus/trunk/client/FavoriteManager.h =================================================================== --- dcplusplus/trunk/client/FavoriteManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/FavoriteManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -269,11 +269,11 @@ void onHttpFinished() throw(); // SettingsManagerListener - virtual void on(SettingsManagerListener::Load, SimpleXML* xml) throw() { + virtual void on(SettingsManagerListener::Load, SimpleXML& xml) throw() { load(xml); } - void load(SimpleXML* aXml); + void load(SimpleXML& aXml); string getConfigFile() { return Util::getConfigPath() + "Favorites.xml"; } }; Modified: dcplusplus/trunk/client/QueueItem.h =================================================================== --- dcplusplus/trunk/client/QueueItem.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/QueueItem.h 2006-09-18 21:40:58 UTC (rev 650) @@ -188,7 +188,7 @@ if(isSet(QueueItem::FLAG_XML_BZLIST)) { return getTarget() + ".xml.bz2"; } else { - return getTarget() + ".DcLst"; + return getTarget() + ".xml"; } } Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -561,7 +561,6 @@ wantConnection = false; } else { userQueue.add(qi, aUser); - aUser->setFlag(User::SAVE_NICK); } fire(QueueManagerListener::SourcesUpdated(), qi); @@ -1143,8 +1142,6 @@ File::deleteFile(getQueueFile()); File::renameFile(getQueueFile() + ".tmp", getQueueFile()); - ClientManager::getInstance()->save(); - dirty = false; } catch(const FileException&) { // ... Modified: dcplusplus/trunk/client/SSLSocket.cpp =================================================================== --- dcplusplus/trunk/client/SSLSocket.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/SSLSocket.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -30,9 +30,9 @@ } void SSLSocket::connect(const string& aIp, short aPort) throw(SocketException) { + Socket::setBlocking(true); Socket::connect(aIp, aPort); - setBlocking(true); if(ssl) SSL_free(ssl); @@ -43,12 +43,12 @@ checkSSL(SSL_set_fd(ssl, sock)); checkSSL(SSL_connect(ssl)); dcdebug("Connected to SSL server using %s\n", SSL_get_cipher(ssl)); + Socket::setBlocking(false); } void SSLSocket::accept(const Socket& listeningSocket) throw(SocketException) { Socket::accept(listeningSocket); - setBlocking(true); if(ssl) SSL_free(ssl); Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -371,7 +371,7 @@ File::ensureDirectory(SETTING(TLS_TRUSTED_CERTIFICATES_PATH)); - fire(SettingsManagerListener::Load(), &xml); + fire(SettingsManagerListener::Load(), xml); xml.stepOut(); @@ -422,7 +422,7 @@ } xml.stepOut(); - fire(SettingsManagerListener::Save(), &xml); + fire(SettingsManagerListener::Save(), xml); try { File out(aFileName + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE); Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/SettingsManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -37,8 +37,8 @@ typedef X<0> Load; typedef X<1> Save; - virtual void on(Load, SimpleXML*) throw() { } - virtual void on(Save, SimpleXML*) throw() { } + virtual void on(Load, SimpleXML&) throw() { } + virtual void on(Save, SimpleXML&) throw() { } }; class SettingsManager : public Singleton<SettingsManager>, public Speaker<SettingsManagerListener> Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -248,14 +248,14 @@ return tmp; } -void ShareManager::load(SimpleXML* aXml) { +void ShareManager::load(SimpleXML& aXml) { WLock<> l(cs); - if(aXml->findChild("Share")) { - aXml->stepIn(); - while(aXml->findChild("Directory")) { - const string& virt = aXml->getChildAttrib("Virtual"); - string d(aXml->getChildData()), newVirt; + if(aXml.findChild("Share")) { + aXml.stepIn(); + while(aXml.findChild("Directory")) { + const string& virt = aXml.getChildAttrib("Virtual"); + string d(aXml.getChildData()), newVirt; if(d[d.length() - 1] != PATH_SEPARATOR) d += PATH_SEPARATOR; @@ -278,7 +278,7 @@ virtualMap.push_back(make_pair(newVirt, d)); } } - aXml->stepOut(); + aXml.stepOut(); } } @@ -362,16 +362,16 @@ return false; } -void ShareManager::save(SimpleXML* aXml) { +void ShareManager::save(SimpleXML& aXml) { RLock<> l(cs); - aXml->addTag("Share"); - aXml->stepIn(); + aXml.addTag("Share"); + aXml.stepIn(); for(StringPairIter i = virtualMap.begin(); i != virtualMap.end(); ++i) { - aXml->addTag("Directory", i->second); - aXml->addChildAttrib("Virtual", i->first); + aXml.addTag("Directory", i->second); + aXml.addChildAttrib("Virtual", i->first); } - aXml->stepOut(); + aXml.stepOut(); } void ShareManager::addDirectory(const string& aDirectory, const string& aName) throw(ShareException) { Modified: dcplusplus/trunk/client/ShareManager.h =================================================================== --- dcplusplus/trunk/client/ShareManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ShareManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -308,17 +308,17 @@ virtual void on(HashManagerListener::TTHDone, const string& fname, const TTHValue& root) throw(); // SettingsManagerListener - virtual void on(SettingsManagerListener::Save, SimpleXML* xml) throw() { + virtual void on(SettingsManagerListener::Save, SimpleXML& xml) throw() { save(xml); } - virtual void on(SettingsManagerListener::Load, SimpleXML* xml) throw() { + virtual void on(SettingsManagerListener::Load, SimpleXML& xml) throw() { load(xml); } // TimerManagerListener virtual void on(TimerManagerListener::Minute, u_int32_t tick) throw(); - void load(SimpleXML* aXml); - void save(SimpleXML* aXml); + void load(SimpleXML& aXml); + void save(SimpleXML& aXml); }; Modified: dcplusplus/trunk/client/Socket.cpp =================================================================== --- dcplusplus/trunk/client/Socket.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/Socket.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -97,7 +97,7 @@ } -void Socket::bind(short aPort, const string& aIp /* = 0.0.0.0 */) throw (SocketException){ +short Socket::bind(short aPort, const string& aIp /* = 0.0.0.0 */) throw (SocketException){ sockaddr_in sock_addr; sock_addr.sin_family = AF_INET; @@ -108,6 +108,9 @@ sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); check(::bind(sock, (sockaddr *)&sock_addr, sizeof(sock_addr))); } + int size = sizeof(sock_addr); + getsockname(sock, (sockaddr*)&sock_addr, &size); + return ntohs(sock_addr.sin_port); } void Socket::listen() throw(SocketException) { Modified: dcplusplus/trunk/client/Socket.h =================================================================== --- dcplusplus/trunk/client/Socket.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/Socket.h 2006-09-18 21:40:58 UTC (rev 650) @@ -169,7 +169,7 @@ virtual void create(int aType = TYPE_TCP) throw(SocketException); /** Binds a socket to a certain local port and possibly IP. */ - virtual void bind(short aPort = 0, const string& aIp = "0.0.0.0") throw(SocketException); + virtual short bind(short aPort = 0, const string& aIp = "0.0.0.0") throw(SocketException); virtual void listen() throw(SocketException); virtual void accept(const Socket& listeningSocket) throw(SocketException); Modified: dcplusplus/trunk/client/Speaker.h =================================================================== --- dcplusplus/trunk/client/Speaker.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/Speaker.h 2006-09-18 21:40:58 UTC (rev 650) @@ -51,6 +51,14 @@ (*i)->on(type, p1); } } + template<typename T0, class T1> + void fire(T0 type, T1& p1) throw() { + Lock l(listenerCS); + tmp = listeners; + for(ListenerIter i=tmp.begin(); i != tmp.end(); ++i ) { + (*i)->on(type, p1); + } + } template<typename T0, class T1, class T2> void fire(T0 type, const T1& p1, const T2& p2) throw() { Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -564,7 +564,7 @@ "System Log", "Tag", "Target filename too long", -"Unable to open TCP port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP port", +"Unable to open TCP/TLS port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP/TLS port", "TiB", "Time", "Time left", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/StringDefs.h 2006-09-18 21:40:58 UTC (rev 650) @@ -567,7 +567,7 @@ SYSTEM_LOG, // "System Log" TAG, // "Tag" TARGET_FILENAME_TOO_LONG, // "Target filename too long" - TCP_PORT_BUSY, // "Unable to open TCP port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP port" + TCP_PORT_BUSY, // "Unable to open TCP/TLS port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP/TLS port" TiB, // "TiB" TIME, // "Time" TIME_LEFT, // "Time left" Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -166,7 +166,7 @@ bool isFavorite = FavoriteManager::getInstance()->hasSlot(aSource->getUser()); if(!(hasReserved || isFavorite || getFreeSlots() > 0 || getAutoSlot())) { - bool supportsFree = aSource->isSet(UserConnection::FLAG_SUPPORTS_MINISLOTS) || !aSource->isSet(UserConnection::FLAG_NMDC); + bool supportsFree = aSource->isSet(UserConnection::FLAG_SUPPORTS_MINISLOTS); bool allowedFree = aSource->isSet(UserConnection::FLAG_HASEXTRASLOT) || aSource->isSet(UserConnection::FLAG_OP) || getFreeExtraSlots() > 0; if(free && supportsFree && allowedFree) { extraSlot = true; Modified: dcplusplus/trunk/client/User.h =================================================================== --- dcplusplus/trunk/client/User.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/User.h 2006-09-18 21:40:58 UTC (rev 650) @@ -40,7 +40,6 @@ NMDC_BIT, BOT_BIT, TTH_GET_BIT, - SAVE_NICK_BIT, TLS_BIT }; @@ -52,7 +51,6 @@ NMDC = 1<<NMDC_BIT, BOT = 1<<BOT_BIT, TTH_GET = 1<<TTH_GET_BIT, //< User supports getting files by tth -> don't have path in queue... - SAVE_NICK = 1<<SAVE_NICK_BIT, //< Save cid->nick association TLS = 1<<TLS_BIT //< Client supports SSL }; Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/Util.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -941,7 +941,7 @@ } string Util::toAdcFile(const string& file) { - if(file == "files.xml.bz2" || file == "MyList.DcLst") + if(file == "files.xml.bz2" || file == "files.xml") return file; string ret; Modified: dcplusplus/trunk/windows/MainFrm.cpp =================================================================== --- dcplusplus/trunk/windows/MainFrm.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/windows/MainFrm.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -1083,7 +1083,6 @@ if(qi->isSet(QueueItem::FLAG_CLIENT_VIEW)) { if(qi->isSet(QueueItem::FLAG_USER_LIST)) { // This is a file listing, show it... - DirectoryListInfo* i = new DirectoryListInfo(qi->getCurrent()->getUser(), Text::toT(qi->getListName()), speed); PostMessage(WM_SPEAKER, DOWNLOAD_LISTING, (LPARAM)i); Modified: dcplusplus/trunk/yassl/README =================================================================== --- dcplusplus/trunk/yassl/README 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/README 2006-09-18 21:40:58 UTC (rev 650) @@ -1,7 +1,18 @@ -yaSSL Release notes, version 1.3.7 (06/26/06) +yaSSL Release notes, version 1.4.0 (08/13/06) This release of yaSSL contains bug fixes, portability enhancements, + nonblocking connect and accept, better OpenSSL error mapping, and + certificate caching for session resumption. + +See normal build instructions below under 1.0.6. +See libcurl build instructions below under 1.3.0. + + +********************yaSSL Release notes, version 1.3.7 (06/26/06) + + + This release of yaSSL contains bug fixes, portability enhancements, and libcurl 7.15.4 support (any newer versions may not build). See normal build instructions below under 1.0.6. Modified: dcplusplus/trunk/yassl/include/buffer.hpp =================================================================== --- dcplusplus/trunk/yassl/include/buffer.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/buffer.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/cert_wrapper.hpp =================================================================== --- dcplusplus/trunk/yassl/include/cert_wrapper.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/cert_wrapper.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -116,6 +120,7 @@ void setVerifyNone(); void setFailNoCert(); void setSendVerify(); + void setPeerX509(X509*); private: CertManager(const CertManager&); // hide copy CertManager& operator=(const CertManager&); // and assign Modified: dcplusplus/trunk/yassl/include/crypto_wrapper.hpp =================================================================== --- dcplusplus/trunk/yassl/include/crypto_wrapper.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/crypto_wrapper.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -36,6 +40,7 @@ #define yaSSL_CRYPTO_WRAPPER_HPP #include "yassl_types.hpp" +#include <stdio.h> // FILE namespace yaSSL { @@ -410,9 +415,10 @@ class x509; -x509* PemToDer(const char*, CertType); +x509* PemToDer(FILE*, CertType); + } // naemspace #endif // yaSSL_CRYPTO_WRAPPER_HPP Modified: dcplusplus/trunk/yassl/include/factory.hpp =================================================================== --- dcplusplus/trunk/yassl/include/factory.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/factory.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/handshake.hpp =================================================================== --- dcplusplus/trunk/yassl/include/handshake.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/handshake.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/lock.hpp =================================================================== --- dcplusplus/trunk/yassl/include/lock.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/lock.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/log.hpp =================================================================== --- dcplusplus/trunk/yassl/include/log.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/log.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/openssl/ssl.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/ssl.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/openssl/ssl.h 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -36,6 +40,10 @@ #include "opensslv.h" /* for version number */ #include "rsa.h" + +#define YASSL_VERSION "1.4.0" + + #if defined(__cplusplus) extern "C" { #endif @@ -497,7 +505,9 @@ #define V_ASN1_UTF8STRING 12 #define GEN_DNS 2 +#define CERTFICATE_ERROR 0x14090086 /* SSLv3 error */ + typedef struct MD4_CTX { int buffer[32]; /* big enough to hold, check size in Init */ } MD4_CTX; Modified: dcplusplus/trunk/yassl/include/socket_wrapper.hpp =================================================================== --- dcplusplus/trunk/yassl/include/socket_wrapper.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/socket_wrapper.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -67,6 +71,7 @@ class Socket { socket_t socket_; // underlying socket descriptor bool wouldBlock_; // for non-blocking data + bool blocking_; // is option set public: explicit Socket(socket_t s = INVALID_SOCKET); ~Socket(); @@ -80,6 +85,7 @@ bool wait(); bool WouldBlock() const; + bool IsBlocking() const; void closeSocket(); void shutDown(int how = SD_SEND); Modified: dcplusplus/trunk/yassl/include/timer.hpp =================================================================== --- dcplusplus/trunk/yassl/include/timer.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/timer.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/yassl_error.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_error.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/yassl_error.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/yassl_imp.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_imp.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/yassl_imp.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -622,6 +626,7 @@ bool send_server_key_; // server key exchange? bool master_clean_; // master secret clean? bool TLS_; // TLSv1 or greater + bool sessionID_Set_; // do we have a session ProtocolVersion version_; RandomPool& random_; @@ -664,9 +669,9 @@ char cipher_name_[MAX_SUITE_NAME]; char cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME]; - Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion); + Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion, bool haveDH); - void SetSuites(ProtocolVersion pv); + void SetSuites(ProtocolVersion pv, bool removeDH = false); void SetCipherNames(); private: Parameters(const Parameters&); // hide copy Modified: dcplusplus/trunk/yassl/include/yassl_int.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_int.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/yassl_int.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -36,7 +40,11 @@ #include "lock.hpp" #include "openssl/ssl.h" // ASN1_STRING and DH +#ifdef _POSIX_THREADS + #include <pthread.h> +#endif + namespace yaSSL { @@ -76,12 +84,35 @@ }; +// client connect state for nonblocking restart +enum ConnectState { + CONNECT_BEGIN = 0, + CLIENT_HELLO_SENT, + FIRST_REPLY_DONE, + FINISHED_DONE, + SECOND_REPLY_DONE +}; + + +// server accpet state for nonblocking restart +enum AcceptState { + ACCEPT_BEGIN = 0, + ACCEPT_FIRST_REPLY_DONE, + SERVER_HELLO_DONE, + ACCEPT_SECOND_REPLY_DONE, + ACCEPT_FINISHED_DONE, + ACCEPT_THIRD_REPLY_DONE +}; + + // combines all states class States { RecordLayerState recordLayer_; HandShakeState handshakeLayer_; ClientState clientState_; ServerState serverState_; + ConnectState connectState_; + AcceptState acceptState_; char errorString_[MAX_ERROR_SZ]; YasslError what_; public: @@ -91,6 +122,8 @@ const HandShakeState& getHandShake() const; const ClientState& getClient() const; const ServerState& getServer() const; + const ConnectState& GetConnect() const; + const AcceptState& GetAccept() const; const char* getString() const; YasslError What() const; @@ -98,6 +131,8 @@ HandShakeState& useHandShake(); ClientState& useClient(); ServerState& useServer(); + ConnectState& UseConnect(); + AcceptState& UseAccept(); char* useString(); void SetError(YasslError); private: @@ -138,8 +173,9 @@ X509_NAME(const char*, size_t sz); ~X509_NAME(); - char* GetName(); + const char* GetName() const; ASN1_STRING* GetEntry(int i); + size_t GetLength() const; private: X509_NAME(const X509_NAME&); // hide copy X509_NAME& operator=(const X509_NAME&); // and assign @@ -153,6 +189,9 @@ ~StringHolder(); ASN1_STRING* GetString(); +private: + StringHolder(const StringHolder&); // hide copy + StringHolder& operator=(const StringHolder&); // and assign }; @@ -172,6 +211,7 @@ ASN1_STRING* GetBefore(); ASN1_STRING* GetAfter(); + private: X509(const X509&); // hide copy X509& operator=(const X509&); // and assign @@ -198,21 +238,25 @@ uint bornOn_; // create time in seconds uint timeout_; // timeout in seconds RandomPool& random_; // will clean master secret + X509* peerX509_; public: explicit SSL_SESSION(RandomPool&); SSL_SESSION(const SSL&, RandomPool&); ~SSL_SESSION(); - const opaque* GetID() const; - const opaque* GetSecret() const; - const Cipher* GetSuite() const; - uint GetBornOn() const; - uint GetTimeOut() const; + const opaque* GetID() const; + const opaque* GetSecret() const; + const Cipher* GetSuite() const; + uint GetBornOn() const; + uint GetTimeOut() const; + X509* GetPeerX509() const; void SetTimeOut(uint); SSL_SESSION& operator=(const SSL_SESSION&); // allow assign for resumption private: SSL_SESSION(const SSL_SESSION&); // hide copy + + void CopyX509(X509*); }; @@ -237,8 +281,42 @@ }; +#ifdef _POSIX_THREADS + typedef pthread_t THREAD_ID_T; +#else + typedef DWORD THREAD_ID_T; +#endif + +// thread error data +struct ThreadError { + THREAD_ID_T threadID_; + int errorID_; +}; + + +// holds all errors +class Errors { + mySTL::list<ThreadError> list_; + Mutex mutex_; + + Errors() {} // only GetErrors can create +public: + int Lookup(bool peek); // self lookup + void Add(int); + void Remove(); // remove self + + ~Errors() {} + + friend Errors& GetErrors(); // singleton creator +private: + Errors(const Errors&); // hide copy + Errors& operator=(const Errors); // and assign +}; + + Sessions& GetSessions(); // forward singletons sslFactory& GetSSL_Factory(); +Errors& GetErrors(); // openSSL method and context types @@ -429,24 +507,28 @@ // holds input and output buffers class Buffers { +public: + typedef mySTL::list<input_buffer*> inputList; + typedef mySTL::list<output_buffer*> outputList; +private: + inputList dataList_; // list of users app data / handshake + outputList handShakeList_; // buffered handshake msgs + input_buffer* rawInput_; // buffered raw input yet to process public: - Buffers() {} + Buffers(); ~Buffers(); - typedef mySTL::list<input_buffer*> inputList; - typedef mySTL::list<output_buffer*> outputList; - - const inputList& getData() const; + const inputList& getData() const; const outputList& getHandShake() const; inputList& useData(); outputList& useHandShake(); + + void SetRawInput(input_buffer*); // takes ownership + input_buffer* TakeRawInput(); // takes ownership private: Buffers(const Buffers&); // hide copy - Buffers& operator=(const Buffers&); // and assign - - inputList dataList_; // list of users app data / handshake - outputList handShakeList_; // buffered handshake msgs + Buffers& operator=(const Buffers&); // and assign }; @@ -459,7 +541,7 @@ bool resuming_; // trying to resume public: Security(ProtocolVersion, RandomPool&, ConnectionEnd, const Ciphers&, - SSL_CTX*); + SSL_CTX*, bool); const SSL_CTX* GetContext() const; const Connection& get_connection() const; @@ -505,6 +587,7 @@ sslHashes& useHashes(); Socket& useSocket(); Log& useLog(); + Buffers& useBuffers(); // sets void set_pending(Cipher suite); Modified: dcplusplus/trunk/yassl/include/yassl_types.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_types.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/yassl_types.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/mySTL/algorithm.hpp =================================================================== --- dcplusplus/trunk/yassl/mySTL/algorithm.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/mySTL/algorithm.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -8,6 +8,10 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. + * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of Modified: dcplusplus/trunk/yassl/mySTL/helpers.hpp =================================================================== --- dcplusplus/trunk/yassl/mySTL/helpers.hpp 2006-09-18 18:13:... [truncated message content] |