fix: wrong env variable parsing
This commit is contained in:
		@@ -216,55 +216,60 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
 | 
				
			|||||||
    $labels = collect([]);
 | 
					    $labels = collect([]);
 | 
				
			||||||
    $labels->push('traefik.enable=true');
 | 
					    $labels->push('traefik.enable=true');
 | 
				
			||||||
    foreach ($domains as $loop => $domain) {
 | 
					    foreach ($domains as $loop => $domain) {
 | 
				
			||||||
        $uuid = new Cuid2(7);
 | 
					        try {
 | 
				
			||||||
        $url = Url::fromString($domain);
 | 
					            $uuid = new Cuid2(7);
 | 
				
			||||||
        $host = $url->getHost();
 | 
					            $url = Url::fromString($domain);
 | 
				
			||||||
        $path = $url->getPath();
 | 
					            $host = $url->getHost();
 | 
				
			||||||
        $schema = $url->getScheme();
 | 
					            $path = $url->getPath();
 | 
				
			||||||
        $port = $url->getPort();
 | 
					            $schema = $url->getScheme();
 | 
				
			||||||
        if (is_null($port) && !is_null($onlyPort)) {
 | 
					            $port = $url->getPort();
 | 
				
			||||||
            $port = $onlyPort;
 | 
					            if (is_null($port) && !is_null($onlyPort)) {
 | 
				
			||||||
 | 
					                $port = $onlyPort;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $http_label = "{$uuid}-{$loop}-http";
 | 
				
			||||||
 | 
					            $https_label = "{$uuid}-{$loop}-https";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ($schema === 'https') {
 | 
				
			||||||
 | 
					                // Set labels for https
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$https_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)");
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$https_label}.entryPoints=https");
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$https_label}.middlewares=gzip");
 | 
				
			||||||
 | 
					                if ($port) {
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.routers.{$https_label}.service={$https_label}");
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.services.{$https_label}.loadbalancer.server.port=$port");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if ($path !== '/') {
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.routers.{$https_label}.middlewares={$https_label}-stripprefix");
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.middlewares.{$https_label}-stripprefix.stripprefix.prefixes={$path}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$https_label}.tls=true");
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$https_label}.tls.certresolver=letsencrypt");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Set labels for http (redirect to https)
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)");
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$http_label}.entryPoints=http");
 | 
				
			||||||
 | 
					                if ($is_force_https_enabled) {
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.routers.{$http_label}.middlewares=redirect-to-https");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                // Set labels for http
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)");
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$http_label}.entryPoints=http");
 | 
				
			||||||
 | 
					                $labels->push("traefik.http.routers.{$http_label}.middlewares=gzip");
 | 
				
			||||||
 | 
					                if ($port) {
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.routers.{$http_label}.service={$http_label}");
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.services.{$http_label}.loadbalancer.server.port=$port");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if ($path !== '/') {
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.routers.{$http_label}.middlewares={$http_label}-stripprefix");
 | 
				
			||||||
 | 
					                    $labels->push("traefik.http.middlewares.{$http_label}-stripprefix.stripprefix.prefixes={$path}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch(\Throwable $e) {
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $http_label = "{$uuid}-{$loop}-http";
 | 
					 | 
				
			||||||
        $https_label = "{$uuid}-{$loop}-https";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($schema === 'https') {
 | 
					 | 
				
			||||||
            // Set labels for https
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$https_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)");
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$https_label}.entryPoints=https");
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$https_label}.middlewares=gzip");
 | 
					 | 
				
			||||||
            if ($port) {
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.routers.{$https_label}.service={$https_label}");
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.services.{$https_label}.loadbalancer.server.port=$port");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if ($path !== '/') {
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.routers.{$https_label}.middlewares={$https_label}-stripprefix");
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.middlewares.{$https_label}-stripprefix.stripprefix.prefixes={$path}");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$https_label}.tls=true");
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$https_label}.tls.certresolver=letsencrypt");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // Set labels for http (redirect to https)
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)");
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$http_label}.entryPoints=http");
 | 
					 | 
				
			||||||
            if ($is_force_https_enabled) {
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.routers.{$http_label}.middlewares=redirect-to-https");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            // Set labels for http
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)");
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$http_label}.entryPoints=http");
 | 
					 | 
				
			||||||
            $labels->push("traefik.http.routers.{$http_label}.middlewares=gzip");
 | 
					 | 
				
			||||||
            if ($port) {
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.routers.{$http_label}.service={$http_label}");
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.services.{$http_label}.loadbalancer.server.port=$port");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if ($path !== '/') {
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.routers.{$http_label}.middlewares={$http_label}-stripprefix");
 | 
					 | 
				
			||||||
                $labels->push("traefik.http.middlewares.{$http_label}-stripprefix.stripprefix.prefixes={$path}");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return $labels;
 | 
					    return $labels;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,6 +102,7 @@ function refreshSession(?Team $team = null): void
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
function handleError(?Throwable $error = null, ?Livewire\Component $livewire = null, ?string $customErrorMessage = null)
 | 
					function handleError(?Throwable $error = null, ?Livewire\Component $livewire = null, ?string $customErrorMessage = null)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    ray($error);
 | 
				
			||||||
    if ($error instanceof TooManyRequestsException) {
 | 
					    if ($error instanceof TooManyRequestsException) {
 | 
				
			||||||
        if (isset($livewire)) {
 | 
					        if (isset($livewire)) {
 | 
				
			||||||
            return $livewire->dispatch('error', "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds.");
 | 
					            return $livewire->dispatch('error', "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds.");
 | 
				
			||||||
@@ -227,11 +228,15 @@ function base_ip(): string
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
function getFqdnWithoutPort(String $fqdn)
 | 
					function getFqdnWithoutPort(String $fqdn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    $url = Url::fromString($fqdn);
 | 
					    try {
 | 
				
			||||||
    $host = $url->getHost();
 | 
					        $url = Url::fromString($fqdn);
 | 
				
			||||||
    $scheme = $url->getScheme();
 | 
					        $host = $url->getHost();
 | 
				
			||||||
    $path = $url->getPath();
 | 
					        $scheme = $url->getScheme();
 | 
				
			||||||
    return "$scheme://$host$path";
 | 
					        $path = $url->getPath();
 | 
				
			||||||
 | 
					        return "$scheme://$host$path";
 | 
				
			||||||
 | 
					    } catch (\Throwable $e) {
 | 
				
			||||||
 | 
					        return $fqdn;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * If fqdn is set, return it, otherwise return public ip.
 | 
					 * If fqdn is set, return it, otherwise return public ip.
 | 
				
			||||||
@@ -1520,6 +1525,9 @@ function parseEnvVariable(Str|string $value)
 | 
				
			|||||||
            $command = $value->after('SERVICE_')->before('_');
 | 
					            $command = $value->after('SERVICE_')->before('_');
 | 
				
			||||||
            $forService = $value->after('SERVICE_')->after('_')->before('_');
 | 
					            $forService = $value->after('SERVICE_')->after('_')->before('_');
 | 
				
			||||||
            $port = $value->afterLast('_');
 | 
					            $port = $value->afterLast('_');
 | 
				
			||||||
 | 
					            if (filter_var($port, FILTER_VALIDATE_INT) === false) {
 | 
				
			||||||
 | 
					                $port = null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            // SERVICE_BASE64_64_UMAMI
 | 
					            // SERVICE_BASE64_64_UMAMI
 | 
				
			||||||
            $command = $value->after('SERVICE_')->beforeLast('_');
 | 
					            $command = $value->after('SERVICE_')->beforeLast('_');
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user