コード例 #1
0
def check_firewall():
    try:
        if not os.path.exists('/usr/sbin/firewalld'): return False
        data = public.M('firewall').field('port,ps').select()
        import firewalld, firewalls
        fs = firewalls.firewalls()
        accept_ports = firewalld.firewalld().GetAcceptPortList()

        port_list = []
        for port_info in accept_ports:
            if port_info['port'] in port_list:
                continue
            port_list.append(port_info['port'])

        n = 0
        for p in data:
            if p['port'].find('.') != -1:
                continue
            if p['port'] in port_list:
                continue
            fs.AddAcceptPortAll(p['port'], p['ps'])
            n += 1
        #重载
        if n: fs.FirewallReload()
    except:
        pass
コード例 #2
0
ファイル: jobs.py プロジェクト: wengmq/BaoTa
def check_firewall():
    data = public.M('firewall').field('port,ps').select()
    import firewalld, firewalls
    fs = firewalls.firewalls()
    accept_ports = firewalld.firewalld().GetAcceptPortList()

    port_list = []
    for port_info in accept_ports:
        if port_info['port'] in port_list:
            continue
        port_list.append(port_info['port'])

    print(port_list)
    n = 0
    for p in data:
        if p['port'].find('.') != -1:
            continue
        if p['port'] in port_list:
            continue
        print(p['port'])
        print(fs.AddAcceptPortAll(p['port'], p['ps']))
        n += 1

    #重载
    if n: fs.FirewallReload()
コード例 #3
0
ファイル: firewalls.py プロジェクト: WytheLi/panel
 def __init__(self):
     if os.path.exists('/usr/sbin/firewalld'): self.__isFirewalld = True
     if os.path.exists('/usr/sbin/ufw'): self.__isUfw = True
     if self.__isFirewalld:
         try:
             self.__Obj = firewalld.firewalld()
             self.GetList()
         except:
             pass
コード例 #4
0
ファイル: firewalls.py プロジェクト: soitun/BaoTa-Panel
 def __init__(self):
     if os.path.exists('/usr/sbin/firewalld'): self.__isFirewalld = True
     if os.path.exists('/usr/sbin/ufw'): self.__isUfw = True
     if self.__isFirewalld:
         try:
             self.__Obj = firewalld.firewalld();
             self.GetList();
         except:
             pass
コード例 #5
0
 def __init__(self):
     if os.path.exists('/usr/sbin/firewalld'): self.__isFirewalld = True
     if os.path.exists('/usr/sbin/ufw'): self.__isUfw = True
     public.M('firewall').execute("alter table firewall add ports TEXT;",())
     public.M('firewall').execute("alter table firewall add protocol TEXT;",())
     public.M('firewall').execute("alter table firewall add address_ip TEXT;",())
     public.M('firewall').execute("alter table firewall add types TEXT;",())
     #这里判断的是Centos7 的系统
     if self.__isFirewalld:
         self.__Obj = firewalld.firewalld();
         # 获取列表信息
         self.GetList();