# cython:language_level=3
# python 3.7.9
from __future__ import print_function
if 82 - 82: Iii1i
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
if 98 - 98: I11iiIi11i1I % oOO
if 31 - 31: i1I
if 9 - 9: IiI11Ii111 / oOo0O00 / IiIIii11Ii - I11iiIi11i1I - iI1iII1I1I1i
if 16 - 16: i1i1i1111I / i1iiIII111
if 3 - 3: i1 % i1 % i1i1i1111I . Ii * i1
if 9 - 9: i1iiIII111
import sys
import socket
import binascii
import time
import datetime
import struct
import configparser
import subprocess
if 10 - 10: ooOOO / IIiIIiIi11I1 * oOO / i1I / i1I
import logging
from queue import Queue
if 61 - 61: Ooo0Ooo - I1I
from twisted . internet . threads import deferToThread
from collections import deque
if 13 - 13: Ooo0Ooo
from twisted . internet . protocol import DatagramProtocol
from twisted . internet import protocol
from twisted . internet import reactor
from twisted . internet import endpoints
if 46 - 46: iI1iII1I1I1i - Ii * Oo * Ii
from . wgpacket import WGPacket , WGControllerinfo , WGSwipeRecord , WGTools , WGCommand , wgGlobal
from . sm4 import CryptSM4 , SM4_ENCRYPT , SM4_DECRYPT
from . mMonitorInfo import wgcontrollerDoorStatus , mMonitorInfo
from . wgAppConfig import wgAppConfig
if 52 - 52: Oo + I1I / oOO / OooOoo - I1Ii1I1 - ooOOO
class wgTCPConRPC ( DatagramProtocol ) :
 objWGControllerCenterTCP = None
 if 60 - 60: iI1iII1I1I1i . oOO
 def startProtocol ( self ) :
  pass
  if 13 - 13: oOO
 def run ( self , ip , port , command ) :
  self . transport . write ( command , ( ip , port ) )
  if 2 - 2: i1
 def datagramReceived ( self , data , addr ) :
  if len ( data ) % 64 == 0 :
   if WGControllerCenterTCP . commSM4 > 0 :
    IIiIiiIiI = WGControllerCenterTCP . commSM4_Dec ( data )
    OO0000 = WGPacket ( IIiIiiIiI , addr )
   else :
    OO0000 = WGPacket ( data , addr )
    if 92 - 92: I1I / I1I + i1I . oOO
    if 8 - 8: Ii + i1I . I11iiIi11i1I - I1Ii1I1 % I11iiIi11i1I . i1i1i1111I
   wgAppConfig . wglog ( "Server Receive <=UDP [{0}]" . format ( OO0000 . ipport ) )
   if self . objWGControllerCenterTCP . isConnected ( OO0000 . controllerSN ) :
    ii1iIi1i11i = self . objWGControllerCenterTCP . dictControllers [ OO0000 . controllerSN ] . ipport
    self . objWGControllerCenterTCP . tcptransport ( bytes ( data ) , ii1iIi1i11i )
    wgAppConfig . wglog ( "Server Send =>Controller SN= {0:d}  {1}" . format ( OO0000 . controllerSN , ii1iIi1i11i ) )
   del OO0000
   if 80 - 80: Ooo0Ooo
class xid4mobile ( object ) :
 def __init__ ( self , oldxid , addr ) :
  self . xid = oldxid
  self . addr = addr
  self . currentTime = time . time ( )
  if 85 - 85: I11iiIi11i1I % ooOOO + i1iiIII111 / ooOOO / ooo000
  if 17 - 17: oOo0O00 * i1iiIII111 - Iii1i . IiI11Ii111 - Oo % i1i1i1111I
  if 69 - 69: ooOOO % OooOoo
