mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-22 10:20:52 +00:00
use cpp-httplib for HTTP control plane (#1979)
refactored the old control plane code to use [cpp-httplib](https://github.com/yhirose/cpp-httplib) instead of a hand rolled HTTP server. Makes the control plane code much more legible. Also no longer randomly stops responding.
This commit is contained in:
parent
411e54023a
commit
e5fc89821f
@ -15,9 +15,12 @@
|
|||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
DBMirrorSet::DBMirrorSet(DB::ChangeListener *listener) :
|
DBMirrorSet::DBMirrorSet(DB::ChangeListener *listener)
|
||||||
_listener(listener),
|
: _listener(listener)
|
||||||
_running(true)
|
, _running(true)
|
||||||
|
, _syncCheckerThread()
|
||||||
|
, _dbs()
|
||||||
|
, _dbs_l()
|
||||||
{
|
{
|
||||||
_syncCheckerThread = std::thread([this]() {
|
_syncCheckerThread = std::thread([this]() {
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
#include <cpp-httplib/httplib.h>
|
||||||
|
|
||||||
#include "DB.hpp"
|
#include "DB.hpp"
|
||||||
#include "DBMirrorSet.hpp"
|
#include "DBMirrorSet.hpp"
|
||||||
|
|
||||||
@ -66,27 +68,9 @@ public:
|
|||||||
const Identity &identity,
|
const Identity &identity,
|
||||||
const Dictionary<ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY> &metaData);
|
const Dictionary<ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY> &metaData);
|
||||||
|
|
||||||
unsigned int handleControlPlaneHttpGET(
|
void configureHTTPControlPlane(
|
||||||
const std::vector<std::string> &path,
|
httplib::Server &s,
|
||||||
const std::map<std::string,std::string> &urlArgs,
|
const std::function<void(const httplib::Request&, httplib::Response&, std::string)>);
|
||||||
const std::map<std::string,std::string> &headers,
|
|
||||||
const std::string &body,
|
|
||||||
std::string &responseBody,
|
|
||||||
std::string &responseContentType);
|
|
||||||
unsigned int handleControlPlaneHttpPOST(
|
|
||||||
const std::vector<std::string> &path,
|
|
||||||
const std::map<std::string,std::string> &urlArgs,
|
|
||||||
const std::map<std::string,std::string> &headers,
|
|
||||||
const std::string &body,
|
|
||||||
std::string &responseBody,
|
|
||||||
std::string &responseContentType);
|
|
||||||
unsigned int handleControlPlaneHttpDELETE(
|
|
||||||
const std::vector<std::string> &path,
|
|
||||||
const std::map<std::string,std::string> &urlArgs,
|
|
||||||
const std::map<std::string,std::string> &headers,
|
|
||||||
const std::string &body,
|
|
||||||
std::string &responseBody,
|
|
||||||
std::string &responseContentType);
|
|
||||||
|
|
||||||
void handleRemoteTrace(const ZT_RemoteTrace &rt);
|
void handleRemoteTrace(const ZT_RemoteTrace &rt);
|
||||||
|
|
||||||
@ -98,6 +82,8 @@ private:
|
|||||||
void _request(uint64_t nwid,const InetAddress &fromAddr,uint64_t requestPacketId,const Identity &identity,const Dictionary<ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY> &metaData);
|
void _request(uint64_t nwid,const InetAddress &fromAddr,uint64_t requestPacketId,const Identity &identity,const Dictionary<ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY> &metaData);
|
||||||
void _startThreads();
|
void _startThreads();
|
||||||
|
|
||||||
|
std::string networkUpdateFromPostData(uint64_t networkID, const std::string &body);
|
||||||
|
|
||||||
struct _RQEntry
|
struct _RQEntry
|
||||||
{
|
{
|
||||||
uint64_t nwid;
|
uint64_t nwid;
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user