Skip to content

Commit 154b3ec

Browse files
committed
Exposes broadcast and multicast settings on Network
There was a few settings on the network that are exposed on the ZeroTier Central UI which were not available on the provider. This commit includes those extra fields, where one of them are not documented but available on the UI.
1 parent a086b8e commit 154b3ec

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

zerotier/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type V6AssignModeConfig struct {
4040
type Config struct {
4141
Name string `json:"name"`
4242
Private bool `json:"private"`
43+
EnableBroadcast bool `json:"enableBroadcast"`
44+
MulticastLimit int `json:"multicastLimit"`
4345
Routes []Route `json:"routes"`
4446
IpAssignmentPools []IpRange `json:"ipAssignmentPools"`
4547
V4AssignMode V4AssignModeConfig `json:"v4AssignMode"`

zerotier/resource_zerotier_network.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/hashicorp/terraform/helper/hashcode"
1010
"github.com/hashicorp/terraform/helper/schema"
11+
"github.com/hashicorp/terraform/helper/validation"
1112
)
1213

1314
func route() *schema.Resource {
@@ -83,6 +84,20 @@ func resourceZeroTierNetwork() *schema.Resource {
8384
Optional: true,
8485
Default: true,
8586
},
87+
//Warning: Undecoumented on the API, but that is how the UI manages it
88+
"broadcast": &schema.Schema{
89+
Type: schema.TypeBool,
90+
Description: "Enable network broadcast (ff:ff:ff:ff:ff:ff)",
91+
Optional: true,
92+
Default: true,
93+
},
94+
"multicast_limit": &schema.Schema{
95+
Type: schema.TypeInt,
96+
Description: "The maximum number of recipients that can receive an Ethernet multicast or broadcast. Setting to 0 disables multicast, but be aware that only IPv6 with NDP emulation (RFC4193 or 6PLANE addressing modes) or other unicast-only protocols will work without multicast.",
97+
Optional: true,
98+
Default: 32,
99+
ValidateFunc: validation.IntAtLeast(0),
100+
},
86101
"route": &schema.Schema{
87102
Type: schema.TypeSet,
88103
Optional: true,
@@ -163,8 +178,10 @@ func fromResourceData(d *schema.ResourceData) (*Network, error) {
163178
RulesSource: d.Get("rules_source").(string),
164179
Description: d.Get("description").(string),
165180
Config: &Config{
166-
Name: d.Get("name").(string),
167-
Private: d.Get("private").(bool),
181+
Name: d.Get("name").(string),
182+
Private: d.Get("private").(bool),
183+
EnableBroadcast: d.Get("broadcast").(bool),
184+
MulticastLimit: d.Get("multicast_limit").(int),
168185
V4AssignMode: V4AssignModeConfig{
169186
ZT: d.Get("auto_assign_v4").(bool),
170187
},
@@ -214,6 +231,8 @@ func resourceNetworkRead(d *schema.ResourceData, m interface{}) error {
214231
d.Set("name", net.Config.Name)
215232
d.Set("description", net.Description)
216233
d.Set("private", net.Config.Private)
234+
d.Set("broadcast", net.Config.EnableBroadcast)
235+
d.Set("multicast_limit", net.Config.MulticastLimit)
217236
d.Set("auto_assign_v4", net.Config.V4AssignMode.ZT)
218237
d.Set("auto_assign_v6", net.Config.V6AssignMode.ZT)
219238
d.Set("auto_assign_6plane", net.Config.V6AssignMode.SixPLANE)

0 commit comments

Comments
 (0)