82 Commits
CDN ... main

Author SHA1 Message Date
d0ba17e424 变更 2023-08-11 11:22:37 +08:00
055a7ad212 变更 2023-08-11 11:22:15 +08:00
10f3a8e03a 变更 2023-08-11 10:45:18 +08:00
7e0bafa41c 变更 2023-07-24 01:15:29 +08:00
9b1c4589e1 变更 2023-07-21 10:30:02 +08:00
16dfd3d6d7 变更 2023-07-21 10:25:31 +08:00
40d0ae90ff 变更 2023-07-21 10:20:47 +08:00
87f00a7202 modify yungao git 2022-12-08 07:10:35 +08:00
fa0761a9f1 add 2022-12-08 03:25:53 +08:00
7483a4830b add 2022-12-07 23:57:42 +08:00
5070a3c139 添加简介 2022-12-07 23:20:52 +08:00
2c21d2ac74 添加简介 2022-12-07 23:19:58 +08:00
c9c96e73cc modify yungao git 2022-12-07 22:40:21 +08:00
LoveesYe
7bdd4f8054 Update README 2022-08-10 23:21:12 +02:00
LoveesYe
66acb9392b Add files via upload 2022-07-29 15:18:36 +02:00
LoveesYe
b8a0fa535e Update master.sh 2022-07-29 14:13:47 +02:00
LoveesYe
13249045dd Update agent.sh 2022-07-29 14:12:02 +02:00
LoveesYe
34f2a5bde6 Create FAQ 2022-07-28 20:14:39 +02:00
LoveesYe
6fd9cd2dec Update README_EN 2022-07-28 19:18:26 +02:00
LoveesYe
acd7639885 Update README 2022-07-28 18:20:48 +02:00
LoveesYe
32a5777239 Add files via upload 2022-07-27 20:41:45 +02:00
LoveesYe
33b7ac9d4c Update README 2022-07-27 16:19:15 +02:00
LoveesYe
0a183d9486 Add files via upload 2022-07-27 16:14:08 +02:00
LoveesYe
6b26c4779e Delete cdnfly-master-v5.1.13-centos-7.tar.gz 2022-07-27 16:11:18 +02:00
LoveesYe
026bb06418 Delete cdnfly-master-v5.1.13-Ubuntu-16.04.tar.gz 2022-07-27 16:11:10 +02:00
LoveesYe
6b4676c3a9 Delete cdnfly-agent-v5.1.16-Ubuntu-16.04.tar.gz 2022-07-27 16:11:01 +02:00
LoveesYe
86b66d24a1 Add files via upload 2022-07-27 16:10:37 +02:00
LoveesYe
f3e7894b06 Add files via upload 2022-07-27 16:08:32 +02:00
LoveesYe
bd60622d3f Delete test.txt 2022-07-27 15:46:11 +02:00
LoveesYe
34df9361e2 Add files via upload 2022-07-27 15:25:51 +02:00
LoveesYe
88ccece4ad Update README 2022-07-27 15:22:27 +02:00
LoveesYe
bdb5accac3 Add files via upload 2022-07-27 15:17:05 +02:00
LoveesYe
4917621adc Update README 2022-07-27 14:53:47 +02:00
LoveesYe
8f73d81476 Add files via upload 2022-07-27 00:02:44 +02:00
LoveesYe
b9a0ecb5eb Delete epel.repo 2022-07-27 00:00:26 +02:00
LoveesYe
cfaab8b4d4 Delete test.txt 2022-07-27 00:00:15 +02:00
LoveesYe
16ac1013cd Delete acme.sh-3.0.1.zip 2022-07-27 00:00:03 +02:00
LoveesYe
fac8562816 Add files via upload 2022-07-26 23:59:50 +02:00
LoveesYe
05602192c5 Add files via upload 2022-07-26 23:52:20 +02:00
LoveesYe
2f34d73c54 Create test.txt 2022-07-26 23:08:17 +02:00
LoveesYe
dd176411f8 Create test.txt 2022-07-26 23:07:38 +02:00
LoveesYe
60cb088ed1 Add files via upload 2022-07-26 22:50:49 +02:00
LoveesYe
17aa0502db Delete version.json 2022-07-26 22:50:10 +02:00
LoveesYe
e94482887f Delete update.php 2022-07-26 22:50:03 +02:00
LoveesYe
9565b60a4b Delete nginx伪静态.txt 2022-07-26 22:49:55 +02:00
LoveesYe
bee3f1a074 Delete monitor.php 2022-07-26 22:49:13 +02:00
LoveesYe
51aabdbe2d Delete master.sh 2022-07-26 22:48:55 +02:00
LoveesYe
a9d2546380 Delete index.php 2022-07-26 22:46:42 +02:00
LoveesYe
c53bd85e25 Delete config.php 2022-07-26 22:46:33 +02:00
LoveesYe
cd4b032013 Delete api.php 2022-07-26 22:46:26 +02:00
LoveesYe
497aee9c02 Update README 2022-07-26 22:46:08 +02:00
LoveesYe
2645c74ba3 Update README 2022-07-26 22:45:10 +02:00
LoveesYe
7ffb9d136c Update README 2022-07-26 22:42:23 +02:00
LoveesYe
31c4118e28 Delete test.txt 2022-07-26 22:38:57 +02:00
LoveesYe
e09f7eb34b Add files via upload 2022-07-26 22:38:24 +02:00
LoveesYe
1870ad5d8e Create test.txt 2022-07-26 22:38:03 +02:00
LoveesYe
af8ce463b8 Create README_EN 2022-07-20 19:07:38 +02:00
LoveesYe
fa67d558f2 Add files via upload 2022-07-20 19:05:22 +02:00
LoveesYe
d5e3dcdc96 Delete cdnfly-agent-v5.1.15-Ubuntu-16.04.tar.gz 2022-07-20 19:05:07 +02:00
LoveesYe
fa1332822c Add files via upload 2022-07-20 18:41:01 +02:00
LoveesYe
2439b3d9ad Delete cdnfly-master-v5.1.11-Ubuntu-16.04.tar.gz 2022-07-20 18:40:44 +02:00
LoveesYe
cffdb77fec Add files via upload 2022-07-20 17:40:42 +02:00
LoveesYe
67c53f540b Delete cdnfly-master-v5.1.11-Ubuntu-16.04.tar.gz 2022-07-20 17:40:15 +02:00
LoveesYe
c07063e72c Update README 2022-07-20 17:35:49 +02:00
LoveesYe
a1da11c861 Add files via upload 2022-07-20 17:35:10 +02:00
LoveesYe
eafbdbb149 Delete cdnfly-agent-v5.1.15-Ubuntu-16.0412356.tar.gz 2022-07-20 17:34:53 +02:00
LoveesYe
8baba22a8c Add files via upload 2022-07-20 17:31:25 +02:00
LoveesYe
cf9e5540bd Add files via upload 2022-07-20 17:30:53 +02:00
LoveesYe
16860c1c91 Add files via upload 2022-07-20 17:30:21 +02:00
LoveesYe
8a375712d2 Update README 2022-07-17 00:26:32 +02:00
LoveesYe
2d85147fff Update README 2022-07-17 00:25:40 +02:00
LoveesYe
c2aa4ebcaf Update README 2022-07-16 21:25:43 +02:00
LoveesYe
c4823913b7 Update README 2022-07-16 21:25:23 +02:00
LoveesYe
2c79d56afb Update index.php 2022-07-15 23:46:07 +02:00
LoveesYe
3846659e74 Add files via upload 2022-07-15 22:28:37 +02:00
LoveesYe
0ce9da0c24 Update README 2022-07-14 21:05:47 +02:00
LoveesYe
890016ca37 Add files via upload 2022-07-14 21:00:43 +02:00
LoveesYe
cdfc99260e Create README 2022-07-14 21:00:03 +02:00
LoveesYe
5b8d2f9c5d Add files via upload 2022-07-14 20:58:16 +02:00
LoveesYe
6aa2b4339a Delete update.php 2022-07-14 20:57:53 +02:00
LoveesYe
51fbf2917d Delete index.php 2022-07-14 20:57:38 +02:00
LoveesYe
b14aa5dc6c Update README 2022-07-12 22:42:43 +02:00
33 changed files with 1555 additions and 25 deletions

