|
@@ -117,6 +117,7 @@ func (s *Server) setupRoutes() {
|
|
|
protected.GET("/dhcp/bindings", s.handleGetBindings)
|
|
protected.GET("/dhcp/bindings", s.handleGetBindings)
|
|
|
protected.POST("/dhcp/bindings", s.handleCreateBinding)
|
|
protected.POST("/dhcp/bindings", s.handleCreateBinding)
|
|
|
protected.DELETE("/dhcp/bindings/:id", s.handleDeleteBinding)
|
|
protected.DELETE("/dhcp/bindings/:id", s.handleDeleteBinding)
|
|
|
|
|
+ protected.POST("/dhcp/leases/evict", s.handleEvictClient)
|
|
|
|
|
|
|
|
// DNS
|
|
// DNS
|
|
|
protected.GET("/dns/config", s.handleGetDNSConfig)
|
|
protected.GET("/dns/config", s.handleGetDNSConfig)
|
|
@@ -282,6 +283,30 @@ func (s *Server) handleDeleteBinding(c *gin.Context) {
|
|
|
c.JSON(http.StatusOK, gin.H{"message": "Binding deleted"})
|
|
c.JSON(http.StatusOK, gin.H{"message": "Binding deleted"})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (s *Server) handleEvictClient(c *gin.Context) {
|
|
|
|
|
+ var req struct {
|
|
|
|
|
+ MAC string `json:"mac"`
|
|
|
|
|
+ IP string `json:"ip"`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if req.MAC == "" {
|
|
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": "MAC is required"})
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if err := s.dhcpServer.EvictClient(req.MAC); err != nil {
|
|
|
|
|
+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ c.JSON(http.StatusOK, gin.H{"message": "Client evicted successfully"})
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (s *Server) handleGetRecords(c *gin.Context) {
|
|
func (s *Server) handleGetRecords(c *gin.Context) {
|
|
|
records, err := s.dnsServer.GetDNSRecords()
|
|
records, err := s.dnsServer.GetDNSRecords()
|
|
|
if err != nil {
|
|
if err != nil {
|