mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
feat: 应用更新端口之后放开相应防火墙端口 (#563)
This commit is contained in:
parent
1bba2664b6
commit
cca1406f0f
@ -221,27 +221,35 @@ func (a *AppInstallService) Update(req request.AppInstalledUpdate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
changePort := false
|
changePort := false
|
||||||
|
var (
|
||||||
|
oldPorts []int
|
||||||
|
newPorts []int
|
||||||
|
)
|
||||||
port, ok := req.Params["PANEL_APP_PORT_HTTP"]
|
port, ok := req.Params["PANEL_APP_PORT_HTTP"]
|
||||||
if ok {
|
if ok {
|
||||||
portN := int(math.Ceil(port.(float64)))
|
portN := int(math.Ceil(port.(float64)))
|
||||||
if portN != installed.HttpPort {
|
if portN != installed.HttpPort {
|
||||||
|
oldPorts = append(oldPorts, installed.HttpPort)
|
||||||
changePort = true
|
changePort = true
|
||||||
httpPort, err := checkPort("PANEL_APP_PORT_HTTP", req.Params)
|
httpPort, err := checkPort("PANEL_APP_PORT_HTTP", req.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
installed.HttpPort = httpPort
|
installed.HttpPort = httpPort
|
||||||
|
newPorts = append(newPorts, httpPort)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ports, ok := req.Params["PANEL_APP_PORT_HTTPS"]
|
ports, ok := req.Params["PANEL_APP_PORT_HTTPS"]
|
||||||
if ok {
|
if ok {
|
||||||
portN := int(math.Ceil(ports.(float64)))
|
portN := int(math.Ceil(ports.(float64)))
|
||||||
if portN != installed.HttpsPort {
|
if portN != installed.HttpsPort {
|
||||||
|
oldPorts = append(oldPorts, installed.HttpsPort)
|
||||||
httpsPort, err := checkPort("PANEL_APP_PORT_HTTPS", req.Params)
|
httpsPort, err := checkPort("PANEL_APP_PORT_HTTPS", req.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
installed.HttpsPort = httpsPort
|
installed.HttpsPort = httpsPort
|
||||||
|
newPorts = append(newPorts, httpsPort)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,6 +294,11 @@ func (a *AppInstallService) Update(req request.AppInstalledUpdate) error {
|
|||||||
return buserr.WithErr(constant.ErrUpdateBuWebsite, err)
|
return buserr.WithErr(constant.ErrUpdateBuWebsite, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if changePort {
|
||||||
|
go func() {
|
||||||
|
_ = OperateFirewallPort(oldPorts, newPorts)
|
||||||
|
}()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user