Exemple #1
0
	def __init__(self, appname, stream_pub):
		threading.Thread.__init__(self)
		self.TRAccesskey = None
		self.TRCloudapi = None
		self.frps_host = None
		self.frps_port = None
		self.frps_token = None
		self.FRPApi = None
		self.userinfo = {"name": None, "gate": None, "client_online": None, "tunnel_host": None, "tunnel_port": None,
            "tunnel_online": None, "gate_lan_ip": None, "gate_lan_netmask": None, "dest_ip": None,
            "local_vnet_ip": None, "gate_status": None, "gate_vpn_status": None, "gate_vpn_config": None}
		self._dest_services = ["frpc_vnet", "tinc.vnetbridge"]
		self._services_status = {}
		self._gate_online = False
		self._gate_vpn_is_running = False
		self._service_is_running = False
		self._vnet_is_running = False
		self._start_time = None
		self._stop_time = None
		self._enable_heartbeat = APPCtrl().get_heartbeat()
		self._heartbeat_timeout = time.time() + 90
		self._thread_stop = False
		self._appname = appname
		self._mqtt_pub = stream_pub
		self._log = configure_logger('default', 'logs/service.log')
Exemple #2
0
	def __init__(self, appname, stream_pub):
		threading.Thread.__init__(self)
		self._bench = None
		self.TRAccesskey = None
		self.TRCloudapi = None
		self.nps_host = None
		self.NPSApi = None
		self.userinfo = {"name": None, "gate": None, "cid": None, "vkey": None, "client_status": None, "client_online": None,
            "tunnel_alias": None, "tid": None, "tunnel_host": None, "tunnel_port": None, "tunnel_Target": "127.0.0.1:665",
            "tunnel_status": None, "tunnel_online": None, "gate_lan_ip": None, "gate_lan_netmask": None, "dest_ip": None,
            "local_vnet_ip": None, "gate_status": None, "gate_vpn_status": None, "gate_vpn_config": None}
		self._dest_services = ["Npc", "tinc.vnetbridge"]
		self._services_status = {}
		self.__auth_key = None
		self._gate_online = False
		self._gate_vpn_is_running = False
		self._service_is_running = False
		self._vnet_is_running = False
		self._result = {}
		self._handlers = []
		self._start_time = None
		self._stop_time = None
		self._enable_heartbeat = APPCtrl().get_heartbeat()
		self._heartbeat_timeout = time.time() + 90
		self._thread_stop = False
		self._appname = appname
		self._mqtt_pub = stream_pub
		self._log = configure_logger('default', 'logs/service.log')
Exemple #3
0
 def __init__(self, appname):
     threading.Thread.__init__(self)
     self.TRAccesskey = None
     self.TRCloudapi = None
     self._thread_stop = False
     self._appname = appname
     self._log = configure_logger('default', 'logs/service.log')
Exemple #4
0
 def __init__(self, service_name, oobj):
     threading.Thread.__init__(self)
     self.host = "localhost"
     self.port = MQTT_PROT
     self.api = oobj
     self.user = AUTH.split(":")[0]
     self.pwd = AUTH.split(":")[1]
     self.clientid = "API_PUB." + service_name
     self.keepalive = 60
     self.service_name = service_name
     self.pub_queue = Queue()
     self._log = configure_logger('default', 'logs/service.log')
     self._close_connection = False
Exemple #5
0
 async def startup():
     # 启动MQTTBroker
     # formatter = logging.Formatter(
     # 	"[%(asctime)s] :: %(levelname)s :: %(module)s :: %(process)d :: %(thread)d :: %(message)s",
     # 	"%Y-%m-%d %H:%M:%S")
     # handler = logging.StreamHandler()
     # handler.setLevel(logging.DEBUG)
     # handler.setFormatter(formatter)
     # # 为日志器logger添加上面创建的处理器handler
     # fastapi_logger.addHandler(handler)
     alog = configure_logger('default', 'logs/service.log')
     alog.info(
         '****************** Starting hbmqtt Server *****************')
     alog.info("Staring hbmqtt broker..")
     application.broker.start()
     pass
Exemple #6
0
 def __init__(self, appname, stream_pub):
     threading.Thread.__init__(self)
     self._appname = appname
     self._ports = []
     self._thread_stop = False
     self._mqtt_stream_pub = stream_pub
     self._enable_heartbeat = APPCtrl().get_heartbeat()
     self.TRAccesskey = None
     self.TRCloudapi = None
     self.nps_host = None
     self.NPSApi = None
     self.userinfo = {
         "name": None,
         "gate": None,
         "cid": None,
         "vkey": None,
         "client_status": None,
         "client_online": None,
         "tunnel_alias": None,
         "tid": None,
         "tunnel_host": None,
         "tunnel_port": None,
         "tunnel_Target": "127.0.0.1:4678",
         "tunnel_status": None,
         "tunnel_online": None,
         "gate_com_params": None,
         "gate_status": None,
         "gate_npc_status": None,
         "gate_port_name": None,
         "local_port_name": None,
         "info": None
     }
     self.__auth_key = None
     self._gate_online = False
     self._gate_npc_is_running = False
     self._vserial_is_running = False
     self._start_time = None
     self._stop_time = None
     self._heartbeat_timeout = time.time() + 90
     self._vsport_ctrl = None
     self._log = configure_logger('default', 'logs/service.log')
Exemple #7
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import logging
import ctypes
from helper import is_admin
import os, sys, platform, time
from pydantic import BaseModel
from cores.log import configure_logger
import uvicorn
from bases import app

if __name__ == '__main__':
	# 设置日志输出级别,可自己重新定义log_set
	alog = configure_logger('default', 'logs/service.log')
	if not is_admin():
		alog.info("当前用户不是管理员,将以管理员身份运行此程序")
		if sys.version_info[0] == 3:
			ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
		os._exit(0)
	else:
		# 使用 uvicorn 启动 API Server
		debug = False
		# if (platform.system() != "Linux"):
		# 	debug = True
		alog.info("当前工作路径:{0} ,启动参数:debug={1}".format(str(os.getcwd()), str(debug)))
		if os.access(os.getcwd() + r'\vnet\tincd.exe', os.F_OK) and os.access(os.getcwd() + r'\vnet\_frpc\frpc.exe', os.F_OK):
			filename, extension = os.path.splitext(os.path.basename(__file__))
			appStr = filename + ':app'
			alog.info("Staring Service!!")
			if debug:
				uvicorn.run(appStr, host="127.0.0.1", port=8089, reload=debug, log_level="info")
Exemple #8
0
def broker_coro(config):
    broker = Broker(config)
    broker.logger = configure_logger('default', 'logs/service.log')
    broker.logger.setLevel(logging.INFO)
    yield from broker.start()