| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package dhcp
- import "time"
- // DHCPServerInstance represents an interface-bound DHCP server
- type DHCPServerInstance struct {
- ID string `json:"id"`
- Name string `json:"name"` // e.g. "dhcp1", "defconf"
- Interface string `json:"interface"` // e.g. "bridge1", "eth0"
- Network string `json:"network"` // Assigned DHCP Network CIDR or ID e.g. "192.168.88.0/24"
- LeaseTime string `json:"lease_time"` // e.g. "12h", "1d", "30m"
- AddressPool string `json:"address_pool"` // e.g. "192.168.88.10-192.168.88.254"
- Authoritative bool `json:"authoritative"` // default true
- Disabled bool `json:"disabled"` // 'X' flag
- Comment string `json:"comment,omitempty"`
- // Runtime telemetry
- Running bool `json:"running"`
- ActiveLeases int `json:"active_leases"`
- }
- // DHCPNetwork defines options and gateway for a specific subnet (/ip dhcp-server network)
- type DHCPNetwork struct {
- ID string `json:"id"`
- Address string `json:"address"` // CIDR e.g. "192.168.88.0/24"
- Gateway string `json:"gateway"` // Option 3 (Router IP)
- Netmask string `json:"netmask"` // Netmask e.g. "255.255.255.0" or "24"
- DNSServers []string `json:"dns_servers"` // Option 6
- Domain string `json:"domain"` // Option 15
- NTPServers []string `json:"ntp_servers"` // Option 42 (requested by user)
- NextServer string `json:"next_server"` // Option 66 / TFTP server IP/hostname (requested by user)
- BootFileName string `json:"boot_file_name"`// Option 67 / PXE boot filename
- WINSServers []string `json:"wins_servers"` // Option 44
- DHCPOptions []string `json:"dhcp_options"` // Linked custom option IDs
- Comment string `json:"comment,omitempty"`
- }
- // DHCPLease represents an active dynamic lease or static reservation (/ip dhcp-server lease)
- type DHCPLease struct {
- ID string `json:"id"`
- Address string `json:"address"` // Assigned IP
- MACAddress string `json:"mac_address"` // Format "aa:bb:cc:dd:ee:ff"
- ClientID string `json:"client_id,omitempty"`
- Server string `json:"server"` // Server name or "all"
- HostName string `json:"hostname"`
- ExpiresIn string `json:"expires_in"` // e.g. "11h 45m" or "never"
- ExpiresAt time.Time `json:"expires_at"`
- Dynamic bool `json:"dynamic"` // true=from dnsmasq.leases, false=static reservation
- Status string `json:"status"` // "bound", "static", "waiting"
- Disabled bool `json:"disabled"`
- Comment string `json:"comment,omitempty"`
- }
- // DHCPOption represents a raw or typed custom DHCP option (/ip dhcp-server option)
- type DHCPOption struct {
- ID string `json:"id"`
- Name string `json:"name"` // e.g. "unifi-controller", "voip-tftp"
- Code int `json:"code"` // Option code (1 - 254)
- Value string `json:"value"` // Raw IP, text, hex or option string
- Comment string `json:"comment,omitempty"`
- }
- // DHCPServerSummary provides aggregated statistics for KPI cards & sidebar badges
- type DHCPServerSummary struct {
- TotalServers int `json:"total_servers"`
- ActiveServers int `json:"active_servers"`
- TotalNetworks int `json:"total_networks"`
- ActiveLeases int `json:"active_leases"`
- StaticLeases int `json:"static_leases"`
- TotalOptions int `json:"total_options"`
- }
- // DHCPServerConfigStore wraps JSON persistence
- type DHCPServerConfigStore struct {
- Servers []DHCPServerInstance `json:"servers"`
- Networks []DHCPNetwork `json:"networks"`
- StaticLeases []DHCPLease `json:"static_leases"`
- Options []DHCPOption `json:"options"`
- }
- // DHCPServerSetupRequest is used by the MikroTik-style 1-click DHCP Setup Wizard
- type DHCPServerSetupRequest struct {
- Interface string `json:"interface"` // e.g. "bridge1"
- AddressSpace string `json:"address_space"` // e.g. "192.168.88.0/24"
- Gateway string `json:"gateway"` // e.g. "192.168.88.1"
- AddressPool string `json:"address_pool"` // e.g. "192.168.88.10-192.168.88.254"
- DNSServers []string `json:"dns_servers"` // e.g. ["192.168.88.1", "1.1.1.1"]
- LeaseTime string `json:"lease_time"` // e.g. "12h"
- Domain string `json:"domain,omitempty"` // e.g. "lan"
- NTPServers []string `json:"ntp_servers,omitempty"` // e.g. ["192.168.88.1"]
- NextServer string `json:"next_server,omitempty"` // e.g. "192.168.88.50"
- BootFileName string `json:"boot_file_name,omitempty"`// e.g. "pxelinux.0"
- }
|