8
.idea/cdnflydadao.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/cdnflydadao.iml" filepath="$PROJECT_DIR$/.idea/cdnflydadao.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

98
.idea/workspace.xml generated Normal file
View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="19fc4048-f9db-4d9d-ae64-642a4c8149c0" name="变更" comment="变更" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings">
<execution />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://F:/我的电脑/Documents/WeChat Files/wxid_pj54dtlvkjzq11/FileStorage/File/2022-08/云高项目网络IP地址划分资料.xlsx" root0="SKIP_INSPECTION" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2IadvHdnu3Q2Svu1RFVmwDkBl7P" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;last_opened_file_path&quot;: &quot;F:/我的电脑/Documents/WeChat Files/wxid_pj54dtlvkjzq11/FileStorage/File/2022-08&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
<changelist id="19fc4048-f9db-4d9d-ae64-642a4c8149c0" name="变更" comment="" />
<created>1670423856551</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1670423856551</updated>
<workItem from="1670423857731" duration="4364000" />
<workItem from="1670430386964" duration="2490000" />
<workItem from="1670454611831" duration="625000" />
<workItem from="1670768307449" duration="103000" />
<workItem from="1689905971667" duration="1234000" />
</task>
<task id="LOCAL-00001" summary="modify yungao git">
<created>1670424021829</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1670424021829</updated>
</task>
<task id="LOCAL-00002" summary="modify yungao git">
<created>1670454635337</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1670454635337</updated>
</task>
<task id="LOCAL-00003" summary="变更">
<created>1689906048020</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1689906048020</updated>
</task>
<task id="LOCAL-00004" summary="变更">
<created>1689906331181</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1689906331181</updated>
</task>
<task id="LOCAL-00005" summary="变更">
<created>1689906602120</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1689906602120</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="modify yungao git" />
<MESSAGE value="变更" />
<option name="LAST_COMMIT_MESSAGE" value="变更" />
</component>
</project>

