From a774a6fcb0bf7daa550efbc9d9e2f1f2d7898731 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 9 Aug 2022 13:00:55 +0100 Subject: [PATCH] Strip off the last dot and everything to the right of it in the hostname when automatically generating a service name. --- shairport.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shairport.c b/shairport.c index 91bc4416..b4ad115b 100644 --- a/shairport.c +++ b/shairport.c @@ -1454,6 +1454,11 @@ int parse_options(int argc, char **argv) { // now, do the substitutions in the service name char hostname[100]; gethostname(hostname, 100); + + // strip off a terminating ., e.g. .local from the hostname + char *last_dot = strrchr(hostname,'.'); + if (last_dot != NULL) + *last_dot = '\0'; char *i0; if (raw_service_name == NULL)