2
0

FileDB.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. protected:
  30. std::string _path;
  31. std::string _networksPath;
  32. std::string _tracePath;
  33. std::thread _onlineUpdateThread;
  34. std::map< uint64_t,std::map<uint64_t,std::map<int64_t,InetAddress> > > _online;
  35. std::mutex _online_l;
  36. bool _running;
  37. };
  38. } // namespace ZeroTier
  39. #endif