122
FAQ Normal file
View File

@@ -0,0 +1,122 @@
如何搬迁主控
注意下面的迁移步骤不包括迁移elasticsearch的数据
1 备份旧主控数据
在旧主控执行如下命令开始备份(注意:备份前会停止旧主控的进程)
cd /root
curl http://us.centos.bz/cdnfly/backup_master.sh -o backup_master.sh
chmod +x backup_master.sh
./backup_master.sh
这时候将在目录/root下打包生成cdn.sql.gz文件请把这个文件传输到新主控的/root/目录下可以使用scp命令命令如下
cd /root
scp cdn.sql.gz root@新主控IP:/root/
2 在新机器安装好主控程序
首先登录cdnfly.cn更新授权为新主控ip并清空机器码
登录旧主控机器,执行如下命令查看版本:
grep VERSION_NAME /opt/cdnfly/master/conf/config.py
如下图版本为v4.1.6
登录新机器,执行如下命令安装:
curl http://dl.cdnfly.cn/cdnfly/master.sh -o master.sh
chmod +x master.sh
./master.sh --ver v4.1.60
其中v4.1.60替换成自己的主控版本号
3 登录新主控,恢复备份
执行如下命令恢复
cd /root
curl http://us.centos.bz/cdnfly/restore_master.sh -o restore_master.sh
chmod +x restore_master.sh
./restore_master.sh
从旧主控下载/opt/cdnfly/master/conf/config.py上传到新主控覆盖
然后在新主控初始化es,重启新主控
执行如下命令初始化:
cd /tmp
wget us.centos.bz/cdnfly/int_es.sh -O int_es.sh
chmod +x int_es.sh
./int_es.sh /home/es
supervisorctl restart all
其中/var/lib/elasticsearch为es的数据目录可以更改成其它的比如/home/es
4 替换节点里的主控IP
一个个登录节点,执行如下命令替换
new_master_ip="这里替换为新主控IP"
sed -i "s/ES_IP =.*/ES_IP = \"$new_master_ip\"/" /opt/cdnfly/agent/conf/config.py
sed -i "s/MASTER_IP.*/MASTER_IP = \"$new_master_ip\"/g" /opt/cdnfly/agent/conf/config.py
sed -i "s/hosts:.*/hosts: [\"$new_master_ip:9200\"]/" /opt/cdnfly/agent/conf/filebeat.yml
logs_path=`awk '/error_log/{print $2}' /usr/local/openresty/nginx/conf/nginx.conf | sed 's/error.log//'`
if [[ `echo $logs_path | grep ^/ ` != "" ]];then
sed -i "s#.*access.log# - $logs_path/access.log#" /opt/cdnfly/agent/conf/filebeat.yml
sed -i "s#.*stream.log# - $logs_path/stream.log#" /opt/cdnfly/agent/conf/filebeat.yml
fi
sed -i "s#http://.*:88#http://$new_master_ip:88#" /usr/local/openresty/nginx/conf/listen_80.conf /usr/local/openresty/nginx/conf/listen_other.conf
ps aux | grep [/]usr/local/openresty/nginx/sbin/nginx | awk '{print $2}' | xargs kill -HUP || true
supervisorctl restart filebeat
supervisorctl restart agent
supervisorctl restart task
5 迁移完成
登录新主控后台在首页点击检查agent如果没有错误表示主控迁移完成。
如何获取授权
如何授权到期,或者在授权前安装程序,可以登录主控,执行如下命令获取授权:
# 获取授权
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 "未授权,原因:"$ret
deactivate
如何取消管理端域名绑定
在主控上执行如下命令
mysql -uroot -p@cdnflypass cdn -e "update config set value='' where name='admin_domain';"
mysql -uroot -p@cdnflypass cdn -e "update config set value='' where name='user_domain';"
如何重置主控密码
执行如下命令重置密码为cdnfly用户名不变
mysql -uroot -p@cdnflypass cdn -e 'update user set password="$2b$12$UV5ttpNQizMfO.tiBk9ereZ53hDBW0.kak3qa/GRP6aVBfNMB1NsK" where id=1'
如何初始化elasticsearch
当elasticsearch出现无法解决的异常或者elasticsearch数据占满了硬盘可以执行此操作来初始化elasticsearch注意初始化elasticsearch会清空其所有的数据。
执行如下命令初始化:
cd /tmp
wget http://us.centos.bz/cdnfly/int_es.sh -O int_es.sh
chmod +x int_es.sh
./int_es.sh /home/es
其中/home/es为es的数据目录也可以更改成其它的。
如何更换主控IP
首先登录官网修改授权的主控 IP然后登录每个节点执行下面的命令:
new_master_ip="这里替换为主控IP"
es_pwd="这里替换为es密码"
sed -i "s/ES_IP =.*/ES_IP = \"$new_master_ip\"/" /opt/cdnfly/agent/conf/config.py
sed -i "s/MASTER_IP.*/MASTER_IP = \"$new_master_ip\"/g" /opt/cdnfly/agent/conf/config.py
sed -i "s/hosts:.*/hosts: [\"$new_master_ip:9200\"]/" /opt/cdnfly/agent/conf/filebeat.yml
sed -i "s#http://.*:88#http://$new_master_ip:88#" /usr/local/openresty/nginx/conf/listen_80.conf /usr/local/openresty/nginx/conf/listen_other.conf
sed -i "s/ES_PWD =.*/ES_PWD = \"$es_pwd\"/" /opt/cdnfly/agent/conf/config.py
sed -i "s/password:.*/password: \"$es_pwd\"/" /opt/cdnfly/agent/conf/filebeat.yml
sed -i "s/agent-pwd:.*/agent-pwd: \"$es_pwd\"/" /opt/cdnfly/agent/conf/filebeat.yml
ps aux | grep [/]usr/local/openresty/nginx/sbin/nginx | awk '{print $2}' | xargs kill -HUP || true
supervisorctl restart filebeat
supervisorctl restart agent
supervisorctl restart task
es密码在主控的/opt/cdnfly/master/conf/config.py里的LOG_PWD
安装代理软件
当主控无法直接与节点连接时可以通过代理来连接这里介绍安装代理软件的方法目前只支持centos系统安装命令如下
cd /tmp
wget http://us.centos.bz/cdnfly/install_proxy.sh
chmod +x install_proxy.sh
./install_proxy.sh
安装完成后,会显示代理的端口,用户名和密码。
手动备份数据库
eval `grep "MYSQL_PASS" /opt/cdnfly/master/conf/config.py` && mysqldump -uroot -p$MYSQL_PASS cdn | gzip > /root/

