예제 #1
0
    def sendPDU(self, pdu):
        twistedSMPPServerProtocol.sendPDU(self, pdu)

        # Prepare for logging
        if pdu.commandId in [CommandId.deliver_sm, CommandId.data_sm]:
            message_content = pdu.params.get('short_message', None)
            if message_content is None:
                message_content = pdu.params.get('message_payload', '')

            # Do not log text for privacy reasons
            # Added in #691
            if self.config().log_privacy:
                logged_content = '** %s byte content **' % len(message_content)
            else:
                logged_content = '%r' % re.sub(r'[^\x20-\x7E]+', '.', message_content)

        # Stats:
        self.factory.stats.set('last_sent_pdu_at', datetime.now())
        if pdu.commandId == CommandId.deliver_sm:
            self.factory.stats.inc('deliver_sm_count')
            if self.user is not None:
                self.log.info(
                    'DELIVER_SM [uid:%s] [from:%s] [to:%s] [content:%s]',
                    self.user.uid,
                    pdu.params['source_addr'],
                    pdu.params['destination_addr'],
                    logged_content)
                self.user.getCnxStatus().smpps['deliver_sm_count'] += 1
        elif pdu.commandId == CommandId.data_sm:
            self.factory.stats.inc('data_sm_count')
            if self.user is not None:
                self.log.info('DATA_SM [uid:%s] [from:%s] [to:%s] [content:%s]',
                              self.user.uid,
                              pdu.params['source_addr'],
                              pdu.params['destination_addr'],
                              logged_content)
                self.user.getCnxStatus().smpps['data_sm_count'] += 1
        elif pdu.commandId == CommandId.submit_sm_resp:
            if pdu.status == CommandStatus.ESME_RTHROTTLED:
                self.factory.stats.inc('throttling_error_count')
                if self.user is not None:
                    self.user.getCnxStatus().smpps['throttling_error_count'] += 1
            elif pdu.status != CommandStatus.ESME_ROK:
                self.factory.stats.inc('other_submit_error_count')
                if self.user is not None:
                    self.user.getCnxStatus().smpps['other_submit_error_count'] += 1
            else:
                # We got a ESME_ROK
                self.factory.stats.inc('submit_sm_count')
                if self.user is not None:
                    self.user.getCnxStatus().smpps['submit_sm_count'] += 1
예제 #2
0
    def sendPDU(self, pdu):
        twistedSMPPServerProtocol.sendPDU(self, pdu)

        # Stats:
        self.factory.stats.set('last_sent_pdu_at', datetime.now())
        if pdu.commandId == CommandId.deliver_sm:
            self.factory.stats.inc('deliver_sm_count')
            if self.user is not None:
                self.log.info(
                    'DELIVER_SM [uid:%s] [from:%s] [to:%s] [content:%s]' %
                    (self.user.uid, pdu.params['source_addr'],
                     pdu.params['destination_addr'],
                     re.sub(r'[^\x20-\x7E]+', '.',
                            pdu.params['short_message'])))
                self.user.getCnxStatus().smpps['deliver_sm_count'] += 1
        elif pdu.commandId == CommandId.data_sm:
            self.factory.stats.inc('data_sm_count')
            if self.user is not None:
                self.log.info(
                    'DATA_SM [uid:%s] [from:%s] [to:%s] [content:%s]' %
                    (self.user.uid, pdu.params['source_addr'],
                     pdu.params['destination_addr'],
                     re.sub(r'[^\x20-\x7E]+', '.',
                            pdu.params['short_message'])))
                self.user.getCnxStatus().smpps['data_sm_count'] += 1
        elif pdu.commandId == CommandId.submit_sm_resp:
            if pdu.status == CommandStatus.ESME_RTHROTTLED:
                self.factory.stats.inc('throttling_error_count')
                if self.user is not None:
                    self.user.getCnxStatus(
                    ).smpps['throttling_error_count'] += 1
            elif pdu.status != CommandStatus.ESME_ROK:
                self.factory.stats.inc('other_submit_error_count')
                if self.user is not None:
                    self.user.getCnxStatus(
                    ).smpps['other_submit_error_count'] += 1
            else:
                # We got a ESME_ROK
                self.factory.stats.inc('submit_sm_count')
                if self.user is not None:
                    self.user.getCnxStatus().smpps['submit_sm_count'] += 1
예제 #3
0
    def sendPDU(self, pdu):
        twistedSMPPServerProtocol.sendPDU(self, pdu)

        # Stats:
        self.factory.stats.set('last_sent_pdu_at', datetime.now())
        if pdu.commandId == CommandId.deliver_sm:
            self.factory.stats.inc('deliver_sm_count')
            if self.user is not None:
                self.log.info('DELIVER_SM [uid:%s] [from:%s] [to:%s] [content:%s]' % (
                    self.user.uid,
                    pdu.params['source_addr'],
                    pdu.params['destination_addr'],
                    re.sub(r'[^\x20-\x7E]+','.', pdu.params['short_message'])
                    ))
                self.user.getCnxStatus().smpps['deliver_sm_count']+= 1
        elif pdu.commandId == CommandId.data_sm:
            self.factory.stats.inc('data_sm_count')
            if self.user is not None:
                self.log.info('DATA_SM [uid:%s] [from:%s] [to:%s] [content:%s]' % (
                    self.user.uid,
                    pdu.params['source_addr'],
                    pdu.params['destination_addr'],
                    re.sub(r'[^\x20-\x7E]+','.', pdu.params['short_message'])
                    ))
                self.user.getCnxStatus().smpps['data_sm_count']+= 1
        elif pdu.commandId == CommandId.submit_sm_resp:
            if pdu.status == CommandStatus.ESME_RTHROTTLED:
                self.factory.stats.inc('throttling_error_count')
                if self.user is not None:
                    self.user.getCnxStatus().smpps['throttling_error_count']+= 1
            elif pdu.status != CommandStatus.ESME_ROK:
                self.factory.stats.inc('other_submit_error_count')
                if self.user is not None:
                    self.user.getCnxStatus().smpps['other_submit_error_count']+= 1
            else:
                # We got a ESME_ROK
                self.factory.stats.inc('submit_sm_count')
                if self.user is not None:
                    self.user.getCnxStatus().smpps['submit_sm_count']+= 1
예제 #4
0
    def sendPDU(self, pdu):
        twistedSMPPServerProtocol.sendPDU(self, pdu)

        # Stats:
        self.factory.stats.set('last_sent_pdu_at', datetime.now())
예제 #5
0
파일: protocol.py 프로젝트: Koulio/jasmin
    def sendPDU(self, pdu):
        twistedSMPPServerProtocol.sendPDU(self, pdu)

        self.factory.stats.set('last_sent_pdu_at', datetime.now())