zoraxy-dhcp/models.go

55 lines
1.3 KiB
Go

package main
import "time"
// Lease represents a single line from dnsmasq's lease file.
// Format: <timestamp> <mac> <ip> <hostname> <client-id>
type Lease struct {
Expiry time.Time
MAC string
IP string
Hostname string
ClientID string
}
// PinRequest is the JSON body for pin/unpin API calls.
type PinRequest struct {
MAC string `json:"mac"`
IP string `json:"ip"`
Hostname string `json:"hostname"`
}
// PinStatus indicates whether a lease is permanent (pinned).
type PinStatus string
const (
PinStatusActive PinStatus = "active"
PinStatusPermanent PinStatus = "permanent"
)
// LeaseEntry is the combined view sent to the frontend.
type LeaseEntry struct {
Hostname string `json:"hostname"`
IP string `json:"ip"`
MAC string `json:"mac"`
Expiry time.Time `json:"expiry"`
Status PinStatus `json:"status"`
}
// LeasesResponse is the JSON response for GET /ui/api/leases.
type LeasesResponse struct {
Leases []LeaseEntry `json:"leases"`
PinnedCount int `json:"pinned_count"`
ActiveCount int `json:"active_count"`
}
// PinResponse is the JSON response after a pin/unpin action.
type PinResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
}
// ErrorResponse is a generic error JSON response.
type ErrorResponse struct {
Error string `json:"error"`
}