Skip to content

Commit 9a75ae9

Browse files
authored
Merge pull request #18 from Ap3rtur3/master
Added env variable to increase the amount of connection checks
2 parents a8f79d0 + ee2c038 commit 9a75ae9

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ TUNNELER_PORT=sshport
7777
; Depending on your network speeds you will want to modify the default of .5 seconds
7878
TUNNELER_CONN_WAIT=500000
7979

80+
; How often it is checked if the tunnel is created. Useful if the tunnel creation is sometimes slow,
81+
; and you want to minimize waiting times
82+
TUNNELER_CONN_TRIES=1
83+
8084
; Do you want to ensure you have the Tunnel in place for each bootstrap of the framework?
8185
TUNNELER_ON_BOOT=false
8286

config/tunneler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'hostname' => env('TUNNELER_HOSTNAME'),
2020
'port' => env('TUNNELER_PORT'),
2121
'wait' => env('TUNNELER_CONN_WAIT', '500000'),
22+
'tries' => env('TUNNELER_CONN_TRIES', 1),
2223

2324
'on_boot' => filter_var(env('TUNNELER_ON_BOOT', false), FILTER_VALIDATE_BOOLEAN),
2425
'ssh_verbosity' => env('SSH_VERBOSITY',''),

src/Jobs/CreateTunnel.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,15 @@ public function handle(): int
5858
}
5959

6060
$this->createTunnel();
61-
62-
if ($this->verifyTunnel()) {
63-
return 2;
61+
62+
$tries = config('tunneler.tries');
63+
for ($i = 0; $i < $tries; $i++) {
64+
if ($this->verifyTunnel()) {
65+
return 2;
66+
}
67+
68+
// Wait a bit until next iteration
69+
usleep(config('tunneler.wait'));
6470
}
6571

6672
throw new \ErrorException(sprintf("Could Not Create SSH Tunnel with command:\n\t%s\nCheck your configuration.",

0 commit comments

Comments
 (0)