惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
Spread Privacy
Spread Privacy
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
S
Schneier on Security
B
Blog
The Register - Security
The Register - Security
SecWiki News
SecWiki News
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
T
Tenable Blog
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
D
DataBreaches.Net
S
Secure Thoughts
Security Latest
Security Latest
H
Heimdal Security Blog
The Hacker News
The Hacker News
O
OpenAI News
AWS News Blog
AWS News Blog
量子位
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
腾讯CDC
U
Unit 42
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hugging Face - Blog
Hugging Face - Blog
The Last Watchdog
The Last Watchdog
Recorded Future
Recorded Future
V2EX - 技术
V2EX - 技术
爱范儿
爱范儿
F
Full Disclosure

Dosk 技术站

华为荣耀电视盒子刷 Armbian - Dosk 技术站 记录一个没意义的 usb wifi 驱动编译 - Dosk 技术站 我的 2024 - Dosk 技术站 unRAID 7.0.0-beta.1 - Dosk 技术站 关于 unraider 的开心版 - Dosk 技术站 unRAID 6.12.7-rc2 进展 - Dosk 技术站 每年问自己 40 个问题 - Dosk 技术站 Kubernetes 集群导航页 - Dosk 技术站 2023 年度总结 - Dosk 技术站 N100 万兆软路由最终形态 - Dosk 技术站 N100 软路由改造下散热 - Dosk 技术站 N100 万兆软路由测测速 - Dosk 技术站 整活新玩具,半 DIY 一个万兆软路由 - Dosk 技术站 玩玩 WebAuthn:RP2040 One - Dosk 技术站 关于最近以及后续要做什么 - Dosk 技术站 unRAID 6.12.0-rc7/6.12.0-rc6.13 - Dosk 技术站 unRAID 6.12.0-beta18 试用 - Dosk 技术站 unRAID 6.11.4 如何继续开心 - Dosk 技术站 cert-manager 基于 acme.sh 的 webhook - Dosk 技术站 unRAID 虚拟机运行 unRAID 简单步骤 - Dosk 技术站 解决 Chrome 原生谷歌翻译功能的一个思路:3/3 - Dosk 技术站 解决 Chrome 原生谷歌翻译功能的一个思路:1/3 - Dosk 技术站 unraid 命令行包管理器 - Dosk 技术站 继续,unraid 6.11 happy 的方法 - Dosk 技术站 适用于 k8s 的 frpc ingress 实现 - Dosk 技术站 实现了一个简单的通配 DNS 服务 - Dosk 技术站 代码更新,happy unraid 懒人版 - Dosk 技术站 复盘一次群晖的 btrfs + docker:dind 引发的灾难 - Dosk 技术站 unraid 官方版不修改不用 keymaker 可持续 happy 的方法 - Dosk 技术站 unraid 实现完美硬盘启动 - Dosk 技术站 rpi3b+ 跑 pi-kvm 项目记录 - Dosk 技术站 记录一下 docker 里跑 dsm 迅雷套件的过程 - Dosk 技术站 docker 更新,整理 build - Dosk 技术站 记录下 openwrt 改交换机的步骤,以及注意事项 - Dosk 技术站 docker 里跑 openwrt 遇到的奇奇怪怪问题修复 - Dosk 技术站 OpenWrt 添加一个 socat 的 luci web 界面 - Dosk 技术站 在 NAS 里优雅的使用迅雷 - Dosk 技术站 记录一次 rpi4b 使用 openwrt docker 接管网络 - Dosk 技术站 悲伤是一件很耗费精力的事情 - Dosk 技术站 Tablet 板绘 - 梅花 - Dosk 技术站 Chromium 代码下并发 Callback 的骚操作 - Dosk 技术站 Tablet 板绘 - 月光 - Dosk 技术站 测试测试 Forestry - 一个 Jekyll CMS - Dosk 技术站 如何从 Chromium “偷” UI - Dosk 技术站 Cocoa 如何创建置于全屏之上的 NSWindow - Dosk 技术站 修改 Prose 支持中文标题 - Dosk 技术站 macOS & Windows 实现系统/进程/线程的 CPU 统计 - Dosk 技术站 STL 内 std::{bind/tuple/function} 简单实现 - Dosk 技术站 Cocoa 修改 TitleBar 样式 - Dosk 技术站
Cloudflare DDNS 脚本,适配 OpenWrt,自带的不好用 - Dosk 技术站
2021-11-18 · via Dosk 技术站
#!/bin/ash

# Base env
export PATH='/usr/sbin:/usr/bin:/sbin:/bin'

# Params
API_TOKEN='XXXXXXXXXXXXXXXXXXXXXX'
API_TARGET_DOMAIN_4='ip4.dosk.win'
API_TARGET_DOMAIN_6='ip6.dosk.win'
API_ROOT_DOMAIN='dosk.win'

# Runtime params
IP4="$(ifstatus wan | jsonfilter -e '@["ipv4-address"][0].address')"
IP6="$(ifstatus wan6 | jsonfilter -e '@["ipv6-address"][0].address')"

# Functions
base_request() {
  API="$1"
  curl -s \
    -X GET "https://api.cloudflare.com/client/v4/$API" \
    -H "Authorization: Bearer $API_TOKEN" \
    -H "Content-Type:application/json"
}

base_update() {
  API="$1"
  DATA="$2"
  curl -s \
    -X PUT "https://api.cloudflare.com/client/v4/$API" \
    -H "Authorization: Bearer $API_TOKEN" \
    -H "Content-Type:application/json" \
    --data "$DATA"
}

ddns_log() {
  echo "$@"
}

# Main
ddns_log 'Get domain zone id ...'
sleep 1
zone_id="$(base_request "zones?name=$API_ROOT_DOMAIN" | jsonfilter -e '@["result"][0].id')"

ddns_log 'Get IPv4 domain record info ...'
sleep 1
v4_info="$(base_request "zones/$zone_id/dns_records?name=$API_TARGET_DOMAIN_4&type=A")"
v4_record_id="$(echo $v4_info | jsonfilter -e '@["result"][0].id')"
v4_record_ip="$(echo $v4_info | jsonfilter -e '@["result"][0].content')"

ddns_log 'Get IPv6 domain record info ...'
sleep 1
v6_info="$(base_request "zones/$zone_id/dns_records?name=$API_TARGET_DOMAIN_6&type=AAAA")"
v6_record_id="$(echo $v6_info | jsonfilter -e '@["result"][0].id')"
v6_record_ip="$(echo $v6_info | jsonfilter -e '@["result"][0].content')"

ddns_log 'Info summary ...'
sleep 1
ddns_log "IPv4 - $v4_record_id: from $v4_record_ip to $IP4"
ddns_log "IPv6 - $v6_record_id: from $v6_record_ip to $IP6"

if [ "$IP4" != "$v4_record_ip" ];
then
  ddns_log 'Do update IPv4 ...'
  sleep 1
  base_update "zones/$zone_id/dns_records/$v4_record_id" "{\"type\":\"A\",\"name\":\"$API_TARGET_DOMAIN_4\",\"content\":\"$IP4\",\"ttl\":1}" | jsonfilter -e '@["success"]'
fi

if [ "$IP6" != "$v6_record_ip" ];
then
  ddns_log 'Do update IPv6 ...'
  sleep 1
  base_update "zones/$zone_id/dns_records/$v6_record_id" "{\"type\":\"AAAA\",\"name\":\"$API_TARGET_DOMAIN_6\",\"content\":\"$IP6\",\"ttl\":1}" | jsonfilter -e '@["success"]'
fi

ddns_log 'All done !'