mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-13 02:55:18 +08:00
feat:firewalld和ufw同时存在时,不进行操作 (#6688)
Co-authored-by: zengzz01 <zengzz01@mingyuanyun.com>
This commit is contained in:
parent
5374afb226
commit
175b7b89e4
1 changed files with 9 additions and 2 deletions
|
@ -29,10 +29,17 @@ type FirewallClient interface {
|
|||
}
|
||||
|
||||
func NewFirewallClient() (FirewallClient, error) {
|
||||
if _, err := os.Stat("/usr/sbin/firewalld"); err == nil {
|
||||
_, firewalldErr := os.Stat("/usr/sbin/firewalld")
|
||||
_, ufwErr := os.Stat("/usr/sbin/ufw")
|
||||
|
||||
if firewalldErr == nil && ufwErr == nil {
|
||||
return nil, buserr.New("firewalld and ufw both found, only one firewall should be active")
|
||||
}
|
||||
|
||||
if firewalldErr == nil {
|
||||
return client.NewFirewalld()
|
||||
}
|
||||
if _, err := os.Stat("/usr/sbin/ufw"); err == nil {
|
||||
if ufwErr == nil {
|
||||
return client.NewUfw()
|
||||
}
|
||||
return nil, buserr.New(constant.ErrFirewall)
|
||||
|
|
Loading…
Reference in a new issue