Adam Ierymenko vor 6 Jahren
Ursprung
Commit
68ac884d47

+ 0 - 6
controller/EmbeddedNetworkController.cpp

@@ -548,8 +548,6 @@ void EmbeddedNetworkController::request(
 
 unsigned int EmbeddedNetworkController::handleControlPlaneHttpGET(
 	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)
@@ -645,8 +643,6 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpGET(
 
 unsigned int EmbeddedNetworkController::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)
@@ -1055,8 +1051,6 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
 
 unsigned int EmbeddedNetworkController::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)

+ 0 - 6
controller/EmbeddedNetworkController.hpp

@@ -68,22 +68,16 @@ public:
 
 	unsigned int handleControlPlaneHttpGET(
 		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 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);

+ 33 - 33
go/pkg/zerotier/api.go

@@ -313,7 +313,7 @@ func createAPIServer(basePath string, node *Node) (*http.Server, *http.Server, e
 			_ = apiSendObj(out, req, http.StatusOK, node.LocalConfig())
 		} else {
 			out.Header().Set("Allow", "GET, HEAD, PUT, POST")
-			_ = apiSendObj(out, req, http.StatusMethodNotAllowed, nil)
+			_ = apiSendObj(out, req, http.StatusMethodNotAllowed, &APIErr{"unsupported method: " + req.Method})
 		}
 	})
 
@@ -388,38 +388,38 @@ func createAPIServer(basePath string, node *Node) (*http.Server, *http.Server, e
 
 		if req.Method == http.MethodDelete {
 			if queriedID == 0 {
-				_ = apiSendObj(out, req, http.StatusBadRequest, nil)
-			} else {
-				networks := node.Networks()
-				for _, nw := range networks {
-					if nw.id == queriedID {
-						_ = node.Leave(queriedID)
-						_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(nw))
-						return
-					}
+				_ = apiSendObj(out, req, http.StatusBadRequest, &APIErr{"only specific networks can be deleted"})
+				return
+			}
+			networks := node.Networks()
+			for _, nw := range networks {
+				if nw.id == queriedID {
+					_ = node.Leave(queriedID)
+					_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(nw))
+					return
 				}
-				_ = apiSendObj(out, req, http.StatusNotFound, &APIErr{"network not found"})
 			}
+			_ = apiSendObj(out, req, http.StatusNotFound, &APIErr{"network not found"})
 		} else if req.Method == http.MethodPost || req.Method == http.MethodPut {
 			if queriedID == 0 {
 				_ = apiSendObj(out, req, http.StatusBadRequest, nil)
-			} else {
-				var nw APINetwork
-				if apiReadObj(out, req, &nw) == nil {
-					n := node.GetNetwork(nw.ID)
-					if n == nil {
-						n, err := node.Join(nw.ID, nw.Settings, nil)
-						if err != nil {
-							_ = apiSendObj(out, req, http.StatusBadRequest, &APIErr{"only individual networks can be added or modified with POST/PUT"})
-						} else {
-							_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(n))
-						}
+				return
+			}
+			var nw APINetwork
+			if apiReadObj(out, req, &nw) == nil {
+				n := node.GetNetwork(nw.ID)
+				if n == nil {
+					n, err := node.Join(nw.ID, nw.Settings, nil)
+					if err != nil {
+						_ = apiSendObj(out, req, http.StatusBadRequest, &APIErr{"only individual networks can be added or modified with POST/PUT"})
 					} else {
-						if nw.Settings != nil {
-							n.SetLocalSettings(nw.Settings)
-						}
 						_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(n))
 					}
+				} else {
+					if nw.Settings != nil {
+						n.SetLocalSettings(nw.Settings)
+					}
+					_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(n))
 				}
 			}
 		} else if req.Method == http.MethodGet || req.Method == http.MethodHead {
@@ -430,15 +430,15 @@ func createAPIServer(basePath string, node *Node) (*http.Server, *http.Server, e
 					nws = append(nws, apiNetworkFromNetwork(nw))
 				}
 				_ = apiSendObj(out, req, http.StatusOK, nws)
-			} else {
-				for _, nw := range networks {
-					if nw.ID() == queriedID {
-						_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(nw))
-						return
-					}
+				return
+			}
+			for _, nw := range networks {
+				if nw.ID() == queriedID {
+					_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(nw))
+					return
 				}
-				_ = apiSendObj(out, req, http.StatusNotFound, &APIErr{"network not found"})
 			}
+			_ = apiSendObj(out, req, http.StatusNotFound, &APIErr{"network not found"})
 		} else {
 			out.Header().Set("Allow", "GET, HEAD, PUT, POST, DELETE")
 			_ = apiSendObj(out, req, http.StatusMethodNotAllowed, &APIErr{"unsupported method " + req.Method})
@@ -476,7 +476,7 @@ func createAPIServer(basePath string, node *Node) (*http.Server, *http.Server, e
 					}
 				}
 			}
-			_ = apiSendObj(out, req, http.StatusNotFound, nil)
+			_ = apiSendObj(out, req, http.StatusNotFound, &APIErr{"root not found"})
 		} else if req.Method == http.MethodPost || req.Method == http.MethodPut {
 			if len(queriedName) == 0 {
 				_ = apiSendObj(out, req, http.StatusBadRequest, &APIErr{"only individual roots can be added or modified with POST/PUT"})

+ 2 - 0
node/Identity.hpp

@@ -308,6 +308,7 @@ public:
 				} else {
 					b.append((uint8_t)0);
 				}
+				b.append((uint16_t)0); // size of additional fields
 				break;
 
 		}
@@ -371,6 +372,7 @@ public:
 				} else {
 					_hasPrivate = false;
 				}
+				p += b.template at<uint16_t>(p) + 2;
 				break;
 
 			default:

+ 1 - 3
node/Locator.hpp

@@ -329,9 +329,7 @@ public:
 			throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW;
 		memcpy(_signature,b.field(p,_signatureLength),_signatureLength);
 		p += _signatureLength;
-		p += b.template at<uint16_t>(p); p += 2;
-		if (p > b.size())
-			throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW;
+		p += b.template at<uint16_t>(p) + 2;
 
 		return (p - startAt);
 	}

+ 0 - 1
root/root.cpp

@@ -1237,7 +1237,6 @@ int main(int argc,char **argv)
 							ip6[1] = 0;
 						}
 						OSUtils::ztsnprintf(ver,sizeof(ver),"%d.%d.%d",(*p)->vMajor,(*p)->vMinor,(*p)->vRev);
-						double forwardingSpeed = 0.0;
 						fprintf(pf,"%.10llx %21s %45s %10.4f %6s" ZT_EOL_S,
 							(unsigned long long)(*p)->id.address().toInt(),
 							ip4,