FileDB.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c)2019 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: 2026-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. virtual void nodeIsOnline(const uint64_t networkId,const uint64_t memberId,const InetAddress &physicalAddress, const char *osArch);
  30. protected:
  31. std::string _path;
  32. std::string _networksPath;
  33. std::string _tracePath;
  34. std::thread _onlineUpdateThread;
  35. std::map< uint64_t,std::map<uint64_t,std::map<int64_t,InetAddress> > > _online;
  36. std::mutex _online_l;
  37. bool _running;
  38. };
  39. } // namespace ZeroTier
  40. #endif