@@ -23,12 +23,19 @@ class CreateTunnel
2323
2424    public  function  __construct ()
2525    {
26+ 
2627        $ this  ->ncCommand  = sprintf ('%s -z %s %d  > /dev/null 2>&1 ' ,
2728            config ('tunneler.nc_path ' ),
2829            config ('tunneler.local_address ' ),
2930            config ('tunneler.local_port ' )
3031        );
3132
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+ 
3239        $ this  ->sshCommand  = sprintf ('%s %s %s -N -i %s -L %d:%s:%d -p %d %s@%s ' ,
3340            config ('tunneler.ssh_path ' ),
3441            config ('tunneler.ssh_options ' ),
@@ -46,13 +53,13 @@ public function __construct()
4653
4754    public  function  handle (): int 
4855    {
49-         if  ($ this  ->verifyTunnel ()){
56+         if  ($ this  ->verifyTunnel ())  {
5057            return  1 ;
5158        }
5259
5360        $ this  ->createTunnel ();
5461
55-         if  ($ this  ->verifyTunnel ()){
62+         if  ($ this  ->verifyTunnel ())  {
5663            return  2 ;
5764        }
5865
@@ -81,6 +88,10 @@ protected function createTunnel()
8188     */ 
8289    protected  function  verifyTunnel ()
8390    {
91+         if  (config ('tunneler.verify_process ' ) == 'bash ' ) {
92+             return  $ this  ->runCommand ($ this  ->bashCommand );
93+         }
94+ 
8495        return  $ this  ->runCommand ($ this  ->ncCommand );
8596    }
8697
0 commit comments