FileDB.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2025-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. #ifndef ZT_CONTROLLER_FILEDB_HPP
  14. #define ZT_CONTROLLER_FILEDB_HPP
  15. #include "DB.hpp"
  16. namespace ZeroTier
  17. {
  18. class FileDB : public DB
  19. {
  20. public:
  21. FileDB(const char *path);
  22. virtual ~FileDB();
  23. virtual bool waitForReady();
  24. virtual bool isReady();
  25. virtual bool save(nlohmann::json &record,bool notifyListeners);
  26. virtual void eraseNetwork(const uint64_t networkId);
  27. virtual void eraseMember(const uint64_t networkId,const uint64_t memberId);
  28. virtual void nodeIsOnline(const uint64_t networkId,const uint64_t memberId,const InetAddress &physicalAddress);
  29. protected:
  30. String _path;
  31. String _networksPath;
  32. std::thread _onlineUpdateThread;
  33. std::map< uint64_t,std::map<uint64_t,std::map<int64_t,InetAddress> > > _online;
  34. std::mutex _online_l;
  35. bool _running;
  36. };
  37. } // namespace ZeroTier
  38. #endif