2021-10-08 19:08:23 -04:00
|
|
|
/*
|
|
|
|
* RetroShare Friend Server
|
|
|
|
* Copyright (C) 2021-2021 retroshare team <retroshare.project@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* SPDX-FileCopyrightText: Retroshare Team <contact@retroshare.cc>
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "util/rsthreads.h"
|
|
|
|
#include "pqi/pqistreamer.h"
|
2021-11-01 04:16:41 -04:00
|
|
|
#include "pgp/pgphandler.h"
|
2021-10-08 19:08:23 -04:00
|
|
|
|
|
|
|
#include "network.h"
|
|
|
|
|
2021-10-11 17:40:22 -04:00
|
|
|
class RsFriendServerClientRemoveItem;
|
|
|
|
class RsFriendServerClientPublishItem;
|
|
|
|
|
2021-10-31 13:00:43 -04:00
|
|
|
struct PeerInfo
|
|
|
|
{
|
|
|
|
std::string short_certificate;
|
|
|
|
rstime_t last_connection_TS;
|
|
|
|
};
|
|
|
|
|
2021-10-08 19:08:23 -04:00
|
|
|
class FriendServer : public RsTickingThread
|
|
|
|
{
|
2021-10-11 17:40:22 -04:00
|
|
|
public:
|
|
|
|
FriendServer(const std::string& base_directory);
|
|
|
|
|
|
|
|
private:
|
2021-10-31 13:00:43 -04:00
|
|
|
// overloads RsTickingThread
|
|
|
|
|
2021-10-11 17:40:22 -04:00
|
|
|
virtual void threadTick() override;
|
|
|
|
virtual void run() override;
|
2021-10-08 19:08:23 -04:00
|
|
|
|
2021-10-31 13:00:43 -04:00
|
|
|
// Own algorithmics
|
|
|
|
|
2021-10-11 17:40:22 -04:00
|
|
|
void handleClientRemove(const RsFriendServerClientRemoveItem *item);
|
|
|
|
void handleClientPublish(const RsFriendServerClientPublishItem *item);
|
2021-10-08 19:08:23 -04:00
|
|
|
|
2021-10-31 13:00:43 -04:00
|
|
|
void autoWash();
|
|
|
|
void debugPrint();
|
|
|
|
|
|
|
|
// Local members
|
|
|
|
|
2021-10-11 17:40:22 -04:00
|
|
|
FsNetworkInterface *mni;
|
2021-11-01 04:16:41 -04:00
|
|
|
PGPHandler *mPgpHandler;
|
2021-10-08 19:08:23 -04:00
|
|
|
|
2021-10-11 17:40:22 -04:00
|
|
|
std::string mBaseDirectory;
|
2021-10-31 13:00:43 -04:00
|
|
|
|
|
|
|
std::map<RsPeerId, PeerInfo> mCurrentClientPeers;
|
2021-10-08 19:08:23 -04:00
|
|
|
};
|