<commit_before><?php

namespace fkooman\VPN\Server;

class Pools
{
    /** @var array */
    private $pools;

    public function __construct(array $poolsData)
    {
        // XXX listen cannot be the same for different Pool
        // XXX also, if there is more than one pool, listen cannot be '::' or 0.0.0.0

        $this->pools = [];

        $i = 0;
        foreach ($poolsData as $poolName => $poolData) {
            $poolData['name'] = $poolName;
            $this->pools[] = new Pool($i, $poolData);
            ++$i;
        }
    }

    public function getPools()
    {
        return $this->pools;
    }

    public function getManagementSockets()
    {
        $managementSockets = [];

        foreach ($this->pools as $pool) {
            $i = 0;
            foreach ($pool->getInstances() as $instance) {
                $managementSockets[sprintf('%s-%d', $pool->getName(), $i)] = sprintf('tcp://%s:%d', $pool->getManagementIp(), $instance->getManagementPort());
                ++$i;
            }
        }

        return $managementSockets;
    }

    public function getInfo()
    {
        $poolInfo = [];
        foreach ($this->pools as $pool) {
            $routeList = [];
            foreach ($pool->getRoutes() as $route) {
                $routeList[] = $route->getAddressPrefix();
            }
            $dnsList = [];
            foreach ($pool->getDns() as $dns) {
                $dnsList[] = $dns->getAddress();
            }

            $poolInfo[] = [
                'name' => $pool->getName(),
                'range' => $pool->getRange()->getAddressPrefix(),
                'range6' => $pool->getRange6()->getAddressPrefix(),
                'defaultGateway' => $pool->getDefaultGateway(),
                'hostName' => $pool->getHostName(),
                'connectInfo' => $pool->getConnectInfo(),
                'dns' => $dnsList,
                'routes' => $routeList,<commit_msg>fix management socket IP<commit_after><?php

namespace fkooman\VPN\Server;

class Pools
{
    /** @var array */
    private $pools;

    public function __construct(array $poolsData)
    {
        // XXX listen cannot be the same for different Pool
        // XXX also, if there is more than one pool, listen cannot be '::' or 0.0.0.0

        $this->pools = [];

        $i = 0;
        foreach ($poolsData as $poolName => $poolData) {
            $poolData['name'] = $poolName;
            $this->pools[] = new Pool($i, $poolData);
            ++$i;
        }
    }

    public function getPools()
    {
        return $this->pools;
    }

    public function getManagementSockets()
    {
        $managementSockets = [];

        foreach ($this->pools as $pool) {
            $i = 0;
            foreach ($pool->getInstances() as $instance) {
                $managementSockets[sprintf('%s-%d', $pool->getName(), $i)] = sprintf('tcp://%s:%d', $pool->getManagementIp()->getAddress(), $instance->getManagementPort());
                ++$i;
            }
        }

        return $managementSockets;
    }

    public function getInfo()
    {
        $poolInfo = [];
        foreach ($this->pools as $pool) {
            $routeList = [];
            foreach ($pool->getRoutes() as $route) {
                $routeList[] = $route->getAddressPrefix();
            }
            $dnsList = [];
            foreach ($pool->getDns() as $dns) {
                $dnsList[] = $dns->getAddress();
            }

            $poolInfo[] = [
                'name' => $pool->getName(),
                'range' => $pool->getRange()->getAddressPrefix(),
                'range6' => $pool->getRange6()->getAddressPrefix(),
                'defaultGateway' => $pool->getDefaultGateway(),
                'hostName' => $pool->getHostName(),
                'connectInfo' => $pool->getConnectInfo(),
                'dns' => $dnsList,
                'routes' => $routeList,
{'fraction_non_alphanumeric': 0.16242611153945002, 'fraction_numerical': 0.004112053456694937, 'mean_word_length': 1.6971586971586972, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '906652', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1116, 'n_words': 242}