talkincode / toughradius

toughradius provides radius server, tr069 acs
http://www.toughradius.net
GNU General Public License v3.0
564 stars 272 forks source link

增加Mikrotik-Xmit-Limit支持 #95

Closed fillorkill closed 6 years ago

fillorkill commented 8 years ago

目前貌似并不支持 RadiusError:current radius cannot support attribute Mikrotik-Xmit-Limit,Can not encode non-integer(10000000) as integer

jamiesun commented 8 years ago

这是哪里出现的提示

fillorkill commented 8 years ago

authenticate accept之后

修改radiusd.py: 在 # todo: May have a type matching problem下面,修改为: for attr_name in attrs: try:

todo: May have a type matching problem

                    if utils.safestr(attr_name) == "Mikrotik-Xmit-Limit":
                            reply.AddAttribute(utils.safestr(attr_name), int(auth_resp['flow_length'])*1024)
                    else:
                            reply.AddAttribute(utils.safestr(attr_name), attrs[attr_name])
                except Exception as err:
                    errstr = "RadiusError:current radius cannot support attribute {0},{1}".format(
                        attr_name,utils.safestr(err.message))
                    logger.error(errstr)

同时需在radius_authorize.py中def policy_filter最后添加 self.reply['flow_length'] = self.get_user_flow_length() 这样可以实现Mikrotik-Xmit-Limit流量计费,自动断开功能。

jamiesun commented 8 years ago

了解,你是说反向下发流量数据给ros,让ros控制,但是如果用户充值了呢,那还得去动态授权更新这个数据。

jamiesun commented 8 years ago

最好用一个插件去控制,比如速率

if u"input_rate" in auth_resp and u"output_rate" in auth_resp:
    reply = rate_process.process(reply, input_rate=auth_resp['input_rate'], output_rate=auth_resp['output_rate'])