-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
726 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
**/__pycache__ | ||
**/*venv | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
*.db | ||
.python-version | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM python:3.8-slim-buster | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
# Keeps Python from generating .pyc files in the container | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# Turns off buffering for easier container logging | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /cf2dns | ||
|
||
COPY . /cf2dns | ||
|
||
# Install pip requirements | ||
RUN python -m pip install --no-cache-dir --upgrade -r requirements.txt | ||
|
||
|
||
|
||
# Creates a non-root user with an explicit UID and adds permission to access the /app folder | ||
#RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app | ||
#USER appuser | ||
|
||
CMD ["python3", "src/main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
### 增加dddb/cf2dns docker镜像 --update 2024.6.4 | ||
|
||
> 使用方法 | ||
1. 拉取cf2dns docker镜像 `docker pull dddb/cf2dns` | ||
|
||
2. 新建cf2dns_docker工作路径 `cd ~ && mkdir -p cf2dns_docker/logs && cd cf2dns_docker` | ||
|
||
3. 下载所需配置文件 `wget --no-check-certificate -qO ./config.ini https://raw.githubusercontent.com/ddgth/cf2dns/master/docker/src/config.ini` | ||
|
||
4. 根据注释修改`config.ini`配置文件 | ||
|
||
5. 运行docker镜像 `docker run -d -v ~/cf2dns_docker/config.ini:/cf2dns/src/config.ini -v ~/cf2dns_docker/logs:/cf2dns/logs dddb/cf2dns` | ||
|
||
6. 查看运行日志 `tail -100f ~/cf2dns_docker/logs/cf2dns.log` | ||
|
||
|
||
|
||
wget --no-check-certificate -qO ./config.ini https://raw.githubusercontent.com/ddgth/cf2dns/master/docker/src/config.ini | ||
|
||
根据注释修改config.ini配置文件 | ||
|
||
docker run -d -v ./cf2dns_docker/src/config.ini:/cf2dns/src/config.ini -v ./cf2dns_docker/logs:/cf2dns/logs cf2dns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
aliyun-python-sdk-alidns==2.6.19 | ||
aliyun-python-sdk-core==2.13.29 | ||
huaweicloudsdkcore==3.1.5 | ||
huaweicloudsdkdns==3.1.5 | ||
requests==2.28.1 | ||
tencentcloud-sdk-python==3.0.806 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[DEFAULT] | ||
;也可以从https://shop.hostmonit.com获取 | ||
KEY = o1zrmHAF | ||
|
||
;修改需要优选的域名、子域名和线路信息 示例表示要优选的域名有 hostxxnit.com, shop.hostxxnit.com stock.hostxxnit.com, 484848.xyz, shop.484848.xyz | ||
;优选线路字典对照表 CM:移动 CU:联通 CT:电信 AB:境外 DEF:默认 | ||
DOMAINS = {"hostxxnit.com": {"@": ["CM","CU","CT"], "shop": ["CM", "CU", "CT"], "stock": ["CM","CU","CT"]},"484848.xyz": {"@": ["CM","CU","CT"], "shop": ["CM","CU","CT"]}} | ||
|
||
;解析生效条数 免费版DNSPod相同线路最多支持2条解析 | ||
AFFECT_NUM = 2 | ||
|
||
;DNS服务商 DNSPod: 1, 阿里云: 2, 华为云: 3 | ||
DNS_SERVER = 1 | ||
|
||
;如果使用华为云解析 需要从API凭证-项目列表中获取 REGION | ||
REGION_HW = cn-east-3 | ||
|
||
;如果使用阿里云解析 REGION出现错误再修改 默认不需要修改 https://help.aliyun.com/document_detail/198326.html | ||
REGION_ALI = cn-hongkong | ||
|
||
;解析生效时间,默认为600秒 如果不是DNS付费版用户 不要修改!!! | ||
TTL = 600 | ||
|
||
;v4为筛选出IPv4的IP v6为筛选出IPv6的IP | ||
TYPE = v4 | ||
|
||
;API 密钥 | ||
;腾讯云后台获取 https://console.cloud.tencent.com/cam/capi | ||
;阿里云后台获取 https://help.aliyun.com/document_detail/53045.html?spm=a2c4g.11186623.2.11.2c6a2fbdh13O53 注意需要添加DNS控制权限 AliyunDNSFullAccess | ||
;华为云后台获取 https://support.huaweicloud.com/devg-apisign/api-sign-provide-aksk.html | ||
SECRETID = WTTCWxxxxxxxxxxxxxxxxxxxxx84O0V | ||
SECRETKEY = GXkG6D4X1Nxxxxxxxxxxxxxxxxxxxxx4lRg6lT | ||
|
||
;间隔多长时间执行一次 单位:秒 | ||
TIMES = 300 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Mail: [email protected] | ||
# Reference: https://help.aliyun.com/document_detail/29776.html?spm=a2c4g.11186623.2.38.3fc33efexrOFkT | ||
# REGION: https://help.aliyun.com/document_detail/198326.html | ||
import json | ||
from aliyunsdkcore import client | ||
from aliyunsdkalidns.request.v20150109 import DescribeDomainRecordsRequest | ||
from aliyunsdkalidns.request.v20150109 import DeleteDomainRecordRequest | ||
from aliyunsdkalidns.request.v20150109 import UpdateDomainRecordRequest | ||
from aliyunsdkalidns.request.v20150109 import AddDomainRecordRequest | ||
|
||
|
||
rc_format = 'json' | ||
class AliApi(): | ||
def __init__(self, ACCESSID, SECRETKEY, REGION='cn-hongkong'): | ||
self.access_key_id = ACCESSID | ||
self.access_key_secret = SECRETKEY | ||
self.region = REGION | ||
|
||
def del_record(self, domain, record): | ||
clt = client.AcsClient(self.access_key_id, self.access_key_secret, self.region) | ||
request = DeleteDomainRecordRequest.DeleteDomainRecordRequest() | ||
request.set_RecordId(record) | ||
request.set_accept_format(rc_format) | ||
result = clt.do_action(request).decode('utf-8') | ||
result = json.JSONDecoder().decode(result) | ||
return result | ||
|
||
def get_record(self, domain, length, sub_domain, record_type): | ||
clt = client.AcsClient(self.access_key_id, self.access_key_secret, self.region) | ||
request = DescribeDomainRecordsRequest.DescribeDomainRecordsRequest() | ||
request.set_DomainName(domain) | ||
request.set_PageSize(length) | ||
request.set_RRKeyWord(sub_domain) | ||
request.set_Type(record_type) | ||
request.set_accept_format(rc_format) | ||
result = clt.do_action(request).decode('utf-8').replace('DomainRecords', 'data', 1).replace('Record', 'records', 1).replace('RecordId', 'id').replace('Value', 'value').replace('Line', 'line').replace('telecom', '电信').replace('unicom', '联通').replace('mobile', '移动').replace('oversea', '境外').replace('default', '默认') | ||
result = json.JSONDecoder().decode(result) | ||
return result | ||
|
||
def create_record(self, domain, sub_domain, value, record_type, line, ttl): | ||
clt = client.AcsClient(self.access_key_id, self.access_key_secret, self.region) | ||
request = AddDomainRecordRequest.AddDomainRecordRequest() | ||
request.set_DomainName(domain) | ||
request.set_RR(sub_domain) | ||
if line == "电信": | ||
line = "telecom" | ||
elif line == "联通": | ||
line = "unicom" | ||
elif line == "移动": | ||
line = "mobile" | ||
elif line == "境外": | ||
line = "oversea" | ||
elif line == "默认": | ||
line = "default" | ||
request.set_Line(line) | ||
request.set_Type(record_type) | ||
request.set_Value(value) | ||
request.set_TTL(ttl) | ||
request.set_accept_format(rc_format) | ||
result = clt.do_action(request).decode('utf-8') | ||
result = json.JSONDecoder().decode(result) | ||
return result | ||
|
||
def change_record(self, domain, record_id, sub_domain, value, record_type, line, ttl): | ||
clt = client.AcsClient(self.access_key_id, self.access_key_secret, self.region) | ||
request = UpdateDomainRecordRequest.UpdateDomainRecordRequest() | ||
request.set_RR(sub_domain) | ||
request.set_RecordId(record_id) | ||
if line == "电信": | ||
line = "telecom" | ||
elif line == "联通": | ||
line = "unicom" | ||
elif line == "移动": | ||
line = "mobile" | ||
elif line == "境外": | ||
line = "oversea" | ||
elif line == "默认": | ||
line = "default" | ||
request.set_Line(line) | ||
request.set_Type(record_type) | ||
request.set_Value(value) | ||
request.set_TTL(ttl) | ||
request.set_accept_format(rc_format) | ||
result = clt.do_action(request).decode('utf-8') | ||
result = json.JSONDecoder().decode(result) | ||
return result | ||
|
Oops, something went wrong.