Beispiel #1
0
def traffic_job():
    with __lock:
        if not v2_util.is_running():
            return
        try:
            traffics = v2_util.get_inbounds_traffic()
            if not traffics:
                return
            for traffic in traffics:
                upload = int(traffic.get('uplink', 0))
                download = int(traffic.get('downlink', 0))
                tag = traffic['tag']
                Inbound.query.filter_by(tag=tag).update({'up': Inbound.up + upload, 'down': Inbound.down + download})
            db.session.commit()
        except Exception as e:
            logging.warning(f'traffic job error: {e}')
Beispiel #2
0
def traffic_job():
    # with __lock:
    if not v2_util.is_running():
        return
    try:
        traffics = v2_util.get_inbounds_traffic()
        if not traffics:
            return
        for traffic in traffics:
            upload = int(traffic.get("uplink", 0))
            download = int(traffic.get("downlink", 0))
            email = traffic["email"]
            Inbound.query.filter(Inbound.settings.contains(email)).update(
                {"up": Inbound.up + upload, "down": Inbound.down + download},
                synchronize_session=False,
            )
        db.session.commit()
    except Exception as e:
        logging.warning(f"traffic job error: {e}")
Beispiel #3
0
def check_v2ay_alive_job():
    if not v2_util.is_running():
        v2_util.restart(True)