rdcore icon indicating copy to clipboard operation
rdcore copied to clipboard

NAS on the latest version

Open dd1245 opened this issue 3 years ago • 17 comments

Hi.

On the latest version of RADIUSdesk, I can create RADIUS clients, but do not seem to be able to create a NAS now, with its own key. Is this still possible, and if not, If I manually insert an entry into the SQL nas table, will this still work?

dd1245 avatar Jan 25 '22 14:01 dd1245

I can't add NAS Direct (fixed IP).

Add "+" only can add NAS Dynamic.

RD OVA VirtualBox.

antoniovalenzuela avatar Apr 04 '22 01:04 antoniovalenzuela

@dirkvanderwalt Hi, you can help us?

antoniovalenzuela avatar Apr 04 '22 13:04 antoniovalenzuela

Hi,

I need to check if the code paw ported to CakePHPv3. If so, its probably just commented out and we can add maybe a config file setting so it can be displayed.

Nudge me again if I have not replied in 24 hours :-)

dirkvanderwalt avatar Apr 04 '22 13:04 dirkvanderwalt

Thanks. I need direct NAS to setup POD/COA 3799, because currently I can't kill user connected to Coova.

antoniovalenzuela avatar Apr 04 '22 13:04 antoniovalenzuela

Please add timezone "America/Chile" now GMT-4 and DST with GMT-3.

I don't undestand the values of the table "timezone".

I think it would be better to read the timezones of the O.S.

;)

antoniovalenzuela avatar Apr 05 '22 00:04 antoniovalenzuela

Hi @dirkvanderwalt

could you check the code?

antoniovalenzuela avatar Apr 05 '22 15:04 antoniovalenzuela

Please add timezone "America/Chile" now GMT-4 and DST with GMT-3.

I don't undestand the values of the table "timezone".

I think it would be better to read the timezones of the O.S.

;)

Solved, I added into DB. GMT-4.

antoniovalenzuela avatar Apr 05 '22 22:04 antoniovalenzuela

Hi,

I need to check if the code paw ported to CakePHPv3. If so, its probably just commented out and we can add maybe a config file setting so it can be displayed.

Nudge me again if I have not replied in 24 hours :-)

Any luck with allowing the static NAS definitions?

dd1245 avatar Apr 06 '22 15:04 dd1245

@dirkvanderwalt ?

antoniovalenzuela avatar Apr 06 '22 21:04 antoniovalenzuela

Hi everyone,

I checked the code and it is there

https://github.com/RADIUSdesk/rdcore/tree/main/rd/classic/src/view/nas https://github.com/RADIUSdesk/rdcore/blob/main/cake3/rd_cake/src/Controller/NasController.php

So I should have a way to enable / include it checked in (into Github) by Monday.

dirkvanderwalt avatar Apr 08 '22 03:04 dirkvanderwalt

Hi everyone,

I checked the code and it is there

https://github.com/RADIUSdesk/rdcore/tree/main/rd/classic/src/view/nas https://github.com/RADIUSdesk/rdcore/blob/main/cake3/rd_cake/src/Controller/NasController.php

So I should have a way to enable / include it checked in (into Github) by Monday.

That's great. Thanks

dd1245 avatar Apr 08 '22 07:04 dd1245

Actually you should be able to activate them even in the current code Just remove the comments (for root user) https://github.com/RADIUSdesk/rdcore/blob/main/cake3/rd_cake/src/Controller/DashboardController.php#L795

And then for the other normal Access Providers https://github.com/RADIUSdesk/rdcore/blob/main/cake3/rd_cake/src/Controller/DashboardController.php#L1513

Let us know if this works for you

dirkvanderwalt avatar Apr 09 '22 11:04 dirkvanderwalt

Seems to work fine, thanks very much.

dd1245 avatar Apr 09 '22 18:04 dd1245

@dirkvanderwalt
Works, but some issues:

  • Can't delete added "NAS Devices"
  • Kick doesn't work for CoovaChilli COA port 3799 (data saved in optional info)