119
README
View File

@@ -1,3 +1,4 @@
更新说明更新v5.1.13版本主控
感谢大表哥提供主控和节点服务器特此广告:
感谢OK源码中国网提供https://vsok.net) 精品资源源码请去OK源码中国下载
@@ -8,13 +9,35 @@
web目录为验证文件请自行搭建
0.0.0.0改成(自己搭建的验证服务器Ip)
vi /etc/hosts
0.0.0.0 auth.cdnfly.cn
0.0.0.0 auth.cdnfly.cn
114.132.217.36 auth.cdnfly.cn monitor.cdnfly.cn
114.132.217.36 auth.cdnfly.cn monitor.cdnfly.cn
2.主控
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.11版本安装脚本:
curl -fsSL https://git.yungao-tech.com/shadow/cdnflydadao/raw/main/master.sh -o master.sh && chmod +x master.sh && ./master.sh --es-dir /home/es
新v5.1.13版本安装脚本:
curl -fsSL https://git.yungao-tech.com/shadow/cdnflydadao/raw/main/cdnfly/v5.1.13/master/master.sh -o master.sh && chmod +x master.sh && ./master.sh --es-dir /home/es
3.被控
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.15版本安装脚本:
curl -fsSL -m 5 https://git.yungao-tech.com/shadow/cdnflydadao/raw/main/agent/agent.sh -o agent.sh || curl -m 5 https://git.yungao-tech.com/shadow/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://git.yungao-tech.com/shadow/cdnflydadao/raw/main/cdnfly/v5.1.13/agent/agent.sh -o agent.sh || curl -m 5 https://git.yungao-tech.com/shadow/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://git.yungao-tech.com/shadow/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节点安装
/opt/cdnfly/master/panel/src/views/system/update/index.html
@@ -22,3 +45,91 @@ curl -fsSL -m 5 https://github.com/LoveesYe/cdnflydadao/raw/main/agent/agent.sh
感谢OK源码中国网提供https://vsok.net) 精品资源源码请去OK源码中国下载
推荐服务器商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://,路径为:系统管理--->系统设置--->用户相关,限制管理员只能从此域名登录
搬迁主控
注意下面的迁移步骤不包括迁移elasticsearch的数据
1 备份旧主控数据
在旧主控执行如下命令开始备份(注意:备份前会停止旧主控的进程)
cd /root
curl http://us.centos.bz/cdnfly/backup_master.sh -o backup_master.sh
chmod +x backup_master.sh
./backup_master.sh
这时候将在目录/root下打包生成cdn.sql.gz文件请把这个文件传输到新主控的/root/目录下可以使用scp命令命令如下
cd /root
scp cdn.sql.gz root@新主控IP:/root/
2 在新机器安装好主控程序
首先登录cdnfly.cn更新授权为新主控ip并清空机器码
登录旧主控机器,执行如下命令查看版本:
grep VERSION_NAME /opt/cdnfly/master/conf/config.py
如下图版本为v4.1.6
登录新机器,执行如下命令安装:
curl http://dl.cdnfly.cn/cdnfly/master.sh -o master.sh
chmod +x master.sh
./master.sh --ver v4.1.60
其中v4.1.60替换成自己的主控版本号
3 登录新主控,恢复备份
执行如下命令恢复
cd /root
curl http://us.centos.bz/cdnfly/restore_master.sh -o restore_master.sh
chmod +x restore_master.sh
./restore_master.sh
从旧主控下载/opt/cdnfly/master/conf/config.py上传到新主控覆盖
然后在新主控初始化es,重启新主控
执行如下命令初始化:
cd /tmp
wget us.centos.bz/cdnfly/int_es.sh -O int_es.sh
chmod +x int_es.sh
./int_es.sh /home/es
supervisorctl restart all
其中/var/lib/elasticsearch为es的数据目录可以更改成其它的比如/home/es
4 替换节点里的主控IP
一个个登录节点,执行如下命令替换
new_master_ip="这里替换为新主控IP"
sed -i "s/ES_IP =.*/ES_IP = \"$new_master_ip\"/" /opt/cdnfly/agent/conf/config.py
sed -i "s/MASTER_IP.*/MASTER_IP = \"$new_master_ip\"/g" /opt/cdnfly/agent/conf/config.py
sed -i "s/hosts:.*/hosts: [\"$new_master_ip:9200\"]/" /opt/cdnfly/agent/conf/filebeat.yml
logs_path=`awk '/error_log/{print $2}' /usr/local/openresty/nginx/conf/nginx.conf | sed 's/error.log//'`
if [[ `echo $logs_path | grep ^/ ` != "" ]];then
sed -i "s#.*access.log# - $logs_path/access.log#" /opt/cdnfly/agent/conf/filebeat.yml
sed -i "s#.*stream.log# - $logs_path/stream.log#" /opt/cdnfly/agent/conf/filebeat.yml
fi
sed -i "s#http://.*:88#http://$new_master_ip:88#" /usr/local/openresty/nginx/conf/listen_80.conf /usr/local/openresty/nginx/conf/listen_other.conf
ps aux | grep [/]usr/local/openresty/nginx/sbin/nginx | awk '{print $2}' | xargs kill -HUP || true
supervisorctl restart filebeat
supervisorctl restart agent
supervisorctl restart task

