Add files via upload
This commit is contained in:
parent
17aa0502db
commit
60cb088ed1
16
web/api.php
Normal file
16
web/api.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
|
||||
include 'monitor.php';
|
||||
|
||||
$post = file_get_contents('php://input');
|
||||
$param = json_decode($post, true);
|
||||
$result = [];
|
||||
if($param && count($param)>0){
|
||||
foreach($param as $target){
|
||||
$result[] = node_monitor_local('1', $target);
|
||||
}
|
||||
}
|
||||
$data = ['msg'=>$result];
|
||||
echo json_encode($data);
|
22
web/config.php
Normal file
22
web/config.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 多节点监控配置文件
|
||||
* 节点分为国内组和国外组,可分别设置
|
||||
* 组内节点数最好不要多余5个,否则可能会超时
|
||||
* 远程节点只需要上传当前目录的 api.php、monitor.php 文件
|
||||
*/
|
||||
|
||||
$monitor_config = [
|
||||
//国内组
|
||||
'group_1' => [
|
||||
['node_id'=>'1', 'type'=>'local'], //本地节点
|
||||
// ['node_id'=>'2', 'type'=>'remote', 'api'=>'http://www.example.com/api.php'], //远程节点,需填写监控接口地址
|
||||
],
|
||||
|
||||
//国外组
|
||||
'group_2' => [
|
||||
['node_id'=>'1', 'type'=>'local'], //本地节点
|
||||
// ['node_id'=>'2', 'type'=>'remote', 'api'=>'http://www.example.com/api.php'], //远程节点,需填写监控接口地址
|
||||
],
|
||||
];
|
91
web/index.php
Normal file
91
web/index.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
date_default_timezone_set("PRC");
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
define('AES_KEY','L6DYHZ3NEb2QUL6D');
|
||||
define('AES_KEY2','kQ3vaLGnZ8sgyd5T');
|
||||
define('KEY_APPEND', 'rbkgp46j53');
|
||||
|
||||
if (function_exists("set_time_limit"))
|
||||
{
|
||||
@set_time_limit(0);
|
||||
}
|
||||
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
if(strpos($url, '/common/timestamp2') !== false && $method=='POST'){
|
||||
$param = parse_input2();
|
||||
$data = ['now'=>time(), 'rnd'=>$param['rnd']];
|
||||
echo generate_output2($data);
|
||||
}
|
||||
elseif(strpos($url, '/auth2') !== false && $method=='POST'){
|
||||
$param = parse_input2();
|
||||
$data = ['nodes'=>99999, 'machine_code'=>$param['machine_code'], 'end_at'=>time()+3600*24*100*3650];
|
||||
echo generate_output2($data);
|
||||
}
|
||||
elseif(strpos($url, '/common/timestamp') !== false && $method=='POST'){
|
||||
$param = parse_input();
|
||||
$data = ['now'=>time(), 'rnd'=>$param['rnd']];
|
||||
echo generate_output($data);
|
||||
}
|
||||
elseif(strpos($url, '/auth') !== false && $method=='POST'){
|
||||
$param = parse_input();
|
||||
$data = ['nodes'=>99999, 'machine_code'=>$param['machine_code'], 'end_at'=>time()+3600*24*100*365];
|
||||
echo generate_output($data);
|
||||
}
|
||||
elseif(strpos($url, '/check') !== false && $method=='POST'){
|
||||
require 'config.php';
|
||||
require 'monitor.php';
|
||||
$post = file_get_contents('php://input');
|
||||
$param = json_decode($post, true);
|
||||
$result = node_monitor_all($param);
|
||||
$data = ['msg'=>$result];
|
||||
echo json_encode($data);
|
||||
}
|
||||
elseif(strpos($url, '/common/datetime') !== false && $method=='GET'){
|
||||
return date('Y-m-d H:i:s');
|
||||
}
|
||||
elseif(strpos($url, '/master/upgrades') !== false){
|
||||
$version_data = file_get_contents('version.json');
|
||||
if(!$version_data) exit(json_encode(['code'=>-1, 'data'=>[], 'ip'=>$_SERVER['REMOTE_ADDR'], 'msg'=>'版本信息文件不存在']));
|
||||
$version_info = json_decode($version_data, true);
|
||||
if(!$version_info) exit(json_encode(['code'=>-1, 'data'=>[], 'ip'=>$_SERVER['REMOTE_ADDR'], 'msg'=>'解析版本信息文件失败']));
|
||||
$data = ['code'=>0, 'count'=>1, 'data'=>[$version_info], 'ip'=>$_SERVER['REMOTE_ADDR']];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
|
||||
function parse_input2(){
|
||||
$post = file_get_contents('php://input');
|
||||
$de_text = text_decrypt($post, get_aes_key());
|
||||
$param = json_decode($de_text, true);
|
||||
return $param;
|
||||
}
|
||||
function generate_output2($data){
|
||||
$json = json_encode($data);
|
||||
$cipher = text_encrypt($json, get_aes_key());
|
||||
$data = ['code'=>0, 'data'=>$cipher, 'msg'=>''];
|
||||
return json_encode($data);
|
||||
}
|
||||
function get_aes_key(){
|
||||
$key = trim($_GET['key']);
|
||||
$aes_key = substr(md5($key.KEY_APPEND), 0, 16);
|
||||
return $aes_key;
|
||||
}
|
||||
function parse_input(){
|
||||
$post = file_get_contents('php://input');
|
||||
$param = json_decode(text_decrypt($post, AES_KEY), true);
|
||||
return $param;
|
||||
}
|
||||
function generate_output($data){
|
||||
$cipher = text_encrypt(json_encode($data), AES_KEY);
|
||||
$data = ['code'=>0, 'data'=>$cipher, 'msg'=>''];
|
||||
return json_encode($data);
|
||||
}
|
||||
function text_encrypt($data, $key){
|
||||
return openssl_encrypt($data, 'aes-128-cbc', $key, 0, $key);
|
||||
}
|
||||
function text_decrypt($data, $key){
|
||||
return openssl_decrypt($data, 'aes-128-cbc', $key, 0, $key);
|
||||
}
|
249
web/master.sh
Normal file
249
web/master.sh
Normal file
@ -0,0 +1,249 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
#判断系统版本
|
||||
check_sys(){
|
||||
local checkType=$1
|
||||
local value=$2
|
||||
|
||||
local release=''
|
||||
local systemPackage=''
|
||||
local packageSupport=''
|
||||
|
||||
if [[ "$release" == "" ]] || [[ "$systemPackage" == "" ]] || [[ "$packageSupport" == "" ]];then
|
||||
|
||||
if [[ -f /etc/redhat-release ]];then
|
||||
release="centos"
|
||||
systemPackage="yum"
|
||||
packageSupport=true
|
||||
|
||||
elif cat /etc/issue | grep -q -E -i "debian";then
|
||||
release="debian"
|
||||
systemPackage="apt"
|
||||
packageSupport=true
|
||||
|
||||
elif cat /etc/issue | grep -q -E -i "ubuntu";then
|
||||
release="ubuntu"
|
||||
systemPackage="apt"
|
||||
packageSupport=true
|
||||
|
||||
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat";then
|
||||
release="centos"
|
||||
systemPackage="yum"
|
||||
packageSupport=true
|
||||
|
||||
elif cat /proc/version | grep -q -E -i "debian";then
|
||||
release="debian"
|
||||
systemPackage="apt"
|
||||
packageSupport=true
|
||||
|
||||
elif cat /proc/version | grep -q -E -i "ubuntu";then
|
||||
release="ubuntu"
|
||||
systemPackage="apt"
|
||||
packageSupport=true
|
||||
|
||||
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat";then
|
||||
release="centos"
|
||||
systemPackage="yum"
|
||||
packageSupport=true
|
||||
|
||||
else
|
||||
release="other"
|
||||
systemPackage="other"
|
||||
packageSupport=false
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "release=$release\nsystemPackage=$systemPackage\npackageSupport=$packageSupport\n" > /tmp/ezhttp_sys_check_result
|
||||
|
||||
if [[ $checkType == "sysRelease" ]]; then
|
||||
if [ "$value" == "$release" ];then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
elif [[ $checkType == "packageManager" ]]; then
|
||||
if [ "$value" == "$systemPackage" ];then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
elif [[ $checkType == "packageSupport" ]]; then
|
||||
if $packageSupport;then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 安装依赖
|
||||
install_depend() {
|
||||
if check_sys sysRelease ubuntu;then
|
||||
apt-get update
|
||||
apt-get -y install wget python-minimal
|
||||
elif check_sys sysRelease centos;then
|
||||
yum install -y wget python
|
||||
fi
|
||||
}
|
||||
|
||||
get_sys_ver() {
|
||||
cat > /tmp/sys_ver.py <<EOF
|
||||
import platform
|
||||
import re
|
||||
|
||||
sys_ver = platform.platform()
|
||||
sys_ver = re.sub(r'.*-with-(.*)-.*',"\g<1>",sys_ver)
|
||||
if sys_ver.startswith("centos-7"):
|
||||
sys_ver = "centos-7"
|
||||
if sys_ver.startswith("centos-6"):
|
||||
sys_ver = "centos-6"
|
||||
print sys_ver
|
||||
EOF
|
||||
echo `python /tmp/sys_ver.py`
|
||||
}
|
||||
|
||||
download(){
|
||||
local url1=$1
|
||||
local url2=$2
|
||||
local filename=$3
|
||||
|
||||
# 检查文件是否存在
|
||||
# if [[ -f $filename ]]; then
|
||||
# echo "$filename 文件已经存在,忽略"
|
||||
# return
|
||||
# fi
|
||||
|
||||
speed1=`curl -m 5 -L -s -w '%{speed_download}' "$url1" -o /dev/null || true`
|
||||
speed1=${speed1%%.*}
|
||||
speed2=`curl -m 5 -L -s -w '%{speed_download}' "$url2" -o /dev/null || true`
|
||||
speed2=${speed2%%.*}
|
||||
echo "speed1:"$speed1
|
||||
echo "speed2:"$speed2
|
||||
url="$url1\n$url2"
|
||||
if [[ $speed2 -gt $speed1 ]]; then
|
||||
url="$url2\n$url1"
|
||||
fi
|
||||
echo -e $url | while read l;do
|
||||
echo "using url:"$l
|
||||
wget --dns-timeout=5 --connect-timeout=5 --read-timeout=10 --tries=2 "$l" -O $filename && break
|
||||
done
|
||||
|
||||
|
||||
}
|
||||
|
||||
sync_time(){
|
||||
echo "start to sync time and add sync command to cronjob..."
|
||||
|
||||
if check_sys sysRelease ubuntu || check_sys sysRelease debian;then
|
||||
apt-get -y update
|
||||
apt-get -y install ntpdate wget
|
||||
/usr/sbin/ntpdate -u pool.ntp.org || true
|
||||
! grep -q "/usr/sbin/ntpdate -u pool.ntp.org" /var/spool/cron/crontabs/root > /dev/null 2>&1 && echo '*/10 * * * * /usr/sbin/ntpdate -u pool.ntp.org > /dev/null 2>&1 || (date_str=`curl update.cdnfly.cn/common/datetime` && timedatectl set-ntp false && echo $date_str && timedatectl set-time "$date_str" )' >> /var/spool/cron/crontabs/root
|
||||
service cron restart
|
||||
elif check_sys sysRelease centos; then
|
||||
yum -y install ntpdate wget
|
||||
/usr/sbin/ntpdate -u pool.ntp.org || true
|
||||
! grep -q "/usr/sbin/ntpdate -u pool.ntp.org" /var/spool/cron/root > /dev/null 2>&1 && echo '*/10 * * * * /usr/sbin/ntpdate -u pool.ntp.org > /dev/null 2>&1 || (date_str=`curl update.cdnfly.cn/common/datetime` && timedatectl set-ntp false && echo $date_str && timedatectl set-time "$date_str" )' >> /var/spool/cron/root
|
||||
service crond restart
|
||||
fi
|
||||
|
||||
# 时区
|
||||
rm -f /etc/localtime
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
if /sbin/hwclock -w;then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
need_sys() {
|
||||
SYS_VER=`python -c "import platform;import re;sys_ver = platform.platform();sys_ver = re.sub(r'.*-with-(.*)-.*','\g<1>',sys_ver);print sys_ver;"`
|
||||
if [[ $SYS_VER =~ "Ubuntu-16.04" ]];then
|
||||
echo "$sys_ver"
|
||||
elif [[ $SYS_VER =~ "centos-7" ]]; then
|
||||
SYS_VER="centos-7"
|
||||
echo $SYS_VER
|
||||
else
|
||||
echo "目前只支持ubuntu-16.04和Centos-7"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_depend
|
||||
need_sys
|
||||
sync_time
|
||||
|
||||
# 解析命令行参数
|
||||
TEMP=`getopt -o h --long help,ver:,no-mysql,only-mysql,no-es,only-es,master-ip:,es-ip:,es-dir:,es-pwd:,mysql-ip:,ignore-ntp -- "$@"`
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
eval set -- "$TEMP"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-h|--help) help ; exit 1 ;;
|
||||
--ver) VER=$2 ; shift 2 ;;
|
||||
--) shift ; break ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $VER == "" ]]; then
|
||||
# 获取最新版本
|
||||
echo "获取最新版..."
|
||||
latest_version=`curl -s 'http://auth.fikkey.com/master/upgrades?latest=1' | grep -Po 'v\d+\.\d+.\d+' || true`
|
||||
if [[ "$latest_version" == "" ]]; then
|
||||
echo "获取最新版失败,请先登录官网填入主控IP"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "最新版本为$latest_version"
|
||||
dir_name="cdnfly-master-$latest_version"
|
||||
tar_gz_name="$dir_name-$(get_sys_ver).tar.gz"
|
||||
|
||||
else
|
||||
# 安装指定版本
|
||||
if [[ ! `echo "$VER" | grep -P "^v\d+\.\d+\.\d+$"` ]]; then
|
||||
echo "指定的版本格式不正确,应该类似为v4.0.1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dir_name="cdnfly-master-$VER"
|
||||
tar_gz_name="$dir_name-$(get_sys_ver).tar.gz"
|
||||
echo "安装指定版本$VER"
|
||||
fi
|
||||
|
||||
cd /opt/
|
||||
download "https://github.com/LoveesYe/cdnflydadao/raw/main/master/$tar_gz_name" "https://github.com/LoveesYe/cdnflydadao/raw/main/master/$tar_gz_name" "$tar_gz_name"
|
||||
|
||||
tar xf $tar_gz_name
|
||||
rm -rf cdnfly
|
||||
mv $dir_name cdnfly
|
||||
|
||||
# 开始安装
|
||||
cd /opt/cdnfly/master
|
||||
sed -i "s/https:\/\/dl2.cdnfly.cn\//http:\/\/auth.cdnfly.cn\//g" install.sh
|
||||
sed -i "s/https:\/\/us.centos.bz\//http:\/\/auth.cdnfly.cn\//g" install.sh
|
||||
sed -i "s/http:\/\/auth.cdnfly.cn\/cdnfly\/elasticsearch-7.6.1-x86_64.rpm/https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-7.6.1-x86_64.rpm/g" install.sh
|
||||
sed -i "s/http:\/\/auth.cdnfly.cn\/cdnfly\/elasticsearch-7.6.1-amd64.deb/https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-7.6.1-amd64.deb/g" install.sh
|
||||
chmod +x install.sh
|
||||
./install.sh $@
|
||||
|
||||
if [ -f /opt/cdnfly/master/view/upgrade.so ]; then
|
||||
wget https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/api.py -O /opt/venv/lib/python2.7/site-packages/requests/api.py
|
||||
supervisorctl -c /opt/cdnfly/master/conf/supervisord.conf reload
|
||||
|
||||
source /opt/venv/bin/activate
|
||||
cd /opt/cdnfly/master/view
|
||||
ret=`python -c "import util;print util.get_auth_code()" || true`
|
||||
[[ $ret == "(True, None)" ]] && echo "已获取到授权" || echo "未授权,请先购买"
|
||||
deactivate
|
||||
|
||||
echo "安装主控成功!"
|
||||
fi
|
||||
|
135
web/monitor.php
Normal file
135
web/monitor.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
//执行全部监控
|
||||
function node_monitor_all($targets){
|
||||
global $monitor_config;
|
||||
$result = [];
|
||||
$target_group_1 = [];
|
||||
$target_group_2 = [];
|
||||
foreach($targets as $target){
|
||||
if($target['node_group'] == '2') $target_group_2[] = $target;
|
||||
else $target_group_1[] = $target;
|
||||
}
|
||||
if(count($monitor_config['group_1']) > 0 && count($target_group_1) > 0){
|
||||
foreach($monitor_config['group_1'] as $node){
|
||||
if($node['type'] == 'local'){
|
||||
foreach($target_group_1 as $target){
|
||||
$result[] = node_monitor_local($node['node_id'], $target);
|
||||
}
|
||||
}elseif($node['type'] == 'remote'){
|
||||
$result = array_merge($result, node_monitor_remote($node['node_id'], $node['api'], $target_group_1));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count($monitor_config['group_2']) > 0 && count($target_group_2) > 0){
|
||||
foreach($monitor_config['group_2'] as $node){
|
||||
if($node['type'] == 'local'){
|
||||
foreach($target_group_2 as $target){
|
||||
$result[] = node_monitor_local($node['node_id'], $target);
|
||||
}
|
||||
}elseif($node['type'] == 'remote'){
|
||||
$result = array_merge($result, node_monitor_remote($node['node_id'], $node['api'], $target_group_2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//批量执行远程监控
|
||||
function node_monitor_remote($node_id, $apiurl, $targets){
|
||||
$json = json_encode($targets);
|
||||
$data = send_request($apiurl, $json);
|
||||
$arr = json_decode($data, true);
|
||||
if(!$arr || !isset($arr['msg'])) return [];
|
||||
$result = [];
|
||||
foreach($arr['msg'] as $target){
|
||||
$target['node_id'] = $node_id;
|
||||
$result[] = $target;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//单个执行本地监控
|
||||
function node_monitor_local($node_id, $target){
|
||||
$status = false;
|
||||
if($target['type'] == 'http'){
|
||||
$status = check_http($target['target'], $target['port'], $target['path'], $target['host'], $target['timeout']);
|
||||
}elseif($target['type'] == 'ping'){
|
||||
$status = check_ping($target['target'], $target['port'], $target['timeout']);
|
||||
}else{ //tcp
|
||||
$status = check_tcp($target['target'], $target['port'], $target['timeout']);
|
||||
}
|
||||
return ['node_id'=>$node_id, 'success'=>$status?1:0, 'target'=>$target['target']];
|
||||
}
|
||||
|
||||
function check_http($target, $port, $path, $host = '', $timeout = 3){
|
||||
if($timeout > 3) $timeout = 3;
|
||||
if(!$port) $port = 80;
|
||||
if(!$path) $path = '/';
|
||||
if($port == 80){
|
||||
$url = 'http://'.$target.$path;
|
||||
}else{
|
||||
$url = 'http://'.$target.':'.$port.$path;
|
||||
}
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
$httpheader[] = "Accept: */*";
|
||||
$httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
|
||||
$httpheader[] = "Connection: close";
|
||||
if(!empty($host)){
|
||||
$httpheader[] = "Host: ".$host;
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_exec($ch);
|
||||
$errno = curl_errno($ch);
|
||||
if($errno) {
|
||||
curl_close($ch);
|
||||
return false;
|
||||
}
|
||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if($httpcode>=200 && $httpcode<400){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_tcp($target, $port, $timeout = 3){
|
||||
if($timeout > 3) $timeout = 3;
|
||||
if(!$port) $port = 80;
|
||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
socket_set_nonblock($sock);
|
||||
socket_connect($sock, $target, $port);
|
||||
socket_set_block($sock);
|
||||
$status = socket_select($r = array($sock), $w = array($sock), $f = array($sock), $timeout);
|
||||
return $status === 1;
|
||||
}
|
||||
|
||||
function check_ping($target, $port, $timeout = 2){
|
||||
if(!function_exists('exec') || PHP_OS == 'WINNT') return check_tcp($target, $port, $timeout);
|
||||
if($timeout > 2) $timeout = 2;
|
||||
exec('ping -c 1 -w '.$timeout.' '.$target.' > /dev/null', $output, $return_var);
|
||||
if($return_var === 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function send_request($url, $json){
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json; charset=utf-8']);
|
||||
$ret = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $ret;
|
||||
}
|
5
web/nginx伪静态.txt
Normal file
5
web/nginx伪静态.txt
Normal file
@ -0,0 +1,5 @@
|
||||
location / {
|
||||
if (!-e $request_filename){
|
||||
rewrite ^(.*)$ /index.php/$1 last; break;
|
||||
}
|
||||
}
|
30
web/update.php
Normal file
30
web/update.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// 更新cdnfly最新版本信息
|
||||
|
||||
error_reporting(0);
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
$url = 'https://update.cdnfly.cn/master/upgrades?version_num=';
|
||||
$data = send_request($url);
|
||||
$arr = json_decode($data, true);
|
||||
if(!$arr)exit('获取cdnfly版本信息失败,json解析失败');
|
||||
if($arr['code']!=0 || !$arr['data'] || count($arr['data'])==0)exit('获取cdnfly版本信息失败:'.$data);
|
||||
|
||||
$info = $arr['data'][0];
|
||||
if(file_put_contents('version.json', json_encode($info))){
|
||||
exit('保存cdnfly版本信息成功!');
|
||||
}else{
|
||||
exit('保存cdnfly版本信息失败,可能无文件写入权限');
|
||||
}
|
||||
|
||||
|
||||
function send_request($url){
|
||||
$ch=curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
$res=curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $res;
|
||||
}
|
1
web/version.json
Normal file
1
web/version.json
Normal file
@ -0,0 +1 @@
|
||||
{"agent_ver":"50116","create_at":null,"create_at2":"2022-07-24 07:40:38","enable":1,"id":92,"is_test":0,"update_log":"1. \u4fee\u590dcloudflare dns\u65e0\u6cd5\u6dfb\u52a0\u8bb0\u5f55bug\n2. \u4fee\u590d\u65e0\u6cd5\u7b7e\u53d1\u8bc1\u4e66bug","url":"https:\/\/dl2.cdnfly.cn\/cdnfly\/upgrade_script\/master\/50113.sh","version_name":"v5.1.13","version_num":50113}
|
Loading…
Reference in New Issue
Block a user