connectVps method

Future<SSHClientStatus> connectVps(
  1. String tunnel,
  2. String keyApp
)

Implementation

Future<SSHClientStatus> connectVps(String tunnel, String keyApp) async {
  if (sshClientStatus != null &&
      sshClientStatus.sshClient != null &&
      sshClientStatus.sshClient.socket != null) {
    return this.sshClientStatus;
  }

  this.sshClientStatus = new SSHClientStatus();
  String sshResponse = '';
  String tunnelWithoutHttp =
      tunnel.replaceAll("http://", "").replaceAll("https://", "");

  String statusString = getSSHClient(<String>[
    '-l',
    this.sshClientStatus.sshClient.login,
    this.sshClientStatus.sshClient.hostport.toString(),
    '--tunnel',
    tunnelWithoutHttp,
    '--password',
    this.sshClientStatus.sshClient.getPassword.toString()
    //,'--debug'
  ], (_, String v) => sshResponse += v, null, keyApp);

  if (statusString == "true") {
    this.sshClientStatus.sshClientStatus = true;
  } else {
    this.sshClientStatus.sshClientStatus = false;
    this.sshClientStatus.sshClientStatusMsg = statusString;
  }
  return this.sshClientStatus;
}