Skip to content

Commit

Permalink
desktop discovery: unmap IPv6 addresses (#31434)
Browse files Browse the repository at this point in the history
We request only IPv4 addresses when doing DNS queries for Windows
desktops. In some circumstances, we can get addresses that are
represented ("mapped") as IPv6 addresses. Unmap them so that Teleport
always stores the IPv4 format.
  • Loading branch information
zmb3 committed Sep 5, 2023
1 parent b07f58c commit 6943282
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/srv/desktop/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,16 @@ func (s *WindowsService) lookupDesktop(ctx context.Context, hostname string) ([]
hostname, resolverName, err)
}

ch <- addrs
// even though we requested "ip4" it's possible to get IPv4
// addresses mapped to IPv6 addresses, so we unmap them here
result := make([]netip.Addr, 0, len(addrs))
for _, addr := range addrs {
if addr.Is4() || addr.Is4In6() {
result = append(result, addr.Unmap())
}
}

ch <- result
}()
return ch
}
Expand Down

0 comments on commit 6943282

Please sign in to comment.