@@ -23,12 +23,19 @@ class CreateTunnel
23
23
24
24
public function __construct ()
25
25
{
26
+
26
27
$ this ->ncCommand = sprintf ('%s -z %s %d > /dev/null 2>&1 ' ,
27
28
config ('tunneler.nc_path ' ),
28
29
config ('tunneler.local_address ' ),
29
30
config ('tunneler.local_port ' )
30
31
);
31
32
33
+ $ this ->bashCommand = sprintf ('timeout 1 %s -c \'cat < /dev/null > /dev/tcp/%s/%d \' > /dev/null 2>&1 ' ,
34
+ config ('tunneler.bash_path ' ),
35
+ config ('tunneler.local_address ' ),
36
+ config ('tunneler.local_port ' )
37
+ );
38
+
32
39
$ this ->sshCommand = sprintf ('%s %s %s -N -i %s -L %d:%s:%d -p %d %s@%s ' ,
33
40
config ('tunneler.ssh_path ' ),
34
41
config ('tunneler.ssh_options ' ),
@@ -46,13 +53,13 @@ public function __construct()
46
53
47
54
public function handle (): int
48
55
{
49
- if ($ this ->verifyTunnel ()){
56
+ if ($ this ->verifyTunnel ()) {
50
57
return 1 ;
51
58
}
52
59
53
60
$ this ->createTunnel ();
54
61
55
- if ($ this ->verifyTunnel ()){
62
+ if ($ this ->verifyTunnel ()) {
56
63
return 2 ;
57
64
}
58
65
@@ -81,6 +88,10 @@ protected function createTunnel()
81
88
*/
82
89
protected function verifyTunnel ()
83
90
{
91
+ if (config ('tunneler.verify_process ' ) == 'bash ' ) {
92
+ return $ this ->runCommand ($ this ->bashCommand );
93
+ }
94
+
84
95
return $ this ->runCommand ($ this ->ncCommand );
85
96
}
86
97
0 commit comments