This commit is contained in:
Adam Ierymenko 2019-09-22 22:25:55 -07:00
commit 536bc59abb
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
5 changed files with 390 additions and 55 deletions

View file

@ -130,6 +130,7 @@ type NetworkLocalSettings struct {
type Network struct {
node *Node
id NetworkID
mac MAC
tap Tap
config NetworkConfig
settings NetworkLocalSettings // locked by configLock
@ -143,6 +144,7 @@ func newNetwork(node *Node, id NetworkID, t Tap) (*Network, error) {
n := &Network{
node: node,
id: id,
mac: NewMACForNetworkMember(node.Identity().address, id),
tap: t,
config: NetworkConfig{
ID: id,
@ -172,6 +174,12 @@ func newNetwork(node *Node, id NetworkID, t Tap) (*Network, error) {
// ID gets this network's unique ID
func (n *Network) ID() NetworkID { return n.id }
// MAC returns the assigned MAC address of this network
func (n *Network) MAC() MAC { return n.mac }
// Tap gets this network's tap device
func (n *Network) Tap() Tap { return n.tap }
// Config returns a copy of this network's current configuration
func (n *Network) Config() NetworkConfig {
n.configLock.RLock()
@ -179,9 +187,6 @@ func (n *Network) Config() NetworkConfig {
return n.config
}
// Tap gets this network's tap device
func (n *Network) Tap() Tap { return n.tap }
// SetLocalSettings modifies this network's local settings
func (n *Network) SetLocalSettings(ls *NetworkLocalSettings) { n.updateConfig(nil, ls) }