To kick or disconnect I added in public function "kickActive" file RadacctsController.php

shell_exec("echo User-Name='".$ent->username."' | radclient -c '1' -n '3' -r '3' -t '3' -x '127.0.0.1:3799' 'disconnect' 'testing123'");

antoniovalenzuela avatar Apr 10 '22 16:04 antoniovalenzuela

@dirkvanderwalt Works, but some issues:

  • Can't delete added "NAS Devices"
  • Kick doesn't work for CoovaChilli COA port 3799 (data saved in optional info)

To kick or disconnect I added in public function "kickActive" file RadacctsController.php

shell_exec("echo User-Name='".$ent->username."' | radclient -c '1' -n '3' -r '3' -t '3' -x '127.0.0.1:3799' 'disconnect' 'testing123'");

Can you give me example? I've add line like this

shell_exec("echo User-Name='".$ent->username."' | radclient -c '1' -n '3' -r '3' -t '3' -x '".$ent-> nasipaddress.:3799"' 'disconnect' 'secret'");

but I still cant kick the user, I use .$ent->nasipaddress. to determine which NAS, because I have many Mikrotik NAS.

dedykurniadi avatar Jun 09 '22 01:06 dedykurniadi

shell_exec("echo User-Name='".$ent->username."' | radclient -c '1' -n '3' -r '3' -t '3' -x '".$ent-> nasipaddress.:3799"' 'disconnect' 'secret'");

ther right is

shell_exec("echo User-Name='".$ent->username."' | radclient -c '1' -n '3' -r '3' -t '3' -x '".$ent-> nasipaddress.":3799' 'disconnect' 'secret'");

for now i can kick the client

dedykurniadi avatar Jun 13 '22 03:06 dedykurniadi

Hi.

Is there a way to dynamically pull secret from database for radclient? It is useful if we have different secrets for each client.

[EDIT] if anyone is interested, the code for dynamic pull of secrets from database is(paste this function instead of default kickActive):

public function kickActive(){
        $this->loadModel('Nas');
        //__ Authentication + Authorization __
        $user = $this->_ap_right_check();
        if(!$user){
            return;
        }

        $some_session_closed    = false;
        $count                  = 0;
        $msg                    = 'Could not locate session';
        $data                   = ['title' => 'Session Not Found', 'message' => $msg, 'type' =>'warn'];
        $req_q                  = $this->request->getQuery();

        foreach(array_keys($req_q) as $key){
            if(preg_match('/^\d+/',$key)){
                $ent = $this->{$this->main_model}->find()->where(['Radaccts.radacctid' => $key])->first();

                $qr = $this->Nas->find()->where(['Nas.nasname' => $ent->nasipaddress])->first();

                $count++;
                if($ent->acctstoptime !== null){
                    $some_session_closed = true;
                }else{
                    shell_exec("echo User-Name='".$ent->username."', Framed-IP-Address='".$ent->framedipaddress."' | radclient -c '1' -n '3' -r '3' -t '3' -x '".$ent->nasipaddress.":3799' 'disconnect' '".$qr->secret."'");
                    $data = $this->Kicker->kick($ent); //Sent it to the Kicker
                }
            }
        }

        if($count >0){
            $data = ['title' => 'Disconnect Sent', 'message' => 'Disconnect Instructions Sent', 'type' =>'info'];
        }

        if(($some_session_closed)&&($count>0)){
            $msg = 'Sessions Is already Closed';
            if($count > 1){
                $msg = 'Some Sessions Are already Closed';
            }
            $data = ['title' => 'Session Closed Already', 'message' => $msg, 'type' =>'warn'];
        }

        $this->set([
            'success'       => true,
            'data'          => $data
        ]);
        $this->viewBuilder()->setOption('serialize', true);
    }

Best regards, Aleksa.

netcom-rs avatar Nov 23 '22 16:11 netcom-rs