1
1
import asyncio
2
- from typing import Optional , List
2
+ from typing import List , Optional
3
3
4
4
import grpc
5
5
from google .protobuf import json_format
6
6
from grpc ._cython .cygrpc import CompressionAlgorithm , CompressionLevel
7
7
8
- from mapadroid .data_handler .mitm_data .MitmMapper import MitmMapper
9
8
from mapadroid .data_handler .mitm_data .holder .latest_mitm_data .LatestMitmDataEntry import \
10
9
LatestMitmDataEntry
10
+ from mapadroid .data_handler .mitm_data .MitmMapper import MitmMapper
11
11
from mapadroid .grpc .compiled .mitm_mapper import mitm_mapper_pb2
12
12
from mapadroid .grpc .compiled .mitm_mapper .mitm_mapper_pb2 import (
13
- InjectedRequest , InjectionStatus ,
13
+ GetQuestsHeldResponse , InjectedRequest , InjectionStatus ,
14
14
LastKnownLocationResponse , LastMoved , LatestMitmDataEntryRequest ,
15
15
LatestMitmDataEntryResponse , LatestMitmDataEntryUpdateRequest ,
16
- LevelResponse , PokestopVisitsResponse ,
17
- SetLevelRequest , SetPokestopVisitsRequest , SetQuestsHeldRequest , GetQuestsHeldResponse )
16
+ LevelResponse , PokestopVisitsResponse , SetLevelRequest ,
17
+ SetPokestopVisitsRequest , SetQuestsHeldRequest )
18
18
from mapadroid .grpc .compiled .shared .Ack_pb2 import Ack
19
19
from mapadroid .grpc .compiled .shared .Worker_pb2 import Worker
20
20
from mapadroid .grpc .stubs .mitm_mapper .mitm_mapper_pb2_grpc import (
21
21
MitmMapperServicer , add_MitmMapperServicer_to_server )
22
22
from mapadroid .utils .collections import Location
23
23
from mapadroid .utils .logging import LoggerEnums , get_logger
24
- from mapadroid .utils .madGlobals import ( application_args )
24
+ from mapadroid .utils .madGlobals import MadGlobals
25
25
26
26
logger = get_logger (LoggerEnums .mitm_mapper )
27
27
@@ -35,14 +35,14 @@ async def start(self):
35
35
max_message_length = 100 * 1024 * 1024
36
36
options = [('grpc.max_message_length' , max_message_length ),
37
37
('grpc.max_receive_message_length' , max_message_length )]
38
- if application_args .mitmmapper_compression :
38
+ if MadGlobals . application_args .mitmmapper_compression :
39
39
options .extend ([('grpc.default_compression_algorithm' , CompressionAlgorithm .gzip ),
40
40
('grpc.grpc.default_compression_level' , CompressionLevel .medium )])
41
41
self .__server = grpc .aio .server (options = options )
42
42
add_MitmMapperServicer_to_server (self , self .__server )
43
- address = f'{ application_args .mitmmapper_ip } :{ application_args .mitmmapper_port } '
43
+ address = f'{ MadGlobals . application_args .mitmmapper_ip } :{ MadGlobals . application_args .mitmmapper_port } '
44
44
45
- if application_args .mitmmapper_tls_cert_file and application_args .mitmmapper_tls_private_key_file :
45
+ if MadGlobals . application_args .mitmmapper_tls_cert_file and MadGlobals . application_args .mitmmapper_tls_private_key_file :
46
46
await self .__secure_port (address )
47
47
else :
48
48
await self .__insecure_port (address )
@@ -52,8 +52,8 @@ async def start(self):
52
52
await self .__server .start ()
53
53
54
54
async def __secure_port (self , address ):
55
- with open (application_args .mitmmapper_tls_private_key_file , 'r' ) as keyfile , open (
56
- application_args .mitmmapper_tls_cert_file , 'r' ) as certfile :
55
+ with open (MadGlobals . application_args .mitmmapper_tls_private_key_file , 'r' ) as keyfile , open (
56
+ MadGlobals . application_args .mitmmapper_tls_cert_file , 'r' ) as certfile :
57
57
private_key = keyfile .read ()
58
58
certificate_chain = certfile .read ()
59
59
credentials = grpc .ssl_server_credentials (
0 commit comments