Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ates/radius
RADIUS protocol
https://github.com/ates/radius
Last synced: about 1 month ago
JSON representation
RADIUS protocol
- Host: GitHub
- URL: https://github.com/ates/radius
- Owner: ates
- License: apache-2.0
- Created: 2012-04-06T12:00:42.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-02-28T17:19:09.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T09:41:06.793Z (2 months ago)
- Language: Erlang
- Homepage:
- Size: 188 KB
- Stars: 15
- Watchers: 6
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RADIUS protocol
===============[![Build Status](https://secure.travis-ci.org/ates/radius.png)](https://travis-ci.org/ates/radius)
REUSE_PORT
----------To make radius service utilize the REUSE_PORT feature just add the following to the sockets options:
```erlang
{reuseport, N}
```Where N is amount of workers which must be listen the port
Server example
--------------```erlang
-module(server).-behaviour(radius_service).
-export([start/0, stop/0, handle_request/3]).
-export([handle_error/2]).-include("radius.hrl").
-define(SERVICE_NAME, test_radius_server).
start() ->
{ok, _Started} = application:ensure_all_started(radius),
lists:foreach(fun radius_dict:add/1, radius_dict_file:load("dictionary")),
Nas = #nas_spec{name = nas1, ip = {ip, {127,0,0,1}}, secret = "testing123"},
ServiceOpts = [
{ip, {0,0,0,0}},
{port, 1812},
{callback, ?MODULE}
],
radius:start_service(?SERVICE_NAME, ServiceOpts),
radius:add_client(?SERVICE_NAME, Nas).stop() ->
radius:stop_service(?SERVICE_NAME).handle_request(Type, Request, Client) ->
io:format("Type: ~p~nRequest: ~p~nClient: ~p~n", [Type, Request, Client]),
Response = #radius_packet{code = ?ACCESS_ACCEPT, attrs = []},
{ok, Response}.handle_error(Reason, Data) ->
io:format("Reason: ~p, Data: ~p~n", [Reason, Data]).
```Client example
--------------```erlang
-module(client).-export([send/0]).
-include("radius.hrl").
send() ->
{ok, _Started} = application:ensure_all_started(radius),
lists:foreach(fun radius_dict:add/1, radius_dict_file:load("dictionary")),{ok, Pid} = radius_client:start_link({127, 0, 0, 1}, 1812, "testing123"),
Attrs = [
{"User-Name", "john"},
{"Password", "secret"}
],Reply = radius_client:send(Pid, ?ACCESS_REQUEST, Attrs),
io:format("Reply: ~p~n", [Reply]),
radius_client:stop(Pid).
```License
-------All parts of this software are distributed under the Apache License, Version 2.0 terms.