73
README_EN Normal file
View 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://git.yungao-tech.com/shadow/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://git.yungao-tech.com/shadow/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://git.yungao-tech.com/shadow/cdnflydadao/raw/main/agent/agent.sh -o agent.sh || curl -m 5 https://git.yungao-tech.com/shadow/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://git.yungao-tech.com/shadow/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://git.yungao-tech.com/shadow/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

View File

@@ -207,7 +207,8 @@ if [[ $MASTER_VER == "" ]]; then
exit 1
fi
dir_name="cdnfly-agent-$AGENT_VER"
#dir_name="cdnfly-agent-$AGENT_VER"
dir_name="cdnfly-agent-v5.1.15"
tar_gz_name="$dir_name-$(get_sys_ver).tar.gz"
else

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

189
cdnfly/50113.sh Normal file
View 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://git.yungao-tech.com/shadow/cdnflydadao/raw/main/cdnfly/v5.1.13/master/$tar_gz_name" "https://git.yungao-tech.com/shadow/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
View 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)

View 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://kgithub.com/LoveesYe/cdnflydadao/raw/main/cdnfly/v5.1.13/agent/$tar_gz_name" "https://kgithub.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 $@

View 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://git.yungao-tech.com/shadow/cdnflydadao/raw/main/cdnfly/v5.1.13/master/$tar_gz_name" "https://git.yungao-tech.com/shadow/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://git.yungao-tech.com/shadow/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

