FileDB.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. class FileDB : public DB {
  18. public:
  19. FileDB(const char* path);
  20. virtual ~FileDB();
  21. virtual bool waitForReady();
  22. virtual bool isReady();
  23. virtual bool save(nlohmann::json& record, bool notifyListeners);
  24. virtual void eraseNetwork(const uint64_t networkId);
  25. virtual void eraseMember(const uint64_t networkId, const uint64_t memberId);
  26. virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress);
  27. protected:
  28. std::string _path;
  29. std::string _networksPath;
  30. std::string _tracePath;
  31. std::thread _onlineUpdateThread;
  32. std::map<uint64_t, std::map<uint64_t, std::map<int64_t, InetAddress> > > _online;
  33. std::mutex _online_l;
  34. bool _running;
  35. };
  36. } // namespace ZeroTier
  37. #endif