Skip to content

Commit

Permalink
Allow to configure SSH handshake timeout for CopyFilesOverSSH task. (#…
Browse files Browse the repository at this point in the history
…12281)

* * Add "handshakeTimeout" variable with default value of 20000 ms - which is the default when no value is provided to ssh2.
* Add english placeholder resources.

* Pass 'handshakeTimeout' variable to ssh2 and scp2 connections.

* Rename 'handshakeTimeout' to 'readyTimeout'

Co-authored-by: Danny McCormick <[email protected]>
  • Loading branch information
triforcely and Danny McCormick authored Feb 4, 2020
1 parent de73844 commit 150d937
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "Ein Fehler tritt auf, wenn keine zu kopierenden übereinstimmenden Dateien im Quellordner gefunden wurden.",
"loc.input.label.flattenFolders": "Ordner vereinfachen",
"loc.input.help.flattenFolders": "Vereinfacht die Ordnerstruktur und kopiert alle Dateien in den angegebenen Zielordner auf dem Remotecomputer.",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "Überprüfen Sie das Buildprotokoll auf Ausgabe an STDERR vom Befehl.",
"loc.messages.CleanTargetFolder": "Der Zielordner \"%s\" wird auf dem Remotecomputer bereinigt.",
"loc.messages.CleanTargetFolderFailed": "Fehler beim Bereinigen des Zielordners auf dem Remotecomputer. %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "Fail if no matching files to be copied are found under the source folder.",
"loc.input.label.flattenFolders": "Flatten folders",
"loc.input.help.flattenFolders": "Flatten the folder structure and copy all files into the specified target folder on the remote machine.",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "Check the build log for STDERR from the command.",
"loc.messages.CleanTargetFolder": "Cleaning target folder %s on the remote machine",
"loc.messages.CleanTargetFolderFailed": "Failed to clean the target folder on the remote machine. %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "Da error si no se encuentran archivos coincidentes para copiar en la carpeta de origen.",
"loc.input.label.flattenFolders": "Aplanar carpetas",
"loc.input.help.flattenFolders": "Aplana la estructura de carpetas y copia todos los archivos en la carpeta de destino especificada en la máquina remota.",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "Compruebe el registro de compilación para ver si el comando devolvió STDERR.",
"loc.messages.CleanTargetFolder": "Se está limpiando la carpeta de destino %s en la máquina remota",
"loc.messages.CleanTargetFolderFailed": "No se pudo limpiar la carpeta de destino en la máquina remota. %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "Échec si les fichiers correspondants à copier sont introuvables dans le dossier source.",
"loc.input.label.flattenFolders": "Aplatir les dossiers",
"loc.input.help.flattenFolders": "Aplatit la structure du dossier et copie tous les fichiers dans le dossier cible spécifié sur la machine distante.",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "Recherchez dans le journal de génération un STDERR de la commande.",
"loc.messages.CleanTargetFolder": "Nettoyage du dossier cible %s sur la machine distante",
"loc.messages.CleanTargetFolderFailed": "Échec du nettoyage du dossier cible sur la machine distante. %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "Non riesce se nella cartella di origine non vengono trovati file corrispondenti da copiare.",
"loc.input.label.flattenFolders": "Rendi flat le cartelle",
"loc.input.help.flattenFolders": "Rende flat la struttura di cartelle e copia tutti i file nella cartella di destinazione specificata nel computer remoto.",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "Per gli errori STDERR restituiti dal comando, vedere il log di compilazione.",
"loc.messages.CleanTargetFolder": "Pulizia della cartella di destinazione %s nel computer remoto",
"loc.messages.CleanTargetFolderFailed": "Non è stato possibile pulire la cartella di destinazione nel computer remoto. %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "ソース フォルダーの下に一致するコピー対象のファイルが見つからない場合に、失敗します。",
"loc.input.label.flattenFolders": "フォルダーのフラット化",
"loc.input.help.flattenFolders": "フォルダー構造をフラットにし、すべてのファイルを、リモート コンピューター上にある指定のターゲット フォルダーにコピーします。",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "コマンドからの STDERR がないかビルド ログをご確認ください。",
"loc.messages.CleanTargetFolder": "リモート コンピューター上のターゲット フォルダー %s を空にしています",
"loc.messages.CleanTargetFolderFailed": "リモート コンピューター上のターゲット フォルダーを空にできませんでした。%s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "소스 폴더에서 일치하는 복사 대상 파일을 찾을 수 없는 경우 실패합니다.",
"loc.input.label.flattenFolders": "폴더 평면화",
"loc.input.help.flattenFolders": "폴더 구조를 평면화하고 모든 파일을 원격 컴퓨터의 지정된 대상 폴더에 복사합니다.",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "명령에서 STDERR에 대한 빌드 로그를 확인하세요.",
"loc.messages.CleanTargetFolder": "원격 컴퓨터에서 대상 폴더 %s을(를) 정리하는 중",
"loc.messages.CleanTargetFolderFailed": "원격 컴퓨터에서 대상 폴더를 정리하지 못했습니다. %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "Если в исходной папке отсутствуют соответствующие файлы для копирования, операция завершится сбоем.",
"loc.input.label.flattenFolders": "Выполнить сведение папок",
"loc.input.help.flattenFolders": "Выполнение сведения структуры папок и копирование всех файлов в указанную целевую папку на удаленном компьютере.",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "Проверьте наличие в журнале сборки сообщений из потока STDERR от команды.",
"loc.messages.CleanTargetFolder": "Очистка целевой папки %s на удаленном компьютере",
"loc.messages.CleanTargetFolderFailed": "Не удалось очистить целевую папку на удаленном компьютере. %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "如果在源文件夹下找不到要复制的匹配文件,则失败。",
"loc.input.label.flattenFolders": "精简文件夹",
"loc.input.help.flattenFolders": "精简文件夹结构,并将所有文件复制到远程计算机上的指定目标文件夹。",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "从命令检查 STDERR 生成日志。",
"loc.messages.CleanTargetFolder": "正在清理远程计算机上的目标文件夹 %s",
"loc.messages.CleanTargetFolderFailed": "未能清理远程计算机上的目标文件夹。%s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"loc.input.help.failOnEmptySource": "若在來源資料夾中找不到要複製的檔案,作業便會失敗。",
"loc.input.label.flattenFolders": "壓平合併資料夾",
"loc.input.help.flattenFolders": "壓平合併資料夾結構,並將所有檔案複製到遠端電腦上指定的目標資料夾中。",
"loc.input.label.readyTimeout": "SSH handshake timeout",
"loc.input.help.readyTimeout": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"loc.messages.CheckLogForStdErr": "請查看建置記錄中的命令有無 STDERR。",
"loc.messages.CleanTargetFolder": "清理遠端電腦上的目標資料夾 %s",
"loc.messages.CleanTargetFolderFailed": "無法清理遠端電腦上的目標資料夾。%s",
Expand Down
17 changes: 14 additions & 3 deletions Tasks/CopyFilesOverSSHV0/copyfilesoverssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ async function run() {
port = '22';
}

