37 DhtInterface(
const std::shared_ptr<Logger>& l) : logger_(l) {}
49 virtual NodeStatus getStatus(sa_family_t af)
const = 0;
52 void addOnConnectedCallback(std::function<
void()> cb) {
53 onConnectCallbacks_.emplace(std::move(cb));
55 virtual void setOnPublicAddressChanged(PublicAddressChangedCb) {}
57 virtual net::DatagramSocket* getSocket()
const {
return {}; }
69 virtual void shutdown(ShutdownCallback cb,
bool stop =
false) = 0;
77 virtual bool isRunning(sa_family_t af = 0)
const = 0;
79 virtual void registerType(
const ValueType& type) = 0;
81 virtual const ValueType& getType(ValueType::Id type_id)
const = 0;
83 virtual void addBootstrap(
const std::string& ,
const std::string& ) {};
84 virtual void clearBootstrap() {};
92 virtual void insertNode(
const NodeExport& n) = 0;
94 virtual void pingNode(
SockAddr, DoneCallbackSimple&& cb={}) = 0;
96 virtual time_point periodic(
const uint8_t *buf,
size_t buflen,
SockAddr,
const time_point& now) = 0;
97 virtual time_point periodic(
const uint8_t *buf,
size_t buflen,
const sockaddr* from, socklen_t fromlen,
const time_point& now) = 0;
110 virtual void get(
const InfoHash& key, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter&& f={}, Where&& w = {}) = 0;
111 virtual void get(
const InfoHash& key, GetCallbackSimple cb, DoneCallback donecb={}, Value::Filter&& f={}, Where&& w = {}) = 0;
112 virtual void get(
const InfoHash& key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter&& f={}, Where&& w = {}) = 0;
124 virtual void query(
const InfoHash& key, QueryCallback cb, DoneCallback done_cb = {},
Query&& q = {}) = 0;
125 virtual void query(
const InfoHash& key, QueryCallback cb, DoneCallbackSimple done_cb = {}, Query&& q = {}) = 0;
145 DoneCallback cb=
nullptr,
146 time_point created=time_point::max(),
147 bool permanent =
false) = 0;
148 virtual void put(
const InfoHash& key,
150 DoneCallbackSimple cb,
151 time_point created=time_point::max(),
152 bool permanent =
false) = 0;
153 virtual void put(
const InfoHash& key,
155 DoneCallback cb=
nullptr,
156 time_point created=time_point::max(),
157 bool permanent =
false) = 0;
158 virtual void put(
const InfoHash& key,
160 DoneCallbackSimple cb,
161 time_point created=time_point::max(),
162 bool permanent =
false) = 0;
188 virtual size_t listen(
const InfoHash& key, GetCallbackSimple cb, Value::Filter f={}, Where w = {}) = 0;
189 virtual size_t listen(
const InfoHash&, ValueCallback, Value::Filter={}, Where w = {}) = 0;
191 virtual bool cancelListen(
const InfoHash&,
size_t token) = 0;
199 virtual void connectivityChanged() = 0;
207 virtual std::vector<ValuesExport> exportValues()
const = 0;
208 virtual void importValues(
const std::vector<ValuesExport>&) = 0;
210 virtual NodeStats getNodesStats(sa_family_t af)
const = 0;
212 virtual std::string getStorageLog()
const = 0;
213 virtual std::string getStorageLog(
const InfoHash&)
const = 0;
215 virtual std::string getRoutingTablesLog(sa_family_t)
const = 0;
216 virtual std::string getSearchesLog(sa_family_t)
const = 0;
217 virtual std::string getSearchLog(
const InfoHash&, sa_family_t af = AF_UNSPEC)
const = 0;
219 virtual void dumpTables()
const = 0;
220 virtual std::vector<unsigned> getNodeMessageStats(
bool in =
false) = 0;
226 virtual size_t getStorageLimit()
const = 0;
234 virtual std::vector<SockAddr> getPublicAddress(sa_family_t family = 0) = 0;
236 virtual void setLogger(
const Logger& l) {
240 logger_= std::make_shared<Logger>(l);
243 virtual void setLogger(
const std::shared_ptr<Logger>& l) {
253 logger_->setFilter(f);
256 virtual void setPushNotificationToken(
const std::string&) {};
258 virtual void setPushNotificationTopic(
const std::string&) {};
259 virtual void setPushNotificationPlatform(
const std::string&) {};
268 std::shared_ptr<Logger> logger_ {};
269 std::queue<std::function<void()>> onConnectCallbacks_ {};