コード例 #1
0
ファイル: server.py プロジェクト: wflk/maltrail
    def update_timer():
        retries = 0
        while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection(
        ):
            sys.stdout.write(
                "[!] can't update because of lack of network connection (waiting..."
                if not retries else '.')
            sys.stdout.flush()
            time.sleep(10)
            retries += 1

        if retries:
            print(")")

        if retries == CHECK_CONNECTION_MAX_RETRIES:
            print("[x] going to continue without update")
        else:
            if config.USE_SERVER_UPDATE_TRAILS:
                update_trails()

            update_ipcat()

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #2
0
    def update_timer():
        retries = 0
        if not config.no_updates:
            while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection():
                sys.stdout.write("[!] can't update because of lack of Internet connection (waiting..." if not retries else '.')
                sys.stdout.flush()
                time.sleep(10)
                retries += 1

            if retries:
                print(")")

        if config.no_updates or retries == CHECK_CONNECTION_MAX_RETRIES:
            if retries == CHECK_CONNECTION_MAX_RETRIES:
                print("[x] going to continue without online update")
            _ = update_trails(offline=True)
        else:
            _ = update_trails(server=config.UPDATE_SERVER)
            update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #3
0
    def update_timer():
        if config.USE_SERVER_UPDATE_TRAILS:
            update_trails()

        update_ipcat()

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #4
0
ファイル: server.py プロジェクト: beelives/maltrail
    def update_timer():
        if config.USE_SERVER_UPDATE_TRAILS:
            update_trails()

        update_ipcat()

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #5
0
def update_timer():
    retries = 0
    if not config.no_updates:  # 判断是否设置不更新,然后会利用抓取页面检测网络状态
        while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection(
        ):
            sys.stdout.write(
                "[!] can't update because of lack of Internet connection (waiting..."
                if not retries else '.')
            sys.stdout.flush()
            log_error(
                "[!] can't update because of lack of Internet connection (waiting...",
                "Warning")
            time.sleep(10)
            retries += 1

        if retries:
            print(")")
    # 超出次数,那么使用update_trails的离线模式
    if config.no_updates or retries == CHECK_CONNECTION_MAX_RETRIES:
        if retries == CHECK_CONNECTION_MAX_RETRIES:
            print("[x] going to continue without online update")
            log_error("[x] going to continue without online update", "Warning")
        _ = update_trails(offline=True)
    else:  # 正常进入
        _ = update_trails()
        # update_ipcat()
    # 有新的trails
    if _:
        trails.clear()
        trails.update(_)
    elif not trails:  # load_trails()只是加载trails()进内存
        _ = load_trails()
        trails.update(_)

    _regex = ""
    for trail in trails:
        if "static" in trails[trail][1]:
            if re.search(r"[\].][*+]|\[[a-z0-9_.\-]+\]", trail, re.I):
                try:
                    re.compile(trail)
                except:
                    pass
                else:
                    if re.escape(trail) != trail:
                        index = _regex.count("(?P<g")
                        if index < 100:  # Reference: https://stackoverflow.com/questions/478458/python-regular-expressions-with-more-than-100-groups
                            _regex += "|(?P<g%s>%s)" % (index, trail)

    trails._regex = _regex.strip('|')
コード例 #6
0
ファイル: sensor.py プロジェクト: kele2016/maltrail
    def update_timer():
        retries = 0
        while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection():
            sys.stdout.write("[!] can't update because of lack of network connection (waiting..." if not retries else '.')
            sys.stdout.flush()
            time.sleep(10)
            retries += 1

        if retries:
            print(")")

        if retries == CHECK_CONNECTION_MAX_RETRIES:
            print("[x] going to continue without update")
            _ = {}
        else:
            _ = update_trails(server=config.UPDATE_SERVER)

            update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #7
0
    def update_timer():
        retries = 0
        while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection(
        ):
            sys.stdout.write(
                "[!] can't update because of lack of network connection (waiting..."
                if not retries else '.')
            sys.stdout.flush()
            time.sleep(10)
            retries += 1

        if retries:
            print(")")

        if retries == CHECK_CONNECTION_MAX_RETRIES:
            print("[x] going to continue without update")
            _tmp_trails = {}
        else:
            _tmp_trails = update_trails(server=config.UPDATE_SERVER)
            #if config.USE_SERVER_UPDATE_TRAILS:
            #update_trails()

        if _tmp_trails:
            trails.clear()
            trails.update(_tmp_trails)
        elif not trails:
            trails.update(load_trails())

        server_call()
        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #8
0
ファイル: server.py プロジェクト: stamparm/maltrail
    def update_timer():
        retries = 0
        while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection():
            sys.stdout.write("[!] can't update because of lack of Internet connection (waiting..." if not retries else '.')
            sys.stdout.flush()
            time.sleep(10)
            retries += 1

        if retries:
            print(")")

        if retries == CHECK_CONNECTION_MAX_RETRIES:
            print("[x] going to continue without online update")
            _ = update_trails(offline=True)
        else:
            _ = update_trails()
            update_ipcat()

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #9
0
ファイル: server.py プロジェクト: yekeqiang/maltrail
    def update_timer():
        first = True
        while not check_connection():
            sys.stdout.write(
                "[!] can't update because of lack of network connection (waiting..."
                if first else '.')
            sys.stdout.flush()
            time.sleep(60)
            first = False

        if not first:
            print(")")

        if config.USE_SERVER_UPDATE_TRAILS:
            update_trails()

        update_ipcat()

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #10
0
ファイル: sensor.py プロジェクト: pang-w/maltrail
    def update_timer():
        _ = update_trails(server=config.UPDATE_SERVER)

        update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #11
0
    def update_timer():
        _ = update_trails(server=config.UPDATE_SERVER)

        update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #12
0
ファイル: server.py プロジェクト: Tybbow/maltrail
    def update_timer():
        retries = 0
        while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection():
            sys.stdout.write(
                "[!] can't update because of lack of network connection (waiting..." if not retries else "."
            )
            sys.stdout.flush()
            time.sleep(10)
            retries += 1

        if retries:
            print(")")

        if retries == CHECK_CONNECTION_MAX_RETRIES:
            print("[x] going to continue without update")
        else:
            if config.USE_SERVER_UPDATE_TRAILS:
                update_trails()

            update_ipcat()

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
コード例 #13
0
ファイル: sensor.py プロジェクト: OneOaaS/maltrail
    def update_timer():
        first = True
        while not check_connection():
            sys.stdout.write("[!] can't update because of lack of network connection (waiting..." if first else '.')
            sys.stdout.flush()
            time.sleep(60)
            first = False

        if not first:
            print(")")

        _ = update_trails(server=config.UPDATE_SERVER)

        update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()