Skip to content
Draft

f/v2 #38

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
.PHONY: test
test:
docker-compose up --build
open coverage/index.html

.PHONY: clean
clean:
-rm -rf ./coverage ./node_modules
63 changes: 46 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@

# tephra

An event-driven [RADIUS](https://en.wikipedia.org/wiki/RADIUS) server micro-framework based on [node-radius](https://github.com/retailnext/node-radius). Now it's easier than ever to write a RADIUS server that isn't standards-compliant! `;)`
An event-driven [RADIUS](https://en.wikipedia.org/wiki/RADIUS) server micro-framework based on [node-radius](https://github.com/retailnext/node-radius).

## Example
## Configuration

```javascript
var tephra = require('tephra')
Key | Type | Required | Notes
--- | ---- | -------- | -----
`secret` | `String` | ✅ |
`ports` | `Object` | ✅ | All port types are optional, but at least one must be specified, so as to permit instances with different responsibilities.
`ports.authentication` | `Number` | ❌ | Must be a valid port number (0 - 65535 inclusive)
`ports.accounting` | `Number` | ❌ | Must be a valid port number (0 - 65535 inclusive)
`ports.changeOfAuthorisation` | `Number` | ❌ | Must be a valid port number (0 - 65535 inclusive)
`vendorDictionaries` | `Array` | ❌ | Elements of the array must be objects that conform to `{name: String, path: String, id: Number}`

var users = {user1: 'secret_password'}
## Example

var server = new tephra(
'shared_secret',
1812, // authentication port
1813, // accounting port
3799, // change of authorisation port
[ // add dictionaries for vendor-specific attributes
```javascript
import tephra from 'tephra'

var users = {user1: 'foo'}

var server = new tephra({
secret: 'foo',
ports: {
authentication: 1812,
accounting: 1813,
changeOfAuthorisation: 1814
},
vendorDictionaries: [
{
name: 'quux_vendor',
path: '/path/to/quux_vendor/dictionary',
id: 12345
}
]
)
})

server.on('Access-Request', function(packet, rinfo, accept, reject) {
server.on('Access-Request', function(packet, remote_host, accept, reject) {
var username = packet.attributes['User-Name']
var password = packet.attributes['User-Password']

Expand All @@ -46,24 +59,40 @@ server.on('Access-Request', function(packet, rinfo, accept, reject) {

accept(attributes, vendor_attributes, console.log)

}).on('Accounting-Request', function(packet, rinfo, respond) {
}).on('Accounting-Request', function(packet, remote_host, respond) {

// catch all accounting-requests
respond([], {}, console.log)

}).on('Accounting-Request-Start', function(packet, rinfo, respond) {
}).on('Accounting-Request-Start', function(packet, remote_host, respond) {

// or just catch specific accounting-request status types...
respond([], {}, console.log)

}).on('Accounting-Request-Interim-Update', function(packet, rinfo, respond) {
}).on('Accounting-Request-Interim-Update', function(packet, remote_host, respond) {

respond([], {}, console.log)

}).on('Accounting-Request-Stop', function(packet, rinfo, respond) {
}).on('Accounting-Request-Stop', function(packet, remote_host, respond) {

respond([], {}, console.log)

}).on('CoA-ACK', function(packet, remote_host) {

console.log(packet, remote_host)

}).on('CoA-NAK', function(packet, remote_host) {

console.log(packet, remote_host)

}).on('Disconnect-ACK', function(packet, remote_host) {

console.log(packet, remote_host)

}).on('Disconnect-NAK', function(packet, remote_host) {

console.log(packet, remote_host)

})

server.bind()
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
services:
tephra:
build: .
volumes:
- ./coverage:/app/coverage
2 changes: 0 additions & 2 deletions index.js

This file was deleted.

Loading