コード例 #1
0
def dumpPacket(pkt, filePath, pktType=None):
    """Dump packet into file
		Input: (packet or dict) packet, must contain __str__ method
			(string) path to file
		Output: none
	"""
    # check directory
    dirPath = dirname(filePath)
    if not misc.checkDir(dirPath):
        error('Directory %s not available for logging' % dirPath)
        return

    # dump packet to file
    try:
        debug('Dumping packet to file:\n', filePath)
        file = open(filePath, 'a+')
        if pktType == PACKET_TYPE_ACCT:
            pktStr = misc.acctPacketToStr(pkt)
        elif pktType == PACKET_TYPE_AUTH:
            pktStr = misc.authPacketToStr(pkt)
        else:
            pktStr = misc.packetToStr(pkt)
        file.write(pktStr)
        file.close()
    except:
        error('Can not dump packet to file "%s"' % filePath)
        misc.printExceptionError()
コード例 #2
0
ファイル: dumpPacket.py プロジェクト: BackupGGCode/bsdradius
def dumpPacket(pkt, filePath, pktType = None):
	"""Dump packet into file
		Input: (packet or dict) packet, must contain __str__ method
			(string) path to file
		Output: none
	"""
	# check directory
	dirPath = dirname(filePath)
	if not misc.checkDir(dirPath):
		error('Directory %s not available for logging' % dirPath)
		return
		
	# dump packet to file
	try:
		debug ('Dumping packet to file:\n', filePath)
		file = open(filePath, 'a+')
		if pktType == PACKET_TYPE_ACCT:
			pktStr = misc.acctPacketToStr(pkt)
		elif pktType == PACKET_TYPE_AUTH:
			pktStr = misc.authPacketToStr(pkt)
		else:
			pktStr = misc.packetToStr(pkt)
		file.write(pktStr)
		file.close()
	except:
		error('Can not dump packet to file "%s"' % filePath)
		misc.printExceptionError()
コード例 #3
0
ファイル: BsdRadiusServer.py プロジェクト: ikelos/bsdradius
    def ProcessAcctPacket(self, pkt):
        #debug (pkt)
        received = dict(pkt)
        debug(misc.acctPacketToStr(received))

        # wait for accounting modules to process the request
        acctModulesResult = modules.execAccountingModules(received)
        if acctModulesResult == modules.MODULE_OK:
            info('===\n')
            info('Accounting successful')
        else:
            info('===\n')
            info('Accounting failed')
            dumpPacket.dumpFailedAcctPacket(received)
コード例 #4
0
	def ProcessAcctPacket(self, pkt):
		#debug (pkt)
		received = dict(pkt)
		debug (misc.acctPacketToStr(received))
		
		# wait for accounting modules to process the request
		acctModulesResult = modules.execAccountingModules(received)
		if acctModulesResult == modules.MODULE_OK:
			info ('===\n')
			info ('Accounting successful')
		else:
			info ('===\n')
			info ('Accounting failed')
			dumpPacket.dumpFailedAcctPacket(received)
コード例 #5
0
ファイル: test_misc.py プロジェクト: ikelos/bsdradius
	def testAcctPacketToStr(self):
		output = misc.acctPacketToStr(self.acct_pkt)
		self.failUnless(isinstance(output, types.StringTypes))
		self.failUnless(output != '')
コード例 #6
0
ファイル: test_misc.py プロジェクト: BackupGGCode/bsdradius
	def testAcctPacketToStr(self):
		output = misc.acctPacketToStr(self.acct_pkt)
		self.failUnless(isinstance(output, types.StringTypes))
		self.failUnless(output != '')