]> git.proxmox.com Git - pve-common.git/commit - src/PVE/Network.pm
net: add get_local_ip helper
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 18 Sep 2021 12:38:59 +0000 (14:38 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 18 Sep 2021 12:51:01 +0000 (14:51 +0200)
commitac487a888b7fc17a73e702586bd162a5527014b5
tree21b817f41815a576a882496e3368da7c5653826b
parentebbbb05e004ab6d300f74b19c013baa9f5d02415
net: add get_local_ip helper

Sometimes we need to have a fallback for gai (get_ip_from_hostname)
but cannot yet rely on configured networks (get_reachable_networks)
from kernel POV (those may not have been configured yet, e.g., on
boot), so the ones configured in /etc/network/interfaces would be
nice too then, as they're the ones that will get configured soon
anyway on boot.

Add a new helper that takes in all those sources and allows to return
a single (first found) or all of those addresses.

Still prioritize the address we get from getaddrinfo, as there the
admin has control through /etc/hosts, DNS and gai.conf and treat the
remaining ones as fallback.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Network.pm