From 19e42663a0141a75e03d2fed41b3265d7cf73df0 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 24 Oct 2021 20:01:19 +0200 Subject: [PATCH] fixed compilation --- libretroshare/src/friend_server/fsbio.cc | 27 ++++++++++++++++ libretroshare/src/friend_server/fsbio.h | 24 ++++++++++++++ libretroshare/src/friend_server/fsclient.cc | 27 ++++++++++++++++ libretroshare/src/friend_server/fsclient.h | 25 +++++++++++++++ libretroshare/src/friend_server/fsitem.h | 24 ++++++++++++++ libretroshare/src/libretroshare.pro | 1 + libretroshare/src/retroshare/rsfriendserver.h | 32 +++++++++++++------ retroshare-friendserver/src/friendserver.cc | 2 +- retroshare-friendserver/src/network.cc | 2 +- retroshare-friendserver/src/network.h | 2 +- .../src/retroshare-friendserver.cc | 3 +- 11 files changed, 156 insertions(+), 13 deletions(-) diff --git a/libretroshare/src/friend_server/fsbio.cc b/libretroshare/src/friend_server/fsbio.cc index 4104c3c0d..517738225 100644 --- a/libretroshare/src/friend_server/fsbio.cc +++ b/libretroshare/src/friend_server/fsbio.cc @@ -1,3 +1,28 @@ +/******************************************************************************* + * libretroshare/src/file_sharing: fsbio.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2021 by retroshare team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 * + * GNU Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ + +#include "util/rsprint.h" +#include "fsbio.h" + FsBioInterface::FsBioInterface(int socket) : mCLintConnt(socket) { @@ -111,10 +136,12 @@ int FsBioInterface::netstatus() { return 1; // dummy response. } + int FsBioInterface::isactive() { return mCLintConnt > 0; } + bool FsBioInterface::moretoread(uint32_t /* usec */) { return mTotalBufferBytes > 0; diff --git a/libretroshare/src/friend_server/fsbio.h b/libretroshare/src/friend_server/fsbio.h index 2e872d48d..446ad29f8 100644 --- a/libretroshare/src/friend_server/fsbio.h +++ b/libretroshare/src/friend_server/fsbio.h @@ -1,3 +1,27 @@ +/******************************************************************************* + * libretroshare/src/file_sharing: fsbio.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2021 by retroshare team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 * + * GNU Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ + +#include "pqi/pqi_base.h" + class FsBioInterface: public BinInterface { public: diff --git a/libretroshare/src/friend_server/fsclient.cc b/libretroshare/src/friend_server/fsclient.cc index 6ee8518af..c332aee24 100644 --- a/libretroshare/src/friend_server/fsclient.cc +++ b/libretroshare/src/friend_server/fsclient.cc @@ -1,3 +1,30 @@ +/******************************************************************************* + * libretroshare/src/file_sharing: fsclient.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2021 by retroshare team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 * + * GNU Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ + +#include "pqi/pqithreadstreamer.h" + +#include "fsclient.h" +#include "fsbio.h" + FsClient::FsClient(const std::string& address) : mServerAddress(address) { diff --git a/libretroshare/src/friend_server/fsclient.h b/libretroshare/src/friend_server/fsclient.h index 6e79ed1b3..c29a10671 100644 --- a/libretroshare/src/friend_server/fsclient.h +++ b/libretroshare/src/friend_server/fsclient.h @@ -1,3 +1,28 @@ +/******************************************************************************* + * libretroshare/src/file_sharing: fsclient.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2021 by retroshare team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 * + * GNU Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ + +#include +#include "fsitem.h" + // This class runs a client connection to the friend server. It opens a socket at each connection. class FsClient diff --git a/libretroshare/src/friend_server/fsitem.h b/libretroshare/src/friend_server/fsitem.h index 4714178af..3ca7e50d5 100644 --- a/libretroshare/src/friend_server/fsitem.h +++ b/libretroshare/src/friend_server/fsitem.h @@ -1,3 +1,27 @@ +/******************************************************************************* + * libretroshare/src/file_sharing: fsitem.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2021 by retroshare team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 * + * GNU Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ + +#pragma once + #include "serialiser/rsserial.h" #include "serialiser/rsserializer.h" diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index d6f0397df..f8d01a613 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -406,6 +406,7 @@ HEADERS += pqi/authssl.h \ SOURCES += friend_server/fsclient.h \ friend_server/fsbio.h \ + friend_server/fsitem.h \ friend_server/fsmanager.h HEADERS += rsserver/p3face.h \ diff --git a/libretroshare/src/retroshare/rsfriendserver.h b/libretroshare/src/retroshare/rsfriendserver.h index 6b343eb0e..9ce4b25ef 100644 --- a/libretroshare/src/retroshare/rsfriendserver.h +++ b/libretroshare/src/retroshare/rsfriendserver.h @@ -2,19 +2,33 @@ #include #include "util/rstime.h" +// The Friend Server component of Retroshare automatically adds/removes some friends so that the +// +// The current strategy is: +// +// - if total nb of friends < S +// request new friends to the FS +// - if total nb of friends >= S +// do not request anymore (and unpublish the key), but keep the friends already here +// +// Possible states: +// - not started +// - maintain friend list +// - actively request friends +// +// The friend server internally keeps track of which friends have been added using the friend server. +// It's important to keep the ones that are already connected because they may count on us. +// Friends supplied by the FS who never connected for a few days should be removed automatically. + class RsFriendServer { public: - void start() {} - void stop() {} + virtual void start() =0; + virtual void stop() =0; - void checkServerAddress_async(const std::string& addr,uint16_t, const std::function& callback) - { - std::this_thread::sleep_for(std::chrono::seconds(1)); - callback(addr,true); - } - void setServerAddress(const std::string&,uint16_t) {} - void setFriendsToRequest(uint32_t) {} + virtual void checkServerAddress_async(const std::string& addr,uint16_t, const std::function& callback) =0; + virtual void setServerAddress(const std::string&,uint16_t) =0; + virtual void setFriendsToRequest(uint32_t) =0; }; extern RsFriendServer *rsFriendServer; diff --git a/retroshare-friendserver/src/friendserver.cc b/retroshare-friendserver/src/friendserver.cc index a33f34bf7..fa4591955 100644 --- a/retroshare-friendserver/src/friendserver.cc +++ b/retroshare-friendserver/src/friendserver.cc @@ -1,7 +1,7 @@ #include "util/rsdebug.h" #include "friendserver.h" -#include "fsitem.h" +#include "friend_server/fsitem.h" void FriendServer::threadTick() { diff --git a/retroshare-friendserver/src/network.cc b/retroshare-friendserver/src/network.cc index c5451e9b1..5f697e9b0 100644 --- a/retroshare-friendserver/src/network.cc +++ b/retroshare-friendserver/src/network.cc @@ -38,7 +38,7 @@ #include "friend_server/fsbio.h" #include "network.h" -#include "fsitem.h" +#include "friend_server/fsitem.h" FsNetworkInterface::FsNetworkInterface() : mFsNiMtx(std::string("FsNetworkInterface")) diff --git a/retroshare-friendserver/src/network.h b/retroshare-friendserver/src/network.h index e5ff4bc3c..e842ec77c 100644 --- a/retroshare-friendserver/src/network.h +++ b/retroshare-friendserver/src/network.h @@ -22,7 +22,7 @@ #pragma once #include "util/rsthreads.h" -#include "pqi/pqi_base.h" +#include "retroshare/rspeers.h" class pqistreamer; diff --git a/retroshare-friendserver/src/retroshare-friendserver.cc b/retroshare-friendserver/src/retroshare-friendserver.cc index 93ce3f409..c93c59609 100644 --- a/retroshare-friendserver/src/retroshare-friendserver.cc +++ b/retroshare-friendserver/src/retroshare-friendserver.cc @@ -27,7 +27,8 @@ #include "friendserver.h" // debug -#include "fsitem.h" +#include "friend_server/fsitem.h" +#include "friend_server/fsclient.h" int main(int argc, char* argv[]) {