parameters: (aes_data)
return_statement: return xmlrpclib.Binary(mycrypto.encrypt_verify(AES_KEY,json.dumps(res,encoding='utf8')))
docstring: u
docstring_summary: u
docstring_tokens: u
function: def get_flow(aes_data):
      u'''''' 
      text = mycrypto.decrypt_verify(AES_KEY,aes_data.data)
      if text == None:return xmlrpclib.Binary(json.dumps({'statos':'err_ase'},encoding='utf8'))
  
      res={
              'flow_in':{},  # {u'8001':3916788L}
              'flow_out':{},
              'status':'ok'
          }
  
  
      table = iptc.Table(iptc.Table.FILTER)
  
      chain_in = iptc.Chain(table, 'INPUT')
      chain_out = iptc.Chain(table, 'OUTPUT')
  
      table.refresh()
  
      for rule in chain_out.rules:
          try:
              if len(rule.matches)==1:
                  sport = int(rule.matches[0].sport)
                  res['flow_out'][sport] = rule.get_counters()[1]
          except Exception,inst:
              print (u'[警告]未知的 iptables 规则，如果是其他软件添加的可以忽略。')
              print(inst)
      for rule in chain_in.rules:
          try:
              if len(rule.matches)==1:
                  dport = int(rule.matches[0].dport)
                  res['flow_in'][dport] = rule.get_counters()[1]
          except Exception,inst:
              print (u'[警告]未知的 iptables 规则，如果是其他软件添加的可以忽略。')
              print(inst)
  
  
      return xmlrpclib.Binary(mycrypto.encrypt_verify(AES_KEY,json.dumps(res,encoding='utf8')))
function_tokens: def get_flow ( aes_data ) : text = mycrypto . decrypt_verify ( AES_KEY , aes_data . data ) if text == None : return xmlrpclib . Binary ( json . dumps ( { 'statos' : 'err_ase' } , encoding = 'utf8' ) ) res = { 'flow_in' : { } , # {u'8001':3916788L} 'flow_out' : { } , 'status' : 'ok' } table = iptc . Table ( iptc . Table . FILTER ) chain_in = iptc . Chain ( table , 'INPUT' ) chain_out = iptc . Chain ( table , 'OUTPUT' ) table . refresh ( ) for rule in chain_out . rules : try : if len ( rule . matches ) == 1 : sport = int ( rule . matches [ 0 ] . sport ) res [ 'flow_out' ] [ sport ] = rule . get_counters ( ) [ 1 ] except Exception , inst : print ( u'[警告]未知的 iptables 规则，如果是其他软件添加的可以忽略。') print ( inst ) for rule in chain_in . rules : try : if len ( rule . matches ) == 1 : dport = int ( rule . matches [ 0 ] . dport ) res [ 'flow_in' ] [ dport ] = rule . get_counters ( ) [ 1 ] except Exception , inst : print ( u'[警告]未知的 iptables 规则，如果是其他软件添加的可以忽略。') print ( inst ) return xmlrpclib . Binary ( mycrypto . encrypt_verify ( AES_KEY , json . dumps ( res , encoding = 'utf8' ) ) )