Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue from github: 20 #21

Merged
merged 1 commit into from
May 22, 2017
Merged

Issue from github: 20 #21

merged 1 commit into from
May 22, 2017

Conversation

ayamshanov
Copy link
Member

@ayamshanov ayamshanov commented May 17, 2017

Fix for issue #20. This patch set local IP-address for -b (bind) parameter and the extension can work behind the NAT (as an example inside Cloud Environments)


$view = new Zend_View();
$view->setScriptPath(pm_Context::getPlibDir() . 'views/scripts');
$slaveConfiguration = $view->partial('index/slave-config.phtml', ['masterIp' => $masterIp, 'secret' => $keySecret]);
$slaveConfiguration = $view->partial('index/slave-config.phtml', ['masterIp' => $masterIp, 'masterPublicIp' => $masterPublicIp, 'secret' => $keySecret]);
Copy link
Member

Choose a reason for hiding this comment

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

masterIp is unused now, isn't it?

self::$_publicIpAddresses = [];

$request = "<ip><get/></ip>";
$response = pm_ApiRpc::getService('1.6.5.0')->call($request);
Copy link
Member

Choose a reason for hiding this comment

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

lets avoid copy-paste of api calls. we could have only one static array [ $private => $public ] addresses

@xgin
Copy link
Member

xgin commented May 18, 2017

Could you also reword the commit to be more informative

@ayamshanov
Copy link
Member Author

xgin, I updated fix. Please review.

public static function getDefault()
{
return reset(self::getAvailable());
return self::$_defaultIpAddress;
Copy link
Member

Choose a reason for hiding this comment

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

Need to warmup cache with self::getAvailable().
And we have to return default IP even if nothing was marked as default in API.

Copy link
Member

Choose a reason for hiding this comment

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

if (!self::$_defaultIpAddress) {
$ipAddresses = array_keys(self::getAvailable());
}
return self::$_defaultIpAddress ?: reset($ipAddresses);

self::getAvailable();
}

return self::$_ipAddresses[$ipAddress];
Copy link
Member

Choose a reason for hiding this comment

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

simplify: return self::getAvailable()[$ipAddress] (the method getAvailable is already responsible for the cache)

@ayamshanov
Copy link
Member Author

Thank you for advice, I applied your recommendations.

@xgin xgin merged commit bff3e30 into plesk:master May 22, 2017
@xgin
Copy link
Member

xgin commented May 22, 2017

Well done! Let's request for QA assistance & publication.

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.

None yet

2 participants