mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-20 05:28:01 +00:00
Prevent creating members on non-existent networks.
```sh curl -s -X POST "http://localhost:9993/controller/network/abcdabcdabcdabcd/member/1122334455" ``` Would return 200 and ZT_HOME/controller.d/abcdabcdabcdabcd/members/1122334455 would be created. Without a ZT_HOME/controller.d/abcdabcdabcdabcd.json Then other parts of the system mistakenly think a abcdabcdabcdabcd network sorta kinda exists and then fail in weird ways.
This commit is contained in:
parent
4cd1dcfee1
commit
d1a306a021
@ -969,7 +969,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
|
|||||||
sv6.Get(networkPath, networkGet);
|
sv6.Get(networkPath, networkGet);
|
||||||
|
|
||||||
auto createNewNetwork = [&, setContent](const httplib::Request &req, httplib::Response &res) {
|
auto createNewNetwork = [&, setContent](const httplib::Request &req, httplib::Response &res) {
|
||||||
fprintf(stderr, "creating new network (new style)\n");
|
// fprintf(stderr, "creating new network (new style)\n");
|
||||||
uint64_t nwid = 0;
|
uint64_t nwid = 0;
|
||||||
uint64_t nwidPrefix = (Utils::hexStrToU64(_signingIdAddressString.c_str()) << 24) & 0xffffffffff000000ULL;
|
uint64_t nwidPrefix = (Utils::hexStrToU64(_signingIdAddressString.c_str()) << 24) & 0xffffffffff000000ULL;
|
||||||
uint64_t nwidPostfix = 0;
|
uint64_t nwidPostfix = 0;
|
||||||
@ -1136,6 +1136,12 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
|
|||||||
auto memberID = req.matches[2].str();
|
auto memberID = req.matches[2].str();
|
||||||
uint64_t nwid = Utils::hexStrToU64(networkID.c_str());
|
uint64_t nwid = Utils::hexStrToU64(networkID.c_str());
|
||||||
uint64_t memid = Utils::hexStrToU64(memberID.c_str());
|
uint64_t memid = Utils::hexStrToU64(memberID.c_str());
|
||||||
|
|
||||||
|
if (!_db.hasNetwork(nwid)) {
|
||||||
|
res.status = 404;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
json network;
|
json network;
|
||||||
json member;
|
json member;
|
||||||
_db.get(nwid, network, memid, member);
|
_db.get(nwid, network, memid, member);
|
||||||
|
Loading…
Reference in New Issue
Block a user