*/
func();
}
-
unsigned int thread = 0;
for (const auto& threadInfo : RecThreadInfo::infos()) {
if (thread++ == RecThreadInfo::thread_local_id()) {
void apiServerZoneDetailDELETE(const Request& rustRequest, Response& rustResponse);
void apiServerOTConditionsGET(const Request& rustRequest, Response& rustResponse);
void apiServerOTConditionDetailGET(const Request& rustRequest, Response& rustResponse);
+void apiServerOTConditionDetailDELETE(const Request& rustRequest, Response& rustResponse);
}
}
*apifunc = Some(rustweb::apiServerOTConditionDetailGET)
}
+ (&Method::DELETE, ["api", "v1", "servers", "localhost", "otconditions", id]) => {
+ let decoded = form_urlencoded::parse(id.as_bytes());
+ // decoded should contain a single key without value
+ if let Some(kv) = decoded.last() {
+ request.parameters.push(rustweb::KeyValue {
+ key: String::from("id"),
+ value: kv.0.to_string(),
+ });
+ }
+ *apifunc = Some(rustweb::apiServerOTConditionDetailDELETE)
+ }
_ => *filefunc = Some(file),
}
}
fn apiServerZonesPOST(requst: &Request, response: &mut Response) -> Result<()>;
fn apiServerOTConditionsGET(request: &Request, response: &mut Response) -> Result<()>;
fn apiServerOTConditionDetailGET(request: &Request, response: &mut Response) -> Result<()>;
+ fn apiServerOTConditionDetailDELETE(request: &Request, response: &mut Response) -> Result<()>;
fn jsonstat(request: &Request, response: &mut Response) -> Result<()>;
fn prometheusMetrics(request: &Request, response: &mut Response) -> Result<()>;
fn serveStuff(request: &Request, response: &mut Response) -> Result<()>;
WRAPPER(apiServerZonesPOST)
WRAPPER(apiServerOTConditionsGET)
WRAPPER(apiServerOTConditionDetailGET)
+WRAPPER(apiServerOTConditionDetailDELETE)
WRAPPER(jsonstat)
WRAPPER(prometheusMetrics)
WRAPPER(serveStuff)
void doExitNicely();
RecursorControlChannel::Answer doQueueReloadLuaScript(vector<string>::const_iterator begin, vector<string>::const_iterator end);
RecursorControlChannel::Answer luaconfig(bool broadcast);
+struct OpenTelemetryTraceCondition;
+void updateOTConditions(const NetmaskTree<OpenTelemetryTraceCondition>& conditions);
return nullptr;
}
+void updateOTConditions(const OpenTelemetryTraceConditions& conditions)
+{
+ broadcastFunction([conditions] { return pleaseSupplantOTConditions(conditions); });
+}
+
static RecursorControlChannel::Answer help(ArgIterator /* begin */, ArgIterator /* end */)
{
static const std::map<std::string, std::string> commands = {
auto lock = g_initialOpenTelemetryConditions.lock();
if (*lock) {
auto condition = (*lock)->lookup(netmask);
- if (condition != nullptr) {
+ if (condition != nullptr && condition->first == netmask) { // exact match
Json::object object{
{"acl", condition->first.toString()},
{"edns_option_required", condition->second.d_edns_option_required},
}
}
+static void apiServerOTConditionDetailDELETE(HttpRequest* req, HttpResponse* resp)
+{
+ try {
+ Netmask netmask{req->parameters["id"]};
+ auto lock = g_initialOpenTelemetryConditions.lock();
+ if (*lock) {
+ auto condition = (*lock)->lookup(netmask);
+ if (condition != nullptr && condition->first == netmask) { // exact match
+ (*lock)->erase(condition->first);
+ updateOTConditions(**lock);
+ // empty body on success
+ resp->body = "";
+ resp->status = 204; // No Content: declare that the condition is gone now
+ return;
+ }
+ }
+ throw ApiException("Could not find otcondition '" + netmask.toString() + "'");
+ }
+ catch (NetmaskException& ex) {
+ throw ApiException("Could not parse netmask");
+ }
+}
+
static void prometheusMetrics(HttpRequest* /* req */, HttpResponse* resp)
{
static MetricDefinitionStorage s_metricDefinitions;
WRAPPER(apiServerZonesPOST)
WRAPPER(apiServerOTConditionsGET)
WRAPPER(apiServerOTConditionDetailGET)
+WRAPPER(apiServerOTConditionDetailDELETE)
WRAPPER(prometheusMetrics)
WRAPPER(serveStuff)