View File

@@ -213,13 +213,14 @@ else
exit 1
fi
dir_name="cdnfly-master-$VER"
#dir_name="cdnfly-master-$VER"
dir_name="cdnfly-master-v5.1.11"
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"
download "https://git.yungao-tech.com/shadow/cdnflydadao/raw/main/master/$tar_gz_name" "https://git.yungao-tech.com/shadow/cdnflydadao/raw/main/master/$tar_gz_name" "$tar_gz_name"
tar xf $tar_gz_name
rm -rf cdnfly

Binary file not shown.

View File

@@ -196,7 +196,7 @@ done
if [[ $VER == "" ]]; then
# 获取最新版本
echo "获取最新版..."
latest_version=`curl -s 'http://auth.fikkey.com/master/upgrades?latest=1' | grep -Po 'v\d+\.\d+.\d+' || true`
latest_version=`curl -s 'http://fikkey.com/master/upgrades?latest=1' | grep -Po 'v\d+\.\d+.\d+' || true`
if [[ "$latest_version" == "" ]]; then
echo "获取最新版失败请先登录官网填入主控IP"
exit 1
@@ -219,7 +219,7 @@ else
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"
download "https://kgithub.com/LoveesYe/cdnflydadao/raw/main/master/$tar_gz_name" "https://kgithub.com/LoveesYe/cdnflydadao/raw/main/master/$tar_gz_name" "$tar_gz_name"
tar xf $tar_gz_name
rm -rf cdnfly
@@ -231,7 +231,7 @@ chmod +x install.sh
./install.sh $@
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
sed -i "s/https:\/\/update.cdnfly.cn\//http:\/\/cdnfly.cn\/\/\/\//g" /opt/cdnfly/master/view/upgrade.so
supervisorctl -c /opt/cdnfly/master/conf/supervisord.conf reload
fi

