File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ $connection = (new SSHConnection())
24
24
->as('demo')
25
25
->withPassword('password')
26
26
// ->withPrivateKey($privateKeyPath)
27
+ // ->timeout(0)
27
28
->connect();
28
29
29
30
$command = $connection->run('echo "Hello world!"');
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class SSHConnection
18
18
private $ username ;
19
19
private $ password ;
20
20
private $ privateKeyPath ;
21
+ private $ timeout ;
21
22
private $ connected = false ;
22
23
private $ ssh ;
23
24
@@ -51,6 +52,12 @@ public function withPrivateKey(string $privateKeyPath): self
51
52
return $ this ;
52
53
}
53
54
55
+ public function timeout (int $ timeout ): self
56
+ {
57
+ $ this ->timeout = $ timeout ;
58
+ return $ this ;
59
+ }
60
+
54
61
private function sanityCheck ()
55
62
{
56
63
if (!$ this ->hostname ) {
@@ -92,6 +99,10 @@ public function connect(): self
92
99
}
93
100
}
94
101
102
+ if ($ this ->timeout ) {
103
+ $ this ->ssh ->setTimeout ($ this ->timeout );
104
+ }
105
+
95
106
$ this ->connected = true ;
96
107
97
108
return $ this ;
You can’t perform that action at this time.
0 commit comments