def _ProcessInput(self, fd): """Process available data. If this packet should be dropped instead of processed a `ServerPacketError` exception should be raised. The main loop will drop the packet and log the reason. This function calls either :obj:`HandleAuthPacket`, :obj:`HandleAcctPacket` or :obj:`_HandleProxyPacket` depending on which socket is being processed. :param fd: socket to read packet from :type fd: socket class instance :param pkt: packet to process :type pkt: Packet class instance """ if fd.fileno() == self._proxyfd.fileno(): pkt = self._GrabPacket( lambda data, s=self: s.CreatePacket(packet=data), fd) self._HandleProxyPacket(pkt) else: Server._ProcessInput(self, fd)
def _PrepareSockets(self): Server._PrepareSockets(self) self._proxyfd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self._fdmap[self._proxyfd.fileno()] = self._proxyfd self._poll.register(self._proxyfd.fileno(), (select.POLLIN | select.POLLPRI | select.POLLERR))