def init(): schedule_job(check_v2_config_job, config.get_v2_config_check_interval()) schedule_job(traffic_job, config.get_traffic_job_interval()) reset_day = config.get_reset_traffic_day() if reset_day <= 0: return now = datetime.now() next_day = now.date() + timedelta(days=1) next_day = datetime.combine(next_day, datetime.min.time()) Timer((next_day - now).seconds + 5, reset_traffic_job).start()
def init(): schedule_job(check_v2_config_job, config.get_v2_config_check_interval()) schedule_job(traffic_job, config.get_traffic_job_interval())
def init(): schedule.every().day.at("00:00").do(update_config) schedule_job(check_v2_config_job, config.get_v2_config_check_interval()) schedule_job(traffic_job, config.get_traffic_job_interval())
def __get_net_tcp_udp_count(): conns = psutil.net_connections() tcp_count = 0 udp_count = 0 for conn in conns: if conn.type == 1: tcp_count += 1 elif conn.type == 2: udp_count += 1 return tcp_count, udp_count def net(): global __last_net_io cur_net_io = psutil.net_io_counters() sent = cur_net_io.bytes_sent recv = cur_net_io.bytes_recv up = (sent - __last_net_io.bytes_sent) / __get_interval down = (recv - __last_net_io.bytes_recv) / __get_interval tcp_count, udp_count = __get_net_tcp_udp_count() __status["net_io"] = {"up": up, "down": down} __status["net_traffic"] = {"sent": sent, "recv": recv} __status["tcp_count"] = tcp_count __status["udp_count"] = udp_count __last_net_io = cur_net_io schedule_job(refresh_status, 2)
def init(): schedule_job(check_v2_config_job, config.get_v2_config_check_interval()) schedule_job(traffic_job, config.get_traffic_job_interval()) schedule_job(check_v2ay_alive_job, 40) schedule_job(check_v2ray_version_job, 1800)