# cython:language_level=3
import configparser
import time
from typing import List , Tuple
if 82 - 82: Iii1i
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from . mMonitorInfo import mMonitorInfo
from . wgpacket import wgGlobal
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
if 98 - 98: I11iiIi11i1I % oOO
import sys
import socket
import platform
if 31 - 31: i1I
if 9 - 9: IiI11Ii111 / oOo0O00 / IiIIii11Ii - I11iiIi11i1I - iI1iII1I1I1i
class wgAppConfig ( ) :
 arrUDPCloudServer = [ ]
 dbAllowOpen = True
 if 16 - 16: i1i1i1111I / i1iiIII111
 if 3 - 3: i1 % i1 % i1i1i1111I . Ii * i1
 if 9 - 9: i1iiIII111
 wgrecordlogEnable = False
 if 10 - 10: ooOOO / IIiIIiIi11I1 * oOO / i1I / i1I
 if 61 - 61: Ooo0Ooo - I1I
 ACTIVE_UDPQueue4QRwebAPI = False
 ACTIVE_UDPQueue4webAPI = False
 ACTIVE_TCPQueue4webAPI = False
 ACTIVE_TCPQueue4QRwebAPI = False
 if 13 - 13: Ooo0Ooo
 if 46 - 46: iI1iII1I1I1i - Ii * Oo * Ii
 if 52 - 52: Oo + I1I / oOO / OooOoo - I1Ii1I1 - ooOOO
 WEBDisplay = False
 if 60 - 60: iI1iII1I1I1i . oOO
 if 13 - 13: oOO
 mysqlParam = ""
 if 2 - 2: i1
 if 22 - 22: IIiIIiIi11I1 - ooo000 / I1Ii1I1 . ooo000
 if 1 - 1: iI1iII1I1I1i + Ooo0Ooo + oOO * IIiIIiIi11I1
 timeStampEnable = 0
 if 20 - 20: I1I + Ii
 htmlIconExisted = False
 htmlDirExisted = False
 if 75 - 75: Ii % i1iiIII111 * Ii . IIiIIiIi11I1 % I11iiIi11i1I % I1Ii1I1
 if 8 - 8: I1Ii1I1 . IiI11Ii111 . i1 . Oo - i1I
 if 32 - 32: Ii % i1i1i1111I % i1I - I11iiIi11i1I % i1iiIII111
 if 34 - 34: i1iiIII111 * i1
 if 34 - 34: oOo0O00 / i1iiIII111 - Iii1i . iI1iII1I1I1i
 if 80 - 80: i1i1i1111I . I1I % ooOOO % IiIIii11Ii / i1i1i1111I
 if 32 - 32: I1Ii1I1 + oOO - oOo0O00
 if 79 - 79: Iii1i % oOO * Oo + ooOOO / Oo . oOO
 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
 if 70 - 70: IiIIii11Ii
 if 75 - 75: Ooo0Ooo / Ii / IiIIii11Ii + IiIIii11Ii . I1I
 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
 if 30 - 30: I1I . ooo000
 if 43 - 43: ooOOO . I11iiIi11i1I + ooo000
 if 87 - 87: Iii1i + ooOOO . i1I / Ii + Oo
 if 77 - 77: i1iiIII111 + IiI11Ii111 - Oo % ooo000
 if 74 - 74: Ii + Ooo0Ooo
 if 1 - 1: I1I % Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
 if 93 - 93: oOo0O00 % Ooo0Ooo * i1iiIII111
 if 52 - 52: oOO + I1I / ooo000 - I1Ii1I1 * i1I % oOo0O00
 if 52 - 52: oOo0O00 . I1I + i1I - i1iiIII111 % iI1iII1I1I1i
 def logprint ( * args ) :
  if 57 - 57: I1I * IIiIIiIi11I1 % I1Ii1I1 * i1i1i1111I
  try :
   if wgGlobal . allowprint :
    if 37 - 37: IiI11Ii111 * i1i1i1111I + oOo0O00 / I1I / OooOoo
    mMonitorInfo . printCHS ( * args )
    if 4 - 4: i1
    if 61 - 61: iI1iII1I1I1i . i1I - ooo000 / ooo000 - i1
    if 19 - 19: Iii1i * Ooo0Ooo . I1Ii1I1 / I11iiIi11i1I * Ii - oOO
    if 32 - 32: iI1iII1I1I1i
    if 18 - 18: I11iiIi11i1I * IiI11Ii111 % iI1iII1I1I1i + IiI11Ii111
    if 93 - 93: oOO - I1Ii1I1 - IIiIIiIi11I1 * ooOOO - i1
    if 82 - 82: IIiIIiIi11I1 % i1 * ooOOO
    if 57 - 57: oOo0O00
  except Exception as II1iiii :
   pass
   if 50 - 50: I1I / Ooo0Ooo . i1iiIII111 - iI1iII1I1I1i % Ii - I1I
  finally :
   pass
   if 54 - 54: Iii1i % ooo000 % Iii1i - IiIIii11Ii
 def logdebug ( * args ) :
  if 39 - 39: oOO - oOO * i1 % IIiIIiIi11I1
  if wgGlobal . allowprint :
   try :
    try :
     print ( * args )
    finally :
     pass
    IIiII11I = args
    mMonitorInfo . wglog (
 "{0} UDP.{1}\r" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , IIiII11I ) )
   except Exception as II1iiii :
    pass
    if 93 - 93: OooOoo - IiI11Ii111
    pass
  pass
  if 69 - 69: ooo000
 def wglog ( info ) :
  if wgGlobal . testModeDebugPrint > 0 :
   if 76 - 76: Iii1i * Ooo0Ooo . iI1iII1I1I1i / Ii / ooOOO
   mMonitorInfo . printCHS ( "{0} UDP.{1}" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , info ) )
   mMonitorInfo . wglog (
 "{0} UDP.{1}\r" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , info ) )
   if 49 - 49: iI1iII1I1I1i / i1iiIII111 + ooo000
 wgroot_logger = None
 if 36 - 36: i1i1i1111I + Iii1i - oOO * Ii
 if 45 - 45: i1i1i1111I * Ii
 if 97 - 97: i1
 if 26 - 26: IiI11Ii111
 def getConfigString ( paramval , paramName ) :
  iI1i = configparser . ConfigParser ( allow_no_value = True )
  iI1i . read ( wgGlobal . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
  if iI1i . has_option ( 'wgconf' , paramName ) :
   paramval = iI1i [ 'wgconf' ] [ paramName ]
  return paramval
  if 73 - 73: ooOOO - IiIIii11Ii
 def getConfigInt ( paramval , paramName ) :
  iI1i = configparser . ConfigParser ( allow_no_value = True )
  iI1i . read ( wgGlobal . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
  if ( iI1i . has_option ( 'wgconf' , paramName ) ) :
   paramval = int ( iI1i [ 'wgconf' ] [ paramName ] )
  return paramval
  if 22 - 22: Oo % oOo0O00 / i1I . oOo0O00 . i1I
 @ staticmethod
 def isNotLocalHost ( str ) :
  Ooo000oo0O00o = 1
  try :
   if "127.0.0.1" in str :
    Ooo000oo0O00o = 0
  finally :
   pass
  return Ooo000oo0O00o
  if 73 - 73: IiIIii11Ii
 @ staticmethod
 def is_valid_ip ( ip ) :
  try :
   socket . inet_aton ( ip )
   return True
  except socket . error :
   return False
   if 69 - 69: IiIIii11Ii * I11iiIi11i1I . i1iiIII111 * Iii1i
 def getIPV4 ( nouse = None ) :
  if 54 - 54: Ooo0Ooo . iI1iII1I1I1i + OooOoo * Ooo0Ooo
  IIiII11I = [ ]
  if len ( wgGlobal . dataserverIP ) > len ( "0.0.0.0" ) :
   IIiII11I . append ( wgGlobal . dataserverIP )
   return IIiII11I
   if 23 - 23: ooOOO % oOO % iI1iII1I1I1i - i1I - i1iiIII111 + i1
  try :
   if 12 - 12: i1 - i1I - IiI11Ii111
   if str ( platform . system ( ) . lower ( ) ) == 'windows' :
    import subprocess
    OO = ""
    try :
     try :
      OO = subprocess . check_output ( [ 'c:\\windows\\system32\\ipconfig' ] )
     except Exception as ooOOOO00O :
      OO = subprocess . check_output ( [ 'ipconfig' ] )
     ii1 = ""
     try :
      ii1 = OO . decode ( "GBK" )
     except Exception as Oo0O00OOoo :
      try :
       ii1 = OO . decode ( "GB2312" )
      except Exception as o0oO00OO :
       ii1 = OO . decode ( "utf-8" )
     OO = ii1
    except Exception as O0OO0OOOOoo0o :
     pass
     if 41 - 41: oOO
    if len ( OO ) > 0 :
     if 98 - 98: I1I / IIiIIiIi11I1 / i1I + IiI11Ii111 % Oo + I1I
     if 38 - 38: I1Ii1I1 + oOo0O00
     for iii1I1 in OO . splitlines ( ) :
      if 17 - 17: Oo - i1I . IIiIIiIi11I1 + iI1iII1I1I1i - I1Ii1I1 + Ii
      if "IPv4" in iii1I1 :
       OoO = iii1I1 . split ( ":" ) [ 1 ] . strip ( )
       if wgAppConfig . is_valid_ip ( OoO ) and wgAppConfig . isNotLocalHost ( OoO ) :
        IIiII11I . append ( OoO )
        if 63 - 63: i1I
        if 81 - 81: OooOoo . i1I / i1i1i1111I + Oo / Ooo0Ooo % IiI11Ii111
    if len ( IIiII11I ) > 0 :
     return IIiII11I
     if 77 - 77: I11iiIi11i1I / iI1iII1I1I1i - oOo0O00 - Ooo0Ooo % oOo0O00
    i1iI1 = socket . getaddrinfo ( socket . gethostname ( ) , None )
    if 11 - 11: I1Ii1I1 / oOO
    for iI in i1iI1 :
     if 58 - 58: IIiIIiIi11I1 % Ii + oOo0O00 / oOo0O00 * iI1iII1I1I1i * i1i1i1111I
     if ':' not in iI [ 4 ] [ 0 ] :
      if 88 - 88: i1I + I1I
      if wgAppConfig . isNotLocalHost ( iI [ 4 ] [ 0 ] ) :
       IIiII11I . append ( iI [ 4 ] [ 0 ] )
    if len ( IIiII11I ) > 0 :
     return IIiII11I
     if 55 - 55: oOO
     if 29 - 29: ooOOO / i1i1i1111I / I1Ii1I1 . IiI11Ii111 + i1I * oOo0O00
    if len ( IIiII11I ) == 0 :
     try :
      if 57 - 57: iI1iII1I1I1i
      O00OOo = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM )
      try :
       O00OOo . connect ( ( '8.8.8.8' , 80 ) )
      except :
       O00OOo . connect ( ( '127.0.0.1' , 1 ) )
      II1Iiii111i1I = O00OOo . getsockname ( ) [ 0 ]
      O00OOo . close ( )
      IIiII11I . append ( II1Iiii111i1I . strip ( ) )
     except Exception as O0OO0OOOOoo0o :
      pass
     if len ( IIiII11I ) > 0 :
      if 74 - 74: I1Ii1I1
      return IIiII11I
   else :
    if 61 - 61: iI1iII1I1I1i * I1Ii1I1 + Ooo0Ooo % IIiIIiIi11I1 * i1i1i1111I
    if 61 - 61: i1iiIII111 - Oo + I1Ii1I1
    if 43 - 43: IIiIIiIi11I1 * ooo000 + Ii % iI1iII1I1I1i
    if 12 - 12: i1iiIII111 + ooo000 . I11iiIi11i1I
    import subprocess
    OO = ''
    if 1 - 1: iI1iII1I1I1i % Ii - I11iiIi11i1I / IiI11Ii111 + iI1iII1I1I1i - Ii
    if 27 - 27: OooOoo % iI1iII1I1I1i + IIiIIiIi11I1
    try :
     if 16 - 16: IiI11Ii111
     if 31 - 31: oOo0O00 / Iii1i % Ooo0Ooo % i1 . iI1iII1I1I1i . Oo
     OO = subprocess . check_output ( [ 'ip' , 'addr' , 'show' ] ) . decode ( )
     if 83 - 83: oOo0O00 - I11iiIi11i1I
     if 91 - 91: IIiIIiIi11I1 - i1 - iI1iII1I1I1i
     if 71 - 71: I1I - IiI11Ii111
    except Exception as O0OO0OOOOoo0o :
     pass
     if "darwin" not in str ( platform . system ( ) . lower ( ) ) :
      print ( O0OO0OOOOoo0o )
    if len ( OO ) > 0 :
     if 66 - 66: i1i1i1111I / Ooo0Ooo + I11iiIi11i1I + Iii1i + oOo0O00 + i1I
     for iI in OO . split ( '\n' ) :
      o0OOO00OO = 0
      if "inet " not in iI :
       continue
      for oo0OoOoO0O0OO in iI . split ( ' ' ) :
       if 85 - 85: IIiIIiIi11I1 / OooOoo . i1I % Oo + Oo - I11iiIi11i1I
       if len ( oo0OoOoO0O0OO ) > 0 :
        if o0OOO00OO > 0 :
         if 59 - 59: OooOoo
         if 53 - 53: i1i1i1111I / ooOOO - IiI11Ii111 + ooo000 * i1i1i1111I * i1iiIII111
         O0O0o0oo00Oo = oo0OoOoO0O0OO . split ( ":" )
         if len ( O0O0o0oo00Oo ) == 1 :
          if wgAppConfig . isNotLocalHost ( oo0OoOoO0O0OO ) :
           I11 = oo0OoOoO0O0OO . split ( "/" )
           if wgAppConfig . isNotLocalHost (
 I11 [ 0 ] ) :
            IIiII11I . append ( I11 [ 0 ] )
         else :
          if wgAppConfig . isNotLocalHost (
 O0O0o0oo00Oo [ 1 ] ) :
           I11 = O0O0o0oo00Oo [ 1 ] . split ( "/" )
           if wgAppConfig . isNotLocalHost (
 I11 [ 0 ] ) :
            IIiII11I . append ( I11 [ 0 ] )
         break
        if oo0OoOoO0O0OO . index ( 'inet' ) >= 0 :
         o0OOO00OO = 1
     if len ( IIiII11I ) > 0 :
      if 13 - 13: oOo0O00 / Ii . Ii + oOo0O00
      return IIiII11I
      if 46 - 46: OooOoo - I11iiIi11i1I / Ooo0Ooo
    if len ( OO ) == 0 :
     if 73 - 73: I1Ii1I1 / i1i1i1111I / ooo000 % i1 % i1I - OooOoo
     if 30 - 30: ooOOO * ooOOO - Iii1i * iI1iII1I1I1i
     try :
      if 37 - 37: I1Ii1I1 % iI1iII1I1I1i . i1I + Ooo0Ooo + ooOOO * iI1iII1I1I1i
      OO = subprocess . check_output ( [ 'ifconfig' ] ) . decode ( )
      if 39 - 39: IIiIIiIi11I1 - Oo
      if 31 - 31: IiIIii11Ii % oOo0O00 % oOo0O00 * Iii1i
     except Exception as O0OO0OOOOoo0o :
      pass
      if 85 - 85: Iii1i + Ii % IIiIIiIi11I1 % oOo0O00
    if len ( OO ) > 0 :
     if 100 - 100: IiIIii11Ii % i1
     for iI in OO . split ( '\n' ) :
      o0OOO00OO = 0
      if "inet " not in iI :
       continue
      for oo0OoOoO0O0OO in iI . split ( ' ' ) :
       if 82 - 82: ooOOO % OooOoo
       if len ( oo0OoOoO0O0OO ) > 0 :
        if o0OOO00OO > 0 :
         if 81 - 81: Ii
         if 40 - 40: i1I . OooOoo + oOo0O00 . i1iiIII111
         O0O0o0oo00Oo = oo0OoOoO0O0OO . split ( ":" )
         if len ( O0O0o0oo00Oo ) == 1 :
          if wgAppConfig . isNotLocalHost (
 oo0OoOoO0O0OO ) :
           IIiII11I . append ( oo0OoOoO0O0OO )
         else :
          if wgAppConfig . isNotLocalHost (
 O0O0o0oo00Oo [ 1 ] ) :
           IIiII11I . append ( O0O0o0oo00Oo [ 1 ] )
         break
        if oo0OoOoO0O0OO . index ( 'inet' ) >= 0 :
         o0OOO00OO = 1
     if len ( IIiII11I ) > 0 :
      if 96 - 96: I1I / oOO / I11iiIi11i1I + I11iiIi11i1I
      return IIiII11I
      if 35 - 35: IIiIIiIi11I1 + oOo0O00
      if 96 - 96: iI1iII1I1I1i . OooOoo . i1
    if len ( OO ) == 0 :
     try :
      OO = subprocess . check_output ( [ 'hostname' , '-I' ] ) . decode ( )
      if len ( OO ) > 0 :
       for iI in OO . split ( '\n' ) :
        if 87 - 87: ooo000 * IiIIii11Ii % ooo000 . ooOOO . Oo % iI1iII1I1I1i
        if len ( iI . strip ( ) ) > 3 and wgAppConfig . isNotLocalHost ( iI ) :
         IIiII11I . append ( iI . strip ( ) )
         if 48 - 48: ooOOO * ooo000 % IiIIii11Ii * i1 . Iii1i - IiI11Ii111
         if 72 - 72: i1 % i1i1i1111I * iI1iII1I1I1i
         if 90 - 90: Ooo0Ooo * OooOoo . Ii
     except Exception as O0OO0OOOOoo0o :
      pass
      if 5 - 5: Oo - i1 . oOO
     if len ( IIiII11I ) > 0 :
      if 18 - 18: IiIIii11Ii - oOO * i1I - OooOoo
      return IIiII11I
      if 54 - 54: IIiIIiIi11I1 . Ooo0Ooo % Ii + IiIIii11Ii * iI1iII1I1I1i / iI1iII1I1I1i
    if len ( OO ) == 0 :
     try :
      if 31 - 31: IiIIii11Ii . IiIIii11Ii % Ii
      O00OOo = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM )
      try : O00OOo . connect ( ( '8.8.8.8' , 80 ) )
      except : O00OOo . connect ( ( '127.0.0.1' , 1 ) )
      II1Iiii111i1I = O00OOo . getsockname ( ) [ 0 ]
      O00OOo . close ( )
      IIiII11I . append ( II1Iiii111i1I . strip ( ) )
     except Exception as O0OO0OOOOoo0o :
      pass
     if len ( IIiII11I ) > 0 :
      if 51 - 51: Oo / i1i1i1111I - I1I
      return IIiII11I
      if 83 - 83: Iii1i % i1iiIII111 . OooOoo / I1I % oOO . I1I
  except Exception as II1iiii :
   pass
   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
  return IIiII11I
  if 39 - 39: Iii1i * IIiIIiIi11I1 . Ooo0Ooo - Oo
  if 63 - 63: i1i1i1111I - i1iiIII111 . OooOoo % OooOoo . IiI11Ii111 + i1I
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
