Comments (4)
Can you provide a minimal executable example that demonstrates the problem? I think it would be as simple as providing the dictionary file and then a script that encodes a packet with the dictionary and then decodes it.
Otherwise you can look at the tests for examples for how to use vendor-specific attributes.
from node-radius.
@psanford
client.js
var radius = require('radius');
var dgram = require('dgram');
var util = require('util');
var secret = 'MEAZ7iOegPr69lB';
var packet_accepted = {
code: "Access-Request",
secret: secret,
identifier: 0,
attributes: [
['User-Name', 'rajiv'],
['User-Password', 'Ltrx12345']
]
};
var client = dgram.createSocket("udp4");
client.bind(49011);
client.on('err', function(msg) {
console.log('error', msg)
});
client.on('message', function(msg, rinfo) {
var response = radius.decode({packet: msg, secret: secret});
console.log('decoded response', response);
var vsa= response['raw_attributes'][2][1];
console.log(vsa, 'venoder specific attribute', vsa.toString())
});
var encoded = radius.encode(packet_accepted);
client.send(encoded, 0, encoded.length, 1812, "localhost");
server.js
var radius = require('radius');
//loading dictionary file
radius.add_dictionary('vs.dict');
var dgram = require("dgram");
var secret = 'MEAZ7iOegPr69lB';
var server = dgram.createSocket("udp4");
server.on("message", function (msg, rinfo) {
var code, username, password, packet;
try {
packet = radius.decode({packet: msg, secret: secret});
} catch (e) {
console.log("Failed to decode radius packet, silently dropping:", e);
return;
}
if (packet.code != 'Access-Request') {
console.log('unknown packet type: ', packet.code);
return;
}
username = packet.attributes['User-Name'];
password = packet.attributes['User-Password'];
console.log(password,'Access-Request for ' + username);
if (username == 'rajiv' && password == 'Ltrx12345') {
code = 'Access-Accept';
} else {
code = 'Access-Reject';
}
//setting up vendor specific attributes
var response = radius.encode_response({
packet: packet,
code: code,
secret: secret,
attributes: [
['User-Name', 'rajiv'],
['User-Password', 'Ltrx12345'],
['Vendor-Specific', 14988, [['Mikrotik-Wireless-PSK', 'shiva']]]
]
});
console.log('Sending ' + code + ' for user ' + username);
server.send(response, 0, response.length, rinfo.port, rinfo.address, function(err, bytes) {
if (err) {
console.log('Error sending response to ', rinfo);
}
});
});
server.on("listening", function () {
var address = server.address();
console.log("radius server listening " +
address.address + ":" + address.port);
});
server.bind(1812);
vs.dict
# MikroTik vendor specific dictionary
# MikroTik Attributes
VENDOR Mikrotik 14988
BEGIN-VENDOR Mikrotik
ATTRIBUTE Mikrotik-Recv-Limit 1 integer
ATTRIBUTE Mikrotik-Xmit-Limit 2 integer
ATTRIBUTE Mikrotik-Group 3 string
ATTRIBUTE Mikrotik-Wireless-Forward 4 integer
ATTRIBUTE Mikrotik-Wireless-Skip-Dot1x 5 integer
ATTRIBUTE Mikrotik-Wireless-Enc-Algo 6 string
ATTRIBUTE Mikrotik-Wireless-Enc-Key 7 string
ATTRIBUTE Mikrotik-Rate-Limit 8 string
ATTRIBUTE Mikrotik-Realm 9 string
ATTRIBUTE Mikrotik-Host-IP 10 ipaddr
ATTRIBUTE Mikrotik-Mark-Id 11 string
ATTRIBUTE Mikrotik-Advertise-URL 12 string
ATTRIBUTE Mikrotik-Advertise-Interval 13 integer
ATTRIBUTE Mikrotik-Recv-Limit-Gigawords 14 integer
ATTRIBUTE Mikrotik-Xmit-Limit-Gigawords 15 integer
ATTRIBUTE Mikrotik-Wireless-PSK 16 string
ATTRIBUTE Mikrotik-Total-Limit 17 integer
ATTRIBUTE Mikrotik-Total-Limit-Gigawords 18 integer
ATTRIBUTE Mikrotik-Address-List 19 string
ATTRIBUTE Mikrotik-Wireless-MPKey 20 string
ATTRIBUTE Mikrotik-Wireless-Comment 21 string
ATTRIBUTE Mikrotik-Delegated-IPv6-Pool 22 string
ATTRIBUTE Mikrotik_DHCP_Option_Set 23 string
ATTRIBUTE Mikrotik_DHCP_Option_Param_STR1 24 string
ATTRIBUTE Mikortik_DHCP_Option_Param_STR2 25 string
ATTRIBUTE Mikrotik_Wireless_VLANID 26 integer
ATTRIBUTE Mikrotik_Wireless_VLANIDtype 27 integer
ATTRIBUTE Mikrotik_Wireless_Minsignal 28 string
ATTRIBUTE Mikrotik_Wireless_Maxsignal 29 string
# MikroTik Values
VALUE Mikrotik-Wireless-Enc-Algo sfwNaresh 0
VALUE Mikrotik-Wireless-Enc-Algo 40-bit-WEP 1
VALUE Mikrotik-Wireless-Enc-Algo 24
VALUE Mikrotik-Wireless-Enc-Algo AES-CCM 3
VALUE Mikrotik-Wireless-Enc-Algo TKIP 4
VALUE Mikrotik_Wireless_VLANIDtype 802.1q 0
VALUE Mikrotik_Wireless_VLANIDtype 802.1ad
VALUE Mikrotik-Group setup-private-value
1
END-VENDOR Mikrotik
client logs are followed as below:
decoder response:
{ code: 'Access-Accept',
identifier: 0,
length: 58,
authenticator: <Buffer 32 dc 73 12 9b 52 d4 78 39 27 dd f7 74 3c da 18>,
attributes:
{ 'User-Name': 'rajiv',
'User-Password': '&OwAx��3�\b+�\u001b\u00193�',
'Vendor-Specific': {} },
raw_attributes:
[ [ 1, <Buffer 72 61 6a 69 76> ],
[ 2, <Buffer 44 a1 4d 4a 9c a7 0e bb a4 1a 96 81 0e 51 bb e4> ],
[ 26, <Buffer 00 00 3a 8c 10 07 73 68 69 76 61> ] ] }
<Buffer 00 00 3a 8c 10 07 73 68 69 76 61> 'venoder specific attribute' '\u0000\u0000:�\u0010\u0007shiva'
from node-radius.
The client needs to load the dictionary file as well.
from node-radius.
Closing. Reopen if issue persists.
from node-radius.
Related Issues (20)
- Using with hostapd HOT 3
- How to pass custom attributes ? HOT 4
- Packet identifier number HOT 6
- Openwrt, Linux HOT 6
- Attributes without a tag have one after decoding HOT 2
- RADIUS server issue ChangeOfAuthorization (CoA) requests HOT 5
- Error in Freeradius with CHAP Password due to attribute length HOT 2
- Unable to get true from verify_response HOT 4
- Session-Timeout not working HOT 2
- sending PEAP responses HOT 2
- dictionary.rfc2865 incorrect Class attribute definition HOT 2
- There is no password attr HOT 7
- Response verification fails for Status-Server response to FreeRADIUS HOT 5
- User-Password is not defined in my packet. HOT 4
- encode: invalid attributes - must give buffer for unknown attribute 'WISPr-Bandwitdth-Max-Down' HOT 7
- Active Directory integration HOT 2
- Chap Password - Active Directory HOT 2
- Dependency Dashboard
- Disconnect-Request not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-radius.