-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsniffer.py
50 lines (41 loc) · 1.46 KB
/
sniffer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os.path
import logging
import sys
import inspect
# This file is executed by `mitmdump' with `execfile'. Therefore, in
# order to import submodules under the directory where this file exists,
# we need some tricks. See http://stackoverflow.com/questions/3718657
# for the details of the tricks used in the following lines.
THIS_FILENAME = inspect.getframeinfo(inspect.currentframe()).filename
THIS_DIR_PATH = os.path.dirname(os.path.abspath(THIS_FILENAME))
sys.path.append(THIS_DIR_PATH)
import mahjongsoul_sniffer.logging as logging_
from mahjongsoul_sniffer.redis_mirroring import RedisMirroring
logging_.initialize(
module_name='game_abstract_crawler', service_name='sniffer')
_REDIS_MIRRORING_CONFIG = {
'websocket': {
'.lq.Lobby.loginBeat': {
'request_direction': 'outbound',
'action': {
'command': 'SET',
'key': 'login-beat'
}
},
'.lq.Lobby.fetchGameLiveList': {
'request_direction': 'outbound',
'action': {
'command': 'RPUSH',
'key': 'game-abstract-list'
}
}
}
}
redis_mirroring = RedisMirroring(
module_name='game_abstract_crawler', config=_REDIS_MIRRORING_CONFIG)
def websocket_message(flow) -> None:
try:
redis_mirroring.on_websocket_message(flow)
except Exception as e:
logging.exception(
'`RedisMirroring.on_websocket_message` threw an exception.')