MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / __init__

Method __init__

daily/chinaUnicom.py:253–297  ·  view source on GitHub ↗
(self, index, config_str)

Source from the content-addressed store, hash-verified

251
252class UserService:
253 def __init__(self, index, config_str):
254 self.index = index
255 self.valid = False
256 self.notify_logs = []
257 raw_session = requests.Session()
258 import socket
259
260 class SourceAddressAdapter(HTTPAdapter):
261
262 def init_poolmanager(self, connections, maxsize, block=False, **pool_kwargs):
263 pool_kwargs['source_address'] = ('0.0.0.0', 0)
264 super(SourceAddressAdapter, self).init_poolmanager(connections, maxsize, block, **pool_kwargs)
265
266 def get_connection(self, url, proxies=None):
267 return super(SourceAddressAdapter, self).get_connection(url, proxies)
268 retries = Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
269 adapter = SourceAddressAdapter(max_retries=retries)
270 raw_session.mount('http://', adapter)
271 raw_session.mount('https://', adapter)
272 raw_session.headers.update({
273 "User-Agent": COMMON_CONSTANTS["UA"],
274 "Connection": "keep-alive"
275 })
276 raw_session.verify = False
277 import urllib3
278 urllib3.disable_warnings()
279 self.session = FailoverSession(raw_session, self)
280 self.account_mobile = ""
281 self.mobile = ""
282 self.account_password = ""
283 self.token_online = ""
284 self.token_refresh = ""
285 self.cookie = ""
286 self.appId = ""
287 self.city_info = []
288 self.last_read_submission_time = 0
289 if globalConfig.get("refresh_device_id", False):
290 self.uuid = str(uuid.uuid4()).replace('-', '')
291 else:
292 self.uuid = os.environ.get("chinaUnicomUuid") or str(uuid.uuid4()).replace('-', '')
293 self.unicomTokenId = self.random_string(32)
294 self.tokenId_cookie = "chinaunicom-" + self.random_string(32, string.ascii_uppercase + string.digits)
295 self.ecs_token = ""
296 self.rptId = ""
297 self.init_account(config_str)
298
299 def _parse_proxy_response(self, text):
300 """解析代理API响应,支持JSON和文本格式,提取ip/port/user/pass"""

Callers

nothing calls this directly

Calls 5

random_stringMethod · 0.95
init_accountMethod · 0.95
FailoverSessionClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected