Compare commits
64 Commits
CDN
...
CDN-MASTER
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fd9cd2dec | ||
|
|
acd7639885 | ||
|
|
32a5777239 | ||
|
|
33b7ac9d4c | ||
|
|
0a183d9486 | ||
|
|
6b26c4779e | ||
|
|
026bb06418 | ||
|
|
6b4676c3a9 | ||
|
|
86b66d24a1 | ||
|
|
f3e7894b06 | ||
|
|
bd60622d3f | ||
|
|
34df9361e2 | ||
|
|
88ccece4ad | ||
|
|
bdb5accac3 | ||
|
|
4917621adc | ||
|
|
8f73d81476 | ||
|
|
b9a0ecb5eb | ||
|
|
cfaab8b4d4 | ||
|
|
16ac1013cd | ||
|
|
fac8562816 | ||
|
|
05602192c5 | ||
|
|
2f34d73c54 | ||
|
|
dd176411f8 | ||
|
|
60cb088ed1 | ||
|
|
17aa0502db | ||
|
|
e94482887f | ||
|
|
9565b60a4b | ||
|
|
bee3f1a074 | ||
|
|
51aabdbe2d | ||
|
|
a9d2546380 | ||
|
|
c53bd85e25 | ||
|
|
cd4b032013 | ||
|
|
497aee9c02 | ||
|
|
2645c74ba3 | ||
|
|
7ffb9d136c | ||
|
|
31c4118e28 | ||
|
|
e09f7eb34b | ||
|
|
1870ad5d8e | ||
|
|
af8ce463b8 | ||
|
|
fa67d558f2 | ||
|
|
d5e3dcdc96 | ||
|
|
fa1332822c | ||
|
|
2439b3d9ad | ||
|
|
cffdb77fec | ||
|
|
67c53f540b | ||
|
|
c07063e72c | ||
|
|
a1da11c861 | ||
|
|
eafbdbb149 | ||
|
|
8baba22a8c | ||
|
|
cf9e5540bd | ||
|
|
16860c1c91 | ||
|
|
8a375712d2 | ||
|
|
2d85147fff | ||
|
|
c2aa4ebcaf | ||
|
|
c4823913b7 | ||
|
|
2c79d56afb | ||
|
|
3846659e74 | ||
|
|
0ce9da0c24 | ||
|
|
890016ca37 | ||
|
|
cdfc99260e | ||
|
|
5b8d2f9c5d | ||
|
|
6aa2b4339a | ||
|
|
51fbf2917d | ||
|
|
b14aa5dc6c |
52
README
52
README
@@ -1,3 +1,4 @@
|
|||||||
|
更新说明:更新v5.1.13版本主控
|
||||||
感谢大表哥提供主控和节点服务器特此广告:
|
感谢大表哥提供主控和节点服务器特此广告:
|
||||||
|
|
||||||
感谢OK源码中国网提供,(https://vsok.net) 精品资源源码请去OK源码中国下载
|
感谢OK源码中国网提供,(https://vsok.net) 精品资源源码请去OK源码中国下载
|
||||||
@@ -8,17 +9,64 @@
|
|||||||
web目录为验证文件,请自行搭建
|
web目录为验证文件,请自行搭建
|
||||||
0.0.0.0改成(自己搭建的验证服务器Ip)
|
0.0.0.0改成(自己搭建的验证服务器Ip)
|
||||||
vi /etc/hosts
|
vi /etc/hosts
|
||||||
0.0.0.0 auth.cdnfly.cn
|
0.0.0.0 auth.cdnfly.cn monitor.cdnfly.cn
|
||||||
0.0.0.0 auth.cdnfly.cn
|
0.0.0.0 auth.cdnfly.cn monitor.cdnfly.cn
|
||||||
2.主控
|
2.主控
|
||||||
|
v5.1.11版本安装脚本:
|
||||||
curl -fsSL https://github.com/LoveesYe/cdnflydadao/raw/main/master.sh -o master.sh && chmod +x master.sh && ./master.sh --es-dir /home/es
|
curl -fsSL https://github.com/LoveesYe/cdnflydadao/raw/main/master.sh -o master.sh && chmod +x master.sh && ./master.sh --es-dir /home/es
|
||||||
|
|
||||||
|
新v5.1.13版本安装脚本:
|
||||||
|
|
||||||
|
curl -fsSL https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/master/master.sh -o master.sh && chmod +x master.sh && ./master.sh --es-dir /home/es
|
||||||
|
|
||||||
3.被控
|
3.被控
|
||||||
|
v5.1.15版本安装脚本:
|
||||||
curl -fsSL -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/agent/agent.sh -o agent.sh || curl -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/agent/agent.sh -o agent.sh && chmod +x agent.sh && ./agent.sh --master-ver v5.1.11 --master-ip ip --es-ip ip --es-pwd passwd
|
curl -fsSL -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/agent/agent.sh -o agent.sh || curl -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/agent/agent.sh -o agent.sh && chmod +x agent.sh && ./agent.sh --master-ver v5.1.11 --master-ip ip --es-ip ip --es-pwd passwd
|
||||||
|
|
||||||
|
新v5.1.16版本安装脚本:
|
||||||
|
curl -fsSL -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/agent/agent.sh -o agent.sh || curl -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/agent/agent.sh -o agent.sh && chmod +x agent.sh && ./agent.sh --master-ver v5.1.11 --master-ip ip --es-ip ip --es-pwd passwd
|
||||||
|
|
||||||
|
4.
|
||||||
|
已安装过官方版的开心方法:
|
||||||
|
执行以下命令完成开心:
|
||||||
|
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
|
||||||
|
|
||||||
|
如果旧版本要升级,可以先更新自建云端的文件,然后执行“已安装过官方版的开心方法”这一部分的命令,最后在主控后台升级。
|
||||||
|
|
||||||
|
云端节点监控功能说明:
|
||||||
|
|
||||||
|
监控默认是使用云端服务器去请求CDN节点,因此要保持云端和CDN节点之间的网络畅通。另外如果是用宝塔面板,php不要安装bt_safe扩展,否则无法使用tcp类型监控;如果要用ping类型监控,还需要允许exec函数。
|
||||||
|
支持多节点监控(和官方一样),要添加其它监控节点,可以编辑config.php配置文件,根据里面的注释说明添加。
|
||||||
|
|
||||||
修改为你自身安装节点,或使用默认的github节点安装
|
修改为你自身安装节点,或使用默认的github节点安装
|
||||||
/opt/cdnfly/master/panel/src/views/system/update/index.html
|
/opt/cdnfly/master/panel/src/views/system/update/index.html
|
||||||
|
|
||||||
感谢OK源码中国网提供,(https://vsok.net) 精品资源源码请去OK源码中国下载
|
感谢OK源码中国网提供,(https://vsok.net) 精品资源源码请去OK源码中国下载
|
||||||
|
|
||||||
推荐服务器商;OVZH服务商,官网(https://ovzh.com) OVZH最近活动: https://reurl.cc/6Z1WWZ
|
推荐服务器商;OVZH服务商,官网(https://ovzh.com) OVZH最近活动: https://reurl.cc/6Z1WWZ
|
||||||
|
|
||||||
|
主控登录地址为: http://主控IP/
|
||||||
|
管理员账号和密码: admin/cdnfly
|
||||||
|
普通用户账号和密码: jason/cdnfly
|
||||||
|
|
||||||
|
服务器配置要求
|
||||||
|
|
||||||
|
主控
|
||||||
|
1.内存 - 因为主控安装有Elasticsearch,推荐16G及以上,如果网站访问量比较小,8G也行,至少4G。
|
||||||
|
2.硬盘 - 建议固态硬盘, 同样考虑访问日志大小,推荐100G及以上,量小的话都可以。
|
||||||
|
3.CPU - CPU至少2核
|
||||||
|
4.开放80 88 9200端口
|
||||||
|
节点
|
||||||
|
|
||||||
|
1.内存 - 至少2G及以上
|
||||||
|
2.硬盘 - 根据网站缓存的大小配置
|
||||||
|
3.CPU - Nginx主要是跑CPU,所以要想访问性能好,CPU尽量好点。
|
||||||
|
4.开放80 443 5000端口
|
||||||
|
系统
|
||||||
|
支持Centos-7---Ubuntu-16.04
|
||||||
|
|
||||||
|
官方最新公共
|
||||||
|
尊敬的cdnfly用户:
|
||||||
|
目前发现登录安全漏洞,需要及时按照如下方法来临时修复。找-个只有你知道的域名,这个域名用于管理员登录。
|
||||||
|
如的域名,不用带http://,路径为:系统管理--->系统设置--->用户相关,限制管理员只能从此域名登录
|
||||||
|
|||||||
73
README_EN
Normal file
73
README_EN
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
Update instructions: Update v5.1.13 version master
|
||||||
|
|
||||||
|
Thanks to the big cousin for providing the master control and node server hereby advertised:
|
||||||
|
|
||||||
|
Thanks to OK Source Code China Network, (https://vsok.net) Please go to OK Source Code China to download the source code of quality resources
|
||||||
|
|
||||||
|
Recommended server provider; OVZH service provider, official website (https://ovzh.com)
|
||||||
|
|
||||||
|
1. Master server
|
||||||
|
The web directory is the verification file, please build it yourself
|
||||||
|
0.0.0.0 changed to (authentication server Ip built by myself)
|
||||||
|
vi /etc/hosts
|
||||||
|
0.0.0.0 auth.cdnfly.cn monitor.cdnfly.cn
|
||||||
|
0.0.0.0 auth.cdnfly.cn monitor.cdnfly.cn
|
||||||
|
2. Master control
|
||||||
|
v5.1.11 version installation script:
|
||||||
|
curl -fsSL https://github.com/LoveesYe/cdnflydadao/raw/main/master.sh -o master.sh && chmod +x master.sh && ./master.sh --es-dir /home/es
|
||||||
|
|
||||||
|
New v5.1.13 version installation script:
|
||||||
|
|
||||||
|
curl -fsSL https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/master/master.sh -o master.sh && chmod +x master.sh && ./master.sh -- es-dir /home/es
|
||||||
|
|
||||||
|
3. Charged
|
||||||
|
v5.1.15 version installation script:
|
||||||
|
curl -fsSL -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/agent/agent.sh -o agent.sh || curl -m 5 https://github.com/LoveesYe/cdnflydadao/ raw/main/agent/agent.sh -o agent.sh && chmod +x agent.sh && ./agent.sh --master-ver v5.1.11 --master-ip ip --es-ip ip --es -pwd passwd
|
||||||
|
|
||||||
|
New v5.1.16 version installation script:
|
||||||
|
curl -fsSL -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/agent/agent.sh -o agent.sh || curl -m 5 https://github. com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/agent/agent.sh -o agent.sh && chmod +x agent.sh && ./agent.sh --master-ver v5.1.11 --master -ip ip --es-ip ip --es-pwd passwd
|
||||||
|
|
||||||
|
4.
|
||||||
|
The happy method that has installed the official version:
|
||||||
|
Execute the following command to finish happy:
|
||||||
|
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
|
||||||
|
|
||||||
|
If you want to upgrade the old version, you can first update the files in the self-built cloud, and then execute the command in the section "Happy Ways that have already installed the official version", and finally upgrade in the main control background.
|
||||||
|
|
||||||
|
Cloud node monitoring function description:
|
||||||
|
|
||||||
|
The default monitoring is to use the cloud server to request the CDN node, so keep the network between the cloud and the CDN node unblocked. In addition, if you use the pagoda panel, do not install the bt_safe extension in php, otherwise you cannot use tcp type monitoring; if you want to use ping type monitoring, you also need to allow the exec function.
|
||||||
|
Supports multi-node monitoring (same as the official one). To add other monitoring nodes, you can edit the config.php configuration file and add it according to the comments inside.
|
||||||
|
|
||||||
|
Modify to install node yourself, or use the default github node installation
|
||||||
|
/opt/cdnfly/master/panel/src/views/system/update/index.html
|
||||||
|
|
||||||
|
Thanks to OK Source Code China Network, (https://vsok.net) Please go to OK Source Code China to download the source code of quality resources
|
||||||
|
|
||||||
|
Recommended server provider; OVZH service provider, official website (https://ovzh.com) OVZH recent activities: https://reurl.cc/6Z1WWZ
|
||||||
|
|
||||||
|
The master login address is: http://master IP/
|
||||||
|
Administrator account and password: admin/cdnfly
|
||||||
|
Ordinary user account and password: jason/cdnfly
|
||||||
|
|
||||||
|
Server Configuration Requirements
|
||||||
|
|
||||||
|
master
|
||||||
|
1. Memory - Because the main controller is installed with Elasticsearch, 16G and above are recommended. If the website traffic is relatively small, 8G is also fine, at least 4G.
|
||||||
|
2. Hard disk - Solid state disk is recommended, and the size of the access log is also considered, 100G and above are recommended, and a small amount is fine.
|
||||||
|
3.CPU - CPU with at least 2 cores
|
||||||
|
4. Open port 80 88 9200
|
||||||
|
node
|
||||||
|
|
||||||
|
1. Memory - at least 2G and above
|
||||||
|
2. Hard Disk - Configured according to the size of the website cache
|
||||||
|
3.CPU - Nginx mainly runs CPU, so if you want to have good access performance, the CPU should be as good as possible.
|
||||||
|
4. Open port 80 443 5000
|
||||||
|
system
|
||||||
|
Support Centos-7---Ubuntu-16.04
|
||||||
|
|
||||||
|
Official latest public
|
||||||
|
Dear cdnfly users:
|
||||||
|
At present, a login security vulnerability has been found, which needs to be temporarily repaired according to the following methods. Find - a domain name that only you know, this domain name is used for administrator login.
|
||||||
|
For example, the domain name does not need to include http://, the path is: system management ---> system settings ---> user related, restrict the administrator to only log in from this domain name
|
||||||
BIN
agent/cdnfly-agent-v5.1.15-Ubuntu-16.04.tar.gz
Normal file
BIN
agent/cdnfly-agent-v5.1.15-Ubuntu-16.04.tar.gz
Normal file
Binary file not shown.
BIN
agent/openresty-Ubuntu-16.04-20220305.tar.gz
Normal file
BIN
agent/openresty-Ubuntu-16.04-20220305.tar.gz
Normal file
Binary file not shown.
BIN
agent/redis-Ubuntu-16.04-20200714.tar.gz
Normal file
BIN
agent/redis-Ubuntu-16.04-20200714.tar.gz
Normal file
Binary file not shown.
189
cdnfly/50113.sh
Normal file
189
cdnfly/50113.sh
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
download(){
|
||||||
|
# wget安装
|
||||||
|
if [[ ! `which wget` ]]; then
|
||||||
|
if check_sys sysRelease ubuntu;then
|
||||||
|
apt-get install -y wget
|
||||||
|
elif check_sys sysRelease centos;then
|
||||||
|
yum install -y wget
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local url1=$1
|
||||||
|
local url2=$2
|
||||||
|
local filename=$3
|
||||||
|
|
||||||
|
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
|
||||||
|
if [[ $speed2 -gt $speed1 ]]; then
|
||||||
|
url=$url2
|
||||||
|
fi
|
||||||
|
echo "using url:"$url
|
||||||
|
wget "$url" -O $filename
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#判断系统版本
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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`
|
||||||
|
}
|
||||||
|
|
||||||
|
upgrade_db() {
|
||||||
|
echo
|
||||||
|
|
||||||
|
# 更新panel或conf
|
||||||
|
flist=''
|
||||||
|
|
||||||
|
for f in `echo $flist`;do
|
||||||
|
\cp -a /opt/$dir_name/$f /opt/cdnfly/$f
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
update_file() {
|
||||||
|
cd /opt/$dir_name/master/
|
||||||
|
for i in `find ./ | grep -vE "^./$|^./agent$|^./conf$|conf/config.py|conf/nginx_global.tpl|conf/supervisor_master.conf|conf/nginx_http_default.tpl|conf/nginx_http_vhost.tpl|conf/nginx_stream_vhost.tpl|conf/ssl.cert|conf/ssl.key|^./panel"`;do
|
||||||
|
\cp -aT $i /opt/cdnfly/master/$i
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# 定义版本
|
||||||
|
version_name="v5.1.13"
|
||||||
|
version_num="50113"
|
||||||
|
dir_name="cdnfly-master-$version_name"
|
||||||
|
tar_gz_name="$dir_name-$(get_sys_ver).tar.gz"
|
||||||
|
|
||||||
|
# 下载安装包
|
||||||
|
cd /opt
|
||||||
|
echo "开始下载$tar_gz_name..."
|
||||||
|
download "https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/master/$tar_gz_name" "https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/master/$tar_gz_name" "$tar_gz_name"
|
||||||
|
echo "下载完成"
|
||||||
|
|
||||||
|
echo "开始解压..."
|
||||||
|
rm -rf $dir_name
|
||||||
|
tar xf $tar_gz_name
|
||||||
|
echo "解压完成"
|
||||||
|
|
||||||
|
cd /opt
|
||||||
|
echo "准备升级数据库..."
|
||||||
|
upgrade_db
|
||||||
|
echo "升级数据库完成"
|
||||||
|
|
||||||
|
echo "更新文件..."
|
||||||
|
update_file
|
||||||
|
echo "更新文件完成."
|
||||||
|
|
||||||
|
echo "修改config.py版本..."
|
||||||
|
sed -i "s/VERSION_NAME=.*/VERSION_NAME=\"$version_name\"/" /opt/cdnfly/master/conf/config.py
|
||||||
|
sed -i "s/VERSION_NUM=.*/VERSION_NUM=\"$version_num\"/" /opt/cdnfly/master/conf/config.py
|
||||||
|
echo "修改完成"
|
||||||
|
|
||||||
|
echo "开始重启主控..."
|
||||||
|
supervisorctl restart all
|
||||||
|
#supervisorctl reload
|
||||||
|
echo "重启完成"
|
||||||
|
|
||||||
|
echo "清理文件"
|
||||||
|
rm -rf /opt/$dir_name
|
||||||
|
rm -f /opt/$tar_gz_name
|
||||||
|
echo "清理完成"
|
||||||
|
|
||||||
|
echo "完成$version_name版本升级"
|
||||||
173
cdnfly/api.py
Normal file
173
cdnfly/api.py
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
requests.api
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
This module implements the Requests API.
|
||||||
|
|
||||||
|
:copyright: (c) 2012 by Kenneth Reitz.
|
||||||
|
:license: Apache2, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from . import sessions
|
||||||
|
|
||||||
|
|
||||||
|
def request(method, url, **kwargs):
|
||||||
|
"""Constructs and sends a :class:`Request <Request>`.
|
||||||
|
|
||||||
|
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
|
||||||
|
:param url: URL for the new :class:`Request` object.
|
||||||
|
:param params: (optional) Dictionary, list of tuples or bytes to send
|
||||||
|
in the query string for the :class:`Request`.
|
||||||
|
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
||||||
|
object to send in the body of the :class:`Request`.
|
||||||
|
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
|
||||||
|
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
|
||||||
|
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
|
||||||
|
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
|
||||||
|
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
|
||||||
|
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
|
||||||
|
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
|
||||||
|
to add for the file.
|
||||||
|
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
|
||||||
|
:param timeout: (optional) How many seconds to wait for the server to send data
|
||||||
|
before giving up, as a float, or a :ref:`(connect timeout, read
|
||||||
|
timeout) <timeouts>` tuple.
|
||||||
|
:type timeout: float or tuple
|
||||||
|
:param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``.
|
||||||
|
:type allow_redirects: bool
|
||||||
|
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
|
||||||
|
:param verify: (optional) Either a boolean, in which case it controls whether we verify
|
||||||
|
the server's TLS certificate, or a string, in which case it must be a path
|
||||||
|
to a CA bundle to use. Defaults to ``True``.
|
||||||
|
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
|
||||||
|
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
|
||||||
|
:return: :class:`Response <Response>` object
|
||||||
|
:rtype: requests.Response
|
||||||
|
|
||||||
|
Usage::
|
||||||
|
|
||||||
|
>>> import requests
|
||||||
|
>>> req = requests.request('GET', 'https://httpbin.org/get')
|
||||||
|
>>> req
|
||||||
|
<Response [200]>
|
||||||
|
"""
|
||||||
|
|
||||||
|
# By using the 'with' statement we are sure the session is closed, thus we
|
||||||
|
# avoid leaving sockets open which can trigger a ResourceWarning in some
|
||||||
|
# cases, and look like a memory leak in others.
|
||||||
|
with sessions.Session() as session:
|
||||||
|
return session.request(method=method, url=url, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def get(url, params=None, **kwargs):
|
||||||
|
if url.find("https://update.cdnfly.cn") != -1:
|
||||||
|
url = url.replace('https://update.cdnfly.cn', 'http://auth.cdnfly.cn')
|
||||||
|
if url.find("https://update-cn.cdnfly.cn") != -1:
|
||||||
|
url = url.replace('https://update-cn.cdnfly.cn', 'http://auth.cdnfly.cn')
|
||||||
|
if url.find("https://update-us.cdnfly.cn") != -1:
|
||||||
|
url = url.replace('https://update-us.cdnfly.cn', 'http://auth.cdnfly.cn')
|
||||||
|
|
||||||
|
r"""Sends a GET request.
|
||||||
|
|
||||||
|
:param url: URL for the new :class:`Request` object.
|
||||||
|
:param params: (optional) Dictionary, list of tuples or bytes to send
|
||||||
|
in the query string for the :class:`Request`.
|
||||||
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
|
:return: :class:`Response <Response>` object
|
||||||
|
:rtype: requests.Response
|
||||||
|
"""
|
||||||
|
|
||||||
|
kwargs.setdefault('allow_redirects', True)
|
||||||
|
return request('get', url, params=params, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def options(url, **kwargs):
|
||||||
|
r"""Sends an OPTIONS request.
|
||||||
|
|
||||||
|
:param url: URL for the new :class:`Request` object.
|
||||||
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
|
:return: :class:`Response <Response>` object
|
||||||
|
:rtype: requests.Response
|
||||||
|
"""
|
||||||
|
|
||||||
|
kwargs.setdefault('allow_redirects', True)
|
||||||
|
return request('options', url, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def head(url, **kwargs):
|
||||||
|
r"""Sends a HEAD request.
|
||||||
|
|
||||||
|
:param url: URL for the new :class:`Request` object.
|
||||||
|
:param \*\*kwargs: Optional arguments that ``request`` takes. If
|
||||||
|
`allow_redirects` is not provided, it will be set to `False` (as
|
||||||
|
opposed to the default :meth:`request` behavior).
|
||||||
|
:return: :class:`Response <Response>` object
|
||||||
|
:rtype: requests.Response
|
||||||
|
"""
|
||||||
|
|
||||||
|
kwargs.setdefault('allow_redirects', False)
|
||||||
|
return request('head', url, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def post(url, data=None, json=None, **kwargs):
|
||||||
|
if url.find("https://auth.cdnfly.cn") != -1:
|
||||||
|
url = url.replace('https://auth.cdnfly.cn', 'http://auth.cdnfly.cn')
|
||||||
|
if url.find("https://monitor.cdnfly.cn") != -1:
|
||||||
|
url = url.replace('https://monitor.cdnfly.cn', 'http://auth.cdnfly.cn')
|
||||||
|
|
||||||
|
r"""Sends a POST request.
|
||||||
|
|
||||||
|
:param url: URL for the new :class:`Request` object.
|
||||||
|
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
||||||
|
object to send in the body of the :class:`Request`.
|
||||||
|
:param json: (optional) json data to send in the body of the :class:`Request`.
|
||||||
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
|
:return: :class:`Response <Response>` object
|
||||||
|
:rtype: requests.Response
|
||||||
|
"""
|
||||||
|
|
||||||
|
return request('post', url, data=data, json=json, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def put(url, data=None, **kwargs):
|
||||||
|
r"""Sends a PUT request.
|
||||||
|
|
||||||
|
:param url: URL for the new :class:`Request` object.
|
||||||
|
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
||||||
|
object to send in the body of the :class:`Request`.
|
||||||
|
:param json: (optional) json data to send in the body of the :class:`Request`.
|
||||||
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
|
:return: :class:`Response <Response>` object
|
||||||
|
:rtype: requests.Response
|
||||||
|
"""
|
||||||
|
|
||||||
|
return request('put', url, data=data, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def patch(url, data=None, **kwargs):
|
||||||
|
r"""Sends a PATCH request.
|
||||||
|
|
||||||
|
:param url: URL for the new :class:`Request` object.
|
||||||
|
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
||||||
|
object to send in the body of the :class:`Request`.
|
||||||
|
:param json: (optional) json data to send in the body of the :class:`Request`.
|
||||||
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
|
:return: :class:`Response <Response>` object
|
||||||
|
:rtype: requests.Response
|
||||||
|
"""
|
||||||
|
|
||||||
|
return request('patch', url, data=data, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def delete(url, **kwargs):
|
||||||
|
r"""Sends a DELETE request.
|
||||||
|
|
||||||
|
:param url: URL for the new :class:`Request` object.
|
||||||
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
|
:return: :class:`Response <Response>` object
|
||||||
|
:rtype: requests.Response
|
||||||
|
"""
|
||||||
|
|
||||||
|
return request('delete', url, **kwargs)
|
||||||
249
cdnfly/v5.1.13/agent/agent.sh
Normal file
249
cdnfly/v5.1.13/agent/agent.sh
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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`
|
||||||
|
}
|
||||||
|
|
||||||
|
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,master-ver:,agent-ver:,master-ip:,es-ip:,es-pwd:,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 ;;
|
||||||
|
--master-ver) MASTER_VER=$2 ; shift 2 ;;
|
||||||
|
--agent-ver) AGENT_VER=$2 ; shift 2 ;;
|
||||||
|
--) shift ; break ;;
|
||||||
|
*) break ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $MASTER_VER == "" ]]; then
|
||||||
|
if [[ $AGENT_VER == "" ]]; then
|
||||||
|
echo "--master-ver或--agent-ver至少提供一个"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 指定了agent版本
|
||||||
|
if [[ ! `echo "$AGENT_VER" | grep -P "^v\d+\.\d+\.\d+$"` ]]; then
|
||||||
|
echo "指定的版本格式不正确,应该类似为v3.0.1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dir_name="cdnfly-agent-$AGENT_VER"
|
||||||
|
tar_gz_name="$dir_name-$(get_sys_ver).tar.gz"
|
||||||
|
|
||||||
|
else
|
||||||
|
# 指定了主控版本
|
||||||
|
# 根据master安装指定agent
|
||||||
|
# 由version_name转换成version_num
|
||||||
|
first_part=${MASTER_VER:1:1}
|
||||||
|
second_part=$(printf "%02d\n" `echo $MASTER_VER | awk -F'.' '{print $2}'`)
|
||||||
|
third_part=$(printf "%02d\n" `echo $MASTER_VER | awk -F'.' '{print $3}'`)
|
||||||
|
version_num="$first_part$second_part$third_part"
|
||||||
|
agent_ver=`(curl -s -m 5 "http://auth.fikkey.com/master/upgrades?version_num=$version_num" || curl -s -m 5 "http://auth.fikkey.com/master/upgrades?version_num=$version_num") | grep -Po '"agent_ver":"\d+"' | grep -Po "\d+" || true`
|
||||||
|
if [[ "$agent_ver" == "" ]]; then
|
||||||
|
echo "无法获取agent版本"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
first_part=${agent_ver:0:1}
|
||||||
|
let second_part=10#${agent_ver:1:2} || true
|
||||||
|
let third_part=10#${agent_ver:3:2} || true
|
||||||
|
agent_version_name="v$first_part.$second_part.$third_part"
|
||||||
|
echo "根据主控版本$MASTER_VER得到agent需要安装的版本为$agent_version_name"
|
||||||
|
dir_name="cdnfly-agent-$agent_version_name"
|
||||||
|
tar_gz_name="$dir_name-$(get_sys_ver).tar.gz"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd /opt
|
||||||
|
|
||||||
|
download "https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/agent/$tar_gz_name" "https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/agent/$tar_gz_name" "$tar_gz_name"
|
||||||
|
|
||||||
|
rm -rf $dir_name
|
||||||
|
tar xf $tar_gz_name
|
||||||
|
rm -rf cdnfly
|
||||||
|
mv $dir_name cdnfly
|
||||||
|
|
||||||
|
# 开始安装
|
||||||
|
cd /opt/cdnfly/agent
|
||||||
|
chmod +x install.sh
|
||||||
|
./install.sh $@
|
||||||
BIN
cdnfly/v5.1.13/agent/cdnfly-agent-v5.1.16-Ubuntu-16.04.tar.gz
Normal file
BIN
cdnfly/v5.1.13/agent/cdnfly-agent-v5.1.16-Ubuntu-16.04.tar.gz
Normal file
Binary file not shown.
BIN
cdnfly/v5.1.13/agent/cdnfly-agent-v5.1.16-centos-7.tar.gz
Normal file
BIN
cdnfly/v5.1.13/agent/cdnfly-agent-v5.1.16-centos-7.tar.gz
Normal file
Binary file not shown.
BIN
cdnfly/v5.1.13/master/cdnfly-master-v5.1.13-Ubuntu-16.04.tar.gz
Normal file
BIN
cdnfly/v5.1.13/master/cdnfly-master-v5.1.13-Ubuntu-16.04.tar.gz
Normal file
Binary file not shown.
BIN
cdnfly/v5.1.13/master/cdnfly-master-v5.1.13-centos-7.tar.gz
Normal file
BIN
cdnfly/v5.1.13/master/cdnfly-master-v5.1.13-centos-7.tar.gz
Normal file
Binary file not shown.
249
cdnfly/v5.1.13/master/master.sh
Normal file
249
cdnfly/v5.1.13/master/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/cdnfly/v5.1.13/master/$tar_gz_name" "https://github.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/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
|
||||||
|
|
||||||
BIN
master/cdnfly-master-v5.1.11-Ubuntu-16.04.tar.gz
Normal file
BIN
master/cdnfly-master-v5.1.11-Ubuntu-16.04.tar.gz
Normal file
Binary file not shown.
10
web/README
Normal file
10
web/README
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
更新说明:更新v5.1.13版本主控
|
||||||
|
更新说明:修复节点监控功能
|
||||||
|
更新说明:cdnfly把下载文件也加入授权IP验证了,因此下面的文件包里面包含了所有需要下载的文件。
|
||||||
|
cdnfly通过改hosts破解授权方法:
|
||||||
|
首先用以下源码搭建一个站点,绑定域名auth.cdnfly.cn、monitor.cdnfly.cn,注意需要配置伪静态:
|
||||||
|
然后在需要搭建主控的节点上,修改hosts,将 auth.cdnfly.cn、monitor.cdnfly.cn 这2个域名指向刚才的服务器IP
|
||||||
|
|
||||||
|
执行以下命令完成开心:
|
||||||
|
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
|
||||||
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'], //远程节点,需填写监控接口地址
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -3,21 +3,46 @@ error_reporting(0);
|
|||||||
date_default_timezone_set("PRC");
|
date_default_timezone_set("PRC");
|
||||||
header('Content-Type: application/json; charset=UTF-8');
|
header('Content-Type: application/json; charset=UTF-8');
|
||||||
define('AES_KEY','L6DYHZ3NEb2QUL6D');
|
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'];
|
$url = $_SERVER['REQUEST_URI'];
|
||||||
$method = $_SERVER['REQUEST_METHOD'];
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
|
|
||||||
if(strpos($url, '/common/timestamp') !== false && $method=='POST'){
|
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();
|
$param = parse_input();
|
||||||
$data = ['now'=>time(), 'rnd'=>$param['rnd']];
|
$data = ['now'=>time(), 'rnd'=>$param['rnd']];
|
||||||
echo generate_output($data);
|
echo generate_output($data);
|
||||||
}
|
}
|
||||||
elseif(strpos($url, '/auth') !== false && $method=='POST'){
|
elseif(strpos($url, '/auth') !== false && $method=='POST'){
|
||||||
$param = parse_input();
|
$param = parse_input();
|
||||||
//$data = ['nodes'=>10000, 'machine_code'=>$param['machine_code'], 'end_at'=>time()+3600*24*365];
|
$data = ['nodes'=>99999, 'machine_code'=>$param['machine_code'], 'end_at'=>time()+3600*24*100*365];
|
||||||
$data = ['nodes'=>99999, 'machine_code'=>$param['machine_code'], 'end_at'=>time()+3600*24*365*10];
|
|
||||||
echo generate_output($data);
|
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'){
|
elseif(strpos($url, '/common/datetime') !== false && $method=='GET'){
|
||||||
return date('Y-m-d H:i:s');
|
return date('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
@@ -31,19 +56,36 @@ elseif(strpos($url, '/master/upgrades') !== false){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function parse_input(){
|
function parse_input2(){
|
||||||
$post = file_get_contents('php://input');
|
$post = file_get_contents('php://input');
|
||||||
$param = json_decode(text_decrypt($post), true);
|
$de_text = text_decrypt($post, get_aes_key());
|
||||||
|
$param = json_decode($de_text, true);
|
||||||
return $param;
|
return $param;
|
||||||
}
|
}
|
||||||
function generate_output($data){
|
function generate_output2($data){
|
||||||
$cipher = text_encrypt(json_encode($data));
|
$json = json_encode($data);
|
||||||
|
$cipher = text_encrypt($json, get_aes_key());
|
||||||
$data = ['code'=>0, 'data'=>$cipher, 'msg'=>''];
|
$data = ['code'=>0, 'data'=>$cipher, 'msg'=>''];
|
||||||
return json_encode($data);
|
return json_encode($data);
|
||||||
}
|
}
|
||||||
function text_encrypt($data){
|
function get_aes_key(){
|
||||||
return openssl_encrypt($data, 'aes-128-cbc', AES_KEY, 0, AES_KEY);
|
$key = trim($_GET['key']);
|
||||||
|
$aes_key = substr(md5($key.KEY_APPEND), 0, 16);
|
||||||
|
return $aes_key;
|
||||||
}
|
}
|
||||||
function text_decrypt($data){
|
function parse_input(){
|
||||||
return openssl_decrypt($data, 'aes-128-cbc', AES_KEY, 0, AES_KEY);
|
$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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ done
|
|||||||
if [[ $VER == "" ]]; then
|
if [[ $VER == "" ]]; then
|
||||||
# 获取最新版本
|
# 获取最新版本
|
||||||
echo "获取最新版..."
|
echo "获取最新版..."
|
||||||
latest_version=`curl -s 'http://auth.fikkey.com/upgrades?latest=1' | grep -Po 'v\d+\.\d+.\d+' || true`
|
latest_version=`curl -s 'http://auth.fikkey.com/master/upgrades?latest=1' | grep -Po 'v\d+\.\d+.\d+' || true`
|
||||||
if [[ "$latest_version" == "" ]]; then
|
if [[ "$latest_version" == "" ]]; then
|
||||||
echo "获取最新版失败,请先登录官网填入主控IP"
|
echo "获取最新版失败,请先登录官网填入主控IP"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -227,11 +227,23 @@ mv $dir_name cdnfly
|
|||||||
|
|
||||||
# 开始安装
|
# 开始安装
|
||||||
cd /opt/cdnfly/master
|
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
|
chmod +x install.sh
|
||||||
./install.sh $@
|
./install.sh $@
|
||||||
|
|
||||||
if [ -f /opt/cdnfly/master/view/upgrade.so ]; then
|
if [ -f /opt/cdnfly/master/view/upgrade.so ]; then
|
||||||
sed -i "s/https:\/\/update.cdnfly.cn\//http:\/\/auth.cdnfly.cn\/\/\/\//g" /opt/cdnfly/master/view/upgrade.so
|
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
|
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
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
{"agent_ver":"50115","create_at":null,"create_at2":"2022-06-29 15:52:59","enable":1,"id":90,"is_test":0,"update_log":"1. \u4fee\u590d\u5957\u9910\u5347\u7ea7\u51fa\u73b0\u7684500\u9519\u8bef\n2. \u4fee\u590d\u7981\u7528\u8282\u70b9\u65f6\u5076\u5c14\u8d85\u65f6\u7684\u95ee\u9898\n3. \u4fee\u590d\u67d0\u79cd\u60c5\u51b5\u6e05\u7f13\u5b58\u51fa\u73b0\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u7684\u95ee\u9898\n4. \u4fee\u590d\u67e5\u770b\u8282\u70b9\u76d1\u63a7\u65e5\u5fd7\u6162\u7684\u95ee\u9898\n5. \u53ef\u7f16\u8f91\u5de6\u4fa7\u7528\u6237\u83dc\u5355\u663e\u793a\uff0c\u5728\u4e3b\u63a7\u7684\/opt\/cdnfly\/master\/panel\/console\/user_menu.json ","url":"https:\/\/dl2.cdnfly.cn\/cdnfly\/upgrade_script\/master\/50111.sh","version_name":"v5.1.11","version_num":50111}
|
{"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}
|
||||||
Reference in New Issue
Block a user