|
@@ -471,38 +471,36 @@ class OutboundClient:
|
|
def __init__(self, agent, app):
|
|
def __init__(self, agent, app):
|
|
self.app = app
|
|
self.app = app
|
|
self.logger = app.logger
|
|
self.logger = app.logger
|
|
- self.whitelist = []
|
|
|
|
- self.update_whitelist() # 初始化加载白名单
|
|
|
|
|
|
+ self.dataHandleServer = DataHandleServer(app)
|
|
|
|
+ self.whitelist = self.dataHandleServer.update_whitelist() # 初始化加载白名单
|
|
|
|
|
|
# 定时更新白名单
|
|
# 定时更新白名单
|
|
threading.Thread(target=self.refresh_whitelist, daemon=True).start()
|
|
threading.Thread(target=self.refresh_whitelist, daemon=True).start()
|
|
|
|
|
|
-
|
|
|
|
- self.dataHandleServer = DataHandleServer(app)
|
|
|
|
#threading.Thread(target=self.start, args=('0.0.0.0', 8084, agent, logger)).start()
|
|
#threading.Thread(target=self.start, args=('0.0.0.0', 8084, agent, logger)).start()
|
|
server_thread = threading.Thread(target=self.start, args=('0.0.0.0', 8084, agent))
|
|
server_thread = threading.Thread(target=self.start, args=('0.0.0.0', 8084, agent))
|
|
server_thread.daemon = True # 设置守护线程
|
|
server_thread.daemon = True # 设置守护线程
|
|
server_thread.start()
|
|
server_thread.start()
|
|
|
|
|
|
- def update_whitelist(self):
|
|
|
|
- with self.app.app_context():
|
|
|
|
- phones = Whitelist.query.filter_by(del_flag=0).all()
|
|
|
|
- self.whitelist = [phone.phone for phone in phones]
|
|
|
|
- self.logger.info("Whitelist updated: %s", self.whitelist)
|
|
|
|
|
|
+ # def update_whitelist(self):
|
|
|
|
+ # with self.app.app_context():
|
|
|
|
+ # phones = Whitelist.query.filter_by(del_flag=0).all()
|
|
|
|
+ # self.whitelist = [phone.phone for phone in phones]
|
|
|
|
+ # self.logger.info("Whitelist updated: %s", self.whitelist)
|
|
|
|
|
|
def refresh_whitelist(self):
|
|
def refresh_whitelist(self):
|
|
while True:
|
|
while True:
|
|
time.sleep(3600) # 每 1小时 更新一次
|
|
time.sleep(3600) # 每 1小时 更新一次
|
|
- self.update_whitelist()
|
|
|
|
|
|
+ self.dataHandleServer.update_whitelist()
|
|
|
|
|
|
def load_whitelist(self):
|
|
def load_whitelist(self):
|
|
return self.whitelist
|
|
return self.whitelist
|
|
|
|
|
|
- def load_agent_monitor(self):
|
|
|
|
- with self.app.app_context():
|
|
|
|
- agents = AgentMonitor.query.filter_by(check_state=0,service_state=2).all()
|
|
|
|
- agent_nums = [agent.agent_num for agent in agents]
|
|
|
|
- return agent_nums
|
|
|
|
|
|
+ # def load_agent_monitor(self):
|
|
|
|
+ # with self.app.app_context():
|
|
|
|
+ # agents = AgentMonitor.query.filter_by(check_state=0,service_state=2).all()
|
|
|
|
+ # agent_nums = [agent.agent_num for agent in agents]
|
|
|
|
+ # return agent_nums
|
|
|
|
|
|
|
|
|
|
class ESLRequestHandler(socketserver.BaseRequestHandler):
|
|
class ESLRequestHandler(socketserver.BaseRequestHandler):
|