From b15f39419989829e276bca605c87ea2185e0c932 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 22 Aug 2023 01:50:41 +0000 Subject: [PATCH] wireguard: add EndpointAddress.Name() removing the domain from Host Signed-off-by: Alejandro Mery --- pkg/wireguard/config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/wireguard/config.go b/pkg/wireguard/config.go index 345e25e..92f7b21 100644 --- a/pkg/wireguard/config.go +++ b/pkg/wireguard/config.go @@ -49,6 +49,12 @@ type EndpointAddress struct { Port uint16 } +// Name returns the first part of a hostname +func (ep EndpointAddress) Name() string { + before, _, _ := strings.Cut(ep.Host, ".") + return before +} + func (ep EndpointAddress) String() string { switch { case ep.Host == "":