ruby-radius 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +37 -0
- data/dictionary +289 -0
- data/examples/radiusclient.rb +51 -0
- data/examples/rclient.rb +24 -0
- data/lib/radius/auth.rb +131 -0
- data/lib/radius/dictionary.rb +350 -0
- data/lib/radius/packet.rb +504 -0
- data/test/test.pl +45 -0
- data/test/test.rb +34 -0
- metadata +53 -0
data/test/test.pl
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/perl
|
2
|
+
# Test program in Perl using Net::Radius, to compare the results with
|
3
|
+
# our program.
|
4
|
+
# This test program is provided only for illustrative purposes and is
|
5
|
+
# placed in the public domain.
|
6
|
+
# $Id: test.pl 2 2006-12-17 06:16:21Z dido $
|
7
|
+
#
|
8
|
+
use Net::Radius::Packet;
|
9
|
+
use Net::Radius::Dictionary;
|
10
|
+
|
11
|
+
my $dict = new Net::Radius::Dictionary "./dictionary"
|
12
|
+
or die "Cannot read or parse dictionary: $!\n";
|
13
|
+
|
14
|
+
my $packet = new Net::Radius::Packet $dict;
|
15
|
+
|
16
|
+
$packet->set_code('Access-Request');
|
17
|
+
$packet->set_identifier(1);
|
18
|
+
$packet->set_attr('User-Name', 'you');
|
19
|
+
$packet->set_attr('NAS-IP-Address', '127.0.0.1');
|
20
|
+
$packet->set_attr('NAS-Port', 1);
|
21
|
+
$packet->set_attr('Expiration', 1000000);
|
22
|
+
$packet->set_attr('Service-Type' => 'Framed-User');
|
23
|
+
$packet->set_attr('Framed-Protocol' => 'PPP');
|
24
|
+
$packet->set_vsattr(9, 'cisco-avpair', 'This is my VSA 1');
|
25
|
+
$packet->set_vsattr(9, 'cisco-avpair', 'This is my VSA 2');
|
26
|
+
$packet->set_vsattr(1, 'ibm-enum', 'value-1');
|
27
|
+
$packet->set_vsattr(1, 'ibm-enum', 'value-2');
|
28
|
+
$packet->set_vsattr(1, 'ibm-enum', 'value-3');
|
29
|
+
$packet->set_authenticator("aaaaaaaaaaaaaaaa");
|
30
|
+
$packet->set_password('My-Password', 'My-Shared-Secret');
|
31
|
+
my $p = $packet->pack;
|
32
|
+
print unpack("H*", $p) . "\n";
|
33
|
+
|
34
|
+
my $packet2 = new Net::Radius::Packet $dict;
|
35
|
+
# this string----------------| was generated from test.rb
|
36
|
+
$packet2->unpack(pack("H*", "0101009d616161616161616161616161616161610212bd74ad27726cd1110d87303775934bfd0606000000020105796f750706000000010506000000011506000f424004067f0000011a0c00000001fe06000000021a0c00000001fe06000000021a0c00000001fe06000000031a1800000009011254686973206973206d792056534120311a1800000009011254686973206973206d79205653412032"));
|
37
|
+
$packet2->dump;
|
38
|
+
#print "RAD-Code = " . $packet2->code . "\n";
|
39
|
+
#print "RAD-Identifier = " . $packet2->identifier . "\n";
|
40
|
+
#print "RAD-Authenticator = " . $packet2->authenticator . "\n";
|
41
|
+
#foreach $attr ($packet2->attributes) {
|
42
|
+
# $val = ($attr eq "User-Password") ? $packet2->password("My-Shared-Secret") :
|
43
|
+
# $packet2->attr($attr);
|
44
|
+
# print "$attr = $val\n";
|
45
|
+
#}
|
data/test/test.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
# Simple test program, generates a test packet for test.pl, compare with
|
3
|
+
# Net::Radius in Perl.
|
4
|
+
# This test program is provided only for illustrative purposes and is placed
|
5
|
+
# in the public domain.
|
6
|
+
# $Id: test.rb 2 2006-12-17 06:16:21Z dido $
|
7
|
+
|
8
|
+
require './radius/dictionary'
|
9
|
+
require './radius/packet'
|
10
|
+
|
11
|
+
dict = Radius::Dict.new
|
12
|
+
dict.read(File.new("dictionary"))
|
13
|
+
packet = Radius::Packet.new(dict)
|
14
|
+
packet.code = 'Access-Request'
|
15
|
+
packet.identifier = 1
|
16
|
+
packet.set_attr('User-Name', 'you')
|
17
|
+
packet.set_attr('NAS-IP-Address', '127.0.0.1')
|
18
|
+
packet.set_attr('NAS-Port', 1)
|
19
|
+
packet.set_attr('Service-Type', 'Framed-User')
|
20
|
+
packet.set_attr('Framed-Protocol', 'PPP')
|
21
|
+
packet.set_attr('Expiration', 1000000)
|
22
|
+
packet.set_vsattr(9, 'cisco-avpair', 'This is my VSA 1')
|
23
|
+
packet.set_vsattr(9, 'cisco-avpair', 'This is my VSA 2')
|
24
|
+
packet.set_vsattr(1, 'ibm-enum', 'value-2')
|
25
|
+
packet.set_vsattr(1, 'ibm-enum', 'value-2')
|
26
|
+
packet.set_vsattr(1, 'ibm-enum', 'value-3')
|
27
|
+
packet.authenticator = "aaaaaaaaaaaaaaaa"
|
28
|
+
packet.set_password('My-Password', 'My-Shared-Secret')
|
29
|
+
p = packet.pack
|
30
|
+
print p.unpack("H*"), "\n"
|
31
|
+
packet2 = Radius::Packet.new(dict)
|
32
|
+
# This string----| was created by test.pl
|
33
|
+
packet2.unpack(["0101009d616161616161616161616161616161610105796f751506000f424007060000000105060000000104067f0000010212bd74ad27726cd1110d87303775934bfd0606000000021a0c00000001fe06000000011a0c00000001fe06000000021a0c00000001fe06000000031a1800000009011254686973206973206d792056534120311a1800000009011254686973206973206d79205653412032"].pack("H*"))
|
34
|
+
print packet2.to_s('My-Shared-Secret') + "\n"
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-radius
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rafael 'Dido' Sevilla
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-15 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ''
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- dictionary
|
21
|
+
- examples/radiusclient.rb
|
22
|
+
- examples/rclient.rb
|
23
|
+
- README
|
24
|
+
- lib/radius/auth.rb
|
25
|
+
- lib/radius/dictionary.rb
|
26
|
+
- lib/radius/packet.rb
|
27
|
+
- test/test.pl
|
28
|
+
- test/test.rb
|
29
|
+
homepage:
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.7
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 1.8.25
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: A ruby implementation of an RFC 2139 compliant radius client
|
53
|
+
test_files: []
|