예제 #1
0
from utils.authHelper import check_auth
from utils.logging import logger, InterceptHandler
from utils.madGlobals import (WebsocketWorkerRemovedException,
                              WebsocketWorkerTimeoutException,
                              WrongAreaInWalker)
from utils.routeutil import pre_check_value
from worker.WorkerConfigmode import WorkerConfigmode
from worker.WorkerMITM import WorkerMITM
from worker.WorkerQuests import WorkerQuests

OutgoingMessage = collections.namedtuple('OutgoingMessage', ['id', 'message'])
Location = collections.namedtuple('Location', ['lat', 'lng'])

logging.getLogger('websockets.server').setLevel(logging.DEBUG)
logging.getLogger('websockets.protocol').setLevel(logging.DEBUG)
logging.getLogger('websockets.server').addHandler(InterceptHandler())
logging.getLogger('websockets.protocol').addHandler(InterceptHandler())


class WebsocketServer(object):
    def __init__(self,
                 args,
                 mitm_mapper,
                 db_wrapper,
                 routemanagers,
                 device_mappings,
                 auths,
                 pogoWindowManager,
                 configmode=False):
        self.__current_users = {}
        self.__current_users_mutex = Lock()