From 468a9ac9542070cadf26046ca0ea3767c0d04c15 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 29 Sep 2025 09:39:57 +0200 Subject: [PATCH] pulse-server: add the peer ip to client properties When clients connect with IP, add the peer IP address to properties. We might use this later to make a better stream node.name than a copy of the client application name. --- src/modules/module-protocol-pulse/server.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/module-protocol-pulse/server.c b/src/modules/module-protocol-pulse/server.c index 13425debc..4e744e33f 100644 --- a/src/modules/module-protocol-pulse/server.c +++ b/src/modules/module-protocol-pulse/server.c @@ -31,6 +31,7 @@ #include #include +#include "network-utils.h" #include "client.h" #include "commands.h" #include "defs.h" @@ -375,6 +376,7 @@ on_connect(void *data, int fd, uint32_t mask) struct client *client = NULL; const char *client_access = NULL; const char *error_reason = NULL; + char ipname[256]; pid_t pid; length = sizeof(name); @@ -418,10 +420,18 @@ on_connect(void *data, int fd, uint32_t mask) if (client->props == NULL) goto error; + pw_properties_setf(client->props, "pulse.server.type", "%s", server->addr.ss_family == AF_UNIX ? "unix" : "tcp"); + if (server->addr.ss_family != AF_UNIX) { + uint16_t port = 0; + if (pw_net_get_ip(&name, ipname, sizeof(ipname), NULL, &port) >= 0) + pw_properties_setf(client->props, + "pulse.server.peer", "%s:%d", ipname, port); + } + client->routes = pw_properties_new(NULL, NULL); if (client->routes == NULL) goto error;