Compare commits

...

5 Commits

Author SHA1 Message Date
T-X 2550eb4596
Merge 49604ce507 into 3d08b0fee8 2024-02-05 10:04:11 +01:00
Florian Maurer 3d08b0fee8 wgpeerselector: fix undefined variable peer
Signed-off-by: Florian Maurer <f.maurer@outlook.de>
2024-01-22 23:22:23 +01:00
Matthias Schiffer 53ea3b8977 libplatforminfo: update bcm27xx target name
The RPi targets were renamed in OpenWrt 21.02 (Gluon 2022.1). As
libplatforminfo was not adjusted, image names were using autodetected
model names including a revision number again, requiring additional
manifest aliases.
2023-12-19 18:40:02 +01:00
Matthias Schiffer 28a35ea2c9 libplatforminfo: drop obsolete ar71xx-mikrotik target
The obsolete ar71xx-mikrotik.c was symlinked to template/nosysupgrade.c.
As all new mikrotik targets have sysupgrade support, we can just remove
the symlink and use the default handling of libplatforminfo.

nosysupgrade.c becomes unused, but it left in the repository for future
experimental targets without sysupgrade support.
2023-12-19 18:40:02 +01:00
Linus Lüssing 49604ce507 respondd: add provider "respondd-providers" to list registrations
Add an internal respondd provider "respondd-providers" which allows a
respondd querier to query which providers are registered on a node.
Example output:

{
	"respondd-providers": [
		"neighbours",
		"nodeinfo",
		"statistics",
		"statistics-extended"
	]
}

This can be useful for providers which are known to be bulky, where the
actual data is better queried via HTTP/TCP instead. But where such a
provider is only present on a few nodes, so you'd want to avoid
trying each node via HTTP.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
2022-03-22 02:06:38 +01:00
4 changed files with 55 additions and 4 deletions

View File

@ -1 +0,0 @@
template/nosysupgrade.c

View File

@ -78,6 +78,11 @@ struct provider_list {
respondd_provider provider;
};
struct key_list {
struct key_list *next;
char *key;
};
struct request_type {
struct provider_list *providers;
@ -101,6 +106,7 @@ struct request_schedule {
static int64_t now;
static struct hsearch_data htab;
static struct key_list *keys;
static struct json_object * merge_json(struct json_object *a, struct json_object *b);
@ -272,6 +278,23 @@ static void load_cache_time(struct request_type *r, const char *name) {
}
static void add_key(const char *key) {
struct key_list **pos, *pentry;
int i = 0;
for (pos = &keys; *pos; pos = &(*pos)->next) {
if (strcmp(key, (*pos)->key) == 0)
return;
if (strcmp(key, (*pos)->key) < 0)
break;
}
pentry = malloc(sizeof(*pentry));
pentry->key = strdup(key);
pentry->next = *pos;
*pos = pentry;
}
static void add_provider(const char *name, const struct respondd_provider_info *provider) {
ENTRY key = {
.key = (char *)provider->request,
@ -306,6 +329,31 @@ static void add_provider(const char *name, const struct respondd_provider_info *
*pos = pentry;
}
static struct json_object *respondd_provider_providers(void) {
struct key_list **pos;
struct json_object *provider;
struct json_object *ret = json_object_new_array();
if (!ret)
return NULL;
for (pos = &keys; *pos; pos = &(*pos)->next) {
provider = json_object_new_string((*pos)->key);
json_object_array_add(ret, provider);
}
return ret;
}
static void add_providers_provider(void) {
const struct respondd_provider_info providers[] = {
{"respondd-providers", respondd_provider_providers},
{}
};
add_provider("respondd", providers);
}
static void load_providers(const char *path) {
update_time();
@ -339,10 +387,14 @@ static void load_providers(const char *path) {
if (!providers)
continue;
for (; providers->request; providers++)
for (; providers->request; providers++) {
add_provider(ent->d_name, providers);
add_key(providers->request);
}
}
add_providers_provider();
closedir(dir);
out:

View File

@ -380,7 +380,7 @@ function WGPeerSelector:main()
if self:try_connect_to_peer(peer, timeout) then
connected_peer = peer
log(syslog.LOG_INFO, 'Connection established with '..peer.name..'.')
log(syslog.LOG_INFO, 'Connection established with '..connected_peer.name..'.')
end
elseif state == 'established' then
@ -388,8 +388,8 @@ function WGPeerSelector:main()
if not connected_peer:has_recent_handshake() then
connected_peer:uninstall_from_kernel()
log(syslog.LOG_INFO, 'Connection to '..connected_peer.name..' lost.')
connected_peer = nil
log(syslog.LOG_INFO, 'Connection to '..peer.name..' lost.')
else
-- check connections every 5 seconds
sleep(5)