fix: WAN network support was broken

This commit is contained in:
Mateusz Filipowicz
2025-02-06 23:30:34 +01:00
parent 4be261d2a8
commit c393dcbe71
8 changed files with 13 additions and 8 deletions

3
.gitignore vendored
View File

@@ -3,3 +3,6 @@
# goreleaser
/dist/
.idea
*.iml

View File

@@ -1,6 +1,6 @@
# Unifi Go SDK [![GoDoc](https://godoc.org/github.com/paultyng/go-unifi?status.svg)](https://godoc.org/github.com/paultyng/go-unifi)
# Unifi Go SDK [![GoDoc](https://godoc.org/github.com/filipowm/go-unifi?status.svg)](https://godoc.org/github.com/filipowm/go-unifi)
This was written primarily for use in my [Terraform provider for Unifi](https://github.com/paultyng/terraform-provider-unifi).
This was written primarily for use in my [Terraform provider for Unifi](https://github.com/filipowm/terraform-provider-unifi).
## Versioning

View File

@@ -431,6 +431,8 @@ func generateCode(fieldsDir string, outDir string) error {
f.CustomUnmarshalType = "*bool"
f.CustomUnmarshalFunc = "emptyBoolToTrue"
}
case "WANUsername", "XWANPassword":
f.OmitEmpty = true
}
return nil
}

2
go.mod
View File

@@ -1,4 +1,4 @@
module github.com/paultyng/go-unifi
module github.com/filipowm/go-unifi
go 1.22.1

View File

@@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"
"github.com/paultyng/go-unifi/unifi"
"github.com/filipowm/go-unifi/unifi"
"github.com/tj/assert"
)

View File

@@ -231,7 +231,7 @@ type Network struct {
WANSmartqUpRate int `json:"wan_smartq_up_rate,omitempty"` // [0-9]{1,6}|1000000
WANType string `json:"wan_type,omitempty"` // disabled|dhcp|static|pppoe|dslite
WANTypeV6 string `json:"wan_type_v6,omitempty"` // disabled|slaac|dhcpv6|static
WANUsername string `json:"wan_username"` // [^"' ]+|^$
WANUsername string `json:"wan_username,omitempty"` // [^"' ]+|^$
WANVLAN int `json:"wan_vlan,omitempty"` // [0-9]|[1-9][0-9]{1,2}|[1-3][0-9]{3}|40[0-8][0-9]|409[0-4]|^$
WANVLANEnabled bool `json:"wan_vlan_enabled"`
WireguardClientConfigurationFile string `json:"wireguard_client_configuration_file,omitempty"`
@@ -257,7 +257,7 @@ type Network struct {
XServerKey string `json:"x_server_key,omitempty"`
XSharedClientCrt string `json:"x_shared_client_crt,omitempty"`
XSharedClientKey string `json:"x_shared_client_key,omitempty"`
XWANPassword string `json:"x_wan_password"` // [^"' ]+|^$
XWANPassword string `json:"x_wan_password,omitempty"` // [^"' ]+|^$
XWireguardPrivateKey string `json:"x_wireguard_private_key,omitempty"`
}

View File

@@ -5,7 +5,7 @@ import (
"reflect"
"testing"
"github.com/paultyng/go-unifi/unifi"
"github.com/filipowm/go-unifi/unifi"
)
func TestNetworkUnmarshalJSON(t *testing.T) {

View File

@@ -2,4 +2,4 @@
package unifi
const UnifiVersion = "9.0.108"
const UnifiVersion = "9.0.114"