forked from azpanel/azpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
143 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace app\controller; | ||
|
||
use GuzzleHttp\Client; | ||
|
||
class ProxyController extends UserBase | ||
{ | ||
public function test() | ||
{ | ||
$addr = input('socks5_address/s'); | ||
$port = input('socks5_port/d'); | ||
|
||
try { | ||
if ($addr === '' || $port === '' || $port < 1 || $port > 65535) { | ||
throw new \Exception("代理服务器参数不正确"); | ||
} | ||
$client = new Client([ | ||
'proxy' => "socks5://{$addr}:{$port}", | ||
'timeout' => 5, | ||
]); | ||
$response = $client->request('GET', 'https://myip.ipip.net'); | ||
$statusCode = (int) $response->getStatusCode(); | ||
|
||
return json([ | ||
'status' => $statusCode !== 204 ? true : false, | ||
'msg' => $response->getBody()->getContents(), | ||
]); | ||
} catch (\Exception $e) { | ||
return json([ | ||
'status' => false, | ||
'msg' => $e->getMessage(), | ||
]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters