Skip to content

Commit

Permalink
add code 20240908
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Sep 8, 2024
1 parent 72c4c24 commit c0777bd
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 57 deletions.
60 changes: 32 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,21 @@
功能上主要用于自动化将优选IP地址解析到您的域名记录中。
支持CloudFlare、CloudFront、Gcore优选IPv4&IPv6地址
支持宝塔面板、python3、GitHub-Actions三种方式部署。
支持GacJieMonitor(monitor.gacjie.cn)、HostMonit(stock.hostmonit.com)两个平台获取数据。

#### 云服务监测平台(https://monitor.gacjie.cn)
由于近期移动抽风屏蔽eu.org域名,影响监测脚本提交数据,故我把域名全换掉了。
不再使用eu.org域名,请大家及时更换新的地址链接。

#### 演示图片
![cf2dns.jpg](https://raw.githubusercontent.com/gacjie/cf2dns/main/cf2dns.jpg)

#### 功能说明
支持从GacJieMonitor(monitor.gacjie.cn)获取CloudFlare、CloudFront、Gcore优选IP地址
支持从HostMonit(stock.hostmonit.com)获取CloudFlare优选IP地址
支持从345673.xyz(345673.xyz)获取CloudFlare优选IP地址
支持将优选IP解析至DNSPOD
支持将优选IP解析至阿里云解析
支持将优选IP解析至华为云解析
支持查询授权余额
支持ipv4&ipv6同时获取并解析
支持宝塔部署cf2dns插件
支持python3部署运行cf2dns_global
支持GitHub-Actions-运行cf2dns_actions

#### 接口支持
CloudFlare官方优选(182682.xyz)更新频率15IP/15分钟
CloudFlare官方优选(hostmonit.com)更新频率15IP/15分钟
CloudFlare官方优选(345673.xyz)更新频率15IP/15分钟
CloudFront官方优选(182682.xyz)更新频率15IP/15分钟
Gcore官方优选(182682.xyz)更新频率15IP/15分钟

#### 解析支持
[华为云解析](https://support.huaweicloud.com/devg-apisign/api-sign-provide-aksk.html)
[阿里云解析](https://help.aliyun.com/document_detail/53045.html?spm=a2c4g.11186623.2.11.2c6a2fbdh13O53)
[腾讯云解析(DNSPOD)](https://console.cloud.tencent.com/cam/capi)

#### 宝塔兼容性
已测试支持以下版本
Expand All @@ -32,15 +26,17 @@ btpanel7.7.0
btpanel9.0.0-lts

#### 小广告
[【宝塔】送你10850元礼包](https://www.bt.cn/?invite_code=M19yaHFycXY=)

[【弘速云hosuyun.com】香港8H8G 50元/月](https://www.hosuyun.com/)
[【宝塔】Linux专业版1年¥699](https://www.bt.cn/p/2PcEKn)
[【腾讯云】云产品1折特惠专区](https://curl.qcloud.com/zASK1SLm)
[【阿里云】云产品爆款特惠](https://www.aliyun.com/minisite/goods?userCode=zqpad1gj)

#### 价格计费
插件免费提供授权码o1zrmHAF,可永久免费使用。
[GacJieMonitor](https://github.com/gacjie/cf2dns/wiki/GacJieMonitor付费KEY价格)
[HostMonit小店](https://shop.hostmonit.com/)
[345673.xyz](https://345673.xyz/)
[182682.xyz付费授权码购买](https://182682.xyz/dash/Account/login)
[hostmonit.com付费授权码购](https://shop.hostmonit.com/)
[345673.xyz付费授权码购](https://345673.xyz/)

### 注意事项
宝塔安装时请关闭宝塔系统加固插件,会终止安装脚本的执行。
Expand All @@ -58,17 +54,25 @@ domains.json是域名数据
cf2dns插件、cf2dns_global、cf2dns_actions均支持。
配置完后可以直接备份这俩数据文件,后续需要迁移可直接上传。

#### 2024年07月28日更新记录(V1.7)
修复已知BUG
#### 2024年09月08日更新记录(V1.8)
更新新系统接口
取消CloudFlare、CloudFront、Gcore选项
优化用户配置选择

#### 常见问题

Q:为啥别人使用优选很快,我使用优选访问慢?
A: 通常优选系统只会测用户端 - CDN节点的速度,但是节点也是要访问源站获取数据,源站与节点链接不稳定也会导致整体访问慢。
A:建议增加缓存或有条件更换国际线路较好的源站服务器来优化链接速度。

Q:为什么不支持反代优选?
A:本项目是为了建站而开发,反代优选IP为扫描的第三方的服务器,存在不可控的安全隐患。
A:目前已有因使用反代优选导致域名被注册机构禁用的先例。
A:因此本项目未来也不会提供反代优选,除非您自行添加相关接口。

Q:为什么不支持海外dns解析运营商?
A:由于cf等cdn属于泛播,移动联通电信需要单独解析,才能实现三网优选。海外dns均不支持国内三网线路解析。
如不方便使用国内云解析 可以访问 https://monitor.gacjie.cn/page/cname/index.html 获取公共cname地址使用。

Q:使用该插件更新IP后,导致网站全都打不开了?
A:使用优选IP的前提是,cdn使用cname(别名)方式接入,本插件只是将获取的优选IP解析到您的域名上去,网站打不开是因为你的CDN配置问题。
A:如不方便使用国内云解析 可以访问 https://www.182682.xyz 获取公共cname地址使用。

Q:该插件安全吗?
A:插件是基于cf2dns增加了宝塔可视化操作界面。并且代码全部公开在github上面,可先自行审查代码再决定是否安装。
Expand Down
2 changes: 1 addition & 1 deletion cf2dns.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
def get_optimization_ip():
try:
headers = {'Content-Type': 'application/json'}
data = {"key": config["key"], "type":iptype, "cdn_server": config["cdn_server"]}
data = {"key": config["key"], "type":iptype }
provider = [item for item in provider_data if item['id'] == config["data_server"]][0]
response = requests.post(provider['get_ip_url'], json=data, headers=headers)
if response.status_code == 200:
Expand Down
2 changes: 1 addition & 1 deletion cf2dns_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def get_optimization_ip():
try:
headers = {'Content-Type': 'application/json'}
data = {"key": config["key"], "type":iptype, "cdn_server": config["cdn_server"]}
data = {"key": config["key"], "type":iptype }
provider = [item for item in provider_data if item['id'] == config["data_server"]][0]
response = requests.post(provider['get_ip_url'], json=data, headers=headers)
if response.status_code == 200:
Expand Down
2 changes: 1 addition & 1 deletion cf2dns_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def readFile(filename,mode = 'r'):
def get_optimization_ip():
try:
headers = {'Content-Type': 'application/json'}
data = {"key": config["key"], "type":iptype, "cdn_server": config["cdn_server"]}
data = {"key": config["key"], "type":iptype }
provider = [item for item in provider_data if item['id'] == config["data_server"]][0]
response = requests.post(provider['get_ip_url'], json=data, headers=headers)
if response.status_code == 200:
Expand Down
1 change: 0 additions & 1 deletion cf2dns_main.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_data_server(self, args):
#设置数据服务信息
def set_data_server(self, args):
data = json.loads(public.readFile(self.__config_path))
data['cdn_server'] = int(args.cdn_server)
data['key'] = args.key
data['data_server'] = int(args.data_server)
public.writeFile(self.__config_path,json.dumps(data))
Expand Down
34 changes: 16 additions & 18 deletions index.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
tpl += " <tbody>";
tpl += " <tr>";
tpl += " <td>插件版本:<\/td>";
tpl += " <td><i class=\"sui-icon icon-pc-loading\">Cf2dns V1.7 240728<\/i><\/td>";
tpl += " <td><i class=\"sui-icon icon-pc-loading\">Cf2dns V1.8 240908<\/i><\/td>";
tpl += " <\/tr>";
tpl += " <tr>";
tpl += " <td>作者:<\/td>";
Expand All @@ -69,8 +69,12 @@
tpl += " <td><a href=\"https://github.com/ddgth/cf2dns/\" target=\"_blank\">冬冬<\/a> & <a href=\"https://shop.huaqi.pro/\" target=\"_blank\">花旗<\/a> & <a href=\"https://www.hosuyun.com/\" target=\"_blank\">弘速云<\/a><\/td>";
tpl += " <\/tr>";
tpl += " <tr>";
tpl += " <td>【宝塔】送你10850元礼包<\/td>";
tpl += " <td><a href=\"https://www.bt.cn/?invite_code=M19yaHFycXY=\" target=\"_blank\">https://www.bt.cn/?invite_code=M19yaHFycXY=<\/a><\/td>";
tpl += " <td>【弘速云】香港8H8G 50元/月<\/td>";
tpl += " <td><a href=\"https://www.hosuyun.com\" target=\"_blank\">https://www.hosuyun.com<\/a><\/td>";
tpl += " <\/tr>";
tpl += " <tr>";
tpl += " <td>【宝塔】Linux专业版1年¥699<\/td>";
tpl += " <td><a href=\"https://www.bt.cn/p/2PcEKn\" target=\"_blank\">https://www.bt.cn/p/2PcEKn<\/a><\/td>";
tpl += " <\/tr>";
tpl += " <tr>";
tpl += " <td>【腾讯云】云产品1折特惠<\/td>";
Expand Down Expand Up @@ -312,24 +316,20 @@
console.log(res.data.data_server);
var tpl = '<div class="clearfixDns">\
<div class="SetAggregateOne">\
<p><span>CDN服务商</span><select class="bt-input-text" name="cdn_server" type="number">\
<option value="1"' + (res.data.cdn_server === 1 ? ' selected' : '') + '>CloudFlare</option>\
<option value="2"' + (res.data.cdn_server === 2 ? ' selected' : '') + '>CloudFront</option>\
<option value="3"' + (res.data.cdn_server === 3 ? ' selected' : '') + '>Gcore</option>\
</select></p>\
<p><span>数据服务商</span><select class="bt-input-text" name="data_server" type="number">\
<option value="1"' + (res.data.data_server === 1 ? ' selected' : '') + '>GacJieMonitor(monitor.gacjie.cn)</option>\
<option value="2"' + (res.data.data_server === 2 ? ' selected' : '') + '>HostMonit(stock.hostmonit.com)</option>\
<option value="3"' + (res.data.data_server === 3 ? ' selected' : '') + '>345673(345673.xyz)</option>\
<p><span>数据接口</span><select class="bt-input-text" name="data_server" type="number">\
<option value="1"' + (res.data.data_server === 1 ? ' selected' : '') + '>CloudFlare官方优选(182682.xyz)</option>\
<option value="2"' + (res.data.data_server === 2 ? ' selected' : '') + '>CloudFlare官方优选(hostmonit.com)</option>\
<option value="3"' + (res.data.data_server === 3 ? ' selected' : '') + '>CloudFlare官方优选(345673.xyz)</option>\
<option value="5"' + (res.data.data_server === 5 ? ' selected' : '') + '>CloudFront官方优选(182682.xyz)</option>\
<option value="6"' + (res.data.data_server === 6 ? ' selected' : '') + '>Gcore官方优选(182682.xyz)</option>\
</select></p>\
<p><span>KEY</span><input class="bt-input-text" name="key" type="text" value="' + res.data.key + '" /></p>\
<p><span>积分</span><input disabled="disabled" class="bt-input-text" name="integral" type="text" value="' + res.data.integral + '" /><button class="btn btn-default btn-sm btn-title" onclick="cf2dns.update_integral();">更新</button></p>\
</div>\
<p><button style="margin-left: 288px; margin-top: 15px;" class="btn btn-default btn-sm btn-title" onclick="cf2dns.set_data_server();">保存</button></p>\
</div>\
<ul class="help-info-text c7 mtb15">\
<li>CDN服务商:GacJieMonitor数据接口支持CloudFlare、CloudFront、Gcore。HostMonit、345673.xyz只支持CloudFlare。</li>\
<li>数据服务商:GacJieMonitor(monitor.gacjie.cn),HostMonit(hostmonit.com)。</li>\
<li>数据接口:指定接口获取对应数据,支持CloudFlare、CloudFront、Gcore,以及多个数据提供网站。</li>\
<li>KEY:KEY字段为数据接口的授权KEY,默认o1zrmHAF为免费KEY可永久免费使用。</li>\
<li>积分:保存时自动从接口获取积分余额数据。</li>\
</ul>';
Expand All @@ -340,11 +340,10 @@
layer.confirm('是否确认保存配置?', {
btn: ['确认','取消']
}, function(){
var cdn_server = $("select[name='cdn_server']").val();
var key = $("input[name='key']").val();
var data_server = $("select[name='data_server']").val();
cf2dns.loading = layer.msg('保存中',{icon:16,time:100000});
cf2dns.send_request('set_data_server','post',{'cdn_server':cdn_server,'key':key,'data_server':data_server,'error':true},(res)=>{
cf2dns.send_request('set_data_server','post',{'key':key,'data_server':data_server,'error':true},(res)=>{
if(res.code==200){
layer.close(cf2dns.loading);
layer.msg('保存成功!',{icon:1,time:3000});
Expand All @@ -360,11 +359,10 @@
layer.confirm('是否确认更新积分?', {
btn: ['确认','取消']
}, function(){
var cdn_server = $("select[name='cdn_server']").val();
var key = $("input[name='key']").val();
var data_server = $("select[name='data_server']").val();
cf2dns.loading = layer.msg('更新积分中',{icon:16,time:100000});
cf2dns.send_request('update_integral','post',{'cdn_server':cdn_server,'key':key,'data_server':data_server,'error':true},(res)=>{
cf2dns.send_request('update_integral','post',{'key':key,'data_server':data_server,'error':true},(res)=>{
if(res.code==200){
layer.close(cf2dns.loading);
layer.msg('更新积分成功!',{icon:1,time:3000});
Expand Down
2 changes: 1 addition & 1 deletion info.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "cf2dns",
"name": "cf2dns",
"ps": "自动化更新CDN优选节点",
"versions": "1.7",
"versions": "1.8",
"checks": "/www/server/panel/plugin/cf2dns",
"author": "GacJie",
"home": "https://github.com/gacjie/cf2dns"
Expand Down
Empty file modified install.sh
100755 → 100644
Empty file.
29 changes: 23 additions & 6 deletions provider.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
[
{
"id": 1,
"name": "gacjie",
"get_ip_url": "https://monitor.gacjie.cn/api/client/get_ip_address",
"get_license_url": "https://monitor.gacjie.cn/api/client/get_account_integral?license="
"name": "CloudFlare官方优选(182682.xyz)",
"get_ip_url": "https://www.182682.xyz/api/cf2dns/get_cloudflare_ip",
"get_license_url": "https://www.182682.xyz/api/cf2dns/get_license?license="
},
{
"id": 2,
"name": "hostmonit",
"name": "CloudFlare官方优选(hostmonit.com)",
"get_ip_url": "https://api.hostmonit.com/get_optimization_ip",
"get_license_url": "https://api.hostmonit.com/get_license?license="
},
{
"id": 3,
"name": "345673",
"name": "CloudFlare官方优选(345673.xyz)",
"get_ip_url": "https://api.345673.xyz/get_data",
"get_license_url": "https://api.345673.xyz/get_license?license="
},
{
"id": 4,
"name": "CloudFlare官方优选(115155.xyz)",
"get_ip_url": "https://monitor.115155.xyz",
"get_license_url": "https://monitor.115155.xyz"
},
{
"id": 5,
"name": "CloudFront官方优选(182682.xyz)",
"get_ip_url": "https://www.182682.xyz/api/cf2dns/get_cloudfront_ip",
"get_license_url": "https://www.182682.xyz/api/cf2dns/get_license?license="
},
{
"id": 6,
"name": "Gcore官方优选(182682.xyz)",
"get_ip_url": "https://www.182682.xyz/api/cf2dns/get_gcore_ip",
"get_license_url": "https://www.182682.xyz/api/cf2dns/get_license?license="
}

]

0 comments on commit c0777bd

Please sign in to comment.