forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_network.go
36 lines (30 loc) · 893 Bytes
/
custom_network.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package net
import (
boship "github.com/cloudfoundry/bosh-agent/platform/net/ip"
boshsettings "github.com/cloudfoundry/bosh-agent/settings"
)
type dnsConfigArg struct {
DNSServers []string
}
type customNetwork struct {
boshsettings.Network
Interface string
NetworkIP string
Broadcast string
HasDefaultGateway bool
}
type networkInterfaceConfigArg struct {
DNSServers []string
Networks []customNetwork
HasDNSNameServers bool
}
func (c customNetwork) ToInterfaceAddress() boship.InterfaceAddress {
return boship.NewSimpleInterfaceAddress(c.Interface, c.IP)
}
// toInterfaceAddresses bulk converts customNetworks to InterfaceAddresses
func toInterfaceAddresses(networks []customNetwork) (addresses []boship.InterfaceAddress) {
for _, network := range networks {
addresses = append(addresses, network.ToInterfaceAddress())
}
return
}