const readyTimeout = getReadyTimeoutVariable();

// set up the SSH connection configuration based on endpoint details
let sshConfig;
if (privateKey) {
Expand All @@ -124,7 +126,8 @@ async function run() {
port: port,
username: username,
privateKey: privateKey,
passphrase: password
passphrase: password,
readyTimeout: readyTimeout
}
} else {
// use password
Expand All @@ -133,7 +136,8 @@ async function run() {
host: hostname,
port: port,
username: username,
password: password
password: password,
readyTimeout: readyTimeout
}
}

Expand Down Expand Up @@ -232,4 +236,11 @@ async function run() {
}
}

run();
run();

function getReadyTimeoutVariable(): number {
let readyTimeoutString: string = tl.getInput('readyTimeout', true);
const readyTimeout: number = parseInt(readyTimeoutString, 10);

return readyTimeout;
}
13 changes: 13 additions & 0 deletions Tasks/CopyFilesOverSSHV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@
"helpMarkDown": "Delete all existing files and subfolders in the target folder before copying.",
"groupName": "advanced"
},
{
"name": "readyTimeout",
"type": "string",
"label": "SSH handshake timeout",
"defaultValue": "20000",
"required": true,
"groupName": "advanced",
"helpMarkDown": "How long (in milliseconds) to wait for the SSH handshake to complete.",
"validation": {
"expression": "isMatch(value, '(^\\d*$)','Multiline')",
"message": "Enter a valid value for timeout."
}
},
{
"name": "overwrite",
"type": "boolean",
Expand Down
13 changes: 13 additions & 0 deletions Tasks/CopyFilesOverSSHV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@
"helpMarkDown": "ms-resource:loc.input.help.cleanTargetFolder",
"groupName": "advanced"
},
{
"name": "readyTimeout",
"type": "string",
"label": "ms-resource:loc.input.label.readyTimeout",
"defaultValue": "20000",
"required": true,
"groupName": "advanced",
"helpMarkDown": "ms-resource:loc.input.help.readyTimeout",
"validation": {
"expression": "isMatch(value, '(^\\d*$)','Multiline')",
"message": "Enter a valid value for timeout."
}
},
{
"name": "overwrite",
"type": "boolean",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/CopyFilesOverSSHV0/typings/globals/node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ declare module "tls" {
* Initiate TLS renegotiation process.
*
* NOTE: Can be used to request peer's certificate after the secure connection has been established.
* ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
* ANOTHER NOTE: When running as the server, socket will be destroyed with an error after readyTimeout timeout.
* @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized,
* requestCert (See tls.createServer() for details).
* @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation
Expand Down Expand Up @@ -2456,7 +2456,7 @@ declare module "tls" {
SNICallback?: (servername: string, cb: (err: Error, ctx: SecureContext) => any) => any;
ecdhCurve?: string;
dhparam?: string | Buffer;
handshakeTimeout?: number;
readyTimeout?: number;
ALPNProtocols?: string[] | Buffer;
sessionTimeout?: number;
ticketKeys?: any;
Expand Down

0 comments on commit 150d937

Please sign in to comment.