mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-05-31 16:00:09 +00:00
fix: IPv6 compatibility across containers and PHP AIO interface (#8019)
This commit is contained in:
@@ -5,6 +5,7 @@ namespace AIO\Data;
|
||||
|
||||
use AIO\Auth\PasswordGenerator;
|
||||
use AIO\Controller\DockerController;
|
||||
use AIO\Helper\NetworkHelper;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
|
||||
@@ -1111,9 +1112,9 @@ class ConfigurationManager
|
||||
'INSTALL_LATEST_MAJOR' => $this->installLatestMajor ? 'yes' : '',
|
||||
'REMOVE_DISABLED_APPS' => $this->nextcloudKeepDisabledApps ? '' : 'yes',
|
||||
// Allow to get local ip-address of database container which allows to talk to it even in host mode (the container that requires this needs to be started first then)
|
||||
'AIO_DATABASE_HOST' => gethostbyname('nextcloud-aio-database'),
|
||||
'AIO_DATABASE_HOST' => NetworkHelper::resolveHostname('nextcloud-aio-database'),
|
||||
// Allow to get local ip-address of caddy container and add it to trusted proxies automatically
|
||||
'CADDY_IP_ADDRESS' => in_array('caddy', $this->aioCommunityContainers, true) ? gethostbyname('nextcloud-aio-caddy') : '',
|
||||
'CADDY_IP_ADDRESS' => in_array('caddy', $this->aioCommunityContainers, true) ? NetworkHelper::resolveHostname('nextcloud-aio-caddy') : '',
|
||||
'WHITEBOARD_ENABLED' => $this->isWhiteboardEnabled ? 'yes' : '',
|
||||
'AIO_VERSION' => $this->getAioVersion(),
|
||||
default => $this->getRegisteredSecret($placeholder),
|
||||
|
||||
@@ -71,4 +71,5 @@ class DataConst {
|
||||
public static function GetAioVersionFile() : string {
|
||||
return (string)realpath(__DIR__ . '/../../templates/includes/aio-version.twig');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use AIO\Container\VersionState;
|
||||
use AIO\ContainerDefinitionFetcher;
|
||||
use AIO\Data\ConfigurationManager;
|
||||
use AIO\Data\DataConst;
|
||||
use AIO\Helper\NetworkHelper;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use http\Env\Response;
|
||||
@@ -449,7 +450,7 @@ readonly class DockerActionManager {
|
||||
|
||||
// Special things for the jellyfin community container
|
||||
} elseif ($container->identifier === 'nextcloud-aio-jellyfin') {
|
||||
$lldapIp = gethostbyname('nextcloud-aio-lldap');
|
||||
$lldapIp = NetworkHelper::resolveHostname('nextcloud-aio-lldap');
|
||||
if ($lldapIp !== 'nextcloud-aio-lldap') {
|
||||
$requestBody['HostConfig']['ExtraHosts'] = ['nextcloud-aio-lldap:' . $lldapIp];
|
||||
}
|
||||
|
||||
23
php/src/Helper/NetworkHelper.php
Normal file
23
php/src/Helper/NetworkHelper.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace AIO\Helper;
|
||||
|
||||
class NetworkHelper {
|
||||
/**
|
||||
* Resolve a hostname to its IP address, trying IPv4 first and falling back
|
||||
* to IPv6 (AAAA record) when no A record is found. Returns the hostname
|
||||
* unchanged when neither record resolves successfully.
|
||||
*/
|
||||
public static function resolveHostname(string $hostname): string {
|
||||
$ipv4 = gethostbyname($hostname);
|
||||
if ($ipv4 !== $hostname) {
|
||||
return $ipv4;
|
||||
}
|
||||
$records = dns_get_record($hostname, DNS_AAAA);
|
||||
if (is_array($records) && isset($records[0]['ipv6']) && $records[0]['ipv6'] !== '') {
|
||||
return $records[0]['ipv6'];
|
||||
}
|
||||
return $hostname;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user