[RADIATOR] multiple hosts

Heikki Vatiainen hvn at open.com.au
Wed Nov 30 14:47:26 CST 2011


On 11/25/2011 11:02 AM, Alexander Hartmaier wrote:

> @list: please feel free to suggest improvements or simplification if 
> possible!

The code looks fine. I thought I'd say a couple of words how I have been
doing hooks lately.

Instead of creating an individual file for each hook, they can collected
into one file. Something like this should work:

# ProxyHooks.pm
#
package ProxyHooks;
use strict;
use warnings;

my $h = "ProxyHooks"; # Common prefix for log entries

sub reply {
     my $p  = ${$_[0]};  # reply packet from remote radius server
     my $rp = ${$_[1]};  # reply packet to NAS
     my $op = ${$_[2]};  # original request packet
     my $sp = ${$_[3]};  # packet sent to remote radius server
     my $nextIdentifier = $_[4]; # See config example for this

     main::log($main::LOG_DEBUG, "$h: reply: $nextIdentifer");
     # rest of the hook code
}

sub noReply {
     # more code
}

# More functions

# End module with this line
1;


How to to use in configuration file:

StartupHook sub { require "/etc/radiator/ProxyHooks.pm"; }

<Handler ...>
  <AuthBy RADIUS>
    Identifier auth-radius1
    ReplyHook sub { ProxyHooks::reply(@_, 'auth-radius2'); }
    # ...
  </AuthBy>
  <AuthBy RADIUS>
    Identifier auth-radius2
    # ...
  </AuthBy>
</Handler>

Notes about the above:
- all hooks in one file: reduces clutter in config directory
- possibility to add own arguments to hook calls
- can use functions in .pm. Not everything has to be in one sub
- use strict etc. can be specified only once
- same functionality as with individual files, just organised differently


-- 
Heikki Vatiainen <hvn at open.com.au>

Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS,
NetWare etc.


More information about the radiator mailing list