Auth.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* 认证请求
* @author:dc
* @time 2025/3/31 11:20
* Class Auth
*/
class Auth {
private $data;
public function __construct(string $data)
{
$this->data = $data;
$this->check();
}
public $tag; // tag
public $sign; // 签名
public $rang; // 随机串
public $out_ip; // 代理出口ip
public $host; // 请求地址
public $timeOut; // 超时
private function check(){
list($this->tag, $this->sign ,$this->rang, $this->out_ip ,$this->host, $this->timeOut) = explode(' ', $this->data.' ');
// 来源不对,直接关闭
if ($this->sign !== md5('fob.'.$this->rang)){
$this->error('签名验证失败');
}
// 没有出口ip
// if(!$this->out_ip){
// $this->error('出口ip不可空');
// }
// 没有代理地址
if(!$this->host){
$this->error('代理地址不可空');
}
$this->timeOut = intval($this->timeOut);
$this->timeOut = $this->timeOut ? $this->timeOut : 5;
}
public function error($msg){
throw new Exception("500 ".$msg."\r\n");
}
}