14.04.2026 Update
This commit is contained in:
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"alpine-router/config"
|
||||
"alpine-router/nat"
|
||||
"nano-router/config"
|
||||
"nano-router/nat"
|
||||
)
|
||||
|
||||
func HandleNATGet(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -46,16 +46,26 @@ func HandleNATSave(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := nat.Save(&cfg); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "save: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
appCfg, err := config.Load()
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "load config.yaml: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
for _, ifaceName := range cfg.Interfaces {
|
||||
if appCfg.Interfaces != nil {
|
||||
if ic, ok := appCfg.Interfaces[ifaceName]; ok && ic.Type == "wan" {
|
||||
fail(w, http.StatusBadRequest, "WAN interface "+ifaceName+" cannot have NAT/Masquerade")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := nat.Save(&cfg); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "save: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
appCfg.NAT.Interfaces = cfg.Interfaces
|
||||
if err := config.Save(appCfg); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "save config.yaml: "+err.Error())
|
||||
|
||||
Reference in New Issue
Block a user