PHP code example of anafay / radius-server

1. Go to this page and download the library: Download anafay/radius-server library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anafay / radius-server example snippets


class RadiusServer implements RadiusServerInterface {
    public function onAccessRequest(IncomingMessage $message) {
        if(check($message)){
            $message->replyAccept()
                ->addAttribute(Message::ATTR_FRAMED_IP_ADDRESS, '192.168.0.1')
                ->addAttribute(Message::ATTR_SESSION_TIMEOUT,180)
                ->send();
        }else{
            $message->replyReject()
                ->addAttribute(Message::ATTR_REPLY_MESSAGE,'Restricted')
                ->send();
        }
    }

    public function onAccountingStart(IncomingMessage $message, Session $session) {
        $this->log($session,'start');
    }

    public function onAccountingStop(IncomingMessage $message, Session $session) {
        $this->log($session,'stop');
        $this->save($session);
    }

    public function onInterimUpdate(IncomingMessage $message, Session $session) {
        $this->log($session,'interim');
    }
    ....
}

$loop = React\EventLoop\Factory::create();
$radius = new Factory(new RadiusServer(),'secret');
$radius->listen($loop,'10.1.0.1');
$loop->run();