Skip to content

Commit

Permalink
Improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjackyliang committed Oct 4, 2017
1 parent 7669b8b commit 3e0156d
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions transmissionVPN/portforward.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?php /* Port Forwarding Check for transmissionVPN
------------------------------------------------------- */

$host = $argv[1];
$port = $argv[2];

$connection = @fsockopen($host, $port, $errno, $errstr, 10);

if(is_resource($connection)) {
echo 'open' . "\n";
fclose($connection);
} elseif(empty($port)) {
echo 'empty' . "\n";
} else {
echo 'closed' . "\n";
}
<?php
/**
* Port forwarding check.
*
* @since 1.0.0
*/
$host = $argv[1];
$port = $argv[2];

$connection = @fsockopen( $host, $port, $errno, $errstr, 10 );

if ( is_resource( $connection ) ) {
echo 'open' . "\n";
fclose( $connection );
} elseif ( empty( $port ) ) {
echo 'empty' . "\n";
} else {
echo 'closed' . "\n";
}

0 comments on commit 3e0156d

Please sign in to comment.