Alejandro Mery
11 months ago
3 changed files with 33 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||||||
|
package zones |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
"net/netip" |
||||||
|
"time" |
||||||
|
) |
||||||
|
|
||||||
|
func (m *Machine) lookupNetIP() ([]netip.Addr, error) { |
||||||
|
timeout := 2 * time.Second |
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout) |
||||||
|
|
||||||
|
defer cancel() |
||||||
|
|
||||||
|
return m.zone.zones.resolver.LookupNetIP(ctx, "ip", m.FullName()) |
||||||
|
} |
||||||
|
|
||||||
|
func (m *Machine) updatePublicAddresses() error { |
||||||
|
addrs, err := m.lookupNetIP() |
||||||
|
if err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
|
||||||
|
m.PublicAddresses = addrs |
||||||
|
return nil |
||||||
|
} |
Loading…
Reference in new issue