Skip to content

Added warnings when port 80 may clash.#110

Merged
dvdcastro merged 2 commits into
citricity:mainfrom
dvdcastro:port-80-warnings
Mar 4, 2026
Merged

Added warnings when port 80 may clash.#110
dvdcastro merged 2 commits into
citricity:mainfrom
dvdcastro:port-80-warnings

Conversation

@dvdcastro
Copy link
Copy Markdown
Collaborator

Addresses #109

* Uses a short TCP connection attempt for portability across OS.
*/
public function isPort80InUse(): bool {
$fp = @fsockopen('127.0.0.1', self::PROXY_PORT, $errno, $errstr, 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, this is a really neat way of doing it as it should work with any operating system.

Comment thread src/Service/ProxyService.php Outdated
* When proxy mode is enabled: if port 80 is in use and not by mchef-proxy, warn that proxy mode will not work.
* Call from: config --proxy (when enabling), mchef up, and when creating instance from recipe.
*/
public function warnIfPort80BlockedForProxy(): void {
Copy link
Copy Markdown
Collaborator

@gthomas2 gthomas2 Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to

public function warnIfPort80BlockedForProxy(bool $skipEnabledCheck = false): void {
        if (!$skipEnabledCheck && !$this->isProxyModeEnabled()) {
            return;
        }

Comment thread src/Command/Config.php Outdated

private function setProxy(bool $proxy) {
if ($proxy) {
$this->proxyService->warnIfPort80BlockedForProxy();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comment about suggested change to warnIfPort80BlockedForProxy and change this to

$this->proxyService->warnIfPort80BlockedForProxy(true);

If we don't force the warning to skip the config check, we won't see the warning here because the configurator hasn't had chance to turn on "useProxy" yet.

Copy link
Copy Markdown
Collaborator

@gthomas2 gthomas2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a small bug that needs fixing regarding not warning if config isn't set

@dvdcastro
Copy link
Copy Markdown
Collaborator Author

Thanks for the comments @gthomas2

I've added another commit addressing them.

@dvdcastro dvdcastro merged commit bf779ca into citricity:main Mar 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants