Skip to content

Commit

Permalink
feat(面板设置): 修改端口时自动放行
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Nov 9, 2023
1 parent e56fcac commit b769032
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/http/controllers/setting_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ func (r *SettingController) Update(ctx http.Context) http.Response {
port := cast.ToString(updateRequest.Port)
if oldPort != port {
tools.Exec("sed -i 's/APP_PORT=" + oldPort + "/APP_PORT=" + port + "/g' /www/panel/panel.conf")
if tools.IsRHEL() {
tools.Exec("firewall-cmd --remove-port=" + cast.ToString(port) + "/tcp --permanent 2>&1")
tools.Exec("firewall-cmd --add-port=" + cast.ToString(port) + "/tcp --permanent 2>&1")
tools.Exec("firewall-cmd --reload")
} else {
tools.Exec("ufw delete allow " + cast.ToString(port) + "/tcp")
tools.Exec("ufw allow " + cast.ToString(port) + "/tcp")
tools.Exec("ufw reload")
}
}
oldEntrance := tools.Exec(`cat /www/panel/panel.conf | grep APP_ENTRANCE | awk -F '=' '{print $2}' | tr -d '\n'`)
entrance := cast.ToString(updateRequest.Entrance)
Expand Down

0 comments on commit b769032

Please sign in to comment.