use newer netip types

This commit is contained in:
Samuel Lorch 2023-04-23 19:40:11 +02:00
parent d4fc2116b5
commit 627a1105ee
3 changed files with 4 additions and 8 deletions

View file

@ -2,15 +2,14 @@ package network
import (
"encoding/json"
"nfsense.net/nfsense/internal/definitions/common"
"net/netip"
)
type Interface struct {
Alias string `json:"alias,omitempty" validate:"min=0,max=3"`
Type InterfaceType `json:"type" validate:"min=0,max=3"`
AddressingMode InterfaceAddressingMode `json:"addressing_mode" validate:"min=0,max=2"`
Address *common.IPCIDR `json:"address,omitempty" validate:"excluded_unless=AddressingMode 1"`
Address *netip.Prefix `json:"address,omitempty" validate:"excluded_unless=AddressingMode 1"`
HardwareDevice *string `json:"hardware_device,omitempty"`
// TODO fix Validator for int pointers with min=0,max=4094
VlanID *uint `json:"vlan_id,omitempty"`

View file

@ -2,14 +2,12 @@ package network
import (
"net/netip"
"nfsense.net/nfsense/internal/definitions/common"
)
type StaticRoute struct {
Name string `json:"name,omitempty"`
Interface string `json:"interface,omitempty"`
Gateway netip.Addr `json:"gateway,omitempty"`
Destination common.IPNet `json:"destination,omitempty"`
Destination netip.Prefix `json:"destination,omitempty"`
Metric uint `json:"metric,omitempty"`
}

View file

@ -5,7 +5,6 @@ import (
"net/netip"
"go4.org/netipx"
"nfsense.net/nfsense/internal/definitions/common"
)
type Address struct {
@ -13,7 +12,7 @@ type Address struct {
Comment string `json:"comment,omitempty"`
Host *netip.Addr `json:"host,omitempty" validate:"excluded_unless=Type 0"`
Range *netipx.IPRange `json:"range,omitempty" validate:"excluded_unless=Type 1"`
NetworkAddress *common.IPNet `json:"network,omitempty" validate:"excluded_unless=Type 2"`
NetworkAddress *netip.Prefix `json:"network,omitempty" validate:"excluded_unless=Type 2"`
Children *[]string `json:"children,omitempty"`
}