FileDB.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* (c) ZeroTier, Inc.
  2. * See LICENSE.txt in nonfree/
  3. */
  4. #ifndef ZT_CONTROLLER_FILEDB_HPP
  5. #define ZT_CONTROLLER_FILEDB_HPP
  6. #include "DB.hpp"
  7. namespace ZeroTier {
  8. class FileDB : public DB {
  9. public:
  10. FileDB(const char* path);
  11. virtual ~FileDB();
  12. virtual bool waitForReady();
  13. virtual bool isReady();
  14. virtual bool save(nlohmann::json& record, bool notifyListeners);
  15. virtual void eraseNetwork(const uint64_t networkId);
  16. virtual void eraseMember(const uint64_t networkId, const uint64_t memberId);
  17. virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress);
  18. virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress, const char* osArch);
  19. protected:
  20. std::string _path;
  21. std::string _networksPath;
  22. std::string _tracePath;
  23. std::thread _onlineUpdateThread;
  24. std::map<uint64_t, std::map<uint64_t, std::map<int64_t, InetAddress> > > _online;
  25. std::mutex _online_l;
  26. bool _running;
  27. };
  28. } // namespace ZeroTier
  29. #endif