diff options
m--------- | depends/odhtdb | 0 | ||||
-rw-r--r-- | include/Channel.hpp | 9 | ||||
-rw-r--r-- | project.conf | 6 | ||||
-rw-r--r-- | src/Channel.cpp | 4 | ||||
-rw-r--r-- | src/main.cpp | 12 |
5 files changed, 15 insertions, 16 deletions
diff --git a/depends/odhtdb b/depends/odhtdb -Subproject 7757816fc214e5b571ab4b857b3d6bb780070eb +Subproject 13f2007d104149f69ab7a794d2e119830e638ea diff --git a/include/Channel.hpp b/include/Channel.hpp index 663b163..34752da 100644 --- a/include/Channel.hpp +++ b/include/Channel.hpp @@ -15,12 +15,9 @@ #include <odhtdb/Group.hpp> #include <odhtdb/Hash.hpp> #include <odhtdb/DhtKey.hpp> +#include <odhtdb/Database.hpp> #include <future> -namespace odhtdb -{ - class Database; -} namespace dchat { @@ -101,8 +98,8 @@ namespace dchat std::vector<User*> users; std::unordered_map<u64, OnlineDiscordUser*> discordUserById; odhtdb::Signature::MapPublicKey<OnlineUser*> publicKeyOnlineUsersMap; - dht::InfoHash pingKey; - std::future<size_t> pingListener; + odhtdb::InfoHash pingKey; + sibs::ListenHandle pingListener; sf::Clock pingTimer; std::vector<BridgeService*> bridgeServices; diff --git a/project.conf b/project.conf index ebb949f..c3dd875 100644 --- a/project.conf +++ b/project.conf @@ -1,8 +1,8 @@ [package] name = "dchat" -version = "0.1.0" +version = "0.2.0" type = "executable" -platforms = ["linux32", "linux64"] +platforms = ["linux", "win"] [dependencies] sfml-window = "2.5" @@ -16,4 +16,4 @@ x11 = "1.6.5" libnsgif = "0.2.0" libpreview = "0.2.0" libzmq = "4.2" -libgd = "2.2.5"
\ No newline at end of file +libgd = "2.2.5" diff --git a/src/Channel.cpp b/src/Channel.cpp index 82f8ef0..501e5bc 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -87,7 +87,7 @@ namespace dchat if(database) { - database->cancelNodeListener(pingKey, pingListener); + database->cancelNodeListener(pingListener); database->stopSeeding(*databaseNodeInfo.getRequestHash()); sendPing(0); } @@ -387,7 +387,7 @@ namespace dchat signedSerializer.add(pingTimestampSec); string signedData = onlineLocalUser->keyPair.getPrivateKey().sign(odhtdb::DataView(signedSerializer.getBuffer().data(), signedSerializer.getBuffer().size())); serializer.add((const u8*)signedData.data(), signedData.size()); - database->sendCustomMessage(pingKey, move(serializer.getBuffer())); + database->sendCustomMessage(pingKey, serializer.getBuffer().data(), serializer.getBuffer().size()); } } diff --git a/src/main.cpp b/src/main.cpp index efb354f..3abff99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ #include <ntp/NtpClient.hpp> #include <sibs/SafeSerializer.hpp> #include <X11/Xlib.h> +#include <math.h> using namespace std; using namespace dchat; @@ -397,7 +398,7 @@ int main(int argc, char **argv) } } }; - database = new odhtdb::Database("bootstrap.ring.cx", 4222, Cache::getDchatDir(), callbackFuncs); + database = new odhtdb::Database("206.189.13.66", 27130, Cache::getDchatDir(), callbackFuncs); auto addSystemMessage = [&lastFocusedTimer](const std::string &msg, bool plainText = true) { @@ -550,7 +551,7 @@ int main(int argc, char **argv) sibs::SafeSerializer keySerializer; keySerializer.add((const u8*)channelNodeHash->getData(), channelNodeHash->getSize()); keySerializer.add((const u8*)encryptionKey->data, odhtdb::ENCRYPTION_KEY_BYTE_SIZE); - dht::InfoHash key = odhtdb::Database::getInfoHash(keySerializer.getBuffer().data(), keySerializer.getBuffer().size()); + odhtdb::InfoHash key = odhtdb::Database::getInfoHash(keySerializer.getBuffer().data(), keySerializer.getBuffer().size()); database->receiveCustomMessage(key, [&channelMessageMutex, encryptionKey, channelEncryptionKey, currentChannel, &database](const void *data, usize size) { // TODO: User can remove channel @currentChannel before we get here, meaning @currentChannel is deleted and would be invalid; causing the program to crash @@ -648,8 +649,10 @@ int main(int argc, char **argv) sibs::SafeSerializer keySerializer; keySerializer.add((const u8*)nodeHash->getData(), nodeHash->getSize()); keySerializer.add((const u8*)encryptionKeyBinRaw.data(), odhtdb::ENCRYPTION_KEY_BYTE_SIZE); - dht::InfoHash key = odhtdb::Database::getInfoHash(keySerializer.getBuffer().data(), keySerializer.getBuffer().size()); - database->sendCustomMessage(key, move(serializer.getBuffer()), [&database, nodeHash, encryptionKey, &waitingToJoinChannels, &channelMessageMutex, keyPair, ¤tUsername, ¤tPassword, &localNodeUsers](bool gotResponse, const void *data, usize size) + odhtdb::InfoHash key = odhtdb::Database::getInfoHash(keySerializer.getBuffer().data(), keySerializer.getBuffer().size()); + database->sendCustomMessage(key, serializer.getBuffer().data(), serializer.getBuffer().size(), + [&database, nodeHash, encryptionKey, &waitingToJoinChannels, &channelMessageMutex, keyPair, ¤tUsername, ¤tPassword, &localNodeUsers] + (bool gotResponse, const void *data, usize size) { if(!gotResponse) { @@ -695,7 +698,6 @@ int main(int argc, char **argv) fprintf(stderr, "Failed while parsing join response for invite link, reason: %s\n", e.what()); } return true; - }); waitingToJoin = true; }); |