From da1abc9f57f45c43868171e32384f602ace95bfe Mon Sep 17 00:00:00 2001 From: Ed Jeffreys Date: Sun, 8 Mar 2026 12:49:05 +0000 Subject: [PATCH] fix: incorrect conversion between integer types Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- internal/tailscale/client.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/tailscale/client.go b/internal/tailscale/client.go index 325d984..b415159 100644 --- a/internal/tailscale/client.go +++ b/internal/tailscale/client.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "io" + "math" "net" "net/http" "slices" @@ -287,9 +288,10 @@ func (c *Client) buildServeConfig(services []Service) *ServeConfig { } for _, svc := range services { - port := uint16(svc.Port) - if port == 0 { - port = 443 + // Default to 443 if the service port is zero or out of range for uint16. + port := uint16(443) + if svc.Port > 0 && svc.Port <= math.MaxUint16 { + port = uint16(svc.Port) } svcName := fmt.Sprintf("svc:%s", svc.Hostname)