File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ $connection = (new SSHConnection())
2424 ->as('demo')
2525 ->withPassword('password')
2626 // ->withPrivateKey($privateKeyPath)
27+ // ->timeout(0)
2728 ->connect();
2829
2930$command = $connection->run('echo "Hello world!"');
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class SSHConnection
1818 private $ username ;
1919 private $ password ;
2020 private $ privateKeyPath ;
21+ private $ timeout ;
2122 private $ connected = false ;
2223 private $ ssh ;
2324
@@ -51,6 +52,12 @@ public function withPrivateKey(string $privateKeyPath): self
5152 return $ this ;
5253 }
5354
55+ public function timeout (int $ timeout ): self
56+ {
57+ $ this ->timeout = $ timeout ;
58+ return $ this ;
59+ }
60+
5461 private function sanityCheck ()
5562 {
5663 if (!$ this ->hostname ) {
@@ -92,6 +99,10 @@ public function connect(): self
9299 }
93100 }
94101
102+ if ($ this ->timeout ) {
103+ $ this ->ssh ->setTimeout ($ this ->timeout );
104+ }
105+
95106 $ this ->connected = true ;
96107
97108 return $ this ;
You can’t perform that action at this time.
0 commit comments