Example #1
0
    def handle_data(self):
        """Handles a received packet"""
        self.session.add_event("Received packet", request=str(self.packet))

        if SAPRouter not in self.packet or not router_is_known_type(self.packet):
            self.logger.debug("Invalid packet sent to SAPRouter")

        router = self.packet[SAPRouter]
        if router_is_route(router):
            return self.handle_route(router)
        elif router_is_control(router):
            return self.handle_control(router)
        elif router_is_admin(router):
            return self.handle_admin(router)
Example #2
0
    def handle_data(self):
        if self.routed:
            self.request.send(self.packet)
            return

        self.packet.decode_payload_as(SAPRouter)
        route_request = self.packet[SAPRouter]

        if router_is_route(route_request):
            if route_request.route_string[1].hostname == "10.0.0.1" and \
               route_request.route_string[1].port == "3200":
                self.routed = True
                self.request.send(SAPRouter(type=SAPRouter.SAPROUTER_PONG))
            else:
                self.request.send(SAPRouter(type=SAPRouter.SAPROUTER_ERROR,
                                            return_code=-94))
        else:
            self.request.send(SAPRouter(type=SAPRouter.SAPROUTER_ERROR))