You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
821 B
44 lines
821 B
package zones |
|
|
|
import ( |
|
"net/netip" |
|
"strings" |
|
) |
|
|
|
// A Machine is a machine on a Zone |
|
type Machine struct { |
|
zone *Zone |
|
ID int |
|
Name string `toml:"name"` |
|
|
|
PublicAddresses []netip.Addr `toml:"public,omitempty"` |
|
Rings []*RingInfo `toml:"rings,omitempty"` |
|
} |
|
|
|
func (m *Machine) String() string { |
|
return m.Name |
|
} |
|
|
|
// FullName returns the Name of the machine including domain name |
|
func (m *Machine) FullName() string { |
|
if domain := m.zone.zones.domain; domain != "" { |
|
var s = []string{ |
|
m.Name, |
|
domain, |
|
} |
|
|
|
return strings.Join(s, ".") |
|
} |
|
|
|
return m.Name |
|
} |
|
|
|
// IsGateway tells if the Machine is a ring0 gateway |
|
func (m *Machine) IsGateway() bool { |
|
_, ok := m.getRingInfo(0) |
|
return ok |
|
} |
|
|
|
func (m *Machine) getPeerByName(name string) (*Machine, bool) { |
|
return m.zone.zones.GetMachineByName(name) |
|
}
|
|
|