]> git.proxmox.com Git - pve-common.git/commit
Network: add helpers to resolve hostnames to IPs
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 2 May 2017 09:51:19 +0000 (11:51 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 4 May 2017 06:42:55 +0000 (08:42 +0200)
commit87aa00de73e579ebc10a49a04c7d633953a48510
tree02ed84259780d601ec01813ee144d341a6fe08a9
parent09f8882f6cc3c8b6153a717695fe9ae9504d3408
Network: add helpers to resolve hostnames to IPs

Add addr_to_ip and get_ip_from_hostname helpers to PVE::Network

The first helper, addr_to_ip, is based on Wolfgangs version of this
[0]
I just moved it from PVE::Tools to PVE::Network, as it seems a more
fitting place.
It uses getnameinfo to extract information from the paddr parameter,
which is sockaddr struct
It gets used in the second helper and in a bug fix series from
Wolfgang [1]

The second helper, get_ip_from_hostname, resolves an hostname to an
IP and checks if it isn't one from the for loopback reserved 127/8
subnet. It will be used in get_remote_nodeip from PVE::CLuster and
for a bugfix in pvecm.

[0]: http://pve.proxmox.com/pipermail/pve-devel/2017-April/026099.html
[1]: http://pve.proxmox.com/pipermail/pve-devel/2017-April/026098.html

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