summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2022-03-17 18:20:12 +0000
committerFelix Fietkau2022-03-17 18:22:14 +0000
commitb97405aa632a76c9977bb8c95be4336b5141e886 (patch)
treeaaaa28e014da057e2a27e8081cdc87af07542bf6
parentbdfcb11847cee05a69e8d040a2e5d00a4bdfc16c (diff)
downloadqosify-b97405aa632a76c9977bb8c95be4336b5141e886.tar.gz
Revert "ubus: remove dnsmasq subscriber"
This reverts commit a78bd43c4a542c18842ef981641d4e8948cbdc28. Under some conditions it might still be useful to have this as a backup Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--ubus.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/ubus.c b/ubus.c
index d38d53f..644df1a 100644
--- a/ubus.c
+++ b/ubus.c
@@ -308,9 +308,53 @@ static struct ubus_object qosify_object = {
};
static void
+qosify_subscribe_dnsmasq(struct ubus_context *ctx)
+{
+ static struct ubus_subscriber sub = {
+ .cb = qosify_ubus_add_dns_host,
+ };
+ uint32_t id;
+
+ if (!sub.obj.id &&
+ ubus_register_subscriber(ctx, &sub))
+ return;
+
+ if (ubus_lookup_id(ctx, "dnsmasq.dns", &id))
+ return;
+
+ ubus_subscribe(ctx, &sub, id);
+}
+
+static void
+qosify_ubus_event_cb(struct ubus_context *ctx, struct ubus_event_handler *ev,
+ const char *type, struct blob_attr *msg)
+{
+ static const struct blobmsg_policy policy =
+ { "path", BLOBMSG_TYPE_STRING };
+ struct blob_attr *attr;
+ const char *path;
+
+ blobmsg_parse(&policy, 1, &attr, blobmsg_data(msg), blobmsg_len(msg));
+
+ if (!attr)
+ return;
+
+ path = blobmsg_get_string(attr);
+ if (!strcmp(path, "dnsmasq.dns"))
+ qosify_subscribe_dnsmasq(ctx);
+}
+
+
+static void
ubus_connect_handler(struct ubus_context *ctx)
{
+ static struct ubus_event_handler ev = {
+ .cb = qosify_ubus_event_cb
+ };
+
ubus_add_object(ctx, &qosify_object);
+ ubus_register_event_handler(ctx, &ev, "ubus.object.add");
+ qosify_subscribe_dnsmasq(ctx);
}
static struct ubus_auto_conn conn;