Commit 2ee359b0 authored by Ray Bellis's avatar Ray Bellis

expose primary API via index.js

parent 74e2b536
......@@ -6,6 +6,7 @@
"lib": "lib",
"test": "test"
},
"main": "index.js",
"scripts": {
"test": "mocha",
"docs": "./node_modules/.bin/jsdoc -c ./.jsdoc.conf.json"
......
#!/usr/bin/env node
let RadiusClient = require('./lib/client');
let Dictionary = require('./lib/dictionary');
let RADIUS = require('.');
Dictionary.load('dictionary.rfc2865');
RADIUS.Dictionary.load('dictionary.rfc2865');
let client = new RadiusClient({host: '127.0.0.1', secret: 'secret'});
let client = new RADIUS.Client({host: '127.0.0.1', secret: 'secret'});
client.request('Accounting-Request').then(function(p) {
console.log('-- response --');
......
#!/usr/bin/env node
let RadiusClient = require('./lib/client');
let RadiusPacket = require('./lib/packet');
let AttributeList = require('./lib/attrlist');
let Dictionary = require('./lib/dictionary');
const RADIUS = require('.');
Dictionary.load('dictionary.rfc2865');
RADIUS.Dictionary.load('dictionary.rfc2865');
let client = new RadiusClient({host: '127.0.0.1', secret: 'secret'});
let client = new RADIUS.Client({host: '127.0.0.1', secret: 'secret'});
let attrs = new AttributeList();
let attrs = new RADIUS.AttributeList();
attrs.add('User-Name', 'ray');
attrs.add('User-Password', 'mypass');
......@@ -17,7 +14,7 @@ client.request('Access-Request', attrs).then(function(p) {
console.log('-- auth succeeded --');
console.log(p);
}).catch(function(e) {
if (e instanceof RadiusPacket) {
if (e instanceof RADIUS.Packet) {
console.log('-- auth failed --');
console.log(e);
} else {
......
#!/usr/bin/env node
const RadiusServer = require('./lib/server');
const RADIUS = require('.');
const logic = {
auth: function(req, res) {
......@@ -25,7 +25,7 @@ const defaults = {
}
};
new RadiusServer()
new RADIUS.Server()
.loadDictionary('dictionary.rfc2865')
.loadDictionary('dictionary.cisco')
.addClient('127.0.0.1', 'secret')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment