Esempio n. 1
0
 def handle_write(self):
   if len(cfg.stat_buf) == 0:
     return;
   data = cfg.stat_buf[0]
   result = msgpkt.send(self, 'DAT', data)
   if result:
     cfg.stat_buf = cfg.stat_buf[1:]
Esempio n. 2
0
 def handle_write(self):
   if len(servers[self.ip]['buf']) == 0:
     return;
   data = servers[self.ip]['buf'][0]
   result = msgpkt.send(self, 'DAT', data)
   if result:
     servers[self.ip]['buf'] = servers[self.ip]['buf'][1:]
Esempio n. 3
0
 def handle_write(self):
   if self.senddata == '':
     return
   log.l.LogIt('CTL010', 'D', 'cmd o: %s', self.senddata)
   result = msgpkt.send(self, 'CTL', self.senddata)
   if result:
     self.senddata = ''
     self.handle_close()
Esempio n. 4
0
 def handle_write(self):
   if len(self.senddata):
     message = self.senddata[0]
     log.l.LogIt('RSD003', 'D', 'o (%s): %s', (self.peer_ip, message))
     result = msgpkt.send(self, 'cfg', message)
     if result:
       self.senddata = self.senddata[1:]
       if self.finished:
         self.handle_close()
Esempio n. 5
0
 def handle_write(self):
   if len(cfg.servers[self.ip]['cmdbuf']):
     command = cfg.servers[self.ip]['cmdbuf'][0]
     log.l.LogIt('RTS005', 'D', '%s o: %s', (self.ip, command))
     try:
       result = msgpkt.send(self, 'cfg', command)
     except:
       self.handle_close()
       return
     if result:
       cfg.servers[self.ip]['cmdbuf'] = cfg.servers[self.ip]['cmdbuf'][1:]
Esempio n. 6
0
 def handle_write(self):
   if self.senddata == '':
     return
   log.l.LogIt('RSC003', 'D', 'cmd o: %s', (self.senddata))
   msg = self.subsystem+' ('+self.my_ip+'): '+self.senddata
   result = msgpkt.send(self, 'SRV', msg)
   if result:
     self.senddata = ''
     if self.terminate:
       log.l.LogIt('RSC004', 'I', 'command termination', ())
       sock.close_all()	# this terminates sock.loop(), ending program
     else:
       self.handle_close()
Esempio n. 7
0
 def handle_write(self):
   if len(self.senddata) == 0:
     return
     
   if self.mode == 'router':
     data = self.target+' ('+self.my_ip+'): '+self.senddata[0]
   else:
     data = self.target+' ('+cfg.name+':'+self.my_ip+'): '+self.senddata[0]
   log.l.LogIt('RTC005', 'D', 'cmd o: %s', data)
   result = msgpkt.send(self, 'CMD', data)
   if result:
     self.senddata = self.senddata[1:]
   if len(self.senddata) == 0:
     self.handle_close()
Esempio n. 8
0
  sock.loop(60, reconnect)

#--------------------------------------
elif option == 'sna' or option == 'tcp' or option == 'all':
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  try:
    s.connect((host, portsrv))
  except:
    try:
      s.close()
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      s.connect((host, portapr))
    except:
      print 'aprstat deamon not running.'
      sys.exit(1)
  msgpkt.send(s, 'GET', option)
  #--------------
  while 1:
    get_hdr = ''
    get_len = 0
    msg = ''
    eof = 0
    #----------------------
    while len(get_hdr) < 5:
      try:
        get_hdr += s.recv(5 - len(get_hdr))
        if len(get_hdr) == 0:
          eof = 1
          break
      except:
        print 'socket error: closing connection.'