Пример #1
0
def validate_dealine(self):
    # 获取已经过期的port
    port_service.check_port_date()
    overdue = port_service.get_overdue_ports()
    # 先查一下这些端口是否在开放,如果开发就将他关闭
    if Linux.check_ports_open(overdue):
        print("The overdue ports %s" % (overdue, ))
        # 将这些端口墙了
        Linux.delete_port(overdue)
    for port in overdue:
        # 移除端口
        manager.remove_port({'server_port': port})
Пример #2
0
def destroy_port_info(dic=None):
    if dic is not None:
        load_dict = jfileutl.get_dict()
        # 去除所有的端口数据
        port_password = load_dict.get("port_password")
        for port, data in port_password.items():
            if data.get("id") == dic.get("id"):
                # 写入bak的delConfig中
                jfileutl.write_file_to_bak(port_password[port])
                # 把它有效至为1就行
                del port_password[port]
                break
        # 将指定端口墙了
        Linux.delete_port([dic.get("server_port")])
        # 更新到文件中去
        jfileutl.write_file(load_dict)
        # 重启ssr
        Linux.restart_ssr()
    else:
        print("The agr can`t be null")
Пример #3
0
def overdue_port_info(dic=None):
    if dic is not None:
        load_dict = jfileutl.get_dict()
        # 去除所有的端口数据
        port_password = load_dict.get("port_password")
        for port, data in port_password.items():
            if data.get("id") == dic.get("id"):
                # 把它有效至为1就行
                port_password[port]['flowMark'] = 1
                port_password[port]['dateMark'] = 1
                port_password[port]['used'] = port_password[port]['total']
                port_password[port]['remain'] = 0
                port_password[port]['endTm'] = datetime.strftime(
                    datetime.now(), "%Y-%m-%d")
                break
        # 将指定端口墙了
        if Linux.delete_port([dic.get("server_port")]):
            pass
        # 更新到文件中去
        jfileutl.write_file(load_dict)
        # 重启ssr
        Linux.restart_ssr()
    else:
        print("The agr can`t be null")