mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 03:36:53 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace Pterodactyl\Http\Controllers\Admin\Nodes;
 | 
						|
 | 
						|
use Illuminate\Support\Str;
 | 
						|
use Illuminate\Http\Request;
 | 
						|
use Pterodactyl\Models\Node;
 | 
						|
use Illuminate\Http\JsonResponse;
 | 
						|
use Pterodactyl\Http\Controllers\Controller;
 | 
						|
use Pterodactyl\Repositories\Wings\DaemonConfigurationRepository;
 | 
						|
 | 
						|
class SystemInformationController extends Controller
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * @var \Pterodactyl\Repositories\Wings\DaemonConfigurationRepository
 | 
						|
     */
 | 
						|
    private $repository;
 | 
						|
 | 
						|
    /**
 | 
						|
     * SystemInformationController constructor.
 | 
						|
     */
 | 
						|
    public function __construct(DaemonConfigurationRepository $repository)
 | 
						|
    {
 | 
						|
        $this->repository = $repository;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns system information from the Daemon.
 | 
						|
     *
 | 
						|
     * @return \Illuminate\Http\JsonResponse
 | 
						|
     *
 | 
						|
     * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
 | 
						|
     */
 | 
						|
    public function __invoke(Request $request, Node $node)
 | 
						|
    {
 | 
						|
        $data = $this->repository->setNode($node)->getSystemInformation();
 | 
						|
 | 
						|
        return new JsonResponse([
 | 
						|
            'version' => $data['version'] ?? '',
 | 
						|
            'system' => [
 | 
						|
                'type' => Str::title($data['os'] ?? 'Unknown'),
 | 
						|
                'arch' => $data['architecture'] ?? '--',
 | 
						|
                'release' => $data['kernel_version'] ?? '--',
 | 
						|
                'cpus' => $data['cpu_count'] ?? 0,
 | 
						|
            ],
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
}
 |