This commit is contained in:
MasonLiu 2025-01-08 13:54:01 +08:00
parent 5f80ee78cf
commit c6e4e837ec
4 changed files with 83 additions and 1 deletions

46
IP-test.php Normal file
View File

@ -0,0 +1,46 @@
<?php
function getRealIP() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
// 检查是否通过了HTTP客户端IP
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
// 检查是否通过了代理服务器
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
// 如果包含多个IP地址取第一个
if (strpos($ip, ',') !== false) {
$ip = explode(',', $ip)[0];
}
} elseif (!empty($_SERVER['HTTP_X_REAL_IP'])) {
// 检查是否通过了真实的IP地址
$ip = $_SERVER['HTTP_X_REAL_IP'];
} else {
// 如果没有通过代理服务器,直接获取远程地址
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
$remote_addr = $_SERVER['REMOTE_ADDR'];
$forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $remote_addr;
$real_ip = $_SERVER['HTTP_X_REAL_IP'] ?? $remote_addr;
// 如果X-Forwarded-For包含多个IP地址取第一个
if (strpos($forwarded_for, ',') !== false) {
$forwarded_for = explode(',', $forwarded_for)[0];
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IP地址测试接口</title>
</head>
<body>
<h4>IP地址: <?php echo htmlspecialchars($remote_addr); ?></h4>
<h4>X-Forwarded-For: <?php echo htmlspecialchars($forwarded_for); ?></h4>
<h4>X-Real-IP: <?php echo htmlspecialchars($real_ip); ?></h4>
</body>
</html>

30
IP-test.py Normal file
View File

@ -0,0 +1,30 @@
from flask import Flask, request, render_template_string
app = Flask(__name__)
@app.route('/')
def index():
remote_addr = request.remote_addr
Forwarded_For = request.headers.get('X-Forwarded-For', request.remote_addr)
Real_IP = request.headers.get('X-Real-IP', request.remote_addr)
# 如果X-Forwarded-For包含多个IP地址取第一个
if Forwarded_For and ',' in Forwarded_For:
Forwarded_For = Forwarded_For.split(',')[0].strip()
return render_template_string('''
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IP地址测试接口</title>
</head>
<body>
<h4>IP地址: {{ remote_addr }}</h4>
<h4>X-Forwarded-For: {{ Forwarded_For }}</h4>
<h4>X-Real-IP: {{ Real_IP }}</h4>
</body>
</html>
''', remote_addr=remote_addr, Forwarded_For=Forwarded_For, Real_IP=Real_IP)
if __name__ == '__main__':
app.run(debug=True, port=7193) # 指定端口号为8080

View File

@ -1,9 +1,14 @@
### 开发计划 ### 开发计划
#### 使用代理池https://uu-proxy.com/pricing #### 使用代理池https://uu-proxy.com/pricing
#### API测试接口https://test.masonliu.com/api/IP-test.php
#### 模块分离: #### 模块分离:
- 获取模块使用商家给出的api接口获取代理源 - 获取模块使用商家给出的api接口获取代理源
- 检查模块:监测代理源中的个代理接口是否存活 - 检查模块:监测代理源中的个代理接口是否存活
实现:
通过先行代理询问API测试接口是否代理成功或是可运行若正常则进入代理模块若失败则选取下一个代理链接进行测试。
- 轮转代理模块:启动代理程序,将存活代理接口启动对应代理 - 轮转代理模块:启动代理程序,将存活代理接口启动对应代理
实现:
通过循环设置不断地更新代理接口
- 循环模块:定时循环以上进程 - 循环模块:定时循环以上进程
- 配置模块设定轮转间隔api接口等等配置 - 配置模块设定轮转间隔api接口等等配置
#### 预计使用方法: #### 预计使用方法:

View File

@ -1,2 +1,3 @@
PySocks PySocks
requests requests
flask