MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / firewallUpdatePort

Function firewallUpdatePort

core/utils/firewall/firewall.go:32–41  ·  view source on GitHub ↗
(oldPort, newPort string)

Source from the content-addressed store, hash-verified

30}
31
32func firewallUpdatePort(oldPort, newPort string) error {
33 stdout, err := cmd.NewCommandMgr().RunWithStdout("firewall-cmd", "--zone=public", "--add-port="+newPort+"/tcp", "--permanent")
34 if err != nil {
35 return fmt.Errorf("add (port: %s/tcp) failed, err: %s", newPort, stdout)
36 }
37
38 _, _ = cmd.NewCommandMgr().RunWithStdout("firewall-cmd", "--zone=public", "--remove-port="+oldPort+"/tcp", "--permanent")
39 _, _ = cmd.NewCommandMgr().RunWithStdout("firewall-cmd", "--reload")
40 return nil
41}
42
43func ufwUpdatePort(oldPort, newPort string) error {
44 stdout, err := cmd.NewCommandMgr().RunWithStdout("ufw", "allow", newPort)

Callers 1

UpdatePortFunction · 0.85

Calls 1

RunWithStdoutMethod · 0.45

Tested by

no test coverage detected