How to use the pyrad.tools function in pyrad

To help you get started, we’ve selected a few pyrad examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jamiesun / PyRadius / radiusd / utils.py View on Github external
def get_acctinputoctets(self):
        try:return tools.DecodeInteger(self.get(42)[0])
        except:return None
github pyradius / pyrad / pyrad / packet.py View on Github external
def _DecodeValue(self, attr, value):
        if attr.values.HasBackward(value):
            return attr.values.GetBackward(value)
        else:
            return tools.DecodeAttr(attr.type, value)
github jamiesun / PyRadius / radiusd / utils.py View on Github external
def get_macaddr(self):
        try:return tools.DecodeString(self.get(31)[0]).replace("-",":")
        except:return None
github jamiesun / PyRadius / radiusd / utils.py View on Github external
def CreateReply(self, msg=None,**attributes):
        reply = AuthPacket2(AccessAccept, self.id,
            self.secret, self.authenticator, dict=self.dict,
            **attributes)
        if msg:
            reply.set_reply_msg(tools.EncodeString(msg))
        return reply
github jamiesun / PyRadius / radiusd / utils.py View on Github external
def get_chappwd(self):
        try:return tools.DecodeOctets(self.get(3)[0])
        except:return None
github jamiesun / PyRadius / radiusd / utils.py View on Github external
def get_eventtimestamp(self,timetype=0):
        try:
            _time = tools.DecodeDate(self.get(55)[0])
            if timetype == 0:
                return datetime.datetime.fromtimestamp(_time).strptime("%Y-%m-%d %H:%M:%S")
            else:
                return datetime.datetime.fromtimestamp(_time-(8*3600)).strptime("%Y-%m-%d %H:%M:%S")
        except:
            return None
github jamiesun / PyRadius / radiusd / utils.py View on Github external
def get_nasaddr(self):
        try:return tools.DecodeAddress(self.get(4)[0])
        except:return None
github pyradius / pyrad / pyrad / packet.py View on Github external
def _EncodeValue(self, attr, value):
        result = ''
        if attr.values.HasForward(value):
            result = attr.values.GetForward(value)
        else:
            result = tools.EncodeAttr(attr.type, value)

        if attr.encrypt == 2:
            # salt encrypt attribute
            result = self.SaltCrypt(result)

        return result
github pyradius / pyrad / pyrad / dictionary.py View on Github external
(attr, key, value) = tokens[1:]

        try:
            adef = self.attributes[attr]
        except KeyError:
            if defer:
                self.defer_parse.append((copy(state), copy(tokens)))
                return
            raise ParseError('Value defined for unknown attribute ' + attr,
                             file=state['file'],
                             line=state['line'])

        if adef.type in ['integer', 'signed', 'short', 'byte', 'integer64']:
            value = int(value, 0)
        value = tools.EncodeAttr(adef.type, value)
        self.attributes[attr].values.Add(key, value)