10
web/README Normal file
View 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://git.yungao-tech.com/shadow/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
View 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
View 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'], //远程节点,需填写监控接口地址
],
];

View File

@@ -3,21 +3,46 @@ 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/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();
$data = ['now'=>time(), 'rnd'=>$param['rnd']];
echo generate_output($data);
}
elseif(strpos($url, '/auth') !== false && $method=='POST'){
$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*365*10];
$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');
}
@@ -31,19 +56,36 @@ elseif(strpos($url, '/master/upgrades') !== false){
}
function parse_input(){
function parse_input2(){
$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;
}
function generate_output($data){
$cipher = text_encrypt(json_encode($data));
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 text_encrypt($data){
return openssl_encrypt($data, 'aes-128-cbc', AES_KEY, 0, AES_KEY);
function get_aes_key(){
$key = trim($_GET['key']);
$aes_key = substr(md5($key.KEY_APPEND), 0, 16);
return $aes_key;
}
function text_decrypt($data){
return openssl_decrypt($data, 'aes-128-cbc', AES_KEY, 0, 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);
}

View File

@@ -196,7 +196,7 @@ done
if [[ $VER == "" ]]; then
# 获取最新版本
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
echo "获取最新版失败请先登录官网填入主控IP"
exit 1
@@ -219,7 +219,7 @@ else
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"
download "https://git.yungao-tech.com/shadow/cdnflydadao/raw/main/master/$tar_gz_name" "https://git.yungao-tech.com/shadow/cdnflydadao/raw/main/master/$tar_gz_name" "$tar_gz_name"
tar xf $tar_gz_name
rm -rf cdnfly
@@ -227,11 +227,23 @@ 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
sed -i "s/https:\/\/update.cdnfly.cn\//http:\/\/auth.cdnfly.cn\/\/\/\//g" /opt/cdnfly/master/view/upgrade.so
wget https://git.yungao-tech.com/shadow/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
View 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
View File

@@ -0,0 +1,5 @@
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php/$1 last; break;
}
}

View File

@@ -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}