from twisted . internet . protocol import Factory
if 45 - 45: i1
class WGControllerCenterTCP ( Factory ) :
 testModeAllowAutoRemoteOpenDoor = 0
 logModeFileQR = 0
 logModeFileSwipe = 0
 if 48 - 48: iI1iII1I1I1i / oOo0O00 % IiI11Ii111
 logModeHourToClear = 3
 if 84 - 84: oOO . Oo + ooOOO / Oo . oOO
 logModeWeekToClear = 0
 if 20 - 20: IiI11Ii111 + i1iiIII111 / I1I
 if 88 - 88: I11iiIi11i1I + ooOOO - i1i1i1111I . Ooo0Ooo * Ii + Iii1i
 if 43 - 43: ooOOO * I1Ii1I1
 if 95 - 95: Ooo0Ooo % Iii1i % i1i1i1111I . OooOoo
 testModeDebugPrint = 0
 commPID = 0
 if 70 - 70: IiIIii11Ii
 commSM4 = 0
 commSM4Key = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 crypt_sm4_enc = CryptSM4 ( )
 crypt_sm4_dec = CryptSM4 ( )
 if 75 - 75: Ooo0Ooo / Ii / IiIIii11Ii + IiIIii11Ii . I1I
 dictControllers = dict ( )
 dictControllersSendDataTime = dict ( )
 dictXid = dict ( )
 _Global_xid = 0
 _xid = 0
 verbose = 0
 if 88 - 88: Oo * IiIIii11Ii
 if 100 - 100: IiI11Ii111 - OooOoo * I1Ii1I1 / Ooo0Ooo / Iii1i
 if 23 - 23: Ooo0Ooo + i1 * I1Ii1I1 + Oo * Ii - IIiIIiIi11I1
 if 29 - 29: IiIIii11Ii - oOo0O00
 TCPQueue4HeartBeatPacket = None
 TCPQueue4Mobile = None
 TCPQueue4ReplyFromController = None
 TCPQueue4QRCode = None
 TCPQueue4Dingyue = None
 if 30 - 30: I1I . ooo000
 TCPQueue4webAPI = None
 TCPQueue4QRwebAPI = None
 if 43 - 43: ooOOO . I11iiIi11i1I + ooo000
 commUDP = None
 if 87 - 87: Iii1i + ooOOO . i1I / Ii + Oo
 if 77 - 77: i1iiIII111 + IiI11Ii111 - Oo % ooo000
 @ staticmethod
 def setTestMode ( val ) :
  WGControllerCenterTCP . testModeAllowAutoRemoteOpenDoor = val
  if 74 - 74: Ii + Ooo0Ooo
  if 1 - 1: I1I % Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
 def setModeDebugPrint ( val ) :
  WGControllerCenterTCP . testModeDebugPrint = val
 def setCommPID ( val ) :
  WGControllerCenterTCP . commPID = val
  if 93 - 93: oOo0O00 % Ooo0Ooo * i1iiIII111
  if 52 - 52: oOO + I1I / ooo000 - I1Ii1I1 * i1I % oOo0O00
 def setCommSM4 ( val ) :
  oOoO00 = val . encode ( 'utf-8' )
  if len ( oOoO00 ) > 0 :
   if 84 - 84: iI1iII1I1I1i - I1I - I11iiIi11i1I
   ooO0000Ooo0O = b'\xc9\xee\xdb\xda\xce\xa2\xb8\xfb\xca\xb5\xd2\xb5\xd3\xd0\xcf\xde'
   iiii = CryptSM4 ( )
   oO00o00OO = bytes ( binascii . unhexlify ( val ) )
   iiii . set_key ( ooO0000Ooo0O , SM4_DECRYPT )
   o00o = iiii . crypt_ecb ( oO00o00OO )
   if 97 - 97: Ooo0Ooo
   WGControllerCenterTCP . commSM4 = 1
   i1Ii1iiIiI111 = [ 0x0 , 0x0 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ]
   O00O0Oo0OOO = 16 ;
   if len ( o00o ) < 16 :
    O00O0Oo0OOO = len ( o00o )
   for II1iIIi1Ii in range ( 0 , O00O0Oo0OOO ) :
    i1Ii1iiIiI111 [ II1iIIi1Ii ] = o00o [ II1iIIi1Ii ]
   WGControllerCenterTCP . commSM4Key = bytes ( i1Ii1iiIiI111 )
   WGControllerCenterTCP . crypt_sm4_enc . set_key ( WGControllerCenterTCP . commSM4Key , SM4_ENCRYPT )
   WGControllerCenterTCP . crypt_sm4_dec . set_key ( WGControllerCenterTCP . commSM4Key , SM4_DECRYPT )
   if 35 - 35: oOO + OooOoo . OooOoo
 def commSM4_Enc ( val ) :
  if 30 - 30: OooOoo * I1I * Ooo0Ooo . Ooo0Ooo
  return WGControllerCenterTCP . crypt_sm4_enc . crypt_ecb ( val )
  if 43 - 43: Ooo0Ooo - I1I . ooo000 - Iii1i % i1I
 def commSM4_Dec ( val ) :
  return WGControllerCenterTCP . crypt_sm4_dec . crypt_ecb ( val )
  if 49 - 49: IiIIii11Ii . ooo000 + oOO - oOO
  if 78 - 78: i1 - ooOOO
  if 56 - 56: ooo000 . ooo000 + I1Ii1I1 * iI1iII1I1I1i
  if 17 - 17: Iii1i % i1I - Iii1i % Ooo0Ooo . OooOoo
  if 60 - 60: ooOOO . ooo000
  if 42 - 42: i1iiIII111 - i1iiIII111
  if 98 - 98: Ooo0Ooo + i1i1i1111I + Iii1i - oOO
  if 7 - 7: i1i1i1111I / Ii * Iii1i
  if 32 - 32: IiI11Ii111 . OooOoo
  if 31 - 31: Oo - i1I
  if 28 - 28: ooOOO * I1Ii1I1 + IiI11Ii111 % Oo
  if 100 - 100: Oo + i1I
  if 4 - 4: ooo000 % I1I - i1i1i1111I
  if 76 - 76: i1 * oOo0O00 . IiI11Ii111 * i1I . IiIIii11Ii . oOO
  if 55 - 55: i1i1i1111I + i1iiIII111 % Ooo0Ooo . Oo - IiIIii11Ii - iI1iII1I1I1i
  if 91 - 91: I1Ii1I1 - I11iiIi11i1I
  if 84 - 84: oOO % iI1iII1I1I1i - Ooo0Ooo
  if 94 - 94: i1iiIII111 + i1i1i1111I / iI1iII1I1I1i + iI1iII1I1I1i / i1I
  if 79 - 79: i1iiIII111 - IIiIIiIi11I1 . I1Ii1I1 + I1I - ooOOO + i1iiIII111
  if 36 - 36: ooOOO * Iii1i % I1I % i1 . Ooo0Ooo
  if 63 - 63: IIiIIiIi11I1 / IIiIIiIi11I1 * Iii1i - oOo0O00 . i1
  if 52 - 52: oOo0O00 / i1I * IIiIIiIi11I1 + I11iiIi11i1I % Ooo0Ooo + oOO
  if 43 - 43: iI1iII1I1I1i * oOo0O00 + ooOOO
  if 30 - 30: I1I
  if 41 - 41: oOO
  if 98 - 98: I1I / IIiIIiIi11I1 / i1I + IiI11Ii111 % Oo + I1I
  if 38 - 38: I1Ii1I1 + oOo0O00
  if 2 - 2: OooOoo % Ii + oOO . OooOoo + IIiIIiIi11I1 * Oo
 def getNewXid ( self ) :
  self . _Global_xid = self . _Global_xid + 1
  if ( self . _Global_xid >= 0x5fffffff ) or ( self . _Global_xid < 0x50000001 ) :
   self . _Global_xid = 0x50000001
  self . _xid = self . _Global_xid
  return self . _Global_xid ;
  if 2 - 2: IIiIIiIi11I1 + iI1iII1I1I1i - I1Ii1I1 + ooOOO . IIiIIiIi11I1
 def isConnected ( self , sn ) :
  iIi111ii = self . dictControllers . get ( sn )
  if iIi111ii is None :
   return False
  elif ( abs ( time . time ( ) - iIi111ii . refreshTimeFrom1970 ) < 60 * 5 ) :
   return True
  return False
  if 20 - 20: i1i1i1111I + Oo / Ooo0Ooo % IiI11Ii111 % IiI11Ii111
  if 29 - 29: iI1iII1I1I1i - oOo0O00 - Ooo0Ooo % i1I + IiI11Ii111
 def addToTCPQueue4webAPI ( self , data ) :
  if wgAppConfig . ACTIVE_TCPQueue4webAPI :
   if len ( self . TCPQueue4webAPI ) > 1000 :
    self . TCPQueue4webAPI . popleft ( )
   self . TCPQueue4webAPI . append ( data )
   if 8 - 8: Oo * I1I / i1i1i1111I + i1 / I1Ii1I1
   if 71 - 71: I1Ii1I1
 def addToTCPQueue4QRwebAPI ( self , data ) :
  if wgAppConfig . ACTIVE_TCPQueue4QRwebAPI :
   if len ( self . TCPQueue4QRwebAPI ) > 1000 :
    self . TCPQueue4QRwebAPI . popleft ( )
   self . TCPQueue4QRwebAPI . append ( data )
   if 1 - 1: IiI11Ii111 - oOo0O00 - i1 . oOo0O00
   if 91 - 91: iI1iII1I1I1i * i1 . ooOOO
 def DealTCPQueue4HeartBeatPacket ( self ) :
  I1i = False
  while True :
   if self . TCPQueue4HeartBeatPacket . __len__ ( ) > 0 :
    I1i = True
    if 83 - 83: OooOoo + i1i1i1111I
    OO0000 = self . TCPQueue4HeartBeatPacket . popleft ( )
    if 8 - 8: IiI11Ii111 + i1I
    OO0 = OO0000 . commandData
    O00OOo = OO0000 . ipport
    II1Iiii111i1I = WGControllerinfo ( OO0 , O00OOo )
    iIi111ii = self . dictControllers . get ( II1Iiii111i1I . controllerSN )
    if 74 - 74: I1Ii1I1
    if 61 - 61: iI1iII1I1I1i * I1Ii1I1 + Ooo0Ooo % IIiIIiIi11I1 * i1i1i1111I
    if iIi111ii is None :
     if not wgGlobal . checkconstrollersWhitelist ( II1Iiii111i1I . controllerSN ) :
      continue
     self . dictControllers [ II1Iiii111i1I . controllerSN ] = II1Iiii111i1I
     self . dictControllersSendDataTime [ II1Iiii111i1I . controllerSN ] = 0
     if 61 - 61: i1iiIII111 - Oo + I1Ii1I1
     if 43 - 43: IIiIIiIi11I1 * ooo000 + Ii % iI1iII1I1I1i
     if 12 - 12: i1iiIII111 + ooo000 . I11iiIi11i1I
     if 1 - 1: iI1iII1I1I1i % Ii - I11iiIi11i1I / IiI11Ii111 + iI1iII1I1I1i - Ii
     if 27 - 27: OooOoo % iI1iII1I1I1i + IIiIIiIi11I1
     mMonitorInfo . printCHS ( "TCP. add controller SN= {0:d} {1} NO.{2} [{3}]" . format ( II1Iiii111i1I . controllerSN , II1Iiii111i1I . ipport , len ( self . dictControllers ) , time . strftime ( '%Y-%m-%d %H:%M:%S' ) ) )
     mMonitorInfo . wglog ( "TCP. add controller SN= {0:d} {1} NO.{2} [{3}]" . format ( II1Iiii111i1I . controllerSN , II1Iiii111i1I . ipport , len ( self . dictControllers ) , time . strftime ( '%Y-%m-%d %H:%M:%S' ) ) )
    else :
     self . dictControllers [ II1Iiii111i1I . controllerSN ] = II1Iiii111i1I
     i1i1iI1i1Iii = 0
     if II1Iiii111i1I . recordIndex != iIi111ii . recordIndex :
      if II1Iiii111i1I . recordData is not None :
       self . addToTCPQueue4webAPI ( OO0000 )
       if 15 - 15: OooOoo . oOo0O00 - ooOOO % Ooo0Ooo
       if 62 - 62: iI1iII1I1I1i / OooOoo % I1I - IiI11Ii111
       if self . testModeDebugPrint > 0 :
        if ( II1Iiii111i1I . recordIndex > iIi111ii . recordIndex + 1 ) :
         if len ( II1Iiii111i1I . commandData ) == 192 :
          II1Iiii111i1I . get5Swipe ( iIi111ii . recordIndex + 1 )
        II1Iiii111i1I . recordData . getDescription ( )
       if WGControllerCenterTCP . logModeFileSwipe > 0 :
        if II1Iiii111i1I . recordIndex > iIi111ii . recordIndex + 1 :
         if len ( II1Iiii111i1I . commandData ) == 192 :
          if 66 - 66: i1i1i1111I / Ooo0Ooo + I11iiIi11i1I + Iii1i + oOo0O00 + i1I
          II1Iiii111i1I . get5SwipeFileLog ( iIi111ii . recordIndex + 1 , II1Iiii111i1I . controllerSN , root_loggerTCP )
        II1Iiii111i1I . recordData . getDescriptionFileLog ( II1Iiii111i1I . controllerSN , root_loggerTCP )
        if 75 - 75: OooOoo - oOO - IiIIii11Ii - oOO + ooo000 % iI1iII1I1I1i
        if 42 - 42: i1 * i1I
      if II1Iiii111i1I . recordType == 0x01 :
       if ( self . countUsersOfDingyue ) > 0 and ( self . optionNewRecordSend > 0 ) :
        if 50 - 50: Ii - i1iiIII111
        self . TCPQueue4Dingyue . append ( OO0000 )
        if 96 - 96: ooo000 * OooOoo - Ii - OooOoo
        if 65 - 65: Oo + Oo - iI1iII1I1I1i % OooOoo . Ooo0Ooo
        if 84 - 84: IIiIIiIi11I1 . ooOOO
        if 44 - 44: ooo000 * i1i1i1111I * oOO + i1iiIII111 - IIiIIiIi11I1
       i11Ii = 0
       if WGControllerCenterTCP . testModeAllowAutoRemoteOpenDoor > 0 :
        i11Ii = 1
        if 96 - 96: Ooo0Ooo
        if 13 - 13: Oo * I1Ii1I1 - oOo0O00 * Ii . Ii + oOo0O00
        if 46 - 46: OooOoo - I11iiIi11i1I / Ooo0Ooo
        if 73 - 73: I1Ii1I1 / i1i1i1111I / ooo000 % i1 % i1I - OooOoo
        if 30 - 30: ooOOO * ooOOO - Iii1i * iI1iII1I1I1i
       if i11Ii > 0 :
        oOOOOOOoOOooO0O0 = [ 0x17 , 0x40 , 0x00 , 0x00 , 0xFF , 0xFF , 0xFF , 0xFF , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ]
        for II1iIIi1Ii in ( 4 , 5 , 6 , 7 ) :
         oOOOOOOoOOooO0O0 [ II1iIIi1Ii ] = OO0 [ II1iIIi1Ii ]
        oOOOOOOoOOooO0O0 [ 8 ] = II1Iiii111i1I . recordDoorNO
        O0 = self . getNewXid ( )
        if 51 - 51: i1I . Ii * IiI11Ii111
        if 96 - 96: i1 + IiIIii11Ii % I1I / IiI11Ii111
        if 33 - 33: OooOoo * Oo * Ii * iI1iII1I1I1i + i1I . IiIIii11Ii
        WGTools . longToByte ( II1Iiii111i1I . recordData . recordcurrentval , oOOOOOOoOOooO0O0 , 20 , 8 )
        oOOOOOOoOOooO0O0 [ 32 ] = 0x5A
        WGTools . longToByte ( O0 , oOOOOOOoOOooO0O0 , 40 , 4 )
        if WGControllerCenterTCP . commSM4 > 0 :
         oOOOOOOoOOooO0O0 = WGControllerCenterTCP . commSM4_Enc ( oOOOOOOoOOooO0O0 )
         if 94 - 94: oOo0O00 . i1iiIII111
         if 96 - 96: I1I / oOO / I11iiIi11i1I + I11iiIi11i1I
        self . tcptransport ( bytes ( oOOOOOOoOOooO0O0 ) , O00OOo )
        i1i1iI1i1Iii = 1
        wgAppConfig . wglog ( "Server Send =>Controller RemoteOpenDoor SN= {0:d} DoorNO= {1:d} {2}" . format ( II1Iiii111i1I . controllerSN , II1Iiii111i1I . recordDoorNO , II1Iiii111i1I . ipport ) )
        if 35 - 35: IIiIIiIi11I1 + oOo0O00
        if 96 - 96: iI1iII1I1I1i . OooOoo . i1
        if 87 - 87: ooo000 * IiIIii11Ii % ooo000 . ooOOO . Oo % iI1iII1I1I1i
        if 48 - 48: ooOOO * ooo000 % IiIIii11Ii * i1 . Iii1i - IiI11Ii111
        if 72 - 72: i1 % i1i1i1111I * iI1iII1I1I1i
        if 90 - 90: Ooo0Ooo * OooOoo . Ii
        if 5 - 5: Oo - i1 . oOO
        if 18 - 18: IiIIii11Ii - oOO * i1I - OooOoo
        if 54 - 54: IIiIIiIi11I1 . Ooo0Ooo % Ii + IiIIii11Ii * iI1iII1I1I1i / iI1iII1I1I1i
        if 31 - 31: IiIIii11Ii . IiIIii11Ii % Ii
        if 51 - 51: Oo / i1i1i1111I - I1I
        if 83 - 83: Iii1i % i1iiIII111 . OooOoo / I1I % oOO . I1I
        if 76 - 76: i1iiIII111 / OooOoo
        if 77 - 77: ooOOO
        if 19 - 19: ooOOO % I1Ii1I1
        if 15 - 15: OooOoo . IiIIii11Ii . i1I / Iii1i + ooOOO / Ii
        if 17 - 17: I11iiIi11i1I - i1i1i1111I . iI1iII1I1I1i - I11iiIi11i1I + Oo % iI1iII1I1I1i
        if 65 - 65: Ii % I11iiIi11i1I
        if 39 - 39: Iii1i * IIiIIiIi11I1 . Ooo0Ooo - Oo
        if 63 - 63: i1i1i1111I - i1iiIII111 . OooOoo % OooOoo . IiI11Ii111 + i1I
        if 71 - 71: ooo000 + I11iiIi11i1I % iI1iII1I1I1i + IiI11Ii111 % Oo - Oo
        if 84 - 84: I1I % iI1iII1I1I1i - Ooo0Ooo / iI1iII1I1I1i + Ooo0Ooo - Oo
        if 41 - 41: ooOOO + OooOoo + IIiIIiIi11I1 * i1i1i1111I
        if 12 - 12: i1i1i1111I
        if 56 - 56: IiIIii11Ii
        if 17 - 17: i1I . oOO % Oo + IiIIii11Ii - Ooo0Ooo
        if 93 - 93: oOo0O00
        if 77 - 77: Oo + I11iiIi11i1I % I1I
   else :
    if 20 - 20: i1 - IiIIii11Ii . IiIIii11Ii % ooOOO . i1 % Ooo0Ooo
    return I1i
    if 72 - 72: oOO % IiI11Ii111 . ooOOO * I1Ii1I1 . ooOOO
 def DealTCPQueue4QRCode ( self ) :
  I1i = False
  while True :
   if self . TCPQueue4QRCode . __len__ ( ) > 0 :
    I1i = True
    if 90 - 90: IiIIii11Ii + I1Ii1I1 . OooOoo
    OO0000 = self . TCPQueue4QRCode . popleft ( )
    if 73 - 73: i1i1i1111I - Iii1i / I11iiIi11i1I . ooo000 / iI1iII1I1I1i - i1iiIII111
    OO0 = OO0000 . commandData
    O00OOo = OO0000 . ipport
    I1I11i = binascii . hexlify ( OO0 )
    i1i1 = ( OO0 [ 8 ] + ( OO0 [ 9 ] << 8 ) )
    I1II1IIIi = I1I11i [ ( 64 * 2 ) : ( 64 * 2 + i1i1 * 2 ) ]
    wgAppConfig . wglog ( "TCP Server Receive <=From Controller SN = {0} QRCode Data: {1} " . format ( OO0000 . controllerSN , I1II1IIIi ) )
    wgAppConfig . wglog ( "TCP                                   QRCode(Convert To String): {0} " . format ( str ( OO0 [ 64 : 64 + i1i1 ] ) ) )
    if WGControllerCenterTCP . logModeFileQR > 0 :
     if 97 - 97: IiIIii11Ii . Oo - i1I + I11iiIi11i1I - oOo0O00
     if 6 - 6: IiI11Ii111 - Ii
     if 1 - 1: I1I + OooOoo
     if 98 - 98: i1iiIII111 + Iii1i . IIiIIiIi11I1
     oO00 = "{0:0>2X}{1:0>2X}-{2:0>2X}-{3:0>2X} {4:0>2X}:{5:0>2X}:{6:0>2X}" . format ( 0x20 , OO0 [ 51 ] , OO0 [ 52 ] , OO0 [ 53 ] , OO0 [ 37 ] , OO0 [ 38 ] , OO0 [ 39 ] )
     try :
      II1 = datetime . datetime . strptime ( oO00 , "%Y-%m-%d %H:%M:%S" )
     except Exception as II :
      pass
      if 10 - 10: Ooo0Ooo % ooo000 % Ooo0Ooo
      II1 = datetime . datetime . strptime ( "2000-01-19 19:19:19" , "%Y-%m-%d %H:%M:%S" )
      mMonitorInfo . wglog ( "1602" )
      mMonitorInfo . wglog ( II )
     root_loggerTCP . info ( "SN={0}:QR:DoorNO ={1:d},InExit ={2},Time={3:%Y-%m-%d %H:%M:%S},QRCode={4},ConvertedString={5}" . format ( OO0000 . controllerSN , OO0 [ 14 ] , "In" if OO0 [ 15 ] == 1 else "Exit" , II1 , I1II1IIIi , str ( OO0 [ 64 : 64 + i1i1 ] ) ) )
    iIi111ii = self . dictControllers . get ( OO0000 . controllerSN )
    if 38 - 38: ooo000
    if iIi111ii is not None :
     if iIi111ii . ipport != O00OOo :
      iIi111ii . ipport = O00OOo
      self . dictControllersSendDataTime [ OO0000 . controllerSN ] = 0
      if 3 - 3: IiI11Ii111 / IiIIii11Ii - i1i1i1111I
    i11Ii = 0
    if ( WGControllerCenterTCP . testModeAllowAutoRemoteOpenDoor > 0 ) :
     i11Ii = 1
     if 56 - 56: i1
     if 56 - 56: I11iiIi11i1I - ooo000 . i1iiIII111 + i1iiIII111 / I1Ii1I1
     if 10 - 10: Oo * I11iiIi11i1I % IiIIii11Ii / OooOoo + i1
     if 14 - 14: I1I + I1Ii1I1
     if 78 - 78: i1i1i1111I * I1Ii1I1
    if i11Ii > 0 :
     O0O00000O0O = OO0 [ 14 ]
     O0 = self . getNewXid ( )
     III = 123456789888
     oOOOOOOoOOooO0O0 = WGCommand . cmdRemoteOpenDoorInLocalnetwork ( OO0000 . controllerSN , O0O00000O0O , 1 , III , O0 )
     if ( WGControllerCenterTCP . commSM4 > 0 ) :
      oOOOOOOoOOooO0O0 = WGControllerCenterTCP . commSM4_Enc ( oOOOOOOoOOooO0O0 )
      if 81 - 81: i1I + IiIIii11Ii . I11iiIi11i1I
     self . tcptransport ( bytes ( oOOOOOOoOOooO0O0 ) , O00OOo )
     wgAppConfig . wglog ( "Server Send =>Controller RemoteOpenDoor SN= {0:d} DoorNO= {1:d} {2}" . format ( OO0000 . controllerSN , O0O00000O0O , OO0000 . ipport ) )
   else :
    if 10 - 10: iI1iII1I1I1i - Ii . IiIIii11Ii
    return I1i
    if 37 - 37: i1i1i1111I
    if 79 - 79: ooo000 % i1I - Ii % i1I - I1I
 def DealTCPQueue4Mobile ( self ) :
  I1i = False
  while True :
   if self . TCPQueue4Mobile . __len__ ( ) > 0 :
    I1i = True
    if 42 - 42: I11iiIi11i1I - Ii / Oo - i1i1i1111I + I11iiIi11i1I
    OO0000 = self . TCPQueue4Mobile . popleft ( )
    if 83 - 83: i1 . iI1iII1I1I1i
    OO0 = OO0000 . commandData
    iIi111ii = self . dictControllers . get ( OO0000 . controllerSN )
    wgAppConfig . wglog ( "Server Receive <=Mobile or PC Client [{0}]" . format ( OO0000 . ipport ) )
    if self . isConnected ( OO0000 . controllerSN ) :
     oOOOOO0 = [ OO0 [ II1iIIi1Ii ] for II1iIIi1Ii in range ( 0 , len ( OO0 ) ) ]
     oOOOOO0 [ 0 ] = 0x17
     if ( WGControllerCenterTCP . commPID > 0 ) :
      oOOOOO0 [ 2 ] = 0
      oOOOOO0 [ 3 ] = 0
     if len ( OO0 ) > 64 :
      if 77 - 77: i1iiIII111
      if WGTools . isValid64Group ( oOOOOO0 ) :
       for II1iIIi1Ii in range ( 0 , len ( OO0 ) // 64 ) :
        if oOOOOO0 [ II1iIIi1Ii * 64 ] > 0 :
         oOOOOO0 [ II1iIIi1Ii * 64 ] = 0x17
     I11 = OO0000 . sid
     O0 = self . getNewXid ( )
     O000oO = O0
     for II1iIIi1Ii in ( 40 , 41 , 42 , 43 ) :
      oOOOOO0 [ II1iIIi1Ii ] = O0 & 0xff
      O0 = O0 >> 8
     O00OOo = self . dictControllers [ OO0000 . controllerSN ] . ipport
     iI111Ii = xid4mobile ( I11 , OO0000 . ipport )
     if 77 - 77: oOo0O00 . ooo000 % i1iiIII111 * I11iiIi11i1I / Ooo0Ooo . I11iiIi11i1I
     self . dictXid [ O000oO ] = iI111Ii
     if 47 - 47: IiIIii11Ii
     if WGControllerCenterTCP . commSM4 > 0 :
      oOOOOO0 = WGControllerCenterTCP . commSM4_Enc ( oOOOOO0 )
      if 40 - 40: i1iiIII111 / IIiIIiIi11I1
     self . tcptransport ( bytes ( oOOOOO0 ) , O00OOo )
     wgAppConfig . wglog ( "Server Send =>Controller SN= {0:d}  {1}" . format ( OO0000 . controllerSN , O00OOo ) )
    else :
     oOOOOO0 = None
     if 25 - 25: OooOoo / i1i1i1111I
     if OO0000 . controllerSN == 999999901 :
      if not wgAppConfig . ACTIVE_TCPQueue4webAPI :
       wgAppConfig . ACTIVE_TCPQueue4webAPI = True
       if 38 - 38: I11iiIi11i1I
      if ( len ( self . TCPQueue4webAPI ) > 0 ) :
       Ii1Iiii11i1 = self . TCPQueue4webAPI . popleft ( ) . commandData
       oOOOOO0 = [ Ii1Iiii11i1 [ II1iIIi1Ii ] for II1iIIi1Ii in range ( 0 , len ( Ii1Iiii11i1 ) ) ]
       for II1iIIi1Ii in ( 40 , 41 , 42 , 43 ) :
        oOOOOO0 [ II1iIIi1Ii ] = OO0 [ II1iIIi1Ii ]
     elif OO0000 . controllerSN == 999999902 :
      if not wgAppConfig . ACTIVE_TCPQueue4QRwebAPI :
       wgAppConfig . ACTIVE_TCPQueue4QRwebAPI = True
       if 57 - 57: Ooo0Ooo
      if len ( self . TCPQueue4QRwebAPI ) > 0 :
       Ii1Iiii11i1 = self . TCPQueue4QRwebAPI . popleft ( ) . commandData
       oOOOOO0 = [ Ii1Iiii11i1 [ II1iIIi1Ii ] for II1iIIi1Ii in range ( 0 , len ( Ii1Iiii11i1 ) ) ]
       for II1iIIi1Ii in ( 40 , 41 , 42 , 43 ) :
        oOOOOO0 [ II1iIIi1Ii ] = OO0 [ II1iIIi1Ii ]
     if oOOOOO0 is None :
      if 47 - 47: i1 * IiI11Ii111 - iI1iII1I1I1i + oOO / oOo0O00 / IIiIIiIi11I1
      oOOOOO0 = [ OO0 [ II1iIIi1Ii ] for II1iIIi1Ii in range ( 0 , len ( OO0 ) ) ]
      oOOOOO0 [ 0 ] = 0x37
      oOOOOO0 [ 8 ] = 0x00
      if 25 - 25: i1I * iI1iII1I1I1i - oOo0O00
      for II1iIIi1Ii in ( 0 , 1 , 2 , 3 ) :
       oOOOOO0 [ II1iIIi1Ii + 44 ] = oOOOOO0 [ II1iIIi1Ii + 40 ]
       oOOOOO0 [ II1iIIi1Ii + 48 ] = oOOOOO0 [ II1iIIi1Ii + 4 ]
       oOOOOO0 [ II1iIIi1Ii + 4 ] = 0
     O00OOo = OO0000 . ipport
     if 100 - 100: I11iiIi11i1I % I1Ii1I1 - IiI11Ii111 / OooOoo
     self . tcptransport ( bytes ( oOOOOO0 ) , O00OOo )
     wgAppConfig . wglog ( "Server Reply =>mobile Controller SN= {0:d} unconnected {1}" . format ( OO0000 . controllerSN , O00OOo ) )
   else :
    if 33 - 33: IIiIIiIi11I1
    return I1i
    if 48 - 48: I11iiIi11i1I . oOo0O00 . I1Ii1I1 . iI1iII1I1I1i + I11iiIi11i1I
 def DealTCPQueue4ReplyFromController ( self ) :
  I1i = False
  while True :
   try :
    if self . TCPQueue4ReplyFromController . __len__ ( ) > 0 :
     I1i = True
     if 19 - 19: i1 . IiIIii11Ii - Ooo0Ooo . Ii
     OO0000 = self . TCPQueue4ReplyFromController . popleft ( )
     if 51 - 51: i1 + i1i1i1111I - i1 + i1iiIII111 . Oo
     OO0 = OO0000 . commandData
     if 92 - 92: OooOoo + Ii / IIiIIiIi11I1 + OooOoo * IIiIIiIi11I1 * iI1iII1I1I1i
     iI111Ii = self . dictXid . get ( OO0000 . sid )
     if iI111Ii is not None :
      oOOOOO0 = [ OO0 [ II1iIIi1Ii ] for II1iIIi1Ii in range ( 0 , len ( OO0 ) ) ]
      if 79 - 79: i1i1i1111I
      if 3 - 3: OooOoo / IiI11Ii111 % I11iiIi11i1I
      if 55 - 55: oOo0O00
      if 31 - 31: Ii . Ooo0Ooo / IiI11Ii111
      if 59 - 59: Oo
      if 64 - 64: Iii1i % I11iiIi11i1I * i1 % OooOoo * oOo0O00
      if 55 - 55: IiI11Ii111
      if 46 - 46: Ooo0Ooo % I1Ii1I1
      if 86 - 86: I11iiIi11i1I . i1i1i1111I + oOO % I11iiIi11i1I % Iii1i % ooo000
      if ( 1 > 0 ) :
       oOOOOO0 [ 0 ] = 0x37
       if 61 - 61: ooo000
       if ( ( len ( OO0 ) > 64 ) and ( len ( OO0 ) != 192 ) ) :
        if 48 - 48: Iii1i * i1i1i1111I + IiIIii11Ii
        if not WGTools . isValid64Group ( OO0 ) :
         pass
        else :
         for II1iIIi1Ii in range ( 0 , len ( OO0 ) // 64 ) :
          if oOOOOO0 [ II1iIIi1Ii * 64 ] > 0 :
           oOOOOO0 [ II1iIIi1Ii * 64 ] = 0x37
           if 31 - 31: Oo * i1iiIII111 % Ii / oOO + I1Ii1I1 + iI1iII1I1I1i
      O0 = iI111Ii . xid
      for II1iIIi1Ii in ( 40 , 41 , 42 , 43 ) :
       oOOOOO0 [ II1iIIi1Ii ] = O0 & 0xff
       O0 = O0 >> 8
      O00OOo = iI111Ii . addr
      if 90 - 90: I1Ii1I1 * i1i1i1111I / iI1iII1I1I1i * Ii
      self . tcptransport ( bytes ( oOOOOO0 ) , O00OOo )
      wgAppConfig . logdebug ( "????Server Send =>Mobile New {0} from {1} DataLen={2:d} " . format ( binascii . hexlify ( bytes ( oOOOOO0 ) ) , O00OOo , len ( bytes ( oOOOOO0 ) ) ) )
      wgAppConfig . wglog ( "Server Send =>Mobile = {0}" . format ( OO0000 . ipport ) )
      if 38 - 38: I1I . Ii
      self . dictXid . pop ( OO0000 . sid , None )
      if 41 - 41: ooo000 % IIiIIiIi11I1 % ooOOO
    else :
     if 5 - 5: oOo0O00 / Ii + i1iiIII111 * Oo + Ooo0Ooo + ooo000
     if self . dictXid . __len__ ( ) > 100 :
      if 96 - 96: i1iiIII111 - IIiIIiIi11I1 / IIiIIiIi11I1 * IiIIii11Ii
      oOoO0o0OOooO0 = self . dictXid . keys ( )
      O00Oo0OOO = time . time ( )
      if 6 - 6: IiI11Ii111 + ooOOO - Ii * ooo000 . I11iiIi11i1I + I1Ii1I1
      if 4 - 4: iI1iII1I1I1i % Ii
      for II1iIIi1Ii in list ( oOoO0o0OOooO0 ) :
       iI111Ii = self . dictXid . get ( II1iIIi1Ii )
       if ( O00Oo0OOO > iI111Ii . currentTime + 3 ) :
        self . dictXid . pop ( II1iIIi1Ii , None )
        if 17 - 17: i1
        if 100 - 100: IiIIii11Ii + i1I - IiI11Ii111 . iI1iII1I1I1i / IiIIii11Ii + iI1iII1I1I1i
        if 98 - 98: i1I
     return I1i
   except Exception as II :
    pass
    if 18 - 18: ooo000 + ooOOO + Oo / I1Ii1I1 . IIiIIiIi11I1
    if 67 - 67: Oo % ooOOO + iI1iII1I1I1i * I1I
    mMonitorInfo . wglog ( "1603" )
    if 79 - 79: IIiIIiIi11I1 * Oo / OooOoo
    mMonitorInfo . wglog ( "{0}: {1}" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , II ) )
    return I1i
    if 10 - 10: iI1iII1I1I1i / i1iiIII111 . IiIIii11Ii * i1i1i1111I
 def tcptransport ( self , data , addr ) :
  if 71 - 71: oOo0O00 + I1Ii1I1 / I11iiIi11i1I + Oo / I1I
  for iiI11II1i in self . clients :
   iI11I1 = iiI11II1i . transport . getPeer ( )
   if iI11I1 == addr :
    iiI11II1i . transport . write ( data )
    break
    if 53 - 53: i1i1i1111I % i1iiIII111 / i1i1i1111I * iI1iII1I1I1i
    if 60 - 60: IiIIii11Ii % oOO / i1I * OooOoo / I11iiIi11i1I - Ii
 optionNewRecordSend = 0
 countUsersOfDingyue = 0
 listUsersOfDingyue = [ ]
 if 16 - 16: oOo0O00 / I1Ii1I1 / i1 + I11iiIi11i1I + oOo0O00
 def DealTCPQueue4Dingyue ( self ) :
  I1i = False
  if 11 - 11: oOO / OooOoo + oOo0O00
  if 79 - 79: I11iiIi11i1I . I1Ii1I1 * i1I % I1Ii1I1 / IiI11Ii111
  if 93 - 93: i1I + Iii1i . Ii . i1I * ooOOO
  if 84 - 84: Ooo0Ooo % IiI11Ii111
  if 82 - 82: IIiIIiIi11I1
  if 81 - 81: oOo0O00 + i1 - ooo000 * iI1iII1I1I1i + i1i1i1111I
  while True :
   if self . TCPQueue4Dingyue . __len__ ( ) > 0 :
    I1i = True
    if 89 - 89: I1Ii1I1
    OO0000 = self . TCPQueue4Dingyue . popleft ( )
    if 57 - 57: iI1iII1I1I1i - i1iiIII111 / OooOoo % i1iiIII111
    OO0 = OO0000 . commandData
    if 92 - 92: IiIIii11Ii * OooOoo - IiIIii11Ii
    if 66 - 66: i1iiIII111 . iI1iII1I1I1i / ooOOO . i1 - OooOoo
    if OO0000 . functionID == 0x10 and ( ( OO0000 . controllerSN == 0x7EEEEEEE ) or ( OO0000 . controllerSN == 0x7EEEEEEC ) ) :
     if OO0000 . controllerSN == 0x7EEEEEEE :
      if 13 - 13: oOo0O00
      OoO00 = 60 * 5
      if ( OO0 [ 8 ] > 0 ) :
       OoO00 = 60 * OO0 [ 8 ]
      self . optionNewRecordSend = OO0 [ 9 ]
      oO0O = time . time ( ) + OoO00
      OooO0Ooo0 = 0
      if len ( self . listUsersOfDingyue ) > 0 :
       for II1iIIi1Ii in self . listUsersOfDingyue :
        if II1iIIi1Ii [ 0 ] == OO0000 . ipport :
         II1iIIi1Ii [ 1 ] = oO0O
         OooO0Ooo0 = 1
         break
      if OooO0Ooo0 == 0 :
       self . listUsersOfDingyue . append ( [ OO0000 . ipport , oO0O ] )
       self . countUsersOfDingyue = len ( self . listUsersOfDingyue )
      wgAppConfig . wglog ( "Server receive subscription refresh<= from Mobile or PC Client [{0}]" . format ( OO0000 . ipport ) )
      if 46 - 46: Ii
     if OO0000 . controllerSN == 0x7EEEEEEC :
      if 37 - 37: IIiIIiIi11I1 % oOO + Oo . Ooo0Ooo
      if len ( self . listUsersOfDingyue ) > 0 :
       for II1iIIi1Ii in self . listUsersOfDingyue :
        if II1iIIi1Ii [ 0 ] == OO0000 . ipport :
         self . listUsersOfDingyue . remove ( II1iIIi1Ii )
         self . countUsersOfDingyue = len ( self . listUsersOfDingyue )
         break
      wgAppConfig . wglog ( "Server receive unsubscription <= from Mobile or PC Client [{0}]" . format ( OO0000 . ipport ) )
      if 18 - 18: IiIIii11Ii * IiIIii11Ii - Ii
      if 52 - 52: i1I
     oOOOOO0 = [ OO0 [ II1iIIi1Ii ] for II1iIIi1Ii in range ( 0 , 64 ) ]
     oOOOOO0 [ 0 ] = 0x37
     oOOOOO0 [ 8 ] = 0x01
     O00OOo = OO0000 . ipport
     if 72 - 72: oOO + oOo0O00
     self . tcptransport ( bytes ( oOOOOO0 ) , O00OOo )
     if 10 - 10: iI1iII1I1I1i % ooOOO % IiI11Ii111 % Oo
     if 17 - 17: ooo000
     if 48 - 48: IiIIii11Ii % I1I / IiI11Ii111
     if 66 - 66: Ii % Ii . i1iiIII111 / IIiIIiIi11I1
     if 67 - 67: IiI11Ii111 / OooOoo % IiI11Ii111 + i1iiIII111
     if 21 - 21: oOo0O00 % i1iiIII111 % I11iiIi11i1I % oOO
     wgAppConfig . wglog ( "Server reply => Mobile or PC Client [{0}]" . format ( O00OOo ) )
    elif OO0000 . cmdtype == 0x17 :
     if ( self . countUsersOfDingyue ) > 0 :
      OoOO0oO0O = time . time ( )
      O00OOo = OO0000 . ipport
      for II1iIIi1Ii in self . listUsersOfDingyue :
       if 93 - 93: Iii1i * IIiIIiIi11I1 % i1I + i1 % Ii * i1I
       self . tcptransport ( OO0000 . commandData , II1iIIi1Ii [ 0 ] )
       if 62 - 62: IiI11Ii111 % ooo000
       if 19 - 19: Ii / Oo % Iii1i / i1iiIII111 - OooOoo - Ooo0Ooo
       if 89 - 89: I11iiIi11i1I - IiI11Ii111
       if 61 - 61: Ii * OooOoo * I1I % i1iiIII111 % IIiIIiIi11I1 * I11iiIi11i1I
       if 49 - 49: iI1iII1I1I1i / i1iiIII111 % oOO
       if 46 - 46: ooOOO * IIiIIiIi11I1 % i1 / oOO + i1 + oOo0O00
       wgAppConfig . wglog ( "Server Send =>subscriber(mobile or PC) = {0}" . format ( II1iIIi1Ii [ 0 ] ) )
       wgAppConfig . logdebug ( "????DealTCPQueue4Dingyue Server send =>subscriber(mobile or PC) {0} from {1} DataLen={2:d} " . format ( binascii . hexlify ( bytes ( OO0000 . commandData ) ) , O00OOo , len ( bytes ( OO0000 . commandData ) ) ) )
       if 99 - 99: I1I * IIiIIiIi11I1 * i1iiIII111
       if 62 - 62: ooOOO % Oo + i1I
   else :
    if 87 - 87: ooo000 - OooOoo + Ii + i1i1i1111I + IiIIii11Ii
    if 57 - 57: IIiIIiIi11I1 + I1I / ooOOO % ooOOO % Oo / IiI11Ii111
    if 95 - 95: i1 / I11iiIi11i1I . i1 / Oo . Ooo0Ooo
    if 43 - 43: Oo - OooOoo * oOO . Ooo0Ooo / IIiIIiIi11I1 * IIiIIiIi11I1
    if 84 - 84: i1iiIII111 + oOo0O00
    if 83 - 83: i1i1i1111I
    if 84 - 84: oOO / Ii * Ooo0Ooo / Ii / ooo000
    if 64 - 64: oOo0O00 * Ii
    if 2 - 2: IiI11Ii111 % i1iiIII111 . oOo0O00
    if 59 - 59: I11iiIi11i1I % OooOoo - iI1iII1I1I1i % I1I + i1iiIII111 . I1Ii1I1
    if 94 - 94: ooOOO * I1Ii1I1 * i1iiIII111 . oOo0O00
    return I1i
    if 73 - 73: I1Ii1I1 / ooo000 % I11iiIi11i1I - i1i1i1111I + Oo - I1Ii1I1
    if 18 - 18: i1 + ooOOO . i1 - iI1iII1I1I1i
    if 97 - 97: oOo0O00 + i1I % Iii1i
    if 34 - 34: i1 + Oo . oOo0O00 - ooo000 / I11iiIi11i1I * oOo0O00
    if 89 - 89: oOo0O00
    if 48 - 48: i1 / IIiIIiIi11I1 / iI1iII1I1I1i / IiI11Ii111 * IiIIii11Ii
    if 54 - 54: IIiIIiIi11I1 % I1I % IiI11Ii111 / I11iiIi11i1I . I11iiIi11i1I - IiIIii11Ii
    if 10 - 10: Ii . I11iiIi11i1I % i1I / OooOoo % I1Ii1I1
    if 42 - 42: Oo - I1I * i1I * i1i1i1111I - I11iiIi11i1I
    if 58 - 58: iI1iII1I1I1i
    if 17 - 17: iI1iII1I1I1i - Ii % iI1iII1I1I1i % oOo0O00 * Iii1i
    if 51 - 51: I1I . i1i1i1111I % Ii
    if 55 - 55: i1i1i1111I * Ii % i1i1i1111I
    if 61 - 61: oOo0O00
    if 53 - 53: Ooo0Ooo / IiIIii11Ii
    if 49 - 49: ooo000 - oOO . IiIIii11Ii / Oo
    if 23 - 23: I11iiIi11i1I - i1 / Iii1i . iI1iII1I1I1i + oOO
    if 55 - 55: i1 - iI1iII1I1I1i / OooOoo + I1I + Oo
    if 5 - 5: IiI11Ii111 - i1 . i1i1i1111I / IiI11Ii111 . iI1iII1I1I1i . IiI11Ii111
    if 87 - 87: i1 . Ii * iI1iII1I1I1i - oOO / Ii / OooOoo
 def __init__ ( self , tcploc = 1 ) :
  if 65 - 65: i1I / i1I + IiI11Ii111
  self . clients = set ( )
  if 99 - 99: i1 + OooOoo + I11iiIi11i1I * Ooo0Ooo / ooOOO + Ii
  self . TCPQueue4HeartBeatPacket = deque ( )
  self . TCPQueue4Mobile = deque ( )
  self . TCPQueue4QRCode = deque ( )
  self . TCPQueue4ReplyFromController = deque ( )
  self . TCPQueue4Dingyue = deque ( )
  self . TCPQueue4webAPI = deque ( )
  self . TCPQueue4QRwebAPI = deque ( )
  if 72 - 72: I1Ii1I1 * Ooo0Ooo * IIiIIiIi11I1 % IiIIii11Ii . ooo000
  self . taskqueueWGControllerCenterTCP = Queue ( )
  if 68 - 68: Ooo0Ooo * OooOoo - oOo0O00
  if 49 - 49: IIiIIiIi11I1 % i1
  if 29 - 29: OooOoo * Ii - oOO
  if 53 - 53: I11iiIi11i1I % ooo000 / ooOOO / I1I
  if 43 - 43: iI1iII1I1I1i . i1i1i1111I + I1I % ooOOO . IiI11Ii111 - IiI11Ii111
  if 6 - 6: I1I
  if 98 - 98: oOO * IIiIIiIi11I1 / i1iiIII111 / Iii1i + I1I
  if 25 - 25: IIiIIiIi11I1 . IiI11Ii111 / I1I * i1 - i1iiIII111 % oOo0O00
  if 49 - 49: IiIIii11Ii % ooOOO + I11iiIi11i1I + IIiIIiIi11I1
  if 60 - 60: IIiIIiIi11I1
  if 98 - 98: IiIIii11Ii / Ooo0Ooo + Ii
  if 73 - 73: OooOoo * Iii1i
  if 34 - 34: i1I % Ooo0Ooo * OooOoo + i1iiIII111 / i1
  if 49 - 49: IIiIIiIi11I1 / i1iiIII111 % IIiIIiIi11I1 + IIiIIiIi11I1 * iI1iII1I1I1i
  if 22 - 22: I1Ii1I1 + oOO / I1Ii1I1 - Ii % Ii % i1i1i1111I
  if 86 - 86: Iii1i
  if 53 - 53: i1 * i1i1i1111I
  if 91 - 91: I1I . I11iiIi11i1I
  if 59 - 59: IiI11Ii111 . IiI11Ii111 * IIiIIiIi11I1
  if 85 - 85: Iii1i . oOO % Iii1i - Iii1i
  if 68 - 68: oOO + Iii1i + Ooo0Ooo % Oo / I11iiIi11i1I . OooOoo
  deferToThread ( self . DealMoreData )
  if 31 - 31: I11iiIi11i1I % ooOOO
  if 46 - 46: i1i1i1111I - ooo000 + iI1iII1I1I1i
  self . commUDP = wgTCPConRPC ( )
  self . commUDP . objWGControllerCenterTCP = self
  if 73 - 73: i1 * oOo0O00
  if 88 - 88: Ii
  if 12 - 12: ooo000 - IIiIIiIi11I1 % Iii1i . I1Ii1I1
  reactor . listenUDP ( wgGlobal . dataserverPort + tcploc , self . commUDP )
  if 11 - 11: i1iiIII111 - Oo % Ii % i1
  if 28 - 28: IIiIIiIi11I1 % Ii + ooOOO . i1I % Ii * I1Ii1I1
  if 41 - 41: I1I
  if 76 - 76: ooo000 * i1i1i1111I
 def buildProtocol ( self , addr ) :
  return TcpServerHandle ( self )
  if 39 - 39: i1 % i1I
 def DealMoreData ( self ) :
  if 50 - 50: i1iiIII111 % OooOoo - i1i1i1111I * IiIIii11Ii % Oo . Ooo0Ooo
  while True :
   i111IIi = False
   try :
    if 82 - 82: IIiIIiIi11I1 - IiIIii11Ii / oOO
    if 49 - 49: i1I / ooo000 * IiI11Ii111 . oOo0O00
    if 32 - 32: i1i1i1111I . OooOoo + OooOoo - ooo000 * IiIIii11Ii + Oo
    if 12 - 12: oOo0O00
    if 57 - 57: Oo + i1i1i1111I / I1Ii1I1
    O00OoooO0o = self . DealTCPQueue4HeartBeatPacket ( )
    OO = ( self . DealTCPQueue4QRCode ( ) )
    O00 = ( self . DealTCPQueue4Mobile ( ) )
    iIiiIIIIiiiI = ( self . DealTCPQueue4ReplyFromController ( ) )
    OOoOOo = ( self . DealTCPQueue4Dingyue ( ) )
    i111IIi = i111IIi or O00OoooO0o or OO or O00 or iIiiIIIIiiiI or OOoOOo
    if 93 - 93: IiI11Ii111 - I1I % Oo - oOo0O00 / ooo000 . i1iiIII111
    if 80 - 80: iI1iII1I1I1i + Ooo0Ooo + IiI11Ii111 * OooOoo
    if 39 - 39: I1I % i1iiIII111 - I1Ii1I1
   except Exception as II :
    pass
    mMonitorInfo . wglog ( "1601" )
    mMonitorInfo . wglog ( II )
   if not i111IIi :
    time . sleep ( 0.001 )
   if not i111IIi :
    try :
     O000O0 = self . taskqueueWGControllerCenterTCP . get ( block = True )
     self . taskqueueWGControllerCenterTCP . task_done ( )
    except Exception as IIIIi1i1 :
     pass
     if 70 - 70: oOO * Iii1i
     if 94 - 94: I1I * oOo0O00 - i1i1i1111I * Ooo0Ooo
     if 87 - 87: oOo0O00 / ooOOO / OooOoo * Ooo0Ooo
     if 49 - 49: iI1iII1I1I1i
     if 77 - 77: ooo000 % I11iiIi11i1I % Ooo0Ooo * oOO
     if 5 - 5: oOO * i1i1i1111I % Oo
     if 99 - 99: IiIIii11Ii * I1Ii1I1
     if 83 - 83: i1I . ooo000 * Ooo0Ooo + Iii1i . Oo
     if 34 - 34: I11iiIi11i1I % oOO
     if 75 - 75: i1 % IiIIii11Ii - iI1iII1I1I1i - i1I * I11iiIi11i1I * OooOoo
 def datagramReceivedShare ( self , data , addr ) :
  if 45 - 45: IIiIIiIi11I1
  if 14 - 14: i1i1i1111I - OooOoo . IiIIii11Ii
  if 40 - 40: I1I - IIiIIiIi11I1 % IiIIii11Ii
  if 61 - 61: iI1iII1I1I1i
  if 93 - 93: i1iiIII111 - oOo0O00 . Oo . i1iiIII111 . Oo * I1Ii1I1
  if 95 - 95: I1Ii1I1 % oOO
  if 21 - 21: Ooo0Ooo % i1 - ooo000
  if 81 - 81: Ooo0Ooo / ooo000
  if 4 - 4: I1I % i1I - ooo000 - I1I . ooOOO / i1i1i1111I
  if 74 - 74: oOO
  if 24 - 24: I1I + Oo - ooOOO
  if 86 - 86: i1iiIII111 % ooo000 % ooo000 % i1I
  if 15 - 15: iI1iII1I1I1i + I1Ii1I1 % oOo0O00
  if 79 - 79: OooOoo . Oo + oOo0O00 / I1Ii1I1 . IiIIii11Ii
  if 89 - 89: ooo000 % Ooo0Ooo
  if 77 - 77: ooo000 % Ooo0Ooo
  if 24 - 24: oOO * I1Ii1I1 * I1Ii1I1 % IIiIIiIi11I1
  if 37 - 37: i1iiIII111 / iI1iII1I1I1i
  if 80 - 80: IiIIii11Ii
  if 2 - 2: I1I / oOO - IIiIIiIi11I1 % Ooo0Ooo
  if 88 - 88: iI1iII1I1I1i - I1Ii1I1 - i1I . Iii1i
  IIII11 = 0
  if 99 - 99: I11iiIi11i1I % i1I . ooOOO . oOO
  if 47 - 47: iI1iII1I1I1i . I1I % Oo - i1 * oOo0O00
  if 5 - 5: IiIIii11Ii + iI1iII1I1I1i . i1 . I1I
  if 95 - 95: IiIIii11Ii * IiI11Ii111 * Ooo0Ooo * IiI11Ii111 / OooOoo
  if 27 - 27: i1I . IiIIii11Ii
  if len ( data ) % 64 == 0 :
   if self . taskqueueWGControllerCenterTCP . empty ( ) :
    self . taskqueueWGControllerCenterTCP . put ( len ( data ) )
   wgAppConfig . logdebug ( "Original Data New {0} from {1} DataLen={2:d} " . format ( binascii . hexlify ( data ) , addr , len ( data ) ) )
   if 69 - 69: oOO % i1iiIII111 / oOo0O00
   if 38 - 38: I11iiIi11i1I + Oo * Ooo0Ooo / ooOOO . OooOoo
   if 90 - 90: OooOoo / i1iiIII111
   OO0000 = WGPacket ( data , addr )
   if 32 - 32: IIiIIiIi11I1 - i1I / ooOOO * Ooo0Ooo * iI1iII1I1I1i - i1i1i1111I
   if 82 - 82: ooo000
   if 66 - 66: IiIIii11Ii + IIiIIiIi11I1 - i1I + i1i1i1111I . iI1iII1I1I1i * IiIIii11Ii
   if ( OO0000 . cmdtype == 0x17 ) and ( OO0000 . controllerSN > 0 ) and ( ( OO0000 . functionID == 0x20 ) or ( OO0000 . functionID == 0x22 ) or ( OO0000 . functionID == 0x26 ) ) and OO0000 . sid == 0 :
    pass
    if 9 - 9: I1I - I1I - ooOOO - oOo0O00 + i1iiIII111
    if 71 - 71: i1I / i1iiIII111 - Ii * Oo . iI1iII1I1I1i
   elif ( OO0000 . cmdtype == 0x37 ) and ( ( WGControllerCenterTCP . commPID & 0xffff ) == OO0000 . reservedA ) :
    pass
   else :
    if WGControllerCenterTCP . commSM4 > 0 :
     if 3 - 3: I1Ii1I1
     if 57 - 57: Ooo0Ooo . OooOoo / oOo0O00 * I1Ii1I1
     if 36 - 36: IiIIii11Ii
     if 33 - 33: IiIIii11Ii
     if 86 - 86: Ii / oOo0O00 - i1 * i1i1i1111I - Oo * Iii1i
     if 28 - 28: OooOoo . i1 % iI1iII1I1I1i % Iii1i
     if 2 - 2: Oo + OooOoo - i1i1i1111I - ooo000 / Oo . Oo
     if 41 - 41: OooOoo + OooOoo - OooOoo
     if 9 - 9: Iii1i % I1Ii1I1 % IiIIii11Ii - I1I * OooOoo
     if 53 - 53: iI1iII1I1I1i * i1i1i1111I / OooOoo . i1I . ooo000
     if 45 - 45: OooOoo + ooOOO / i1i1i1111I * i1
     if ( len ( data ) == 192 ) and ( ( data [ 188 ] == 0 ) and ( data [ 189 ] == 0 ) and ( data [ 190 ] == 0 ) and ( data [ 191 ] == 0 ) ) :
      IIiIiiIiI = WGControllerCenterTCP . commSM4_Dec ( data )
      oOOOOO0 = [ data [ II1iIIi1Ii ] for II1iIIi1Ii in range ( 0 , len ( data ) ) ]
      for II1iIIi1Ii in range ( 0 , 64 ) :
       oOOOOO0 [ II1iIIi1Ii ] = IIiIiiIiI [ II1iIIi1Ii ]
      oOo000o0OO0o = bytes ( oOOOOO0 )
     else :
      oOo000o0OO0o = WGControllerCenterTCP . commSM4_Dec ( data )
      if 31 - 31: Oo - IIiIIiIi11I1 / IiI11Ii111 * i1i1i1111I
     OO0000 = WGPacket ( oOo000o0OO0o , addr )
   if ( 1 < 0 ) :
    pass
   elif ( OO0000 . cmdtype == 0x17 ) and ( OO0000 . controllerSN > 0 ) and ( OO0000 . functionID == 0x20 ) and OO0000 . sid == 0 :
    IIII11 = 1
    self . TCPQueue4HeartBeatPacket . append ( OO0000 )
    if self . countUsersOfDingyue > 0 and ( self . optionNewRecordSend == 0 ) :
     self . TCPQueue4Dingyue . append ( OO0000 )
   elif ( OO0000 . cmdtype == 0x17 ) and ( OO0000 . controllerSN > 0 ) and ( OO0000 . functionID == 0x26 ) and OO0000 . sid == 0 :
    IIII11 = 1
    self . TCPQueue4HeartBeatPacket . append ( OO0000 )
    if self . countUsersOfDingyue > 0 and ( self . optionNewRecordSend == 0 ) :
     self . TCPQueue4Dingyue . append ( OO0000 )
     if 68 - 68: IiIIii11Ii
   elif ( ( OO0000 . cmdtype == 0x17 ) and ( OO0000 . controllerSN > 0 ) and ( OO0000 . functionID == 0x22 ) ) :
    IIII11 = 1
    self . TCPQueue4QRCode . append ( OO0000 )
    self . addToTCPQueue4QRwebAPI ( OO0000 )
    if 41 - 41: i1I - Ooo0Ooo
    if 47 - 47: I1Ii1I1 * i1i1i1111I - i1I . Iii1i . ooOOO
    if ( ( self . countUsersOfDingyue ) > 0 ) :
     self . TCPQueue4Dingyue . append ( OO0000 )
     if 28 - 28: Ii
   elif ( OO0000 . cmdtype == 0x37 ) :
    if ( ( WGControllerCenterTCP . commPID == 0 ) or ( ( WGControllerCenterTCP . commPID & 0xffff ) == OO0000 . reservedA ) ) :
     O00OO0Oo0000 = 1
     if ( not ( wgGlobal . allowpcip == None ) ) :
      if ( not ( addr [ 0 ] in [ wgGlobal . allowpcip ] ) ) :
       O00OO0Oo0000 = 0
     if ( O00OO0Oo0000 == 0 ) :
      pass
     elif ( OO0000 . functionID == 0x10 ) :
      self . TCPQueue4Dingyue . append ( OO0000 )
     else :
      self . TCPQueue4Mobile . append ( OO0000 )
   elif ( OO0000 . controllerSN > 0 ) :
    if ( ( OO0000 . sid <= 0x5fffffff ) and ( OO0000 . sid >= 0x50000001 ) ) :
     if 20 - 20: oOo0O00 . I11iiIi11i1I . I1I
     wgAppConfig . logdebug ( "Server Receive <= From ControllerSN={0},xid={1}" . format ( OO0000 . controllerSN , OO0000 . sid ) )
     if ( OO0000 . sid > 0 ) :
      self . TCPQueue4ReplyFromController . append ( OO0000 )
     if ( OO0000 . functionID == 0x20 ) :
      if 20 - 20: ooo000 + i1i1i1111I % Ooo0Ooo + i1 * Ii
      wgAppConfig . wglog (
 "Server Receive <= From ControllerSN={0} reply xid= {1:d}" . format ( OO0000 . controllerSN , OO0000 . sid ) )
     elif ( OO0000 . functionID == 0x40 ) :
      if ( data [ 8 ] == 1 ) :
       wgAppConfig . wglog ( "Server Receive <= Controller RemoteOpenDoor Successfully ControllerSN= {0:d}" . format ( OO0000 . controllerSN ) )
      else :
       wgAppConfig . wglog ( "Server Receive <= Controller  ???RemoteOpenDoor Failed ControllerSN= {0:d}" . format ( OO0000 . controllerSN ) )
    if ( ( OO0000 . sid <= 0x4fffffff ) and ( OO0000 . sid >= 0x40000001 ) ) :
     if 32 - 32: Ooo0Ooo
     if 15 - 15: IiI11Ii111 % oOo0O00 . I1Ii1I1 * Oo
     IIII11 = 1
   del OO0000
   if self . taskqueueWGControllerCenterTCP . empty ( ) :
    self . taskqueueWGControllerCenterTCP . put ( len ( data ) )
  if IIII11 == 1 :
   if wgGlobal . dataserverIP == "0.0.0.0" :
    if 2 - 2: Iii1i / IIiIIiIi11I1 / I11iiIi11i1I + ooOOO % IiIIii11Ii / OooOoo
    self . commUDP . run ( "127.0.0.1" , wgGlobal . dataserverPort , data )
   else :
    self . commUDP . run ( wgGlobal . dataserverIP , wgGlobal . dataserverPort , bytes ( data ) )
  return
  if 96 - 96: Oo * i1iiIII111 . Ooo0Ooo
  if 35 - 35: ooOOO . i1I * i1i1i1111I * iI1iII1I1I1i - I11iiIi11i1I
  if 47 - 47: IIiIIiIi11I1
  if 73 - 73: I1Ii1I1 + ooOOO
  if 99 - 99: i1I
  if 87 - 87: i1 . I11iiIi11i1I * Ii . i1 . IIiIIiIi11I1 . IiIIii11Ii
  if 50 - 50: Ii / oOO
  if 92 - 92: Ooo0Ooo * i1iiIII111 / Ooo0Ooo / i1iiIII111 * i1i1i1111I + i1I
  if 48 - 48: I11iiIi11i1I
  if 87 - 87: I1Ii1I1
  if 29 - 29: ooo000 . iI1iII1I1I1i . oOo0O00 + i1i1i1111I + oOO
  if 59 - 59: IiIIii11Ii
  if 26 - 26: oOo0O00 % IiI11Ii111 * i1
  if 60 - 60: IIiIIiIi11I1 % oOO / i1
  if 20 - 20: Ooo0Ooo
  if 4 - 4: IiIIii11Ii % Iii1i
  if 43 - 43: ooo000
  if 95 - 95: Oo + I11iiIi11i1I / Ooo0Ooo / Ii - ooOOO / i1i1i1111I
  if 6 - 6: Ooo0Ooo % IiIIii11Ii
  if 59 - 59: i1I . I11iiIi11i1I . ooo000 / i1I . Ii % Ooo0Ooo
  if 85 - 85: oOo0O00 / ooOOO
  if 41 - 41: i1iiIII111 * iI1iII1I1I1i + i1 + i1i1i1111I
  if 26 - 26: Oo % OooOoo
  if 14 - 14: iI1iII1I1I1i - i1iiIII111
  if 53 - 53: oOO
  if 46 - 46: oOo0O00 - iI1iII1I1I1i
  if 34 - 34: i1i1i1111I
  if 21 - 21: IiI11Ii111 + I1I . OooOoo + i1 . ooo000 + I11iiIi11i1I
  if 7 - 7: ooOOO + Iii1i / iI1iII1I1I1i - oOO % Oo / iI1iII1I1I1i
  if 14 - 14: Iii1i . Ii
  if 100 - 100: I1I / ooo000
  if 48 - 48: i1i1i1111I * i1I % i1i1i1111I + i1i1i1111I . iI1iII1I1I1i / OooOoo
  if 12 - 12: Ii . Ii - I1Ii1I1
  if 74 - 74: ooo000 * Iii1i - Ooo0Ooo - I1Ii1I1
  if 46 - 46: ooOOO / ooOOO
  if 58 - 58: IiI11Ii111 . IiI11Ii111
  if 79 - 79: oOo0O00 * IIiIIiIi11I1
  if 53 - 53: Ii - ooOOO . OooOoo - I1I - I11iiIi11i1I
  if 32 - 32: Iii1i % IiIIii11Ii - oOO - IiIIii11Ii - I11iiIi11i1I % i1iiIII111
  if 50 - 50: Iii1i / IiI11Ii111 + i1
  if 4 - 4: IIiIIiIi11I1 . IiIIii11Ii % i1I
  if 30 - 30: i1 . i1
  if 35 - 35: Ii * i1I / IiIIii11Ii - I1Ii1I1 / i1
  if 76 - 76: IiIIii11Ii * Iii1i % IiIIii11Ii
  if 73 - 73: i1I / IIiIIiIi11I1 / oOo0O00 % IIiIIiIi11I1 / Ii
  if 12 - 12: i1
  if 78 - 78: I11iiIi11i1I . IIiIIiIi11I1
  if 1 - 1: I1I % i1iiIII111 / I1Ii1I1
  if 42 - 42: Iii1i
  if 19 - 19: OooOoo * I11iiIi11i1I . i1i1i1111I + ooo000 + i1I
  if 13 - 13: i1iiIII111 + I1Ii1I1 / Ooo0Ooo
  if 82 - 82: i1iiIII111 * oOO / IiI11Ii111 * IiIIii11Ii
  if 29 - 29: I1Ii1I1 % oOo0O00 - oOo0O00 * I1Ii1I1 / Iii1i * i1I
  if 51 - 51: I1Ii1I1 . i1iiIII111 % i1 % i1I * Oo
  if 64 - 64: i1i1i1111I + i1
  if 45 - 45: i1i1i1111I / i1iiIII111 * iI1iII1I1I1i
  if 2 - 2: i1 / i1i1i1111I * IiIIii11Ii
  if 33 - 33: Iii1i
  if 7 - 7: Ooo0Ooo - Ooo0Ooo / ooo000 - IiIIii11Ii
  if 70 - 70: IIiIIiIi11I1 . i1 % iI1iII1I1I1i / i1i1i1111I
  if 5 - 5: i1iiIII111 . Oo + i1i1i1111I
  if 44 - 44: I1Ii1I1 - i1i1i1111I
  if 71 - 71: i1iiIII111
  if 77 - 77: Iii1i - I1Ii1I1 - Ooo0Ooo % Ii / Oo
  if 43 - 43: Ooo0Ooo / oOO
  if 93 - 93: ooOOO % oOo0O00 * i1 + Ii . i1I - oOO
  if 63 - 63: IiIIii11Ii . Iii1i
  if 55 - 55: oOo0O00
  if 85 - 85: IIiIIiIi11I1 % Oo / I1I . oOo0O00 / IIiIIiIi11I1 . Oo
  if 40 - 40: IIiIIiIi11I1 - ooOOO * oOO . ooo000
  if 24 - 24: IiIIii11Ii - iI1iII1I1I1i / Ii
  if 34 - 34: ooOOO - ooOOO / Ii % OooOoo
  if 97 - 97: Oo * IiIIii11Ii . Ooo0Ooo % i1 % Ii % ooo000
  if 67 - 67: IIiIIiIi11I1 % i1 % oOo0O00 - i1i1i1111I
  if 51 - 51: I11iiIi11i1I . I11iiIi11i1I % IiI11Ii111 % Oo / I1Ii1I1 - I1Ii1I1
  if 28 - 28: Ii / Ooo0Ooo
  if 11 - 11: I1I - OooOoo * ooOOO % i1i1i1111I + ooo000 . oOO
  if 51 - 51: ooOOO + iI1iII1I1I1i % IiI11Ii111 . I11iiIi11i1I % Ooo0Ooo
  if 15 - 15: OooOoo / i1I % Oo % Oo
  if 73 - 73: oOo0O00
  if 69 - 69: ooOOO - IIiIIiIi11I1 - i1I
  if 78 - 78: I1Ii1I1 . ooo000 + IiI11Ii111 / IiI11Ii111
  if 88 - 88: Ii - i1iiIII111 - i1 * IIiIIiIi11I1 . IiIIii11Ii + Iii1i
  if 44 - 44: ooOOO + Oo - i1
  if 18 - 18: iI1iII1I1I1i * ooOOO + Ooo0Ooo
  if 78 - 78: I1I . I1I - IIiIIiIi11I1 - IiIIii11Ii % I11iiIi11i1I . I1Ii1I1
  if 9 - 9: I11iiIi11i1I * OooOoo - I11iiIi11i1I
  if 73 - 73: I1Ii1I1
  if 25 - 25: i1 . Ii
  if 59 - 59: IiIIii11Ii
  if 91 - 91: IiIIii11Ii + iI1iII1I1I1i
  if 65 - 65: Oo * Iii1i * IiIIii11Ii / IIiIIiIi11I1
  if 77 - 77: IIiIIiIi11I1 / oOO % IiIIii11Ii + I1Ii1I1
  if 34 - 34: i1i1i1111I * Iii1i + Ii - i1I / i1 / i1
  if 87 - 87: Ooo0Ooo + I11iiIi11i1I
  if 3 - 3: IIiIIiIi11I1 . I1Ii1I1 / Iii1i % ooOOO / oOo0O00 % ooOOO
  if 55 - 55: iI1iII1I1I1i + I1I + oOo0O00 - I11iiIi11i1I
  if 80 - 80: Oo % I11iiIi11i1I . IiIIii11Ii * oOO
  if 83 - 83: oOo0O00 % Oo + i1i1i1111I - ooOOO + i1iiIII111
  if 36 - 36: oOo0O00 * OooOoo / I11iiIi11i1I
  if 98 - 98: IiI11Ii111 . ooo000
class TcpServerHandle ( protocol . Protocol ) :
 arrrefreshtime = dict ( )
 timer4clear = time . time ( ) + 0
 if 85 - 85: OooOoo * Iii1i * IIiIIiIi11I1
 def __init__ ( self , factory ) :
  self . factory = factory
  if 38 - 38: ooo000 - Ii - i1I
 def connectionMade ( self ) :
  if 91 - 91: i1iiIII111 / i1 * oOO * IIiIIiIi11I1 * IiIIii11Ii
  if 65 - 65: oOO / oOo0O00 / Oo
  if 61 - 61: ooOOO * oOO
  if 98 - 98: i1iiIII111 * i1i1i1111I
  if 29 - 29: oOo0O00 / i1iiIII111 - IiIIii11Ii
  self . factory . clients . add ( self )
  wgAppConfig . wglog ( "TCP StartAAA111 len=" + str ( len ( self . factory . clients ) ) )
  pass
  pass
  if 34 - 34: iI1iII1I1I1i + IIiIIiIi11I1 . i1I . IiI11Ii111 % i1i1i1111I
  if 61 - 61: Oo % ooo000
  TcpServerHandle . arrrefreshtime [ self ] = time . time ( )
  if 68 - 68: Ii - OooOoo / I1I
  if 44 - 44: iI1iII1I1I1i % i1iiIII111 / I1Ii1I1 * i1i1i1111I
  if 63 - 63: I1Ii1I1 * Ii + Iii1i
  if 58 - 58: I1Ii1I1 / I1Ii1I1 % IIiIIiIi11I1
 def connectionLost ( self , reason ) :
  if self in self . factory . clients :
   self . factory . clients . remove ( self )
   wgAppConfig . wglog ( "TCP StartAAA666 Del len=" + str ( len ( self . factory . clients ) ) )
   pass
   pass
   if self in TcpServerHandle . arrrefreshtime :
    TcpServerHandle . arrrefreshtime . pop ( self )
    pass
    if 98 - 98: OooOoo
    if 79 - 79: Ooo0Ooo * Ooo0Ooo - ooo000 - Iii1i
   try :
    pass
    del self
   except Exception as II :
    pass
    if 5 - 5: IiIIii11Ii / i1iiIII111 . I1I % Iii1i . i1
    if 29 - 29: oOo0O00 + Oo / I11iiIi11i1I - oOo0O00 % i1i1i1111I / Ii
    if 39 - 39: I11iiIi11i1I - I11iiIi11i1I % i1iiIII111
    if 56 - 56: i1iiIII111 / IiIIii11Ii - I1Ii1I1 / Iii1i - i1 / OooOoo
    if 28 - 28: i1I . I1Ii1I1 % IiIIii11Ii . Ii * ooOOO - oOO
    if 80 - 80: IiI11Ii111
 def dataReceived ( self , data ) :
  if 7 - 7: Iii1i . Oo . iI1iII1I1I1i - Oo - ooOOO % IIiIIiIi11I1
  if 90 - 90: Iii1i / oOo0O00
  O00OOo = self . transport . getPeer ( )
  self . factory . datagramReceivedShare ( data , O00OOo )
  OoOO0oO0O = time . time ( )
  try :
   if self in self . factory . clients :
    TcpServerHandle . arrrefreshtime [ self ] = OoOO0oO0O
   if OoOO0oO0O > TcpServerHandle . timer4clear :
    TcpServerHandle . timer4clear = OoOO0oO0O + 60
    if 54 - 54: I11iiIi11i1I . IiI11Ii111 + OooOoo % Oo - IiI11Ii111 % Oo
    oOo = self . factory . clients . copy ( )
    for IiI1IIii1I in oOo :
     if IiI1IIii1I in TcpServerHandle . arrrefreshtime :
      if OoOO0oO0O > TcpServerHandle . arrrefreshtime [ IiI1IIii1I ] + 92 :
       if 27 - 27: i1iiIII111 - Iii1i / i1i1i1111I . i1I . IIiIIiIi11I1 * OooOoo
       if 12 - 12: Oo . i1 + oOo0O00 - iI1iII1I1I1i + Ii
       if 13 - 13: oOo0O00 . IiIIii11Ii
       if 87 - 87: Oo - Ii . Iii1i
       pass
       pass
       IiI1IIii1I . transport . loseConnection ( )
       TcpServerHandle . arrrefreshtime . pop ( IiI1IIii1I )
       wgAppConfig . wglog ( "TCP StartAAA555 Del len=" + str ( len ( self . factory . clients ) ) )
  except Exception as iII1I1i :
   pass
   wgAppConfig . wglog ( iII1I1i )
   if 48 - 48: Oo / ooo000 - iI1iII1I1I1i
   if 35 - 35: IIiIIiIi11I1 * I1Ii1I1 - OooOoo . Ii
   if 21 - 21: Ooo0Ooo
   if 76 - 76: iI1iII1I1I1i % IiI11Ii111 / IiIIii11Ii - IiI11Ii111
   if 4 - 4: OooOoo * IIiIIiIi11I1 - Ooo0Ooo . Ii - ooOOO . i1iiIII111
   if 2 - 2: I11iiIi11i1I * i1I * i1I * i1iiIII111 / I11iiIi11i1I % IiI11Ii111
   if 13 - 13: i1 * IiIIii11Ii - ooo000 * OooOoo
   if 72 - 72: Iii1i . I1Ii1I1 * IIiIIiIi11I1 % I1Ii1I1 - i1i1i1111I
   if 97 - 97: i1 + ooOOO + I11iiIi11i1I . i1
   if 71 - 71: ooo000 - i1i1i1111I / iI1iII1I1I1i - iI1iII1I1I1i % IIiIIiIi11I1 . iI1iII1I1I1i
   if 41 - 41: IIiIIiIi11I1
   if 96 - 96: Oo . Ooo0Ooo - oOO . Iii1i % IiI11Ii111 . IiI11Ii111
   if 82 - 82: oOO % iI1iII1I1I1i / i1iiIII111
   if 47 - 47: i1
   if 59 - 59: IiI11Ii111 % IIiIIiIi11I1 % IiIIii11Ii
   if 92 - 92: Oo . i1 * i1iiIII111 . IiIIii11Ii
   if 82 - 82: I11iiIi11i1I % Oo + Ii
   if 22 - 22: Ooo0Ooo / ooOOO . I1I % I1I
   if 16 - 16: iI1iII1I1I1i / i1iiIII111 / Ooo0Ooo . Ii
   if 82 - 82: Oo % iI1iII1I1I1i - i1I * OooOoo % Iii1i - I11iiIi11i1I
   if 95 - 95: oOO
   if 56 - 56: I11iiIi11i1I - i1I / OooOoo / ooo000 . IiI11Ii111
   if 78 - 78: ooo000 % IiI11Ii111 - i1
   if 36 - 36: oOo0O00 + OooOoo - Ooo0Ooo / IiI11Ii111
   if 90 - 90: oOo0O00 % oOO * oOO + I1I * I1I / IiI11Ii111
   if 92 - 92: IiIIii11Ii * OooOoo * I1Ii1I1
   if 65 - 65: i1iiIII111 * Oo * oOO + i1I - i1I
   if 86 - 86: oOO - Ooo0Ooo + I11iiIi11i1I . Iii1i . OooOoo - Ii
   if 86 - 86: I1I
   if 35 - 35: ooOOO + OooOoo
   if 8 - 8: I1I + Ii % iI1iII1I1I1i + IiI11Ii111 . oOO * i1
   if 96 - 96: ooo000 % I11iiIi11i1I / oOo0O00 * Ii * ooo000 - Ooo0Ooo
   if 88 - 88: Ii % ooOOO . I1I
   if 80 - 80: IiIIii11Ii / oOO % IiI11Ii111 * I1I
   if 100 - 100: oOo0O00 / I1Ii1I1 - i1i1i1111I * I1Ii1I1 / I11iiIi11i1I * Oo
cp = configparser . ConfigParser ( allow_no_value = True )
cp . read ( wgGlobal . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
if ( cp . has_section ( 'wgconf' ) ) :
 config = cp . items ( "wgconf" )
 if 49 - 49: Ooo0Ooo
 if ( cp . has_option ( 'wgconf' , 'cloudserverIP' ) ) :
  wgGlobal . dataserverIP = cp [ 'wgconf' ] [ 'cloudserverIP' ]
 if ( cp . has_option ( 'wgconf' , 'cloudserverPort' ) ) :
  wgGlobal . dataserverPort = int ( cp [ 'wgconf' ] [ 'cloudserverPort' ] )
  if 36 - 36: OooOoo + i1I / Iii1i + iI1iII1I1I1i + OooOoo
  if 6 - 6: IiI11Ii111 + Ii
  if 100 - 100: oOo0O00 % i1I - IiIIii11Ii % i1iiIII111 . i1 % I1Ii1I1
  if 67 - 67: I11iiIi11i1I
  if 21 - 21: oOO % i1i1i1111I - i1 + I1I
  if 85 - 85: IiIIii11Ii + I1I + IiI11Ii111
  if 68 - 68: Iii1i % IiIIii11Ii . i1 - IiI11Ii111
  if 80 - 80: i1iiIII111 . ooo000
  if 15 - 15: oOO + oOo0O00 * I11iiIi11i1I . IiIIii11Ii
  if 66 - 66: IIiIIiIi11I1 - oOo0O00 . I1I * I11iiIi11i1I + i1i1i1111I
  if 13 - 13: oOO % Iii1i
  if 81 - 81: I1I
  if 86 - 86: Ooo0Ooo / I1I . Ooo0Ooo % i1i1i1111I * OooOoo * Iii1i
  if 59 - 59: Ii + i1i1i1111I . I1Ii1I1 . oOO + i1I . i1
 if ( cp . has_option ( 'wgconf' , 'testModeAllowAutoRemoteOpenDoor' ) ) :
  if 34 - 34: iI1iII1I1I1i - ooo000 * i1iiIII111 - Iii1i
  WGControllerCenterTCP . setTestMode ( int ( cp [ 'wgconf' ] [ 'testModeAllowAutoRemoteOpenDoor' ] ) )
  if ( int ( cp [ 'wgconf' ] [ 'testModeAllowAutoRemoteOpenDoor' ] ) > 0 ) :
   mMonitorInfo . printCHS ( "当前服务处于测试模式:  刷任意卡 远程开门...\r\n[可以通过修改 wgconfig.ini 文件中的 testModeAllowAutoRemoteOpenDoor =0 来关闭测试模式]" )
 if ( cp . has_option ( 'wgconf' , 'testModeDebugPrint' ) ) :
  WGControllerCenterTCP . setModeDebugPrint ( int ( cp [ 'wgconf' ] [ 'testModeDebugPrint' ] ) )
  if 50 - 50: oOO . IiI11Ii111 . i1I . i1i1i1111I . I11iiIi11i1I + Oo
  if 38 - 38: IiI11Ii111 + oOo0O00 . ooo000 - Iii1i - I1Ii1I1 - oOO
  if 29 - 29: ooo000 * oOO
 if ( cp . has_option ( 'wgconf' , 'commSM4' ) ) :
  if 38 - 38: oOo0O00 / IiIIii11Ii * oOO . OooOoo % Ii . Iii1i
  WGControllerCenterTCP . setCommSM4 ( cp [ 'wgconf' ] [ 'commSM4' ] )
  if __name__ == "__main__" :
   mMonitorInfo . printCHS ( "当前服务 启用了通信加密...\r\n[可以通过修改 wgconfig.ini 文件中的 commSM4 =0 来关闭]" )
 if ( cp . has_option ( 'wgconf' , 'allowpcip' ) ) :
  if 74 - 74: oOO - i1i1i1111I % I1I + IiIIii11Ii * I1I
  wgGlobal . allowpcip = ( cp [ 'wgconf' ] [ 'allowpcip' ] )
 if ( cp . has_option ( 'wgconf' , 'logModeFileQR' ) ) :
  WGControllerCenterTCP . logModeFileQR = ( int ( cp [ 'wgconf' ] [ 'logModeFileQR' ] ) )
  if not wgAppConfig . wgrecordlogEnable :
   wgAppConfig . wgrecordlogEnable = WGControllerCenterTCP . logModeFileQR != 0
 if ( cp . has_option ( 'wgconf' , 'logModeFileSwipe' ) ) :
  WGControllerCenterTCP . logModeFileSwipe = ( int ( cp [ 'wgconf' ] [ 'logModeFileSwipe' ] ) )
  if not wgAppConfig . wgrecordlogEnable :
   wgAppConfig . wgrecordlogEnable = WGControllerCenterTCP . logModeFileSwipe != 0
 if ( cp . has_option ( 'wgconf' , 'logModeHourToClear' ) ) :
  WGControllerCenterTCP . logModeHourToClear = ( int ( cp [ 'wgconf' ] [ 'logModeHourToClear' ] ) )
 if ( cp . has_option ( 'wgconf' , 'logModeWeekToClear' ) ) :
  WGControllerCenterTCP . logModeWeekToClear = ( int ( cp [ 'wgconf' ] [ 'logModeWeekToClear' ] ) )
  if 53 - 53: OooOoo % I1Ii1I1 / IiI11Ii111 / I1I + I1Ii1I1 . i1I
  if 7 - 7: oOO - oOo0O00 . i1i1i1111I * Oo + I1I
  if 93 - 93: i1iiIII111 - OooOoo + i1 * oOo0O00 . IiI11Ii111
  if 9 - 9: IIiIIiIi11I1 + iI1iII1I1I1i
  if 43 - 43: oOo0O00 * i1I * i1I / IiIIii11Ii % i1iiIII111
  if 55 - 55: i1iiIII111 . i1
  if 29 - 29: Ooo0Ooo * IiIIii11Ii + i1iiIII111 / iI1iII1I1I1i - IiIIii11Ii - oOo0O00
  if 63 - 63: I1Ii1I1 . IiI11Ii111 * ooOOO . oOO / I1I
  if 34 - 34: i1i1i1111I * i1i1i1111I * I11iiIi11i1I . Iii1i * i1I % ooo000
  if 99 - 99: Ii / ooOOO % oOO % OooOoo - IiIIii11Ii
  if 51 - 51: oOo0O00 % OooOoo
  if 60 - 60: i1i1i1111I % IiIIii11Ii - Iii1i % i1 * IiI11Ii111
  if 88 - 88: OooOoo % iI1iII1I1I1i
  if 21 - 21: i1I % OooOoo
  if 95 - 95: IiIIii11Ii - i1 . i1 - ooOOO . i1 + Ii
  if 86 - 86: IiIIii11Ii % ooo000
  if 61 - 61: Ii . i1iiIII111 * I11iiIi11i1I . ooOOO
  if 95 - 95: oOO % I1Ii1I1 % ooo000
  if 84 - 84: i1I + i1i1i1111I * ooOOO % ooo000
  if 29 - 29: IiIIii11Ii - IIiIIiIi11I1 + IiI11Ii111 - I11iiIi11i1I . OooOoo
  if 57 - 57: i1i1i1111I / I11iiIi11i1I
  if 83 - 83: OooOoo / I1Ii1I1 / IiIIii11Ii
  if 78 - 78: i1 . i1iiIII111 - Oo * IIiIIiIi11I1 - I1I - i1I
  if 21 - 21: Iii1i - Ii / i1I / I1Ii1I1 % I11iiIi11i1I / Ii
root_loggerTCP = logging . getLogger ( "wglogtcp" )
root_loggerTCP . setLevel ( logging . INFO )
if wgAppConfig . wgrecordlogEnable :
 if 74 - 74: I1Ii1I1 . ooOOO
 handler = logging . FileHandler ( wgGlobal . wgcloudpath1001wgrecordtcp_logName , 'a' , 'utf-8' )
 formatter = logging . Formatter ( '%(asctime)s:%(message)s' )
 handler . setFormatter ( formatter )
 root_loggerTCP . addHandler ( handler )
 if 24 - 24: IiI11Ii111 - Iii1i % oOo0O00 * I1I . iI1iII1I1I1i
 if 78 - 78: I1Ii1I1 - Ooo0Ooo / OooOoo % i1I
 if 99 - 99: I11iiIi11i1I % ooOOO
 if 22 - 22: i1iiIII111 * IiI11Ii111 - i1i1i1111I % ooo000 / OooOoo - Oo
 if 3 - 3: I11iiIi11i1I % Ooo0Ooo
 if 20 - 20: I1Ii1I1 . IiI11Ii111 - Ii % I11iiIi11i1I % Oo
 if 12 - 12: OooOoo * oOO % Ooo0Ooo . I11iiIi11i1I
 if 54 - 54: I11iiIi11i1I . i1 - IIiIIiIi11I1
if __name__ == "__main__" :
 if 99 - 99: i1I + i1I * Ooo0Ooo . OooOoo
 if 33 - 33: i1i1i1111I / IiI11Ii111 + Ooo0Ooo % ooOOO
 if 25 - 25: Iii1i
 if ( len ( sys . argv ) == 2 ) :
  wgGlobal . dataserverIP = sys . argv [ 1 ]
  if 74 - 74: I11iiIi11i1I . ooo000 . I1I * i1iiIII111 * Ooo0Ooo
 if ( len ( sys . argv ) == 3 ) :
  wgGlobal . dataserverIP = sys . argv [ 1 ]
  wgGlobal . dataserverPort = int ( sys . argv [ 2 ] )
  if 47 - 47: OooOoo
 if ( len ( wgGlobal . dataserverIP ) < 1 ) :
  mMonitorInfo . printCHS ( "??? wgconfig.ini , configuration..." )
  input ( "Press Enter exit..." )
  sys . exit ( 0 )
  if 55 - 55: ooOOO % oOO + i1I - IiI11Ii111 + ooo000 + I1I
  if 53 - 53: IIiIIiIi11I1 % IiIIii11Ii / oOO % ooOOO - oOo0O00
  if 74 - 74: ooo000 * OooOoo * Oo
  if 96 - 96: I1Ii1I1 - Oo
  if 28 - 28: i1iiIII111 - IiI11Ii111 % Ii * ooo000 / Iii1i
  if 12 - 12: IiI11Ii111 - Ooo0Ooo
 mMonitorInfo . printCHS ( "wgconfig.ini Configuration[UTF-8]..." )
 if 12 - 12: ooOOO
 if 29 - 29: IiI11Ii111 . ooo000 . ooo000
 if 79 - 79: oOo0O00 % IiI11Ii111 * I1Ii1I1 . IIiIIiIi11I1 * Iii1i - I1I
 if 85 - 85: I1I + IiI11Ii111 . I11iiIi11i1I % i1 * IiI11Ii111
 if 22 - 22: IiIIii11Ii . Iii1i / i1i1i1111I / ooo000 + ooo000 + ooo000
 if 76 - 76: Iii1i % i1i1i1111I
 if 12 - 12: oOO + IiIIii11Ii % ooOOO + IiI11Ii111 / I1I
 if 59 - 59: Iii1i % I1Ii1I1 + I11iiIi11i1I - Oo
 mMonitorInfo . printCHS ( "V2.38 2021-09-19 16:53:33 引入支持SM4 start wg cloud server 启动云服务 IP信息: [{0:s}.{1:d}  tcp]" . format ( wgGlobal . dataserverIP , wgGlobal . dataserverPort ) )
 if 72 - 72: I11iiIi11i1I
 if 38 - 38: I11iiIi11i1I . oOO + i1I
 if 33 - 33: ooo000 - IIiIIiIi11I1 % i1iiIII111 / iI1iII1I1I1i - Iii1i % IIiIIiIi11I1
 if 15 - 15: ooo000 . i1 * i1
 if 41 - 41: I11iiIi11i1I + Iii1i % ooOOO * i1
 if 37 - 37: ooo000
 if 87 - 87: i1i1i1111I + I1Ii1I1 % i1iiIII111 - I1I + ooOOO % I1Ii1I1
 if 96 - 96: IIiIIiIi11I1 / I1I * i1 / I1I + I1I / i1
 if 80 - 80: Oo / i1i1i1111I . IIiIIiIi11I1
 if 79 - 79: oOO
 if 6 - 6: IiI11Ii111 + IIiIIiIi11I1 + ooOOO % IIiIIiIi11I1
 if 24 - 24: ooo000 + i1I / Ii / Ooo0Ooo % IIiIIiIi11I1
 if 70 - 70: I11iiIi11i1I
 if 45 - 45: I1Ii1I1 * Oo - I11iiIi11i1I * iI1iII1I1I1i
 if 41 - 41: Iii1i . I1I * i1I - i1iiIII111 . IiI11Ii111 + ooOOO
 if 24 - 24: i1 + IIiIIiIi11I1 + i1iiIII111 % I1Ii1I1 + IIiIIiIi11I1
 if 55 - 55: IiIIii11Ii - IiIIii11Ii
 if 52 - 52: I1Ii1I1 - OooOoo % i1I
 if 88 - 88: ooOOO . i1
 if 72 - 72: I1I - OooOoo / Iii1i - I1Ii1I1
 if 54 - 54: I11iiIi11i1I / i1iiIII111 % oOo0O00 - ooOOO
 if 72 - 72: ooo000 . I1Ii1I1 . I1I . IIiIIiIi11I1 + Oo
 try :
  endpoints . serverFromString ( reactor , "tcp:{0}:interface={1}" . format ( wgGlobal . dataserverPort , wgGlobal . dataserverIP ) ) . listen ( WGControllerCenterTCP ( ) )
  if 58 - 58: ooOOO + IiIIii11Ii + oOO % IiIIii11Ii + Ooo0Ooo . Oo
 except Exception as e :
  pass
  if 45 - 45: I1I % i1I % oOO * oOo0O00 / i1iiIII111 + I11iiIi11i1I
  mMonitorInfo . printCHS ( "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP , wgGlobal . dataserverPort , e ) )
  mMonitorInfo . printCHS ( "wgconfig.ini..." )
  input ( "Press Enter exit..." )
  sys . exit ( 0 )
 reactor . run ( )
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
