It's state, not config.
This commit is contained in:
@@ -65,8 +65,8 @@ func (api *API) DnsmasqGenerate(w http.ResponseWriter, r *http.Request) {
|
||||
overwrite := r.URL.Query().Get("overwrite") == "true"
|
||||
|
||||
// Load global config
|
||||
globalConfigPath := api.getGlobalConfigPath()
|
||||
globalCfg, err := config.LoadGlobalConfig(globalConfigPath)
|
||||
globalConfigPath := api.statePath()
|
||||
globalCfg, err := config.LoadState(globalConfigPath)
|
||||
if err != nil {
|
||||
respondError(w, http.StatusInternalServerError, fmt.Sprintf("Failed to load global config: %v", err))
|
||||
return
|
||||
@@ -174,8 +174,8 @@ func writeConfigFile(path, content string) error {
|
||||
// updateDnsmasqConfig regenerates the main dnsmasq config from global config and restarts.
|
||||
// Instance-specific DNS records are managed via service registration (not here).
|
||||
func (api *API) updateDnsmasqConfig() error {
|
||||
globalConfigPath := api.getGlobalConfigPath()
|
||||
globalCfg, err := config.LoadGlobalConfig(globalConfigPath)
|
||||
globalConfigPath := api.statePath()
|
||||
globalCfg, err := config.LoadState(globalConfigPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("loading global config: %w", err)
|
||||
}
|
||||
@@ -184,9 +184,9 @@ func (api *API) updateDnsmasqConfig() error {
|
||||
return api.dnsmasq.UpdateConfig(globalCfg, nil, true)
|
||||
}
|
||||
|
||||
// getGlobalConfigPath returns the path to the global config file
|
||||
func (api *API) getGlobalConfigPath() string {
|
||||
return api.dataDir + "/config.yaml"
|
||||
// statePath returns the path to the global state file
|
||||
func (api *API) statePath() string {
|
||||
return api.dataDir + "/state.yaml"
|
||||
}
|
||||
|
||||
// DHCPLease represents an active DHCP lease from the dnsmasq leases file
|
||||
@@ -259,7 +259,7 @@ func (api *API) DnsmasqDHCPAddStatic(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
globalConfigPath := api.getGlobalConfigPath()
|
||||
globalConfigPath := api.statePath()
|
||||
if err := api.addDHCPStaticLease(globalConfigPath, req); err != nil {
|
||||
respondError(w, http.StatusInternalServerError, fmt.Sprintf("Failed to add static lease: %v", err))
|
||||
return
|
||||
@@ -280,7 +280,7 @@ func (api *API) DnsmasqDHCPDeleteStatic(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
globalConfigPath := api.getGlobalConfigPath()
|
||||
globalConfigPath := api.statePath()
|
||||
if err := api.removeDHCPStaticLease(globalConfigPath, mac); err != nil {
|
||||
respondError(w, http.StatusInternalServerError, fmt.Sprintf("Failed to remove static lease: %v", err))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user