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

Use the IP from the Server Post if available #96

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions includes/core/apps/wordpress-app/class-wordpress-ssh.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,20 @@ public function get_ssh_key_details( $attributes ) {
$ssh_private_key_encrypted = wpcd_get_option( 'vpn_' . $attributes['provider'] . '_sshkey' ); // We don't decrypt the private key itself....
}

// Get some other data elements...
$instance = WPCD()->get_provider_api( $attributes['provider'] )->call( 'details', $attributes );
// Grab the ip address.
if (metadata_exists('post', $post_id, 'wpcd_server_ipv4')) { // we use the ip from the server post if it's available
$ip = get_post_meta($post_id, 'wpcd_server_ipv4', true);
} else { // otherwise we get it from the provider.
$instance = WPCD()->get_provider_api($attributes['provider'])->call('details', $attributes);

// Make sure the $instance var is valid otherwise return false.
if (is_wp_error($instance) || empty($instance)) {
return false;
}

// Make sure the $instance var is valid otherwise return false.
if ( is_wp_error( $instance ) || empty( $instance ) ) {
return false;
$ip = $instance['ip'];
}

// Grab the ip address.
$ip = $instance['ip'];

// At this point we better have some key data!
$key = array(
'passwd' => $ssh_private_key_password, // decrypted.
Expand Down