mirror of https://github.com/dnomd343/tgbot
Dnomd343
3 years ago
17 changed files with 866 additions and 777 deletions
@ -0,0 +1,37 @@ |
|||
<?php |
|||
|
|||
class Curl { // Curl模拟http请求 |
|||
public $ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67'; |
|||
|
|||
public function get($url, $timeOut = 30) { // curl模拟Get 默认30s超时 |
|||
return $this->run(array( |
|||
[CURLOPT_URL, $url], |
|||
[CURLOPT_RETURNTRANSFER, 1], |
|||
[CURLOPT_CONNECTTIMEOUT, $timeOut], |
|||
[CURLOPT_USERAGENT, $this->ua] |
|||
)); |
|||
} |
|||
|
|||
public function post($url, $data, $timeOut = 30) { // curl模拟Post 默认30s超时 |
|||
return $this->run(array( |
|||
[CURLOPT_URL, $url], |
|||
[CURLOPT_RETURNTRANSFER, 1], |
|||
[CURLOPT_CONNECTTIMEOUT, $timeOut], |
|||
[CURLOPT_USERAGENT, $this->ua], |
|||
[CURLOPT_POST, 1], |
|||
[CURLOPT_POSTFIELDS, $data] |
|||
)); |
|||
} |
|||
|
|||
private function run($configs) { // 发起curl请求 |
|||
$curl = curl_init(); |
|||
foreach ($configs as $config) { |
|||
curl_setopt($curl, $config[0], $config[1]); |
|||
} |
|||
$content = curl_exec($curl); |
|||
curl_close($curl); |
|||
return $content; |
|||
} |
|||
} |
|||
|
|||
?> |
@ -0,0 +1,72 @@ |
|||
<?php |
|||
|
|||
class DNS { // DNS解析功能 |
|||
public function resolveA($domain) { // DNS解析A记录 |
|||
$ipAddr = array(); |
|||
$rs = dns_get_record(strtolower($domain), DNS_A); |
|||
foreach ($rs as $record) { |
|||
$ipAddr[] = ip2long($record['ip']); |
|||
} |
|||
sort($ipAddr); // 解析结果排序 |
|||
foreach ($ipAddr as &$ip) { |
|||
$ip = long2ip($ip); |
|||
} |
|||
return $ipAddr; |
|||
} |
|||
|
|||
public function resolveAAAA($domain) { // DNS解析AAAA记录 |
|||
$ipAddr = array(); |
|||
$rs = dns_get_record(strtolower($domain), DNS_AAAA); |
|||
foreach ($rs as $record) { |
|||
$ipAddr[] = $this->ip2long6($record['ipv6']); |
|||
} |
|||
sort($ipAddr); // 解析结果排序 |
|||
foreach ($ipAddr as &$ip) { |
|||
$ip = $this->long2ip6($ip); |
|||
} |
|||
return $ipAddr; |
|||
} |
|||
|
|||
public function resolveIP($domain) { // DNS解析IP记录 A/AAAA |
|||
$ipAddr = array(); |
|||
$ipv4 = $this->resolveA($domain); |
|||
foreach ($ipv4 as $ip) { |
|||
$ipAddr[] = $ip; |
|||
} |
|||
$ipv6 = $this->resolveAAAA($domain); |
|||
foreach ($ipv6 as $ip) { |
|||
$ipAddr[] = $ip; |
|||
} |
|||
return $ipAddr; |
|||
} |
|||
|
|||
public function ip2long6($ipv6) { // 压缩IPv6地址为long |
|||
$ip_n = inet_pton($ipv6); |
|||
$bits = 15; |
|||
while ($bits >= 0) { |
|||
$bin = sprintf("%08b", (ord($ip_n[$bits]))); |
|||
$ipv6long = $bin.$ipv6long; |
|||
$bits--; |
|||
} |
|||
return gmp_strval(gmp_init($ipv6long, 2), 10); |
|||
} |
|||
|
|||
public function long2ip6($ipv6long) { // 解压long为IPv6地址 |
|||
$bin = gmp_strval(gmp_init($ipv6long, 10), 2); |
|||
if (strlen($bin) < 128) { |
|||
$pad = 128 - strlen($bin); |
|||
for ($i = 1; $i <= $pad; $i++) { |
|||
$bin = '0' . $bin; |
|||
} |
|||
} |
|||
$bits = 0; |
|||
while ($bits <= 7) { |
|||
$bin_part = substr($bin, ($bits * 16), 16); |
|||
$ipv6 .= dechex(bindec($bin_part)) . ':'; |
|||
$bits++; |
|||
} |
|||
return inet_ntop(inet_pton(substr($ipv6, 0, -1))); |
|||
} |
|||
} |
|||
|
|||
?> |
@ -0,0 +1,47 @@ |
|||
<?php |
|||
|
|||
class DNSSEC { |
|||
public function algorithmDesc($id) { // 获取算法类型 |
|||
switch ($id) { |
|||
case '1': |
|||
return 'RSA/MD5'; |
|||
case '3': |
|||
return 'DSA/SHA1'; |
|||
case '5': |
|||
return 'RSA/SHA-1'; |
|||
case '6': |
|||
return 'DSA-NSEC3-SHA1'; |
|||
case '7': |
|||
return 'RSASHA1-NSEC3-SHA1'; |
|||
case '8': |
|||
return 'RSA/SHA-256'; |
|||
case '10': |
|||
return 'RSA/SHA-512'; |
|||
case '12': |
|||
return 'GOST R 34.10-2001'; |
|||
case '13': |
|||
return 'ECDSA Curve P-256 with SHA-256'; |
|||
case '14': |
|||
return 'ECDSA Curve P-384 with SHA-384'; |
|||
case '15': |
|||
return 'Ed25519'; |
|||
case '16': |
|||
return 'Ed448'; |
|||
} |
|||
} |
|||
|
|||
public function digestDesc($id) { // 获取摘要类型 |
|||
switch ($id) { |
|||
case '1': |
|||
return 'SHA-1'; |
|||
case '2': |
|||
return 'SHA-256'; |
|||
case '3': |
|||
return 'GOST R 34.11-94'; |
|||
case '4': |
|||
return 'SHA-384'; |
|||
} |
|||
} |
|||
} |
|||
|
|||
?> |
Loading…
Reference in new issue