Integração Pangolin Proxy
This commit is contained in:
@@ -82,4 +82,30 @@ class ASNService
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getPrefixes($asn)
|
||||
{
|
||||
$asn = ltrim(strtoupper($asn), 'AS');
|
||||
$url = "https://stat.ripe.net/data/announced-prefixes/data.json?resource=AS" . $asn;
|
||||
|
||||
$context = stream_context_create(['http' => ['timeout' => 5]]);
|
||||
$response = @file_get_contents($url, false, $context);
|
||||
|
||||
if ($response === FALSE) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = json_decode($response, true);
|
||||
$prefixes = [];
|
||||
|
||||
if (isset($data['status']) && $data['status'] === 'ok' && isset($data['data']['prefixes'])) {
|
||||
foreach ($data['data']['prefixes'] as $item) {
|
||||
if (isset($item['prefix'])) {
|
||||
$prefixes[] = $item['prefix'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($prefixes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user