From 3995843c449e26057691a543f5ab2dba0323add0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 20:20:39 +0800 Subject: [PATCH] update 2023-02-01 20:20:39 --- ariang/Makefile | 71 + ariang/files/80_ariang-nginx-support | 5 + ariang/files/ariang.locations | 4 + brook/Makefile | 84 +- cgroupfs-mount/Makefile | 47 + cgroupfs-mount/files/cgroupfs-mount.init | 12 + chinadns-ng/Makefile | 80 +- coremark/Makefile | 86 + ddns-scripts/Makefile | 623 +++ ddns-scripts/files/etc/config/ddns | 32 + ddns-scripts/files/etc/hotplug.d/iface/ddns | 11 + ddns-scripts/files/etc/init.d/ddns | 27 + ddns-scripts/files/usr/bin/ddns.sh | 172 + .../usr/lib/ddns/dynamic_dns_functions.sh | 1403 ++++++ .../usr/lib/ddns/dynamic_dns_lucihelper.sh | 172 + .../files/usr/lib/ddns/dynamic_dns_updater.sh | 436 ++ .../usr/lib/ddns/update_cloudflare_com_v4.sh | 202 + .../files/usr/lib/ddns/update_cnkuai_cn.sh | 86 + .../lib/ddns/update_digitalocean_com_v2.sh | 40 + .../files/usr/lib/ddns/update_dnspod_cn.sh | 137 + .../usr/lib/ddns/update_freedns_42_pl.sh | 17 + .../files/usr/lib/ddns/update_gandi_net.sh | 39 + .../usr/lib/ddns/update_godaddy_com_v1.sh | 172 + .../files/usr/lib/ddns/update_no-ip_com.sh | 54 + .../files/usr/lib/ddns/update_ns1_com.sh | 77 + .../files/usr/lib/ddns/update_nsupdate.sh | 48 + .../files/usr/lib/ddns/update_one_com.sh | 142 + .../files/usr/lib/ddns/update_pdns.sh | 52 + .../files/usr/lib/ddns/update_route53_v1.sh | 95 + .../files/usr/lib/ddns/update_transip_nl.sh | 134 + .../usr/share/ddns/default/3322.org.json | 6 + .../usr/share/ddns/default/able.or.kr.json | 6 + .../ddns/default/afraid.org-basicauth.json | 9 + .../ddns/default/afraid.org-keyauth.json | 9 + .../ddns/default/afraid.org-v2-basic.json | 9 + .../ddns/default/afraid.org-v2-token.json | 9 + .../usr/share/ddns/default/all-inkl.com.json | 9 + .../usr/share/ddns/default/bind-nsupdate.json | 9 + .../usr/share/ddns/default/changeip.com.json | 7 + .../share/ddns/default/cloudflare.com-v4.json | 9 + .../usr/share/ddns/default/cnkuai.cn.json | 9 + .../share/ddns/default/core-networks.de.json | 11 + .../usr/share/ddns/default/ddnss.de.json | 7 + .../files/usr/share/ddns/default/ddo.jp.json | 6 + .../usr/share/ddns/default/desec.io.json | 11 + .../usr/share/ddns/default/dhis.org.json | 9 + .../ddns/default/digitalocean.com-v2.json | 9 + .../share/ddns/default/dnsdynamic.org.json | 7 + .../usr/share/ddns/default/dnsever.com.json | 6 + .../usr/share/ddns/default/dnsexit.com.json | 6 + .../usr/share/ddns/default/dnshome.de.json | 9 + .../share/ddns/default/dnsmadeeasy.com.json | 7 + .../usr/share/ddns/default/dnsmax.com.json | 6 + .../usr/share/ddns/default/dnsomatic.com.json | 7 + .../usr/share/ddns/default/dnspark.com.json | 7 + .../usr/share/ddns/default/dnspod.cn.json | 9 + .../files/usr/share/ddns/default/do.de.json | 11 + .../usr/share/ddns/default/domopoli.de.json | 7 + .../usr/share/ddns/default/dtdns.com.json | 6 + .../usr/share/ddns/default/duckdns.org.json | 11 + .../usr/share/ddns/default/duiadns.net.json | 9 + .../files/usr/share/ddns/default/dy.fi.json | 7 + .../files/usr/share/ddns/default/dyn.com.json | 11 + .../usr/share/ddns/default/dyndns.it.json | 7 + .../usr/share/ddns/default/dyndns.org.json | 11 + .../usr/share/ddns/default/dyndnss.net.json | 6 + .../usr/share/ddns/default/dynsip.org.json | 6 + .../usr/share/ddns/default/dynu.com.json | 9 + .../usr/share/ddns/default/dynv6.com.json | 11 + .../usr/share/ddns/default/easydns.com.json | 7 + .../usr/share/ddns/default/editdns.net.json | 6 + .../usr/share/ddns/default/freedns.42.pl.json | 6 + .../usr/share/ddns/default/gandi.net.json | 9 + .../share/ddns/default/godaddy.com-v1.json | 9 + .../files/usr/share/ddns/default/goip.de.json | 9 + .../usr/share/ddns/default/google.com.json | 11 + .../files/usr/share/ddns/default/he.net.json | 11 + .../share/ddns/default/infomaniak.com.json | 11 + .../files/usr/share/ddns/default/inwx.de.json | 11 + .../usr/share/ddns/default/joker.com.json | 7 + .../usr/share/ddns/default/loopia.se.json | 11 + .../usr/share/ddns/default/moniker.com.json | 7 + .../usr/share/ddns/default/mydns.jp.json | 9 + .../usr/share/ddns/default/myip.co.ua.json | 7 + .../ddns/default/myonlineportal.net.json | 11 + .../share/ddns/default/mythic-beasts.com.json | 9 + .../usr/share/ddns/default/namecheap.com.json | 6 + .../usr/share/ddns/default/nettica.com.json | 6 + .../usr/share/ddns/default/no-ip.com.json | 10 + .../usr/share/ddns/default/no-ip.pl.json | 9 + .../usr/share/ddns/default/now-dns.com.json | 11 + .../files/usr/share/ddns/default/ns1.com.json | 9 + .../usr/share/ddns/default/nsupdate.info.json | 11 + .../files/usr/share/ddns/default/one.com.json | 6 + .../usr/share/ddns/default/opendns.com.json | 7 + .../usr/share/ddns/default/oray.com.json | 6 + .../files/usr/share/ddns/default/ovh.com.json | 7 + .../files/usr/share/ddns/default/pdns.json | 9 + .../usr/share/ddns/default/regfish.de.json | 11 + .../usr/share/ddns/default/route53-v1.json | 9 + .../share/ddns/default/schokokeks.org.json | 7 + .../usr/share/ddns/default/selfhost.de.json | 7 + .../share/ddns/default/sitelutions.com.json | 7 + .../usr/share/ddns/default/spdyn.de.json | 11 + .../usr/share/ddns/default/strato.com.json | 7 + .../usr/share/ddns/default/system-ns.com.json | 8 + .../usr/share/ddns/default/thatip.com.json | 6 + .../usr/share/ddns/default/transip.nl.json | 9 + .../usr/share/ddns/default/twodns.de.json | 6 + .../usr/share/ddns/default/udmedia.de.json | 9 + .../usr/share/ddns/default/variomedia.de.json | 11 + .../usr/share/ddns/default/xlhost.de.json | 7 + .../usr/share/ddns/default/zerigo.com.json | 11 + .../usr/share/ddns/default/zoneedit.com.json | 6 + .../files/usr/share/ddns/default/zzzz.io.json | 11 + ddns-scripts/files/usr/share/ddns/list | 72 + ddns-scripts/samples/ddns.config_sample | 319 ++ ddns-scripts/samples/getlocalip_sample.sh | 35 + ddns-scripts/samples/slaac_sample.sh | 59 + ddns-scripts/samples/update_sample.sh | 41 + dns2socks/Makefile | 106 +- dns2tcp/Makefile | 88 +- dockerd/Config.in | 87 + dockerd/Makefile | 183 + dockerd/files/dockerd.init | 285 ++ dockerd/files/etc/config/dockerd | 38 + .../etc/sysctl.d/sysctl-br-netfilter-ip.conf | 7 + dockerd/git-short-commit.sh | 48 + .../patches/001-libdevmapper_name_fix.patch | 11 + hysteria/Makefile | 102 +- ipt2socks/Makefile | 86 +- luci-app-unblockneteasemusic/LICENSE | 674 +++ luci-app-unblockneteasemusic/Makefile | 8 +- luci-app-unblockneteasemusic/README.md | 63 + .../view/unblockneteasemusic/config.js | 358 -- .../view/unblockneteasemusic/status.js | 224 - .../luasrc/controller/unblockneteasemusic.lua | 69 + .../model/cbi/unblockneteasemusic/log.lua | 14 + .../model/cbi/unblockneteasemusic/main.lua | 247 + .../model/cbi/unblockneteasemusic/upgrade.lua | 19 + .../view/unblockneteasemusic/remove_core.htm | 32 + .../view/unblockneteasemusic/status.htm | 21 + .../view/unblockneteasemusic/update_core.htm | 36 + .../root/etc/config/unblockneteasemusic | 3 +- .../root/etc/init.d/unblockneteasemusic | 159 +- .../etc/uci-defaults/luci-unblockneteasemusic | 27 +- .../menu.d/luci-app-unblockneteasemusic.json | 29 - .../acl.d/luci-app-unblockneteasemusic.json | 16 +- .../share/unblockneteasemusic/debugging.sh | 44 +- .../usr/share/unblockneteasemusic/update.sh | 23 +- luci-app-unblockneteasemusic/views/view1.jpg | Bin 0 -> 805187 bytes luci-app-unblockneteasemusic/views/view2.jpg | Bin 0 -> 78114 bytes luci-app-unblockneteasemusic/views/view3.jpg | Bin 0 -> 169344 bytes luci-app-unblockneteasemusic/views/view4.jpg | Bin 0 -> 120071 bytes miniupnpd/Makefile | 80 + miniupnpd/files/firewall.include | 57 + miniupnpd/files/miniupnpd.defaults | 13 + miniupnpd/files/miniupnpd.hotplug | 39 + miniupnpd/files/miniupnpd.init | 219 + miniupnpd/files/upnpd.config | 27 + miniupnpd/patches/100-no-daemon.patch | 25 + miniupnpd/patches/101-no-ssl-uuid.patch | 23 + miniupnpd/patches/102-ipv6-ext-port.patch | 10 + .../patches/103-no-ipv6-autodetection.patch | 27 + miniupnpd/patches/104-always-libuuid.patch | 20 + .../patches/105-build-with-kernel-5.4.patch | 90 + .../patches/106-spam-syslog-ignoring.patch | 13 + mwan3/Makefile | 68 + mwan3/files/etc/config/mwan3 | 23 + mwan3/files/etc/hotplug.d/iface/15-mwan3 | 94 + mwan3/files/etc/hotplug.d/iface/16-mwan3 | 22 + mwan3/files/etc/hotplug.d/iface/16-mwan3-user | 16 + mwan3/files/etc/init.d/mwan3 | 28 + mwan3/files/etc/mwan3.user | 16 + .../mwan3-migrate-flush_conntrack | 26 + mwan3/files/lib/mwan3/common.sh | 6 + mwan3/files/lib/mwan3/mwan3.sh | 1207 +++++ mwan3/files/usr/libexec/rpcd/mwan3 | 230 + mwan3/files/usr/sbin/mwan3 | 213 + mwan3/files/usr/sbin/mwan3rtmon | 38 + mwan3/files/usr/sbin/mwan3track | 293 ++ netdata/Makefile | 105 + netdata/files/netdata.conf | 32 + netdata/files/netdata.init | 21 + .../001-disable-plugins-by-default.patch | 22 + .../002-extra-patch-web_gui_main.js.patch | 15 + ...llectors_python.d.plugin_Makefile.am.patch | 112 + ...gin_python__modules_bases_loaders.py.patch | 14 + netdata/patches/005-freebsd.patch | 1437 ++++++ netdata/test.sh | 3 + nginx/Config_ssl.in | 262 + nginx/Makefile | 604 +++ .../files-luci-support/60_nginx-luci-support | 41 + nginx/files-luci-support/luci.locations | 17 + nginx/files/nginx.init | 73 + .../dav-nginx/100-drop-libxslt-dep.patch | 14 + .../lua-nginx/100-no_by_lua_block.patch | 195 + .../patches/nginx/101-feature_test_fix.patch | 116 + nginx/patches/nginx/102-sizeof_test_fix.patch | 27 + nginx/patches/nginx/103-sys_nerr.patch | 12 + nginx/patches/nginx/104-endianness_fix.patch | 19 + nginx/patches/nginx/200-config.patch | 18 + .../nginx/201-ignore-invalid-options.patch | 12 + nginx/patches/rtmp-nginx/100-bigedian.patch | 1521 ++++++ pdnsd-alt/Makefile | 114 +- pdnsd-alt/files/pdnsd.init | 92 +- pdnsd-alt/patches/010-no-doc-and-test.patch | 84 +- pdnsd-alt/patches/020-headers.patch | 132 +- qBittorrent-static/Makefile | 66 + qBittorrent/Makefile | 95 + rp-pppoe/Makefile | 150 + rp-pppoe/files/ppp/options | 10 + rp-pppoe/files/ppp/pap-secrets | 2 + rp-pppoe/files/ppp/pppoe-server-options | 9 + rp-pppoe/files/ppp_defs.h | 11 + rp-pppoe/files/pppoe-relay.default | 10 + rp-pppoe/files/pppoe-relay.init | 79 + rp-pppoe/files/pppoe-server.default | 10 + rp-pppoe/files/pppoe-server.init | 79 + rp-pppoe/files/pppoe.config | 23 + rp-pppoe/patches/110-Makefile.patch | 11 + .../120-use-linux-ether-not-netinet.patch | 41 + rp-pppoe/patches/130-static-lib-fix.patch | 12 + shadowsocks-rust/Makefile | 170 +- shadowsocksr-libev/Makefile | 128 +- .../0001-Add-ss-server-and-ss-check.patch | 794 +-- ...Revert-verify_simple-and-auth_simple.patch | 40 +- .../patches/0003-Refine-Usage.patch | 74 +- .../patches/100-fix-gcc-10.patch | 40 +- .../102-Read-listening-mode-from-config.patch | 68 +- ...Add-TPROXY-support-for-TCP-ssr-redir.patch | 308 +- shadowsocksr-libev/src/server/Makefile.am | 110 +- shadowsocksr-libev/src/server/Makefile.in | 1838 +++---- shadowsocksr-libev/src/server/README.md | 6 +- shadowsocksr-libev/src/server/acl.c | 1194 ++--- shadowsocksr-libev/src/server/acl.h | 106 +- shadowsocksr-libev/src/server/auth.c | 1986 ++++---- shadowsocksr-libev/src/server/auth.h | 60 +- shadowsocksr-libev/src/server/base64.c | 238 +- shadowsocksr-libev/src/server/base64.h | 32 +- shadowsocksr-libev/src/server/cache.c | 616 +-- shadowsocksr-libev/src/server/cache.h | 124 +- shadowsocksr-libev/src/server/check.c | 470 +- shadowsocksr-libev/src/server/common.h | 116 +- shadowsocksr-libev/src/server/crc32.c | 194 +- shadowsocksr-libev/src/server/encrypt.c | 3290 ++++++------ shadowsocksr-libev/src/server/encrypt.h | 444 +- shadowsocksr-libev/src/server/http.c | 304 +- shadowsocksr-libev/src/server/http.h | 68 +- shadowsocksr-libev/src/server/http_simple.c | 1252 ++--- shadowsocksr-libev/src/server/http_simple.h | 42 +- shadowsocksr-libev/src/server/jconf.c | 520 +- shadowsocksr-libev/src/server/jconf.h | 156 +- shadowsocksr-libev/src/server/json.c | 2004 ++++---- shadowsocksr-libev/src/server/json.h | 498 +- shadowsocksr-libev/src/server/list.c | 740 +-- shadowsocksr-libev/src/server/list.h | 122 +- shadowsocksr-libev/src/server/netutils.c | 594 +-- shadowsocksr-libev/src/server/netutils.h | 196 +- shadowsocksr-libev/src/server/obfs.c | 410 +- shadowsocksr-libev/src/server/obfs.h | 200 +- shadowsocksr-libev/src/server/obfsutil.c | 72 +- shadowsocksr-libev/src/server/protocol.h | 68 +- shadowsocksr-libev/src/server/resolv.c | 888 ++-- shadowsocksr-libev/src/server/resolv.h | 100 +- shadowsocksr-libev/src/server/rule.c | 274 +- shadowsocksr-libev/src/server/rule.h | 116 +- shadowsocksr-libev/src/server/server.c | 4418 ++++++++--------- shadowsocksr-libev/src/server/server.h | 230 +- shadowsocksr-libev/src/server/tls.c | 526 +- shadowsocksr-libev/src/server/tls.h | 66 +- shadowsocksr-libev/src/server/tls1.2_ticket.c | 1218 ++--- shadowsocksr-libev/src/server/tls1.2_ticket.h | 40 +- shadowsocksr-libev/src/server/udprelay.c | 2904 +++++------ shadowsocksr-libev/src/server/udprelay.h | 190 +- shadowsocksr-libev/src/server/uthash.h | 2148 ++++---- shadowsocksr-libev/src/server/utils.c | 896 ++-- shadowsocksr-libev/src/server/utils.h | 464 +- shadowsocksr-libev/src/server/verify.c | 376 +- shadowsocksr-libev/src/server/verify.h | 38 +- simple-obfs/Makefile | 168 +- sing-box/Makefile | 332 +- sing-box/files/config.json.example | 472 +- sing-box/files/sing-box.init | 106 +- ssocks/Makefile | 154 +- ssocks/patches/001-fix.patch | 30 +- ssocks/patches/002-gcc10.patch | 22 +- tailscale/Makefile | 84 + tailscale/README.md | 28 + tailscale/files/tailscale.conf | 5 + tailscale/files/tailscale.init | 42 + tailscale/test.sh | 8 + transmission-web-control/Makefile | 41 + .../patches/001-remove-ui-original-link.patch | 24 + trojan-go/Makefile | 92 +- trojan-plus/Makefile | 138 +- trojan/Makefile | 130 +- .../patches/001-force-openssl-version.patch | 22 +- upx-static/Makefile | 73 + upx-static/README.md | 20 + upx/Makefile | 62 + upx/patches/010-fix-build-with-gcc11.patch | 28 + uwsgi/Makefile | 168 + uwsgi/files-luci-support/luci-cgi_io.ini | 31 + uwsgi/files-luci-support/luci-webui.ini | 36 + uwsgi/files/emperor.ini | 9 + uwsgi/files/uwsgi.init | 14 + uwsgi/patches/001-dont-hardcode-zlib.patch | 19 + ...dont-override-toolchain-optimization.patch | 11 + ...03-hard-code-Linux-as-compilation-os.patch | 15 + uwsgi/patches/010-uclibc-ng.patch | 11 + ...-plugins-cgi_adds_dontresolve_option.patch | 63 + uwsgi/src/buildconf/openwrt.ini | 30 + v2ray-core/Makefile | 218 +- v2ray-core/files/v2ray.conf | 22 +- v2ray-core/files/v2ray.init | 114 +- v2ray-plugin/Makefile | 76 +- verysync/Makefile | 88 +- watchcat/Makefile | 48 + watchcat/files/migrate-watchcat | 27 + watchcat/files/watchcat.config | 5 + watchcat/files/watchcat.init | 136 + watchcat/files/watchcat.sh | 269 + xray-core/Makefile | 133 +- xray-core/files/config.json.example | 144 - xray-core/files/vpoint_socks_vmess.json | 25 - xray-core/files/vpoint_vmess_freedom.json | 31 - xray-core/files/xray.conf | 11 - xray-core/files/xray.init | 58 - xray-plugin/Makefile | 82 +- 330 files changed, 36119 insertions(+), 19989 deletions(-) create mode 100644 ariang/Makefile create mode 100644 ariang/files/80_ariang-nginx-support create mode 100644 ariang/files/ariang.locations create mode 100644 cgroupfs-mount/Makefile create mode 100755 cgroupfs-mount/files/cgroupfs-mount.init create mode 100644 coremark/Makefile create mode 100644 ddns-scripts/Makefile create mode 100644 ddns-scripts/files/etc/config/ddns create mode 100644 ddns-scripts/files/etc/hotplug.d/iface/ddns create mode 100644 ddns-scripts/files/etc/init.d/ddns create mode 100644 ddns-scripts/files/usr/bin/ddns.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_cloudflare_com_v4.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_cnkuai_cn.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_digitalocean_com_v2.sh create mode 100755 ddns-scripts/files/usr/lib/ddns/update_dnspod_cn.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_freedns_42_pl.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_gandi_net.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_godaddy_com_v1.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_no-ip_com.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_ns1_com.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_nsupdate.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_one_com.sh create mode 100755 ddns-scripts/files/usr/lib/ddns/update_pdns.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_route53_v1.sh create mode 100644 ddns-scripts/files/usr/lib/ddns/update_transip_nl.sh create mode 100644 ddns-scripts/files/usr/share/ddns/default/3322.org.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/able.or.kr.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/afraid.org-basicauth.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/afraid.org-keyauth.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/afraid.org-v2-basic.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/afraid.org-v2-token.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/all-inkl.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/bind-nsupdate.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/changeip.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/cloudflare.com-v4.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/cnkuai.cn.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/core-networks.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/ddnss.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/ddo.jp.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/desec.io.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dhis.org.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/digitalocean.com-v2.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnsdynamic.org.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnsever.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnsexit.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnshome.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnsmadeeasy.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnsmax.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnsomatic.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnspark.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dnspod.cn.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/do.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/domopoli.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dtdns.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/duckdns.org.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/duiadns.net.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dy.fi.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dyn.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dyndns.it.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dyndns.org.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dyndnss.net.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dynsip.org.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dynu.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/dynv6.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/easydns.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/editdns.net.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/freedns.42.pl.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/gandi.net.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/godaddy.com-v1.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/goip.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/google.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/he.net.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/infomaniak.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/inwx.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/joker.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/loopia.se.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/moniker.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/mydns.jp.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/myip.co.ua.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/myonlineportal.net.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/mythic-beasts.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/namecheap.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/nettica.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/no-ip.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/no-ip.pl.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/now-dns.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/ns1.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/nsupdate.info.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/one.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/opendns.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/oray.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/ovh.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/pdns.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/regfish.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/route53-v1.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/schokokeks.org.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/selfhost.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/sitelutions.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/spdyn.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/strato.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/system-ns.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/thatip.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/transip.nl.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/twodns.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/udmedia.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/variomedia.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/xlhost.de.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/zerigo.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/zoneedit.com.json create mode 100644 ddns-scripts/files/usr/share/ddns/default/zzzz.io.json create mode 100644 ddns-scripts/files/usr/share/ddns/list create mode 100644 ddns-scripts/samples/ddns.config_sample create mode 100755 ddns-scripts/samples/getlocalip_sample.sh create mode 100755 ddns-scripts/samples/slaac_sample.sh create mode 100644 ddns-scripts/samples/update_sample.sh create mode 100644 dockerd/Config.in create mode 100644 dockerd/Makefile create mode 100755 dockerd/files/dockerd.init create mode 100644 dockerd/files/etc/config/dockerd create mode 100644 dockerd/files/etc/sysctl.d/sysctl-br-netfilter-ip.conf create mode 100755 dockerd/git-short-commit.sh create mode 100644 dockerd/patches/001-libdevmapper_name_fix.patch create mode 100644 luci-app-unblockneteasemusic/LICENSE create mode 100644 luci-app-unblockneteasemusic/README.md delete mode 100644 luci-app-unblockneteasemusic/htdocs/luci-static/resources/view/unblockneteasemusic/config.js delete mode 100644 luci-app-unblockneteasemusic/htdocs/luci-static/resources/view/unblockneteasemusic/status.js create mode 100644 luci-app-unblockneteasemusic/luasrc/controller/unblockneteasemusic.lua create mode 100644 luci-app-unblockneteasemusic/luasrc/model/cbi/unblockneteasemusic/log.lua create mode 100644 luci-app-unblockneteasemusic/luasrc/model/cbi/unblockneteasemusic/main.lua create mode 100644 luci-app-unblockneteasemusic/luasrc/model/cbi/unblockneteasemusic/upgrade.lua create mode 100644 luci-app-unblockneteasemusic/luasrc/view/unblockneteasemusic/remove_core.htm create mode 100644 luci-app-unblockneteasemusic/luasrc/view/unblockneteasemusic/status.htm create mode 100644 luci-app-unblockneteasemusic/luasrc/view/unblockneteasemusic/update_core.htm mode change 100644 => 100755 luci-app-unblockneteasemusic/root/etc/uci-defaults/luci-unblockneteasemusic delete mode 100644 luci-app-unblockneteasemusic/root/usr/share/luci/menu.d/luci-app-unblockneteasemusic.json create mode 100644 luci-app-unblockneteasemusic/views/view1.jpg create mode 100644 luci-app-unblockneteasemusic/views/view2.jpg create mode 100644 luci-app-unblockneteasemusic/views/view3.jpg create mode 100644 luci-app-unblockneteasemusic/views/view4.jpg create mode 100644 miniupnpd/Makefile create mode 100644 miniupnpd/files/firewall.include create mode 100644 miniupnpd/files/miniupnpd.defaults create mode 100644 miniupnpd/files/miniupnpd.hotplug create mode 100644 miniupnpd/files/miniupnpd.init create mode 100644 miniupnpd/files/upnpd.config create mode 100644 miniupnpd/patches/100-no-daemon.patch create mode 100644 miniupnpd/patches/101-no-ssl-uuid.patch create mode 100644 miniupnpd/patches/102-ipv6-ext-port.patch create mode 100644 miniupnpd/patches/103-no-ipv6-autodetection.patch create mode 100644 miniupnpd/patches/104-always-libuuid.patch create mode 100644 miniupnpd/patches/105-build-with-kernel-5.4.patch create mode 100644 miniupnpd/patches/106-spam-syslog-ignoring.patch create mode 100644 mwan3/Makefile create mode 100644 mwan3/files/etc/config/mwan3 create mode 100644 mwan3/files/etc/hotplug.d/iface/15-mwan3 create mode 100644 mwan3/files/etc/hotplug.d/iface/16-mwan3 create mode 100644 mwan3/files/etc/hotplug.d/iface/16-mwan3-user create mode 100755 mwan3/files/etc/init.d/mwan3 create mode 100644 mwan3/files/etc/mwan3.user create mode 100644 mwan3/files/etc/uci-defaults/mwan3-migrate-flush_conntrack create mode 100644 mwan3/files/lib/mwan3/common.sh create mode 100644 mwan3/files/lib/mwan3/mwan3.sh create mode 100755 mwan3/files/usr/libexec/rpcd/mwan3 create mode 100755 mwan3/files/usr/sbin/mwan3 create mode 100755 mwan3/files/usr/sbin/mwan3rtmon create mode 100755 mwan3/files/usr/sbin/mwan3track create mode 100644 netdata/Makefile create mode 100644 netdata/files/netdata.conf create mode 100644 netdata/files/netdata.init create mode 100644 netdata/patches/001-disable-plugins-by-default.patch create mode 100644 netdata/patches/002-extra-patch-web_gui_main.js.patch create mode 100644 netdata/patches/003-patch-collectors_python.d.plugin_Makefile.am.patch create mode 100644 netdata/patches/004-patch-collectors_python.d.plugin_python__modules_bases_loaders.py.patch create mode 100644 netdata/patches/005-freebsd.patch create mode 100644 netdata/test.sh create mode 100644 nginx/Config_ssl.in create mode 100644 nginx/Makefile create mode 100644 nginx/files-luci-support/60_nginx-luci-support create mode 100644 nginx/files-luci-support/luci.locations create mode 100644 nginx/files/nginx.init create mode 100644 nginx/patches/dav-nginx/100-drop-libxslt-dep.patch create mode 100644 nginx/patches/lua-nginx/100-no_by_lua_block.patch create mode 100644 nginx/patches/nginx/101-feature_test_fix.patch create mode 100644 nginx/patches/nginx/102-sizeof_test_fix.patch create mode 100644 nginx/patches/nginx/103-sys_nerr.patch create mode 100644 nginx/patches/nginx/104-endianness_fix.patch create mode 100644 nginx/patches/nginx/200-config.patch create mode 100644 nginx/patches/nginx/201-ignore-invalid-options.patch create mode 100644 nginx/patches/rtmp-nginx/100-bigedian.patch mode change 100755 => 100644 pdnsd-alt/files/pdnsd.init create mode 100644 qBittorrent-static/Makefile create mode 100644 qBittorrent/Makefile create mode 100644 rp-pppoe/Makefile create mode 100644 rp-pppoe/files/ppp/options create mode 100644 rp-pppoe/files/ppp/pap-secrets create mode 100644 rp-pppoe/files/ppp/pppoe-server-options create mode 100644 rp-pppoe/files/ppp_defs.h create mode 100644 rp-pppoe/files/pppoe-relay.default create mode 100755 rp-pppoe/files/pppoe-relay.init create mode 100644 rp-pppoe/files/pppoe-server.default create mode 100755 rp-pppoe/files/pppoe-server.init create mode 100644 rp-pppoe/files/pppoe.config create mode 100644 rp-pppoe/patches/110-Makefile.patch create mode 100644 rp-pppoe/patches/120-use-linux-ether-not-netinet.patch create mode 100644 rp-pppoe/patches/130-static-lib-fix.patch create mode 100644 tailscale/Makefile create mode 100644 tailscale/README.md create mode 100644 tailscale/files/tailscale.conf create mode 100644 tailscale/files/tailscale.init create mode 100644 tailscale/test.sh create mode 100644 transmission-web-control/Makefile create mode 100644 transmission-web-control/patches/001-remove-ui-original-link.patch create mode 100755 upx-static/Makefile create mode 100755 upx-static/README.md create mode 100644 upx/Makefile create mode 100644 upx/patches/010-fix-build-with-gcc11.patch create mode 100644 uwsgi/Makefile create mode 100644 uwsgi/files-luci-support/luci-cgi_io.ini create mode 100644 uwsgi/files-luci-support/luci-webui.ini create mode 100644 uwsgi/files/emperor.ini create mode 100644 uwsgi/files/uwsgi.init create mode 100644 uwsgi/patches/001-dont-hardcode-zlib.patch create mode 100644 uwsgi/patches/002-dont-override-toolchain-optimization.patch create mode 100644 uwsgi/patches/003-hard-code-Linux-as-compilation-os.patch create mode 100644 uwsgi/patches/010-uclibc-ng.patch create mode 100644 uwsgi/patches/030-plugins-cgi_adds_dontresolve_option.patch create mode 100644 uwsgi/src/buildconf/openwrt.ini create mode 100644 watchcat/Makefile create mode 100644 watchcat/files/migrate-watchcat create mode 100644 watchcat/files/watchcat.config create mode 100644 watchcat/files/watchcat.init create mode 100644 watchcat/files/watchcat.sh delete mode 100644 xray-core/files/config.json.example delete mode 100644 xray-core/files/vpoint_socks_vmess.json delete mode 100644 xray-core/files/vpoint_vmess_freedom.json delete mode 100644 xray-core/files/xray.conf delete mode 100755 xray-core/files/xray.init diff --git a/ariang/Makefile b/ariang/Makefile new file mode 100644 index 00000000000..af89ca8af3b --- /dev/null +++ b/ariang/Makefile @@ -0,0 +1,71 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ariang +PKG_VERSION:=1.3.2 +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).zip +PKG_SOURCE_URL:=https://github.com/mayswind/AriaNg/releases/download/$(PKG_VERSION) +PKG_HASH:=2186dacf57c9d1650e00084c0454f2227e910f3203d89c6190f547b40cac7243 +UNPACK_CMD=unzip -q -d $(1) $(DL_DIR)/$(PKG_SOURCE) + +PKG_MAINTAINER:=Ansuel Smith +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/package.mk + +define Package/ariang/default + SECTION:=net + CATEGORY:=Network + SUBMENU:=Download Manager + DEPENDS:=+aria2 + TITLE:=AriaNg webui + URL:=https://ariang.mayswind.net + PKGARCH:=all +endef + +define Package/ariang/description + AriaNg is a web frontend making aria2 easier to use. AriaNg is written in pure html & javascript, thus it does not need any compilers or runtime environment. +endef + +Package/ariang-nginx/description = $(Package/ariang/description) + +define Package/ariang + $(Package/ariang/default) + DEPENDS += +uhttpd + TITLE += for uhttpd webserver +endef + +define Package/ariang-nginx + $(Package/ariang/default) + DEPENDS += +nginx + TITLE += for nginx webserver +endef + +define Build/Compile +endef + +define Package/ariang/install + $(INSTALL_DIR) \ + $(1)/www/ariang + + $(CP) \ + $(PKG_BUILD_DIR)/{langs,css,js,fonts} \ + $(PKG_BUILD_DIR)/index.html \ + $(PKG_BUILD_DIR)/LICENSE \ + $(PKG_BUILD_DIR)/favicon.* \ + $(PKG_BUILD_DIR)/robots.txt \ + $(1)/www/ariang +endef + +define Package/ariang-nginx/install + $(Package/ariang/install) + $(INSTALL_DIR) $(1)/etc/nginx/conf.d/ + $(INSTALL_BIN) ./files/ariang.locations $(1)/etc/nginx/conf.d/ + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/80_ariang-nginx-support $(1)/etc/uci-defaults/80_ariang-nginx-support +endef + +$(eval $(call BuildPackage,ariang)) +$(eval $(call BuildPackage,ariang-nginx)) diff --git a/ariang/files/80_ariang-nginx-support b/ariang/files/80_ariang-nginx-support new file mode 100644 index 00000000000..0a89ccd1b23 --- /dev/null +++ b/ariang/files/80_ariang-nginx-support @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -x /etc/init.d/nginx ] && /etc/init.d/nginx running && /etc/init.d/nginx reload + +exit 0 diff --git a/ariang/files/ariang.locations b/ariang/files/ariang.locations new file mode 100644 index 00000000000..28b0a8ada5f --- /dev/null +++ b/ariang/files/ariang.locations @@ -0,0 +1,4 @@ +location /ariang { + index index.html; + alias /www/ariang/; +} \ No newline at end of file diff --git a/brook/Makefile b/brook/Makefile index 8c3cafac3ab..935ebe44b0f 100644 --- a/brook/Makefile +++ b/brook/Makefile @@ -1,44 +1,44 @@ -# SPDX-License-Identifier: GPL-3.0-only -# -# Copyright (C) 2021 ImmortalWrt.org - -include $(TOPDIR)/rules.mk - -PKG_NAME:=brook +# SPDX-License-Identifier: GPL-3.0-only +# +# Copyright (C) 2021 ImmortalWrt.org + +include $(TOPDIR)/rules.mk + +PKG_NAME:=brook PKG_VERSION:=20230122 -PKG_RELEASE:=$(AUTORELEASE) - -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://codeload.github.com/txthinking/brook/tar.gz/v$(PKG_VERSION)? +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/txthinking/brook/tar.gz/v$(PKG_VERSION)? PKG_HASH:=52643df51144b4b1afbacb51156f92ba61adbcff77dd8f76e3278ce70644f237 - -PKG_MAINTAINER:=Tianling Shen -PKG_LICENSE:=GPL-3.0 -PKG_LICENSE_FILES:=LICENSE - -PKG_BUILD_DEPENDS:=golang/host -PKG_BUILD_PARALLEL:=1 -PKG_USE_MIPS16:=0 - -GO_PKG:=github.com/txthinking/brook -GO_PKG_BUILD_PKG:=$(GO_PKG)/cli/brook - -include $(INCLUDE_DIR)/package.mk -include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk - -define Package/brook - SECTION:=net - CATEGORY:=Network - SUBMENU:=Web Servers/Proxies - TITLE:=A cross-platform proxy software - DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle - URL:=https://github.com/txthinking/brook -endef - -define Package/brook/description - Brook is a cross-platform strong encryption and not detectable proxy. - Zero-Configuration. -endef - -$(eval $(call GoBinPackage,brook)) -$(eval $(call BuildPackage,brook)) + +PKG_MAINTAINER:=Tianling Shen +PKG_LICENSE:=GPL-3.0 +PKG_LICENSE_FILES:=LICENSE + +PKG_BUILD_DEPENDS:=golang/host +PKG_BUILD_PARALLEL:=1 +PKG_USE_MIPS16:=0 + +GO_PKG:=github.com/txthinking/brook +GO_PKG_BUILD_PKG:=$(GO_PKG)/cli/brook + +include $(INCLUDE_DIR)/package.mk +include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk + +define Package/brook + SECTION:=net + CATEGORY:=Network + SUBMENU:=Web Servers/Proxies + TITLE:=A cross-platform proxy software + DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle + URL:=https://github.com/txthinking/brook +endef + +define Package/brook/description + Brook is a cross-platform strong encryption and not detectable proxy. + Zero-Configuration. +endef + +$(eval $(call GoBinPackage,brook)) +$(eval $(call BuildPackage,brook)) diff --git a/cgroupfs-mount/Makefile b/cgroupfs-mount/Makefile new file mode 100644 index 00000000000..40facab5c3c --- /dev/null +++ b/cgroupfs-mount/Makefile @@ -0,0 +1,47 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=cgroupfs-mount +PKG_RELEASE:=2 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/tianon/$(PKG_NAME) +PKG_SOURCE_VERSION:=0549428171605eae3097a3e21bf7664845eac9e8 +PKG_SOURCE_DATE:=2020-06-26 +PKG_MIRROR_HASH:=ca217ffff5aa938149d2d8adfe15d800903d2fec180acb2400c36d62905988ea + +PKG_MAINTAINER:=Gerard Ryan + +include $(INCLUDE_DIR)/package.mk + +define Package/cgroupfs-mount/config + config CGROUPFS_MOUNT_KERNEL_CGROUPS + bool "Enable kernel cgroups support" + depends on PACKAGE_cgroupfs-mount + default y if ( DOCKER_KERNEL_OPTIONS || LXC_KERNEL_OPTIONS ) + select KERNEL_CGROUPS +endef + +define Package/cgroupfs-mount + SECTION:=utils + CATEGORY:=Utilities + TITLE:=cgroup mount scripts + DEPENDS:=+mount-utils + MENU:=1 +endef + +define Package/cgroupfs-mount/description +Simple scripts to properly mount the cgroupfs hierarchy, especially structured for Debian packaging +endef + +Build/Compile=# Nothing to compile, just install the scripts + +define Package/cgroupfs-mount/install + $(INSTALL_DIR) $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/cgroupfs-mount $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/cgroupfs-umount $(1)/usr/bin/ + + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/cgroupfs-mount.init $(1)/etc/init.d/cgroupfs-mount +endef + +$(eval $(call BuildPackage,cgroupfs-mount)) diff --git a/cgroupfs-mount/files/cgroupfs-mount.init b/cgroupfs-mount/files/cgroupfs-mount.init new file mode 100755 index 00000000000..0d6b68dc393 --- /dev/null +++ b/cgroupfs-mount/files/cgroupfs-mount.init @@ -0,0 +1,12 @@ +#!/bin/sh /etc/rc.common + +START=01 + +boot() { + # Procd mounts non-hierarchical cgroupfs so unmount first before cgroupfs-mount + if mountpoint -q /sys/fs/cgroup; then + umount /sys/fs/cgroup/ + fi + + cgroupfs-mount +} diff --git a/chinadns-ng/Makefile b/chinadns-ng/Makefile index 8158b4d755a..b51674e9f76 100644 --- a/chinadns-ng/Makefile +++ b/chinadns-ng/Makefile @@ -1,40 +1,40 @@ -# SPDX-License-Identifier: GPL-3.0-only -# -# Copyright (C) 2021 ImmortalWrt.org - -include $(TOPDIR)/rules.mk - -PKG_NAME:=chinadns-ng -PKG_VERSION:=1.0-beta.25 -PKG_RELEASE:=$(AUTORELEASE) - -PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=https://github.com/zfl9/chinadns-ng.git -PKG_SOURCE_DATE:=2021-05-08 -PKG_SOURCE_VERSION:=14cc6348d67b09cae37d9bce554c89c2c0e0b265 -PKG_MIRROR_HASH:=3b66fc0888d9488e3b8e39df3016d51fae1b43325d292381e94aa3c7d2318282 - -PKG_LICENSE:=AGPL-3.0-only -PKG_LICENSE_FILES:=LICENSE -PKG_MAINTAINER:=pexcn - -PKG_BUILD_PARALLEL:=1 -PKG_INSTALL:=1 - -include $(INCLUDE_DIR)/package.mk - -define Package/chinadns-ng - SECTION:=net - CATEGORY:=Network - SUBMENU:=IP Addresses and Names - TITLE:=ChinaDNS next generation, refactoring with epoll and ipset. - URL:=https://github.com/zfl9/chinadns-ng - DEPENDS:=+ipset -endef - -define Package/chinadns-ng/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/chinadns-ng $(1)/usr/bin -endef - -$(eval $(call BuildPackage,chinadns-ng)) +# SPDX-License-Identifier: GPL-3.0-only +# +# Copyright (C) 2021 ImmortalWrt.org + +include $(TOPDIR)/rules.mk + +PKG_NAME:=chinadns-ng +PKG_VERSION:=1.0-beta.25 +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/zfl9/chinadns-ng.git +PKG_SOURCE_DATE:=2021-05-08 +PKG_SOURCE_VERSION:=14cc6348d67b09cae37d9bce554c89c2c0e0b265 +PKG_MIRROR_HASH:=3b66fc0888d9488e3b8e39df3016d51fae1b43325d292381e94aa3c7d2318282 + +PKG_LICENSE:=AGPL-3.0-only +PKG_LICENSE_FILES:=LICENSE +PKG_MAINTAINER:=pexcn + +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/chinadns-ng + SECTION:=net + CATEGORY:=Network + SUBMENU:=IP Addresses and Names + TITLE:=ChinaDNS next generation, refactoring with epoll and ipset. + URL:=https://github.com/zfl9/chinadns-ng + DEPENDS:=+ipset +endef + +define Package/chinadns-ng/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/chinadns-ng $(1)/usr/bin +endef + +$(eval $(call BuildPackage,chinadns-ng)) diff --git a/coremark/Makefile b/coremark/Makefile new file mode 100644 index 00000000000..80431d2e44a --- /dev/null +++ b/coremark/Makefile @@ -0,0 +1,86 @@ +# +# Copyright (C) 2018 Lim Guo Wei +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=coremark +PKG_SOURCE_DATE:=2022-01-03 +PKG_SOURCE_VERSION:=b24e397f7103061b3673261d292a0667bd3bc1b8 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_DATE).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/eembc/coremark/tar.gz/$(PKG_SOURCE_VERSION)? +PKG_HASH:=1b8c36b202f39b4f8a872ed7d5db1dc4473ee27f7bc2885a9da20e72925c58c3 +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION) + +PKG_MAINTAINER:=Lim Guo Wei \ + Aleksander Jan Bajkowski +PKG_LICENSE:=Apache-2.0 +PKG_LICENSE_FILES:=LICENSE.md + +PKG_USE_MIPS16:=0 + +include $(INCLUDE_DIR)/package.mk + +define Package/coremark + SECTION:=utils + CATEGORY:=Utilities + TITLE:=CoreMark Embedded Microprocessor Benchmark + URL:=https://github.com/eembc/coremark +endef + +define Package/coremark/description + Embedded Microprocessor Benchmark +endef + +define Package/coremark/config + config COREMARK_OPTIMIZE_O3 + bool "Use all optimizations (-O3)" + depends on PACKAGE_coremark + default y + help + This enables additional optmizations using the -O3 compilation flag. + + config COREMARK_ENABLE_MULTITHREADING + bool "Enable multithreading support" + depends on PACKAGE_coremark + default n + help + This enables multithreading support + + config COREMARK_NUMBER_OF_THREADS + int "Number of threads" + depends on COREMARK_ENABLE_MULTITHREADING + default 2 + help + Number of threads to run in parallel +endef + +TARGET_CFLAGS += -flto + +ifeq ($(CONFIG_COREMARK_OPTIMIZE_O3),y) + TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3 +endif + +ifeq ($(CONFIG_COREMARK_ENABLE_MULTITHREADING),y) + EXTRA_CFLAGS := -DMULTITHREAD=$(CONFIG_COREMARK_NUMBER_OF_THREADS) -DUSE_PTHREAD +endif + +define Build/Compile + $(SED) 's|EXE = .exe|EXE =|' $(PKG_BUILD_DIR)/posix/core_portme.mak + mkdir $(PKG_BUILD_DIR)/$(ARCH) + $(CP) -r $(PKG_BUILD_DIR)/linux/* $(PKG_BUILD_DIR)/$(ARCH) + $(MAKE) -C $(PKG_BUILD_DIR) PORT_DIR=$(ARCH) $(MAKE_FLAGS) \ + PORT_CFLAGS="$(TARGET_CFLAGS)" XCFLAGS="$(EXTRA_CFLAGS)" compile +endef + +define Package/coremark/install + $(INSTALL_DIR) $(1)/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/coremark $(1)/bin/ +endef + +$(eval $(call BuildPackage,coremark)) diff --git a/ddns-scripts/Makefile b/ddns-scripts/Makefile new file mode 100644 index 00000000000..54dd3211783 --- /dev/null +++ b/ddns-scripts/Makefile @@ -0,0 +1,623 @@ +# +# Copyright (C) 2008-2018 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=ddns-scripts +PKG_VERSION:=2.8.2 +PKG_RELEASE:=25 + +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/ddns-scripts/Default + SECTION:=net + CATEGORY:=Network + SUBMENU:=IP Addresses and Names + PKGARCH:=all +endef + + +define Package/ddns-scripts + $(call Package/ddns-scripts/Default) + TITLE:=Dynamic DNS Client scripts (with IPv6 support) + DEPENDS:=+ddns-scripts-services +endef + +define Package/ddns-scripts/description + Dynamic DNS Client scripts (with IPv6 support) + A highly configurable set of scripts for doing dynamic dns updates. + - IPv6 support + - DNS server support + - Glue Record support (require BIND host or KNOT host) + - DNS requests via TCP + - Proxy server support + - log file support + - support to run once + Version: $(PKG_VERSION)-$(PKG_RELEASE) + Info : https://openwrt.org/docs/guide-user/services/ddns/client +endef + +define Package/ddns-scripts/conffiles +/etc/config/ddns +endef + + +define Package/ddns-scripts-services + $(call Package/ddns-scripts/Default) + TITLE:=Common ddns providers + PROVIDES:=ddns-scripts_service +endef + +define Package/ddns-scripts-services/description + Dynamic DNS Client definitions for supported services +endef + + +define Package/ddns-scripts-cloudflare + $(call Package/ddns-scripts/Default) + TITLE:=Extension for cloudflare.com API v4 + DEPENDS:=ddns-scripts +curl + PROVIDES:=ddns-scripts_cloudflare.com-v4 +endef + +define Package/ddns-scripts-cloudflare/description + Dynamic DNS Client scripts extension for cloudflare.com API v4 (require curl) +endef + + +define Package/ddns-scripts-freedns + $(call Package/ddns-scripts/Default) + TITLE:=Extension for freedns.42.pl + DEPENDS:=ddns-scripts +curl + PROVIDES:=ddns-scripts_freedns_42_pl +endef + +define Package/ddns-scripts-freedns/description + Dynamic DNS Client scripts extension for "freedns.42.pl". +endef + + +define Package/ddns-scripts-godaddy + $(call Package/ddns-scripts/Default) + TITLE:=Extension for godaddy.com API v1 + DEPENDS:=ddns-scripts +curl + PROVIDES:=ddns-scripts_godaddy.com-v1 +endef + +define Package/ddns-scripts-godaddy/description + Dynamic DNS Client scripts extension for "godaddy.com API v1". +endef + + +define Package/ddns-scripts-digitalocean + $(call Package/ddns-scripts/Default) + TITLE:=Extention for digitalocean.com API v2 + DEPENDS:=ddns-scripts +curl + PROVIDES:=ddns-scripts_digitalocean.com-v2 +endef + +define Package/ddns-scripts-digitalocean/description + Dynamic DNS Client scripts extension for "digitalocean.com API v2". + The script directly updates a DNS record using the DO API. + It requires: + "option dns_server" to be set to the server to be used by nsupdate. + "option domain" the dns domain to update the record for (eg. A-record: home.) + "option username" the dns record name to update (eg. A-record: .example.com) + "option param_opt" the id of the dns record to update (check using chrome inspector in the DO dns tab) + "option password" the api token generated in the DO panel +endef + + +define Package/ddns-scripts-dnspod + $(call Package/ddns-scripts/Default) + TITLE:=Extension for dnspod.cn API + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-dnspod/description + Dynamic DNS Client scripts extension for dnspod.cn API (require curl) +endef + + +define Package/ddns-scripts-noip + $(call Package/ddns-scripts/Default) + TITLE:=Extension for no-ip.com + DEPENDS:=ddns-scripts + PROVIDES:=ddns-scripts_no-ip_com +endef + +define Package/ddns-scripts-noip/description + Dynamic DNS Client scripts extension for "no-ip.com". +endef + +define Package/ddns-scripts-ns1 + $(call Package/ddns-scripts/Default) + TITLE:=NS1 API + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-ns1/description + Dynamic DNS Client scripts extension for "ns1.com". + It requires: + "option username" to be a valid zone for ns1.com + "option password" to be a valid API key for ns1.com +endef + + +define Package/ddns-scripts-nsupdate + $(call Package/ddns-scripts/Default) + TITLE:=Extension for using bind nsupdate. + DEPENDS:=ddns-scripts +bind-client + PROVIDES:=ddns-scripts_nsupdate +endef + +define Package/ddns-scripts-nsupdate/description + Dynamic DNS Client scripts extension for direct updates using bind nsupdate + The script directly updates a PowerDNS (or maybe bind server) via nsupdate + from bind-client package. + It requires: + "option dns_server" to be set to the server to be used by nsupdate. + "option username" should be set to the key name and + "option password" to the base64 encoded shared secret. +endef + + +define Package/ddns-scripts-route53 + $(call Package/ddns-scripts/Default) + TITLE:=Extension for route53 API v1 + DEPENDS:=ddns-scripts +curl +openssl-util + PROVIDES:=ddns-scripts_route53-v1 +endef + +define Package/ddns-scripts-route53/description + Dynamic DNS Client scripts extension for Amazon AWS "route53 API v1". + Note: You must also install ca-certificate or ca-bundle. + It requires: + "option username" to be a valid AWS access key id + "option password" to be the matching AWS secret key id + "option domain" to contain the hosted zone ID +endef + + +define Package/ddns-scripts-cnkuai + $(call Package/ddns-scripts/Default) + TITLE:=CnKuai API + DEPENDS:=ddns-scripts +curl +giflib-utils + PROVIDES:=ddns-scripts_cnkuai_cn +endef + +define Package/ddns-scripts-cnkuai/description + Dynamic DNS Client scripts extension for "cnkuai.cn". + It requires: + "option username" to be a valid CnKuai control panel id + "option password" to be the matching CnKuai control panel password + "option domain" to contain the domain +endef + + +define Package/ddns-scripts-gandi + $(call Package/ddns-scripts/Default) + TITLE:=Gandi API + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-gandi/description + Dynamic DNS Client scripts extension for "gandi.net". + It requires: + "option username" to be a valid subdomain for gandi.net + "option password" to be a valid API key for gandi.net +endef + + +define Package/ddns-scripts-pdns + $(call Package/ddns-scripts/Default) + TITLE:=PowerDNS API + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-pdns/description + Dynamic DNS Client scripts extension for "PowerDNS" via API. + It requires: + "option param_opt(Optional Parameter)" to be a valid root URL for the PowerDNS webserver + "option username" to be a valid subdomain for the PowerDNS domain + "option password" to be a valid API key for the PowerDNS webserver +endef + + +define Package/ddns-scripts-transip + $(call Package/ddns-scripts/Default) + TITLE:=Extension for TransIP API + DEPENDS:=ddns-scripts +curl +openssl-util +!BUSYBOX_CONFIG_MKTEMP:coreutils-mktemp +endef + +define Package/ddns-scripts-transip/description + Dynamic DNS Client scripts extension for "transip.nl". + Note: You must also install ca-certificate or ca-bundle. + It requires: + "option username" to be a valid username for transip.nl + "option password" to be a valid matching private key + "option domain" to contain the base domain + "option param_enc" to contain the name of the DNS record to update + "option param_opt" to contain the TTL of the DNS record to update +endef + +define Package/ddns-scripts-one + $(call Package/ddns-scripts/Default) + TITLE:=Extension for one.com Control Panel + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scrtips-one/description + Dynamic DNS Client scripts extension for "one.com". + It requires: + "option username" to be a valid Email for one.com Control Panel + "option password" to be the matching one.com Control Panel password + "option domain" to contain the domain / subdomain +endef + + +define Build/Configure +endef + +define Build/Compile +endef + + +define Package/ddns-scripts/install + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_DATA) ./files/etc/hotplug.d/iface/ddns \ + $(1)/etc/hotplug.d/iface/95-ddns + + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/etc/init.d/ddns \ + $(1)/etc/init.d/ddns + + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/etc/config/ddns \ + $(1)/etc/config/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns + echo "$(PKG_VERSION)-$(PKG_RELEASE)" > $(1)/usr/share/ddns/version + + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_DATA) ./files/usr/lib/ddns/dynamic_dns_functions.sh \ + $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/dynamic_dns_lucihelper.sh \ + $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/dynamic_dns_updater.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) ./files/usr/bin/ddns.sh \ + $(1)/usr/bin/ddns +endef + +define Package/ddns-scripts/postinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns enabled + /etc/init.d/ddns start +fi +exit 0 +endef + +define Package/ddns-scripts/prerm +#!/bin/sh +if [ -n "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop + /etc/init.d/ddns disable +fi +exit 0 +endef + + +define Package/ddns-scripts-services/install + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/* \ + $(1)/usr/share/ddns/default + + # Remove special services + rm $(1)/usr/share/ddns/default/cloudflare.com-v4.json + rm $(1)/usr/share/ddns/default/freedns.42.pl.json + rm $(1)/usr/share/ddns/default/godaddy.com-v1.json + rm $(1)/usr/share/ddns/default/digitalocean.com-v2.json + rm $(1)/usr/share/ddns/default/dnspod.cn.json + rm $(1)/usr/share/ddns/default/no-ip.com.json + rm $(1)/usr/share/ddns/default/bind-nsupdate.json + rm $(1)/usr/share/ddns/default/route53-v1.json + rm $(1)/usr/share/ddns/default/cnkuai.cn.json + rm $(1)/usr/share/ddns/default/gandi.net.json + rm $(1)/usr/share/ddns/default/pdns.json + rm $(1)/usr/share/ddns/default/transip.nl.json + rm $(1)/usr/share/ddns/default/ns1.com.json + rm $(1)/usr/share/ddns/default/one.com.json +endef + + +define Package/ddns-scripts-cloudflare/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_cloudflare_com_v4.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/cloudflare.com-v4.json \ + $(1)/usr/share/ddns/default/ +endef + +define Package/ddns-scripts-cloudflare/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-freedns/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_freedns_42_pl.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/freedns.42.pl.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-freedns/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-godaddy/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_godaddy_com_v1.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/godaddy.com-v1.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-godaddy/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-digitalocean/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_digitalocean_com_v2.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/digitalocean.com-v2.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-digitalocean/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-dnspod/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_dnspod_cn.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/dnspod.cn.json \ + $(1)/usr/share/ddns/default/ +endef + +define Package/ddns-scripts-dnspod/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-noip/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_no-ip_com.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/no-ip.com.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-noip/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-ns1/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_ns1_com.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/ns1.com.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-ns1/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-nsupdate/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_nsupdate.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/bind-nsupdate.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-nsupdate/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-route53/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_route53_v1.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/route53-v1.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-route53/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-cnkuai/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_cnkuai_cn.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/cnkuai.cn.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-cnkuai/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-gandi/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_gandi_net.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/gandi.net.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-gandi/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-pdns/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_pdns.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/pdns.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-pdns/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-transip/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_transip_nl.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/transip.nl.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-transip/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-one/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_one_com.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/one.com.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-one/prerm +#!/bin/sh +if [-z "${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +$(eval $(call BuildPackage,ddns-scripts)) +$(eval $(call BuildPackage,ddns-scripts-services)) +$(eval $(call BuildPackage,ddns-scripts-cloudflare)) +$(eval $(call BuildPackage,ddns-scripts-freedns)) +$(eval $(call BuildPackage,ddns-scripts-godaddy)) +$(eval $(call BuildPackage,ddns-scripts-digitalocean)) +$(eval $(call BuildPackage,ddns-scripts-dnspod)) +$(eval $(call BuildPackage,ddns-scripts-noip)) +$(eval $(call BuildPackage,ddns-scripts-nsupdate)) +$(eval $(call BuildPackage,ddns-scripts-route53)) +$(eval $(call BuildPackage,ddns-scripts-cnkuai)) +$(eval $(call BuildPackage,ddns-scripts-gandi)) +$(eval $(call BuildPackage,ddns-scripts-pdns)) +$(eval $(call BuildPackage,ddns-scripts-transip)) +$(eval $(call BuildPackage,ddns-scripts-ns1)) +$(eval $(call BuildPackage,ddns-scripts-one)) diff --git a/ddns-scripts/files/etc/config/ddns b/ddns-scripts/files/etc/config/ddns new file mode 100644 index 00000000000..b45855f0d05 --- /dev/null +++ b/ddns-scripts/files/etc/config/ddns @@ -0,0 +1,32 @@ +# +# Please read https://openwrt.org/docs/guide-user/base-system/ddns +# +config ddns "global" + option ddns_dateformat "%F %R" +# option ddns_rundir "/var/run/ddns" +# option ddns_logdir "/var/log/ddns" + option ddns_loglines "250" + option upd_privateip "0" + + +config service "myddns_ipv4" + option service_name "dyndns.org" + option lookup_host "yourhost.example.com" + option domain "yourhost.example.com" + option username "your_username" + option password "your_password" + option interface "wan" + option ip_source "network" + option ip_network "wan" + +config service "myddns_ipv6" + option update_url "http://[USERNAME]:[PASSWORD]@your.provider.net/nic/update?hostname=[DOMAIN]&myip=[IP]" + option lookup_host "yourhost.example.com" + option domain "yourhost.example.com" + option username "your_username" + option password "your_password" + option use_ipv6 "1" + option interface "wan6" + option ip_source "network" + option ip_network "wan6" + diff --git a/ddns-scripts/files/etc/hotplug.d/iface/ddns b/ddns-scripts/files/etc/hotplug.d/iface/ddns new file mode 100644 index 00000000000..9ef172deb66 --- /dev/null +++ b/ddns-scripts/files/etc/hotplug.d/iface/ddns @@ -0,0 +1,11 @@ +#!/bin/sh + +# there are other ACTIONs like ifupdate we don't need +case "$ACTION" in + ifup) # OpenWrt is giving a network not phys. Interface + /etc/init.d/ddns enabled && /usr/lib/ddns/dynamic_dns_updater.sh -n "$INTERFACE" -- start + ;; + ifdown) + /usr/lib/ddns/dynamic_dns_updater.sh -n "$INTERFACE" -- stop + ;; +esac diff --git a/ddns-scripts/files/etc/init.d/ddns b/ddns-scripts/files/etc/init.d/ddns new file mode 100644 index 00000000000..b2156a6a630 --- /dev/null +++ b/ddns-scripts/files/etc/init.d/ddns @@ -0,0 +1,27 @@ +#!/bin/sh /etc/rc.common +START=95 +STOP=10 + +boot() { + return 0 +} + +reload() { + /usr/lib/ddns/dynamic_dns_updater.sh -- reload + return 0 +} + +restart() { + /usr/lib/ddns/dynamic_dns_updater.sh -- stop + sleep 1 # give time to shutdown + /usr/lib/ddns/dynamic_dns_updater.sh -- start +} + +start() { + /usr/lib/ddns/dynamic_dns_updater.sh -- start +} + +stop() { + /usr/lib/ddns/dynamic_dns_updater.sh -- stop + return 0 +} diff --git a/ddns-scripts/files/usr/bin/ddns.sh b/ddns-scripts/files/usr/bin/ddns.sh new file mode 100644 index 00000000000..921465f7e49 --- /dev/null +++ b/ddns-scripts/files/usr/bin/ddns.sh @@ -0,0 +1,172 @@ +#!/bin/sh +# +# Copyright (C) 2020 TDT AG +# +# This is free software, licensed under the GNU General Public License v2. +# See https://www.gnu.org/licenses/gpl-2.0.txt for more information. +# + +. /lib/functions.sh + +DDNS_PACKAGE_DIR="/usr/share/ddns" +URL="https://raw.githubusercontent.com/openwrt/packages/master/net/ddns-scripts/files" + +usage() { + local code="$1" + local msg="$2" + + echo "$msg" + echo "" + echo "Usage: $(basename "$0") " + echo "" + echo "Supported ddns :" + echo " service: Command for custom ddns service providers" + echo "" + echo "Supported ddns 'service' command :" + echo " update: Update local custom ddns service list" + echo " list-available: List all available custom service providers" + echo " list-installed: List all installed custom service providers" + echo " install : Install custom service provider" + echo " remove : Remove custom service provider" + echo " purge: Remove local custom ddns services" + + exit "$code" +} + +action_update() { + local cacert + + config_load ddns + config_get url global 'url' "${URL}${DDNS_PACKAGE_DIR}" + config_get cacert global 'cacert' "IGNORE" + url="${url}/list" + + mkdir -p "${DDNS_PACKAGE_DIR}" + + if [ "$cacert" = "IGNORE" ]; then + uclient-fetch \ + --no-check-certificate \ + "$url" \ + -O "${DDNS_PACKAGE_DIR}/list" + elif [ -f "$cacert" ]; then + uclient-fetch \ + --ca-certificate="${cacert}" \ + "$url" \ + -O "${DDNS_PACKAGE_DIR}/list" + elif [ -n "$cacert" ]; then + echo "Certification file not found ($cacert)" + exit 5 + fi +} + +action_list_available() { + if [ -f "${DDNS_PACKAGE_DIR}/list" ]; then + cat "${DDNS_PACKAGE_DIR}/list" + else + echo "No custom service list file found. Please download first" + exit 3 + fi +} + +action_list_installed() { + if [ -d "${DDNS_PACKAGE_DIR}/custom" ]; then + ls "${DDNS_PACKAGE_DIR}/custom" + else + echo "No custom services installed" + exit 4 + fi +} + +action_install() { + local service="$1" + + local url cacert + + config_load ddns + config_get url global 'url' "${URL}${DDNS_PACKAGE_DIR}/default" + config_get cacert global 'cacert' "IGNORE" + url="${url}/${service}.json" + + if [ -z "$service" ]; then + usage "4" "No custom service specified" + fi + + mkdir -p "${DDNS_PACKAGE_DIR}/custom" + + if [ "$cacert" = "IGNORE" ]; then + uclient-fetch \ + --no-check-certificate \ + "${url}" \ + -O "${DDNS_PACKAGE_DIR}/custom/${service}.json" + elif [ -f "$cacert" ]; then + uclient-fetch \ + --ca-certifcate="${cacert}" \ + "${url}" \ + -O "${DDNS_PACKAGE_DIR}/custom/${service}.json" + elif [ -n "$cacert" ]; then + echo "Certification file not found ($cacert)" + exit 5 + fi +} + +action_remove() { + local service="$1" + if [ -z "$service" ]; then + usage "4" "No custom service specified" + fi + + rm "${DDNS_PACKAGE_DIR}/custom/${service}.json" +} + +action_purge() { + rm -rf "${DDNS_PACKAGE_DIR}/custom" + rm -rf "${DDNS_PACKAGE_DIR}/list" +} + +sub_service() { + local action="$1" + local service="$2" + + case "$action" in + update) + action_update + ;; + list-available) + action_list_available + ;; + list-installed) + action_list_installed + ;; + purge) + action_purge + ;; + install) + action_install "$service" + ;; + remove) + action_remove "$service" + ;; + *) + usage "2" "Action not supported" + ;; + esac +} + +main() { + local cmd="$1" + local action="$2" + local service="$3" + + [ "$#" -eq 0 ] && usage "1" + + case "${cmd}" in + service) + sub_service "${action}" "${service}" + ;; + *) + usage "1" "Command not supported" + ;; + esac +} + +main "$@" diff --git a/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh new file mode 100644 index 00000000000..cb345e846be --- /dev/null +++ b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh @@ -0,0 +1,1403 @@ +#!/bin/sh +# /usr/lib/ddns/dynamic_dns_functions.sh +# +#.Distributed under the terms of the GNU General Public License (GPL) version 2.0 +# Original written by Eric Paul Bishop, January 2008 +# (Loosely) based on the script on the one posted by exobyte in the forums here: +# http://forum.openwrt.org/viewtopic.php?id=14040 +# extended and partial rewritten +#.2014-2018 Christian Schoenebeck +# +# function timeout +# copied from http://www.ict.griffith.edu.au/anthony/software/timeout.sh +# @author Anthony Thyssen 6 April 2011 +# +# variables in small chars are read from /etc/config/ddns +# variables in big chars are defined inside these scripts as global vars +# variables in big chars beginning with "__" are local defined inside functions only +# set -vx #script debugger + +. /lib/functions.sh +. /lib/functions/network.sh + +# GLOBAL VARIABLES # +if [ -f "/usr/share/ddns/version" ]; then + VERSION="$(cat "/usr/share/ddns/version")" +else + VERSION="unknown" +fi +SECTION_ID="" # hold config's section name +VERBOSE=0 # default mode is log to console, but easily changed with parameter +MYPROG=$(basename $0) # my program call name + +LOGFILE="" # logfile - all files are set in dynamic_dns_updater.sh +PIDFILE="" # pid file +UPDFILE="" # store UPTIME of last update +DATFILE="" # save stdout data of WGet and other external programs called +ERRFILE="" # save stderr output of WGet and other external programs called +IPFILE="" # store registered IP for read by LuCI status +TLDFILE=/usr/share/public_suffix_list.dat.gz # TLD file used by split_FQDN + +CHECK_SECONDS=0 # calculated seconds out of given +FORCE_SECONDS=0 # interval and unit +RETRY_SECONDS=0 # in configuration + +LAST_TIME=0 # holds the uptime of last successful update +CURR_TIME=0 # holds the current uptime +NEXT_TIME=0 # calculated time for next FORCED update +EPOCH_TIME=0 # seconds since 1.1.1970 00:00:00 + +REGISTERED_IP="" # holds the IP read from DNS +LOCAL_IP="" # holds the local IP read from the box + +URL_USER="" # url encoded $username from config file +URL_PASS="" # url encoded $password from config file +URL_PENC="" # url encoded $param_enc from config file + +UPD_ANSWER="" # Answer given by service on success + +ERR_LAST=0 # used to save $? return code of program and function calls +ERR_UPDATE=0 # error counter on different local and registered ip + +PID_SLEEP=0 # ProcessID of current background "sleep" + +# regular expression to detect IPv4 / IPv6 +# IPv4 0-9 1-3x "." 0-9 1-3x "." 0-9 1-3x "." 0-9 1-3x +IPV4_REGEX="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" +# IPv6 ( ( 0-9a-f 1-4char ":") min 1x) ( ( 0-9a-f 1-4char )optional) ( (":" 0-9a-f 1-4char ) min 1x) +IPV6_REGEX="\(\([0-9A-Fa-f]\{1,4\}:\)\{1,\}\)\(\([0-9A-Fa-f]\{1,4\}\)\{0,1\}\)\(\(:[0-9A-Fa-f]\{1,4\}\)\{1,\}\)" + +# characters that are dangerous to pass to a shell command line +SHELL_ESCAPE="[\"\'\`\$\!();><{}?|\[\]\*\\\\]" + +# dns character set. "-" must be the last character +DNS_CHARSET="[@a-zA-Z0-9._-]" + +# domains can have * for wildcard. "-" must be the last character +DNS_CHARSET_DOMAIN="[@a-zA-Z0-9._*-]" + +# detect if called by ddns-lucihelper.sh script, disable retrys (empty variable == false) +LUCI_HELPER=$(printf %s "$MYPROG" | grep -i "luci") + +# Name Server Lookup Programs +BIND_HOST=$(command -v host) +KNOT_HOST=$(command -v khost) +DRILL=$(command -v drill) +HOSTIP=$(command -v hostip) +NSLOOKUP=$(command -v nslookup) + +# Transfer Programs +WGET=$(command -v wget) +$WGET -V 2>/dev/null | grep -F -q +https && WGET_SSL=$WGET + +CURL=$(command -v curl) +# CURL_SSL not empty then SSL support available +CURL_SSL=$($CURL -V 2>/dev/null | grep -F "https") +# CURL_PROXY not empty then Proxy support available +CURL_PROXY=$(find /lib /usr/lib -name libcurl.so* -exec strings {} 2>/dev/null \; | grep -im1 "all_proxy") + +UCLIENT_FETCH=$(command -v uclient-fetch) + +# Global configuration settings +# allow NON-public IP's +upd_privateip=$(uci -q get ddns.global.upd_privateip) || upd_privateip=0 + +# directory to store run information to. +ddns_rundir=$(uci -q get ddns.global.ddns_rundir) || ddns_rundir="/var/run/ddns" +[ -d $ddns_rundir ] || mkdir -p -m755 $ddns_rundir + +# directory to store log files +ddns_logdir=$(uci -q get ddns.global.ddns_logdir) || ddns_logdir="/var/log/ddns" +[ -d $ddns_logdir ] || mkdir -p -m755 $ddns_logdir + +# number of lines to before rotate logfile +ddns_loglines=$(uci -q get ddns.global.ddns_loglines) || ddns_loglines=250 +ddns_loglines=$((ddns_loglines + 1)) # correct sed handling + +# format to show date information in log and luci-app-ddns default ISO 8601 format +ddns_dateformat=$(uci -q get ddns.global.ddns_dateformat) || ddns_dateformat="%F %R" +DATE_PROG="date +'$ddns_dateformat'" + +# USE_CURL if GNU Wget and cURL installed normally Wget is used by do_transfer() +# to change this use global option use_curl '1' +USE_CURL=$(uci -q get ddns.global.use_curl) || USE_CURL=0 # read config +[ -n "$CURL" ] || USE_CURL=0 # check for cURL + +# loads all options for a given package and section +# also, sets all_option_variables to a list of the variable names +# $1 = ddns, $2 = SECTION_ID +load_all_config_options() +{ + local __PKGNAME="$1" + local __SECTIONID="$2" + local __VAR + local __ALL_OPTION_VARIABLES="" + + # this callback loads all the variables in the __SECTIONID section when we do + # config_load. We need to redefine the option_cb for different sections + # so that the active one isn't still active after we're done with it. For reference + # the $1 variable is the name of the option and $2 is the name of the section + config_cb() + { + if [ ."$2" = ."$__SECTIONID" ]; then + option_cb() + { + __ALL_OPTION_VARIABLES="$__ALL_OPTION_VARIABLES $1" + } + else + option_cb() { return 0; } + fi + } + + config_load "$__PKGNAME" + + # Given SECTION_ID not found so no data, so return 1 + [ -z "$__ALL_OPTION_VARIABLES" ] && return 1 + + for __VAR in $__ALL_OPTION_VARIABLES + do + config_get "$__VAR" "$__SECTIONID" "$__VAR" + done + return 0 +} + +# read's all service sections from ddns config +# $1 = Name of variable to store +load_all_service_sections() { + local __DATA="" + config_cb() + { + # only look for section type "service", ignore everything else + [ "$1" = "service" ] && __DATA="$__DATA $2" + } + config_load "ddns" + + eval "$1=\"$__DATA\"" + return +} + +# starts updater script for all given sections or only for the one given +# $1 = interface (Optional: when given only scripts are started +# configured for that interface) +# used by /etc/hotplug.d/iface/95-ddns on IFUP +# and by /etc/init.d/ddns start +start_daemon_for_all_ddns_sections() +{ + local __EVENTIF="$1" + local __SECTIONS="" + local __SECTIONID="" + local __IFACE="" + + load_all_service_sections __SECTIONS + for __SECTIONID in $__SECTIONS; do + config_get __IFACE "$__SECTIONID" interface "wan" + [ -z "$__EVENTIF" -o "$__IFACE" = "$__EVENTIF" ] || continue + if [ $VERBOSE -eq 0 ]; then # start in background + /usr/lib/ddns/dynamic_dns_updater.sh -v 0 -S "$__SECTIONID" -- start & + else + /usr/lib/ddns/dynamic_dns_updater.sh -v "$VERBOSE" -S "$__SECTIONID" -- start + fi + done +} + +# stop sections process incl. childs (sleeps) +# $1 = section +stop_section_processes() { + local __PID=0 + local __PIDFILE="$ddns_rundir/$1.pid" + [ $# -ne 1 ] && write_log 12 "Error calling 'stop_section_processes()' - wrong number of parameters" + + [ -e "$__PIDFILE" ] && { + __PID=$(cat $__PIDFILE) + ps | grep "^[\t ]*$__PID" >/dev/null 2>&1 && kill $__PID || __PID=0 # terminate it + } + [ $__PID -eq 0 ] # report if process was running +} + +# stop updater script for all defines sections or only for one given +# $1 = interface (optional) +# used by /etc/hotplug.d/iface/95-ddns on 'ifdown' +# and by /etc/init.d/ddns stop +# needed because we also need to kill "sleep" child processes +stop_daemon_for_all_ddns_sections() { + local __EVENTIF="$1" + local __SECTIONS="" + local __SECTIONID="" + local __IFACE="" + + load_all_service_sections __SECTIONS + for __SECTIONID in $__SECTIONS; do + config_get __IFACE "$__SECTIONID" interface "wan" + [ -z "$__EVENTIF" -o "$__IFACE" = "$__EVENTIF" ] || continue + stop_section_processes "$__SECTIONID" + done +} + +# reports to console, logfile, syslog +# $1 loglevel 7 == Debug to 0 == EMERG +# value +10 will exit the scripts +# $2..n text to report +write_log() { + local __LEVEL __EXIT __CMD __MSG __MSE + local __TIME=$(date +%H%M%S) + [ $1 -ge 10 ] && { + __LEVEL=$(($1-10)) + __EXIT=1 + } || { + __LEVEL=$1 + __EXIT=0 + } + shift # remove loglevel + [ $__EXIT -eq 0 ] && __MSG="$*" || __MSG="$* - TERMINATE" + case $__LEVEL in # create log message and command depending on loglevel + 0) __CMD="logger -p user.emerg -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME EMERG : $__MSG" ;; + 1) __CMD="logger -p user.alert -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME ALERT : $__MSG" ;; + 2) __CMD="logger -p user.crit -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME CRIT : $__MSG" ;; + 3) __CMD="logger -p user.err -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME ERROR : $__MSG" ;; + 4) __CMD="logger -p user.warn -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME WARN : $__MSG" ;; + 5) __CMD="logger -p user.notice -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME note : $__MSG" ;; + 6) __CMD="logger -p user.info -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME info : $__MSG" ;; + 7) __MSG=" $__TIME : $__MSG";; + *) return;; + esac + + # verbose echo + [ $VERBOSE -gt 0 -o $__EXIT -gt 0 ] && echo -e "$__MSG" + # write to logfile + if [ ${use_logfile:-1} -eq 1 -o $VERBOSE -gt 1 ]; then + if [ -n "$password" ]; then + # url encode __MSG, password already done + urlencode __MSE "$__MSG" + # replace encoded password inside encoded message + # and url decode (newline was encoded as %00) + __MSG=$( echo -e "$__MSE" \ + | sed -e "s/$URL_PASS/***PW***/g" \ + | sed -e "s/+/ /g; s/%00/\n/g; s/%/\\\\x/g" | xargs -0 printf "%b" ) + fi + printf "%s\n" "$__MSG" >> $LOGFILE + # VERBOSE > 1 then NO loop so NO truncate log to $ddns_loglines lines + [ $VERBOSE -gt 1 ] || sed -i -e :a -e '$q;N;'$ddns_loglines',$D;ba' $LOGFILE + fi + [ -n "$LUCI_HELPER" ] && return # nothing else todo when running LuCI helper script + [ $__LEVEL -eq 7 ] && return # no syslog for debug messages + __CMD=$(echo -e "$__CMD" | tr -d '\n' | tr '\t' ' ') # remove \n \t chars + [ $__EXIT -eq 1 ] && { + eval '$__CMD' # force syslog before exit + exit 1 + } + [ $use_syslog -eq 0 ] && return + [ $((use_syslog + __LEVEL)) -le 7 ] && eval '$__CMD' + + return +} + +# replace all special chars to their %hex value +# used for USERNAME and PASSWORD in update_url +# unchanged: "-"(minus) "_"(underscore) "."(dot) "~"(tilde) +# to verify: "'"(single quote) '"'(double quote) # because shell delimiter +# "$"(Dollar) # because used as variable output +# tested with the following string stored via Luci Application as password / username +# A B!"#AA$1BB%&'()*+,-./:;<=>?@[\]^_`{|}~ without problems at Dollar or quotes +urlencode() { + # $1 Name of Variable to store encoded string to + # $2 string to encode + local __ENC + + [ $# -ne 2 ] && write_log 12 "Error calling 'urlencode()' - wrong number of parameters" + + __ENC="$(awk -v str="$2" 'BEGIN{ORS="";for(i=32;i<=127;i++)lookup[sprintf("%c",i)]=i + for(k=1;k<=length(str);++k){enc=substr(str,k,1);if(enc!~"[-_.~a-zA-Z0-9]")enc=sprintf("%%%02x", lookup[enc]);print enc}}')" + + eval "$1=\"$__ENC\"" # transfer back to variable + return 0 +} + +# extract url or script for given DDNS Provider from +# $1 Name of the provider +# $2 Provider directory +# $3 Name of Variable to store url to +# $4 Name of Variable to store script to +# $5 Name of Variable to store service answer to +get_service_data() { + local provider="$1" + shift + local dir="$1" + shift + + . /usr/share/libubox/jshn.sh + local name data url answer script + + [ $# -ne 3 ] && write_log 12 "Error calling 'get_service_data()' - wrong number of parameters" + + [ -f "${dir}/${provider}.json" ] || { + eval "$1=\"\"" + eval "$2=\"\"" + eval "$3=\"\"" + return 1 + } + + json_load_file "${dir}/${provider}.json" + json_get_var name "name" + if [ "$use_ipv6" -eq "1" ]; then + json_select "ipv6" + else + json_select "ipv4" + fi + json_get_var data "url" + json_get_var answer "answer" + json_select ".." + json_cleanup + + # check if URL or SCRIPT is given + url=$(echo "$data" | grep "^http") + [ -z "$url" ] && script="/usr/lib/ddns/${data}" + + eval "$1=\"$url\"" + eval "$2=\"$script\"" + eval "$3=\"$answer\"" + return 0 +} + +# Calculate seconds from interval and unit +# $1 Name of Variable to store result in +# $2 Number and +# $3 Unit of time interval +get_seconds() { + [ $# -ne 3 ] && write_log 12 "Error calling 'get_seconds()' - wrong number of parameters" + case "$3" in + "days" ) eval "$1=$(( $2 * 86400 ))";; + "hours" ) eval "$1=$(( $2 * 3600 ))";; + "minutes" ) eval "$1=$(( $2 * 60 ))";; + * ) eval "$1=$2";; + esac + return 0 +} + +timeout() { + #.copied from http://www.ict.griffith.edu.au/anthony/software/timeout.sh + # only did the following changes + # - commented out "#!/bin/bash" and usage section + # - replace exit by return for usage as function + # - some reformatting + # + # timeout [-SIG] time [--] command args... + # + # Run the given command until completion, but kill it if it runs too long. + # Specifically designed to exit immediately (no sleep interval) and clean up + # nicely without messages or leaving any extra processes when finished. + # + # Example use + # timeout 5 countdown + # + # Based on notes in my "Shell Script Hints", section "Command Timeout" + # http://www.ict.griffith.edu.au/~anthony/info/shell/script.hints + # + # This script uses a lot of tricks to terminate both the background command, + # the timeout script, and even the sleep process. It also includes trap + # commands to prevent sub-shells reporting expected "Termination Errors". + # + # It took years of occasional trials, errors and testing to get a pure bash + # timeout command working as well as this does. + # + #.Anthony Thyssen 6 April 2011 + # +# PROGNAME=$(type $0 | awk '{print $3}') # search for executable on path +# PROGDIR=$(dirname $PROGNAME) # extract directory of program +# PROGNAME=$(basename $PROGNAME) # base name of program + + # output the script comments as docs +# Usage() { +# echo >&2 "$PROGNAME:" "$@" +# sed >&2 -n '/^###/q; /^#/!q; s/^#//; s/^ //; 3s/^/Usage: /; 2,$ p' "$PROGDIR/$PROGNAME" +# exit 10; +# } + + SIG=-TERM + + while [ $# -gt 0 ]; do + case "$1" in + --) + # forced end of user options + shift; + break ;; +# -\?|--help|--doc*) +# Usage ;; + [0-9]*) + TIMEOUT="$1" ;; + -*) + SIG="$1" ;; + *) + # unforced end of user options + break ;; + esac + shift # next option + done + + # run main command in backgrounds and get its pid + "$@" & + command_pid=$! + + # timeout sub-process abort countdown after ABORT seconds! also backgrounded + sleep_pid=0 + ( + # cleanup sleep process + trap 'kill -TERM $sleep_pid; return 1' 1 2 3 15 + # sleep timeout period in background + sleep $TIMEOUT & + sleep_pid=$! + wait $sleep_pid + # Abort the command + kill $SIG $command_pid >/dev/null 2>&1 + return 1 + ) & + timeout_pid=$! + + # Wait for main command to finished or be timed out + wait $command_pid + status=$? + + # Clean up timeout sub-shell - if it is still running! + kill $timeout_pid 2>/dev/null + wait $timeout_pid 2>/dev/null + + # Uncomment to check if a LONG sleep still running (no sleep should be) + # sleep 1 + # echo "-----------" + # /bin/ps j # uncomment to show if abort "sleep" is still sleeping + + return $status +} + +# sanitize a variable +# $1 variable name +# $2 allowed shell pattern +# $3 disallowed shell pattern +sanitize_variable() { + local __VAR=$1 + eval __VALUE=\$$__VAR + local __ALLOWED=$2 + local __REJECT=$3 + + # removing all allowed should give empty string + if [ -n "$__ALLOWED" ]; then + [ -z "${__VALUE//$__ALLOWED}" ] || write_log 12 "sanitize on $__VAR found characters outside allowed subset" + fi + + # removing rejected pattern should give the same string as the input + if [ -n "$__REJECT" ]; then + [ "$__VALUE" = "${__VALUE//$__REJECT}" ] || write_log 12 "sanitize on $__VAR found rejected characters" + fi +} + +# verify given host and port is connectable +# $1 Host/IP to verify +# $2 Port to verify +verify_host_port() { + local __HOST=$1 + local __PORT=$2 + local __NC=$(command -v nc) + local __NCEXT=$($(command -v nc) --help 2>&1 | grep "\-w" 2>/dev/null) # busybox nc compiled with extensions + local __IP __IPV4 __IPV6 __RUNPROG __PROG __ERR + # return codes + # 1 system specific error + # 2 nslookup/host error + # 3 nc (netcat) error + # 4 unmatched IP version + + [ $# -ne 2 ] && write_log 12 "Error calling 'verify_host_port()' - wrong number of parameters" + + # check if ip or FQDN was given + __IPV4=$(echo $__HOST | grep -m 1 -o "$IPV4_REGEX$") # do not detect ip in 0.0.0.0.example.com + __IPV6=$(echo $__HOST | grep -m 1 -o "$IPV6_REGEX") + # if FQDN given get IP address + [ -z "$__IPV4" -a -z "$__IPV6" ] && { + if [ -n "$BIND_HOST" ]; then # use BIND host if installed + __PROG="BIND host" + __RUNPROG="$BIND_HOST $__HOST >$DATFILE 2>$ERRFILE" + elif [ -n "$KNOT_HOST" ]; then # use Knot host if installed + __PROG="Knot host" + __RUNPROG="$KNOT_HOST $__HOST >$DATFILE 2>$ERRFILE" + elif [ -n "$DRILL" ]; then # use drill if installed + __PROG="drill" + __RUNPROG="$DRILL -V0 $__HOST A >$DATFILE 2>$ERRFILE" # IPv4 + __RUNPROG="$__RUNPROG; $DRILL -V0 $__HOST AAAA >>$DATFILE 2>>$ERRFILE" # IPv6 + elif [ -n "$HOSTIP" ]; then # use hostip if installed + __PROG="hostip" + __RUNPROG="$HOSTIP $__HOST >$DATFILE 2>$ERRFILE" # IPv4 + __RUNPROG="$__RUNPROG; $HOSTIP -6 $__HOST >>$DATFILE 2>>$ERRFILE" # IPv6 + else # use BusyBox nslookup + __PROG="BusyBox nslookup" + __RUNPROG="$NSLOOKUP $__HOST >$DATFILE 2>$ERRFILE" + fi + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG + __ERR=$? + # command error + [ $__ERR -gt 0 ] && { + write_log 3 "DNS Resolver Error - $__PROG Error '$__ERR'" + write_log 7 "$(cat $ERRFILE)" + return 2 + } + # extract IP address + if [ -n "$BIND_HOST" -o -n "$KNOT_HOST" ]; then # use BIND host or Knot host if installed + __IPV4="$(awk -F "address " '/has address/ {print $2; exit}' "$DATFILE")" + __IPV6="$(awk -F "address " '/has IPv6/ {print $2; exit}' "$DATFILE")" + elif [ -n "$DRILL" ]; then # use drill if installed + __IPV4="$(awk '/^'"$__HOST"'/ {print $5}' "$DATFILE" | grep -m 1 -o "$IPV4_REGEX")" + __IPV6="$(awk '/^'"$__HOST"'/ {print $5}' "$DATFILE" | grep -m 1 -o "$IPV6_REGEX")" + elif [ -n "$HOSTIP" ]; then # use hostip if installed + __IPV4="$(grep -m 1 -o "$IPV4_REGEX" "$DATFILE")" + __IPV6="$(grep -m 1 -o "$IPV6_REGEX" "$DATFILE")" + else # use BusyBox nslookup + __IPV4="$(sed -ne "/^Name:/,\$ { s/^Address[0-9 ]\{0,\}: \($IPV4_REGEX\).*$/\\1/p }" "$DATFILE")" + __IPV6="$(sed -ne "/^Name:/,\$ { s/^Address[0-9 ]\{0,\}: \($IPV6_REGEX\).*$/\\1/p }" "$DATFILE")" + fi + } + + # check IP version if forced + if [ $force_ipversion -ne 0 ]; then + __ERR=0 + [ $use_ipv6 -eq 0 -a -z "$__IPV4" ] && __ERR=4 + [ $use_ipv6 -eq 1 -a -z "$__IPV6" ] && __ERR=6 + [ $__ERR -gt 0 ] && { + [ -n "$LUCI_HELPER" ] && return 4 + write_log 14 "Verify host Error '4' - Forced IP Version IPv$__ERR don't match" + } + fi + + # verify nc command + # busybox nc compiled without -l option "NO OPT l!" -> critical error + $__NC --help 2>&1 | grep -i "NO OPT l!" >/dev/null 2>&1 && \ + write_log 12 "Busybox nc (netcat) compiled without '-l' option, error 'NO OPT l!'" + # busybox nc compiled with extensions + $__NC --help 2>&1 | grep "\-w" >/dev/null 2>&1 && __NCEXT="TRUE" + + # connectivity test + # run busybox nc to HOST PORT + # busybox might be compiled with "FEATURE_PREFER_IPV4_ADDRESS=n" + # then nc will try to connect via IPv6 if there is any IPv6 available on any host interface + # not worrying, if there is an IPv6 wan address + # so if not "force_ipversion" to use_ipv6 then connect test via ipv4, if available + [ $force_ipversion -ne 0 -a $use_ipv6 -ne 0 -o -z "$__IPV4" ] && __IP=$__IPV6 || __IP=$__IPV4 + + if [ -n "$__NCEXT" ]; then # BusyBox nc compiled with extensions (timeout support) + __RUNPROG="$__NC -w 1 $__IP $__PORT $DATFILE 2>$ERRFILE" + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG + __ERR=$? + [ $__ERR -eq 0 ] && return 0 + write_log 3 "Connect error - BusyBox nc (netcat) Error '$__ERR'" + write_log 7 "$(cat $ERRFILE)" + return 3 + else # nc compiled without extensions (no timeout support) + __RUNPROG="timeout 2 -- $__NC $__IP $__PORT $DATFILE 2>$ERRFILE" + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG + __ERR=$? + [ $__ERR -eq 0 ] && return 0 + write_log 3 "Connect error - BusyBox nc (netcat) timeout Error '$__ERR'" + return 3 + fi +} + +# verify given DNS server if connectable +# $1 DNS server to verify +verify_dns() { + local __ERR=255 # last error buffer + local __CNT=0 # error counter + + [ $# -ne 1 ] && write_log 12 "Error calling 'verify_dns()' - wrong number of parameters" + write_log 7 "Verify DNS server '$1'" + + while [ $__ERR -ne 0 ]; do + # DNS uses port 53 + verify_host_port "$1" "53" + __ERR=$? + if [ -n "$LUCI_HELPER" ]; then # no retry if called by LuCI helper script + return $__ERR + elif [ $__ERR -ne 0 -a $VERBOSE -gt 1 ]; then # VERBOSE > 1 then NO retry + write_log 4 "Verify DNS server '$1' failed - Verbose Mode: $VERBOSE - NO retry on error" + return $__ERR + elif [ $__ERR -ne 0 ]; then + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Verify DNS server '$1' failed after $retry_count retries" + + write_log 4 "Verify DNS server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + fi + done + return 0 +} + +# analyze and verify given proxy string +# $1 Proxy-String to verify +verify_proxy() { + # complete entry user:password@host:port + # inside user and password NO '@' of ":" allowed + # host and port only host:port + # host only host ERROR unsupported + # IPv4 address instead of host 123.234.234.123 + # IPv6 address instead of host [xxxx:....:xxxx] in square bracket + local __TMP __HOST __PORT + local __ERR=255 # last error buffer + local __CNT=0 # error counter + + [ $# -ne 1 ] && write_log 12 "Error calling 'verify_proxy()' - wrong number of parameters" + write_log 7 "Verify Proxy server 'http://$1'" + + # try to split user:password "@" host:port + __TMP=$(echo $1 | awk -F "@" '{print $2}') + # no "@" found - only host:port is given + [ -z "$__TMP" ] && __TMP="$1" + # now lets check for IPv6 address + __HOST=$(echo $__TMP | grep -m 1 -o "$IPV6_REGEX") + # IPv6 host address found read port + if [ -n "$__HOST" ]; then + # IPv6 split at "]:" + __PORT=$(echo $__TMP | awk -F "]:" '{print $2}') + else + __HOST=$(echo $__TMP | awk -F ":" '{print $1}') + __PORT=$(echo $__TMP | awk -F ":" '{print $2}') + fi + # No Port detected - EXITING + [ -z "$__PORT" ] && { + [ -n "$LUCI_HELPER" ] && return 5 + write_log 14 "Invalid Proxy server Error '5' - proxy port missing" + } + + while [ $__ERR -gt 0 ]; do + verify_host_port "$__HOST" "$__PORT" + __ERR=$? + if [ -n "$LUCI_HELPER" ]; then # no retry if called by LuCI helper script + return $__ERR + elif [ $__ERR -gt 0 -a $VERBOSE -gt 1 ]; then # VERBOSE > 1 then NO retry + write_log 4 "Verify Proxy server '$1' failed - Verbose Mode: $VERBOSE - NO retry on error" + return $__ERR + elif [ $__ERR -gt 0 ]; then + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Verify Proxy server '$1' failed after $retry_count retries" + + write_log 4 "Verify Proxy server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + fi + done + return 0 +} + +do_transfer() { + # $1 # URL to use + local __URL="$1" + local __ERR=0 + local __CNT=0 # error counter + local __PROG __RUNPROG + + [ $# -ne 1 ] && write_log 12 "Error in 'do_transfer()' - wrong number of parameters" + + # Use ip_network as default for bind_network if not separately specified + [ -z "$bind_network" ] && [ "$ip_source" = "network" ] && [ "$ip_network" ] && bind_network="$ip_network" + + # lets prefer GNU Wget because it does all for us - IPv4/IPv6/HTTPS/PROXY/force IP version + if [ -n "$WGET_SSL" ] && [ $USE_CURL -eq 0 ]; then # except global option use_curl is set to "1" + __PROG="$WGET --hsts-file=/tmp/.wget-hsts -nv -t 1 -O $DATFILE -o $ERRFILE" # non_verbose no_retry outfile errfile + # force network/ip to use for communication + if [ -n "$bind_network" ]; then + local __BINDIP + # set correct program to detect IP + [ $use_ipv6 -eq 0 ] && __RUNPROG="network_get_ipaddr" || __RUNPROG="network_get_ipaddr6" + eval "$__RUNPROG __BINDIP $bind_network" || \ + write_log 13 "Can not detect local IP using '$__RUNPROG $bind_network' - Error: '$?'" + write_log 7 "Force communication via IP '$__BINDIP'" + __PROG="$__PROG --bind-address=$__BINDIP" + fi + # force ip version to use + if [ $force_ipversion -eq 1 ]; then + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" # force IPv4/IPv6 + fi + # set certificate parameters + if [ $use_https -eq 1 ]; then + if [ "$cacert" = "IGNORE" ]; then # idea from Ticket #15327 to ignore server cert + __PROG="$__PROG --no-check-certificate" + elif [ -f "$cacert" ]; then + __PROG="$__PROG --ca-certificate=${cacert}" + elif [ -d "$cacert" ]; then + __PROG="$__PROG --ca-directory=${cacert}" + elif [ -n "$cacert" ]; then # it's not a file and not a directory but given + write_log 14 "No valid certificate(s) found at '$cacert' for HTTPS communication" + fi + fi + # disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set) + [ -z "$proxy" ] && __PROG="$__PROG --no-proxy" + + # user agent string if provided + if [ -n "$user_agent" ]; then + # replace single and double quotes + user_agent=$(echo $user_agent | sed "s/'/ /g" | sed 's/"/ /g') + __PROG="$__PROG --user-agent='$user_agent'" + fi + + __RUNPROG="$__PROG '$__URL'" # build final command + __PROG="GNU Wget" # reuse for error logging + + # 2nd choice is cURL IPv4/IPv6/HTTPS + # libcurl might be compiled without Proxy or HTTPS Support + elif [ -n "$CURL" ]; then + __PROG="$CURL -RsS -o $DATFILE --stderr $ERRFILE" + # check HTTPS support + [ -z "$CURL_SSL" -a $use_https -eq 1 ] && \ + write_log 13 "cURL: libcurl compiled without https support" + # force network/interface-device to use for communication + if [ -n "$bind_network" ]; then + local __DEVICE + network_get_device __DEVICE $bind_network || \ + write_log 13 "Can not detect local device using 'network_get_device $bind_network' - Error: '$?'" + write_log 7 "Force communication via device '$__DEVICE'" + __PROG="$__PROG --interface $__DEVICE" + fi + # force ip version to use + if [ $force_ipversion -eq 1 ]; then + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" # force IPv4/IPv6 + fi + # set certificate parameters + if [ $use_https -eq 1 ]; then + if [ "$cacert" = "IGNORE" ]; then # idea from Ticket #15327 to ignore server cert + __PROG="$__PROG --insecure" # but not empty better to use "IGNORE" + elif [ -f "$cacert" ]; then + __PROG="$__PROG --cacert $cacert" + elif [ -d "$cacert" ]; then + __PROG="$__PROG --capath $cacert" + elif [ -n "$cacert" ]; then # it's not a file and not a directory but given + write_log 14 "No valid certificate(s) found at '$cacert' for HTTPS communication" + fi + fi + # disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set) + # or check if libcurl compiled with proxy support + if [ -z "$proxy" ]; then + __PROG="$__PROG --noproxy '*'" + elif [ -z "$CURL_PROXY" ]; then + # if libcurl has no proxy support and proxy should be used then force ERROR + write_log 13 "cURL: libcurl compiled without Proxy support" + fi + + __RUNPROG="$__PROG '$__URL'" # build final command + __PROG="cURL" # reuse for error logging + + # uclient-fetch possibly with ssl support if /lib/libustream-ssl.so installed + elif [ -n "$UCLIENT_FETCH" ]; then + # UCLIENT_FETCH_SSL not empty then SSL support available + UCLIENT_FETCH_SSL=$(find /lib /usr/lib -name libustream-ssl.so* 2>/dev/null) + __PROG="$UCLIENT_FETCH -q -O $DATFILE" + # force network/ip not supported + [ -n "$__BINDIP" ] && \ + write_log 14 "uclient-fetch: FORCE binding to specific address not supported" + # force ip version to use + if [ $force_ipversion -eq 1 ]; then + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" # force IPv4/IPv6 + fi + # https possibly not supported + [ $use_https -eq 1 -a -z "$UCLIENT_FETCH_SSL" ] && \ + write_log 14 "uclient-fetch: no HTTPS support! Additional install one of ustream-ssl packages" + # proxy support + [ -z "$proxy" ] && __PROG="$__PROG -Y off" || __PROG="$__PROG -Y on" + # https & certificates + if [ $use_https -eq 1 ]; then + if [ "$cacert" = "IGNORE" ]; then + __PROG="$__PROG --no-check-certificate" + elif [ -f "$cacert" ]; then + __PROG="$__PROG --ca-certificate=$cacert" + elif [ -n "$cacert" ]; then # it's not a file; nothing else supported + write_log 14 "No valid certificate file '$cacert' for HTTPS communication" + fi + fi + __RUNPROG="$__PROG '$__URL' 2>$ERRFILE" # build final command + __PROG="uclient-fetch" # reuse for error logging + + # Busybox Wget or any other wget in search $PATH (did not support neither IPv6 nor HTTPS) + elif [ -n "$WGET" ]; then + __PROG="$WGET -q -O $DATFILE" + # force network/ip not supported + [ -n "$__BINDIP" ] && \ + write_log 14 "BusyBox Wget: FORCE binding to specific address not supported" + # force ip version not supported + [ $force_ipversion -eq 1 ] && \ + write_log 14 "BusyBox Wget: Force connecting to IPv4 or IPv6 addresses not supported" + # https not supported + [ $use_https -eq 1 ] && \ + write_log 14 "BusyBox Wget: no HTTPS support" + # disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set) + [ -z "$proxy" ] && __PROG="$__PROG -Y off" + + __RUNPROG="$__PROG '$__URL' 2>$ERRFILE" # build final command + __PROG="Busybox Wget" # reuse for error logging + + else + write_log 13 "Neither 'Wget' nor 'cURL' nor 'uclient-fetch' installed or executable" + fi + + while : ; do + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG # DO transfer + __ERR=$? # save error code + [ $__ERR -eq 0 ] && return 0 # no error leave + [ -n "$LUCI_HELPER" ] && return 1 # no retry if called by LuCI helper script + + write_log 3 "$__PROG Error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" # report error + + [ $VERBOSE -gt 1 ] && { + # VERBOSE > 1 then NO retry + write_log 4 "Transfer failed - Verbose Mode: $VERBOSE - NO retry on error" + return 1 + } + + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Transfer failed after $retry_count retries" + + write_log 4 "Transfer failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + done + # we should never come here there must be a programming error + write_log 12 "Error in 'do_transfer()' - program coding error" +} + +send_update() { + # $1 # IP to set at DDNS service provider + local __IP + + [ $# -ne 1 ] && write_log 12 "Error calling 'send_update()' - wrong number of parameters" + + if [ $upd_privateip -eq 0 ]; then + # verify given IP / no private IPv4's / no IPv6 addr starting with fxxx of with ":" + [ $use_ipv6 -eq 0 ] && __IP=$(echo $1 | grep -v -E "(^0|^10\.|^100\.6[4-9]\.|^100\.[7-9][0-9]\.|^100\.1[0-1][0-9]\.|^100\.12[0-7]\.|^127|^169\.254|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-1]\.|^192\.168)") + [ $use_ipv6 -eq 1 ] && __IP=$(echo $1 | grep "^[0-9a-eA-E]") + else + __IP=$(echo $1 | grep -m 1 -o "$IPV4_REGEX") # valid IPv4 or + [ -z "$__IP" ] && __IP=$(echo $1 | grep -m 1 -o "$IPV6_REGEX") # IPv6 + fi + [ -z "$__IP" ] && { + write_log 3 "No or private or invalid IP '$1' given! Please check your configuration" + return 127 + } + + if [ -n "$update_script" ]; then + write_log 7 "parsing script '$update_script'" + . $update_script + else + local __URL __ERR + + # do replaces in URL + __URL=$(echo $update_url | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \ + -e "s#\[PARAMENC\]#$URL_PENC#g" -e "s#\[PARAMOPT\]#$param_opt#g" \ + -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g") + [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#') + + do_transfer "$__URL" || return 1 + + write_log 7 "DDNS Provider answered:${N}$(cat $DATFILE)" + + [ -z "$UPD_ANSWER" ] && return 0 # not set then ignore + + grep -i -E "$UPD_ANSWER" $DATFILE >/dev/null 2>&1 + return $? # "0" if found + fi +} + +get_local_ip () { + # $1 Name of Variable to store local IP (LOCAL_IP) + local __CNT=0 # error counter + local __RUNPROG __DATA __URL __ERR + + [ $# -ne 1 ] && write_log 12 "Error calling 'get_local_ip()' - wrong number of parameters" + write_log 7 "Detect local IP on '$ip_source'" + + while : ; do + if [ -n "$ip_network" -a "$ip_source" = "network" ]; then + # set correct program + network_flush_cache # force re-read data from ubus + [ $use_ipv6 -eq 0 ] && __RUNPROG="network_get_ipaddr" \ + || __RUNPROG="network_get_ipaddr6" + eval "$__RUNPROG __DATA $ip_network" || \ + write_log 13 "Can not detect local IP using $__RUNPROG '$ip_network' - Error: '$?'" + [ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected on network '$ip_network'" + elif [ -n "$ip_interface" -a "$ip_source" = "interface" ]; then + local __DATA4=""; local __DATA6="" + if [ -n "$(command -v ip)" ]; then # ip program installed + write_log 7 "#> ip -o addr show dev $ip_interface scope global >$DATFILE 2>$ERRFILE" + ip -o addr show dev $ip_interface scope global >$DATFILE 2>$ERRFILE + __ERR=$? + if [ $__ERR -eq 0 ]; then + # DATFILE (sample) + # 10: l2tp-inet: mtu 1456 qdisc fq_codel state UNKNOWN qlen 3\ link/ppp + # 10: l2tp-inet inet 95.30.176.51 peer 95.30.176.1/32 scope global l2tp-inet\ valid_lft forever preferred_lft forever + # 5: eth1: mtu 1500 qdisc fq_codel state UP qlen 1000\ link/ether 08:00:27:d0:10:32 brd ff:ff:ff:ff:ff:ff + # 5: eth1 inet 172.27.10.128/24 brd 172.27.10.255 scope global eth1\ valid_lft forever preferred_lft forever + # 5: eth1 inet 172.55.55.155/24 brd 172.27.10.255 scope global eth1\ valid_lft 12345sec preferred_lft 12345sec + # 5: eth1 inet6 2002:b0c7:f326::806b:c629:b8b9:433/128 scope global dynamic \ valid_lft 8026sec preferred_lft 8026sec + # 5: eth1 inet6 fd43:5368:6f6d:6500:806b:c629:b8b9:433/128 scope global dynamic \ valid_lft 8026sec preferred_lft 8026sec + # 5: eth1 inet6 fd43:5368:6f6d:6500:a00:27ff:fed0:1032/64 scope global dynamic \ valid_lft 14352sec preferred_lft 14352sec + # 5: eth1 inet6 2002:b0c7:f326::a00:27ff:fed0:1032/64 scope global dynamic \ valid_lft 14352sec preferred_lft 14352sec + + # remove remove remove replace replace + # link inet6 fxxx sec forever=>-1 / => ' ' to separate subnet from ip + sed "/link/d; /inet6 f/d; s/sec//g; s/forever/-1/g; s/\// /g" $DATFILE | \ + awk '{ print $3" "$4" "$NF }' > $ERRFILE # temp reuse ERRFILE + # we only need inet? IP prefered time + + local __TIME4=0; local __TIME6=0 + local __TYP __ADR __TIME + while read __TYP __ADR __TIME; do + __TIME=${__TIME:-0} # supress shell errors on last (empty) line of DATFILE + # IPversion no "-1" record stored - now "-1" record or new time > oldtime + [ "$__TYP" = "inet6" -a $__TIME6 -ge 0 -a \( $__TIME -lt 0 -o $__TIME -gt $__TIME6 \) ] && { + __DATA6="$__ADR" + __TIME6="$__TIME" + } + [ "$__TYP" = "inet" -a $__TIME4 -ge 0 -a \( $__TIME -lt 0 -o $__TIME -gt $__TIME4 \) ] && { + __DATA4="$__ADR" + __TIME4="$__TIME" + } + done < $ERRFILE + else + write_log 3 "ip Error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" # report error + fi + else # use deprecated ifconfig + write_log 7 "#> ifconfig $ip_interface >$DATFILE 2>$ERRFILE" + ifconfig $ip_interface >$DATFILE 2>$ERRFILE + __ERR=$? + if [ $__ERR -eq 0 ]; then + __DATA4=$(awk ' + /inet addr:/ { # Filter IPv4 + # inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0 + $1=""; # remove inet + $3=""; # remove Bcast: ... + $4=""; # remove Mask: ... + FS=":"; # separator ":" + $0=$0; # reread to activate separator + $1=""; # remove addr + FS=" "; # set back separator to default " " + $0=$0; # reread to activate separator (remove whitespaces) + print $1; # print IPv4 addr + }' $DATFILE + ) + __DATA6=$(awk ' + /inet6/ && /: [0-9a-eA-E]/ { # Filter IPv6 exclude fxxx + # inet6 addr: 2001:db8::xxxx:xxxx/32 Scope:Global + FS="/"; # separator "/" + $0=$0; # reread to activate separator + $2=""; # remove everything behind "/" + FS=" "; # set back separator to default " " + $0=$0; # reread to activate separator + print $3; # print IPv6 addr + }' $DATFILE + ) + else + write_log 3 "ifconfig Error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" # report error + fi + fi + [ $use_ipv6 -eq 0 ] && __DATA="$__DATA4" || __DATA="$__DATA6" + [ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected on interface '$ip_interface'" + elif [ -n "$ip_script" -a "$ip_source" = "script" ]; then + write_log 7 "#> $ip_script >$DATFILE 2>$ERRFILE" + eval $ip_script >$DATFILE 2>$ERRFILE + __ERR=$? + if [ $__ERR -eq 0 ]; then + __DATA=$(cat $DATFILE) + [ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected via script '$ip_script'" + else + write_log 3 "$ip_script Error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" # report error + fi + elif [ -n "$ip_url" -a "$ip_source" = "web" ]; then + do_transfer "$ip_url" + # use correct regular expression + [ $use_ipv6 -eq 0 ] \ + && __DATA=$(grep -m 1 -o "$IPV4_REGEX" $DATFILE) \ + || __DATA=$(grep -m 1 -o "$IPV6_REGEX" $DATFILE) + [ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected on web at '$ip_url'" + else + write_log 12 "Error in 'get_local_ip()' - unhandled ip_source '$ip_source'" + fi + # valid data found return here + [ -n "$__DATA" ] && { + eval "$1=\"$__DATA\"" + return 0 + } + + [ -n "$LUCI_HELPER" ] && return 1 # no retry if called by LuCI helper script + + write_log 7 "Data detected:" + write_log 7 "$(cat $DATFILE)" + + [ $VERBOSE -gt 1 ] && { + # VERBOSE > 1 then NO retry + write_log 4 "Get local IP via '$ip_source' failed - Verbose Mode: $VERBOSE - NO retry on error" + return 1 + } + + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Get local IP via '$ip_source' failed after $retry_count retries" + write_log 4 "Get local IP via '$ip_source' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + done + # we should never come here there must be a programming error + write_log 12 "Error in 'get_local_ip()' - program coding error" +} + +get_registered_ip() { + # $1 Name of Variable to store public IP (REGISTERED_IP) + # $2 (optional) if set, do not retry on error + local __CNT=0 # error counter + local __ERR=255 + local __REGEX __PROG __RUNPROG __DATA __IP + # return codes + # 1 no IP detected + + [ $# -lt 1 -o $# -gt 2 ] && write_log 12 "Error calling 'get_registered_ip()' - wrong number of parameters" + [ $is_glue -eq 1 -a -z "$BIND_HOST" ] && write_log 14 "Lookup of glue records is only supported using BIND host" + write_log 7 "Detect registered/public IP" + + # set correct regular expression + [ $use_ipv6 -eq 0 ] && __REGEX="$IPV4_REGEX" || __REGEX="$IPV6_REGEX" + + if [ -n "$BIND_HOST" ]; then + __PROG="$BIND_HOST" + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -t A" || __PROG="$__PROG -t AAAA" + if [ $force_ipversion -eq 1 ]; then # force IP version + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" + fi + [ $force_dnstcp -eq 1 ] && __PROG="$__PROG -T" # force TCP + [ $is_glue -eq 1 ] && __PROG="$__PROG -v" # use verbose output to get additional section + + __RUNPROG="$__PROG $lookup_host $dns_server >$DATFILE 2>$ERRFILE" + __PROG="BIND host" + elif [ -n "$KNOT_HOST" ]; then + __PROG="$KNOT_HOST" + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -t A" || __PROG="$__PROG -t AAAA" + if [ $force_ipversion -eq 1 ]; then # force IP version + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" + fi + [ $force_dnstcp -eq 1 ] && __PROG="$__PROG -T" # force TCP + + __RUNPROG="$__PROG $lookup_host $dns_server >$DATFILE 2>$ERRFILE" + __PROG="Knot host" + elif [ -n "$DRILL" ]; then + __PROG="$DRILL -V0" # drill options name @server type + if [ $force_ipversion -eq 1 ]; then # force IP version + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" + fi + [ $force_dnstcp -eq 1 ] && __PROG="$__PROG -t" || __PROG="$__PROG -u" # force TCP + __PROG="$__PROG $lookup_host" + [ -n "$dns_server" ] && __PROG="$__PROG @$dns_server" + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG A" || __PROG="$__PROG AAAA" + + __RUNPROG="$__PROG >$DATFILE 2>$ERRFILE" + __PROG="drill" + elif [ -n "$HOSTIP" ]; then # hostip package installed + __PROG="$HOSTIP" + [ $force_dnstcp -ne 0 ] && \ + write_log 14 "hostip - no support for 'DNS over TCP'" + + # is IP given as dns_server ? + __IP=$(echo $dns_server | grep -m 1 -o "$IPV4_REGEX") + [ -z "$__IP" ] && __IP=$(echo $dns_server | grep -m 1 -o "$IPV6_REGEX") + + # we got NO ip for dns_server, so build command + [ -z "$__IP" -a -n "$dns_server" ] && { + __IP="\`$HOSTIP" + [ $use_ipv6 -eq 1 -a $force_ipversion -eq 1 ] && __IP="$__IP -6" + __IP="$__IP $dns_server | grep -m 1 -o" + [ $use_ipv6 -eq 1 -a $force_ipversion -eq 1 ] \ + && __IP="$__IP '$IPV6_REGEX'" \ + || __IP="$__IP '$IPV4_REGEX'" + __IP="$__IP \`" + } + + [ $use_ipv6 -eq 1 ] && __PROG="$__PROG -6" + [ -n "$dns_server" ] && __PROG="$__PROG -r $__IP" + __RUNPROG="$__PROG $lookup_host >$DATFILE 2>$ERRFILE" + __PROG="hostip" + elif [ -n "$NSLOOKUP" ]; then # last use BusyBox nslookup + NSLOOKUP_MUSL=$($(command -v nslookup) localhost 2>&1 | grep -F "(null)") # not empty busybox compiled with musl + [ $force_dnstcp -ne 0 ] && \ + write_log 14 "Busybox nslookup - no support for 'DNS over TCP'" + [ -n "$NSLOOKUP_MUSL" -a -n "$dns_server" ] && \ + write_log 14 "Busybox compiled with musl - nslookup don't support the use of DNS Server" + [ $force_ipversion -ne 0 ] && \ + write_log 5 "Busybox nslookup - no support to 'force IP Version' (ignored)" + + __RUNPROG="$NSLOOKUP $lookup_host $dns_server >$DATFILE 2>$ERRFILE" + __PROG="BusyBox nslookup" + else # there must be an error + write_log 12 "Error in 'get_registered_ip()' - no supported Name Server lookup software accessible" + fi + + while : ; do + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG + __ERR=$? + if [ $__ERR -ne 0 ]; then + write_log 3 "$__PROG error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" + else + if [ -n "$BIND_HOST" -o -n "$KNOT_HOST" ]; then + if [ $is_glue -eq 1 ]; then + __DATA=$(cat $DATFILE | grep "^$lookup_host" | grep -om1 "$__REGEX" ) + else + __DATA=$(cat $DATFILE | awk -F "address " '/has/ {print $2; exit}' ) + fi + elif [ -n "$DRILL" ]; then + __DATA=$(cat $DATFILE | awk '/^'"$lookup_host"'/ {print $5; exit}' ) + elif [ -n "$HOSTIP" ]; then + __DATA=$(cat $DATFILE | grep -om1 "$__REGEX") + elif [ -n "$NSLOOKUP" ]; then + __DATA=$(cat $DATFILE | sed -ne "/^Name:/,\$ { s/^Address[0-9 ]\{0,\}: \($__REGEX\).*$/\\1/p }" ) + fi + [ -n "$__DATA" ] && { + write_log 7 "Registered IP '$__DATA' detected" + [ -z "$IPFILE" ] || echo "$__DATA" > $IPFILE + eval "$1=\"$__DATA\"" # valid data found + return 0 # leave here + } + write_log 4 "NO valid IP found" + __ERR=127 + fi + [ -z "$IPFILE" ] || echo "" > $IPFILE + + [ -n "$LUCI_HELPER" ] && return $__ERR # no retry if called by LuCI helper script + [ -n "$2" ] && return $__ERR # $2 is given -> no retry + [ $VERBOSE -gt 1 ] && { + # VERBOSE > 1 then NO retry + write_log 4 "Get registered/public IP for '$lookup_host' failed - Verbose Mode: $VERBOSE - NO retry on error" + return $__ERR + } + + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Get registered/public IP for '$lookup_host' failed after $retry_count retries" + + write_log 4 "Get registered/public IP for '$lookup_host' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + done + # we should never come here there must be a programming error + write_log 12 "Error in 'get_registered_ip()' - program coding error" +} + +get_uptime() { + # $1 Variable to store result in + [ $# -ne 1 ] && write_log 12 "Error calling 'verify_host_port()' - wrong number of parameters" + local __UPTIME=$(cat /proc/uptime) + eval "$1=\"${__UPTIME%%.*}\"" +} + +trap_handler() { + # $1 trap signal + # $2 optional (exit status) + local __PIDS __PID + local __ERR=${2:-0} + local __OLD_IFS=$IFS + local __NEWLINE_IFS=' +' # __NEWLINE_IFS + + [ $PID_SLEEP -ne 0 ] && kill -$1 $PID_SLEEP 2>/dev/null # kill pending sleep if exist + + case $1 in + 0) if [ $__ERR -eq 0 ]; then + write_log 5 "PID '$$' exit normal at $(eval $DATE_PROG)${N}" + else + write_log 4 "PID '$$' exit WITH ERROR '$__ERR' at $(eval $DATE_PROG)${N}" + fi ;; + 1) write_log 6 "PID '$$' received 'SIGHUP' at $(eval $DATE_PROG)" + # reload config via starting the script again + /usr/lib/ddns/dynamic_dns_updater.sh -v "0" -S "$__SECTIONID" -- start || true + exit 0 ;; # and leave this one + 2) write_log 5 "PID '$$' terminated by 'SIGINT' at $(eval $DATE_PROG)${N}";; + 3) write_log 5 "PID '$$' terminated by 'SIGQUIT' at $(eval $DATE_PROG)${N}";; + 15) write_log 5 "PID '$$' terminated by 'SIGTERM' at $(eval $DATE_PROG)${N}";; + *) write_log 13 "Unhandled signal '$1' in 'trap_handler()'";; + esac + + __PIDS=$(pgrep -P $$) # get my childs (pgrep prints with "newline") + IFS=$__NEWLINE_IFS + for __PID in $__PIDS; do + kill -$1 $__PID # terminate it + done + IFS=$__OLD_IFS + + # remove out and err file + [ -f $DATFILE ] && rm -f $DATFILE + [ -f $ERRFILE ] && rm -f $ERRFILE + + # exit with correct handling: + # remove trap handling settings and send kill to myself + trap - 0 1 2 3 15 + [ $1 -gt 0 ] && kill -$1 $$ +} + +split_FQDN() { + # $1 FQDN to split + # $2 name of variable to store TLD + # $3 name of variable to store (reg)Domain + # $4 name of variable to store Host/Subdomain + + [ $# -ne 4 ] && write_log 12 "Error calling 'split_FQDN()' - wrong number of parameters" + [ -z "$1" ] && write_log 12 "Error calling 'split_FQDN()' - missing FQDN to split" + [ -f $TLDFILE ] || write_log 12 "Error calling 'split_FQDN()' - missing file '$TLDFILE'" + + local _HOST _FDOM _CTLD _FTLD + local _SET="$@" # save given function parameters + + local _PAR=$(echo "$1" | tr [A-Z] [a-z] | tr "." " ") # to lower and replace DOT with SPACE + set -- $_PAR # set new as function parameters + _PAR="" # clear variable for later reuse + while [ -n "$1" ] ; do # as long we have parameters + _PAR="$1 $_PAR" # invert order of parameters + shift + done + set -- $_PAR # use new as function parameters + _PAR="" # clear variable + + while [ -n "$1" ] ; do # as long we have parameters + if [ -z "$_CTLD" ]; then # first loop + _CTLD="$1" # CURRENT TLD to look at + shift + else + _CTLD="$1.$_CTLD" # Next TLD to look at + shift + fi + # check if TLD exact match in tld_names.dat, save TLD + zcat $TLDFILE | grep -E "^$_CTLD$" >/dev/null 2>&1 && { + _FTLD="$_CTLD" # save found + _FDOM="$1" # save domain next step might be invalid + continue + } + # check if match any "*" in tld_names.dat, + zcat $TLDFILE | grep -E "^\*.$_CTLD$" >/dev/null 2>&1 && { + [ -z "$1" ] && break # no more data break + # check if next level TLD match excludes "!" in tld_names.dat + if zcat $TLDFILE | grep -E "^!$1.$_CTLD$" >/dev/null 2>&1 ; then + _FTLD="$_CTLD" # Yes + else + _FTLD="$1.$_CTLD" + shift + fi + _FDOM="$1"; shift + } + [ -n "$_FTLD" ] && break # we have something valid, break + done + + # the leftover parameters are the HOST/SUBDOMAIN + while [ -n "$1" ]; do + _HOST="$1 $_HOST" # remember we need to invert + shift + done + _HOST=$(echo $_HOST | tr " " ".") # insert DOT + + set -- $_SET # set back parameters from function call + [ -n "$_FTLD" ] && { + eval "$2=$_FTLD" # set TLD + eval "$3=$_FDOM" # set registrable domain + eval "$4=$_HOST" # set HOST/SUBDOMAIN + return 0 + } + eval "$2=''" # clear TLD + eval "$3=''" # clear registrable domain + eval "$4=''" # clear HOST/SUBDOMAIN + return 1 +} + +expand_ipv6() { + # Original written for bash by + #.Author: Florian Streibelt + # Date: 08.04.2012 + # License: Public Domain, but please be fair and + # attribute the original author(s) and provide + # a link to the original source for corrections: + #. https://github.com/mutax/IPv6-Address-checks + + # $1 IPv6 to expand + # $2 name of variable to store expanded IPv6 + [ $# -ne 2 ] && write_log 12 "Error calling 'expand_ipv6()' - wrong number of parameters" + + INPUT="$(echo "$1" | tr 'A-F' 'a-f')" + [ "$INPUT" = "::" ] && INPUT="::0" # special case :: + + O="" + + while [ "$O" != "$INPUT" ]; do + O="$INPUT" + + # fill all words with zeroes + INPUT=$( echo "$INPUT" | sed -e 's|:\([0-9a-f]\{3\}\):|:0\1:|g' \ + -e 's|:\([0-9a-f]\{3\}\)$|:0\1|g' \ + -e 's|^\([0-9a-f]\{3\}\):|0\1:|g' \ + -e 's|:\([0-9a-f]\{2\}\):|:00\1:|g' \ + -e 's|:\([0-9a-f]\{2\}\)$|:00\1|g' \ + -e 's|^\([0-9a-f]\{2\}\):|00\1:|g' \ + -e 's|:\([0-9a-f]\):|:000\1:|g' \ + -e 's|:\([0-9a-f]\)$|:000\1|g' \ + -e 's|^\([0-9a-f]\):|000\1:|g' ) + + done + + # now expand the :: + ZEROES="" + + echo "$INPUT" | grep -qs "::" + if [ "$?" -eq 0 ]; then + GRPS="$( echo "$INPUT" | sed 's|[0-9a-f]||g' | wc -m )" + GRPS=$(( GRPS-1 )) # remove carriage return + MISSING=$(( 8-GRPS )) + while [ $MISSING -gt 0 ]; do + ZEROES="$ZEROES:0000" + MISSING=$(( MISSING-1 )) + done + + # be careful where to place the : + INPUT=$( echo "$INPUT" | sed -e 's|\(.\)::\(.\)|\1'$ZEROES':\2|g' \ + -e 's|\(.\)::$|\1'$ZEROES':0000|g' \ + -e 's|^::\(.\)|'$ZEROES':0000:\1|g;s|^:||g' ) + fi + + # an expanded address has 39 chars + CR + if [ $(echo $INPUT | wc -m) != 40 ]; then + write_log 4 "Error in 'expand_ipv6()' - invalid IPv6 found: '$1' expanded: '$INPUT'" + eval "$2='invalid'" + return 1 + fi + + # echo the fully expanded version of the address + eval "$2=$INPUT" + return 0 +} diff --git a/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh new file mode 100644 index 00000000000..ab3eb78e725 --- /dev/null +++ b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh @@ -0,0 +1,172 @@ +#!/bin/sh +# /usr/lib/ddns/dynamic_dns_lucihelper.sh +# +#.Distributed under the terms of the GNU General Public License (GPL) version 2.0 +#.2014-2018 Christian Schoenebeck +# This script is used by luci-app-ddns +# +# variables in small chars are read from /etc/config/ddns as parameter given here +# variables in big chars are defined inside these scripts as gloval vars +# variables in big chars beginning with "__" are local defined inside functions only +# set -vx #script debugger + +. /usr/lib/ddns/dynamic_dns_functions.sh # global vars are also defined here + +usage() { + cat << EOF + +Usage: + $MYPROG [options] -- command + +Commands: + get_local_ip using given INTERFACE or NETWORK or SCRIPT or URL + get_registered_ip for given FQDN + verify_dns given DNS-SERVER + verify_proxy given PROXY + start start given SECTION + reload force running ddns processes to reload changed configuration + restart restart all ddns processes + +Parameters: + -6 => use_ipv6=1 (default 0) + -d DNS-SERVER => dns_server=SERVER[:PORT] + -f => force_ipversion=1 (default 0) + -g => is_glue=1 (default 0) + -i INTERFACE => ip_interface=INTERFACE; ip_source="interface" + -l FQDN => lookup_host=FQDN + -n NETWORK => ip_network=NETWORK; ip_source="network" + -p PROXY => proxy=[USER:PASS@]PROXY:PORT + -s SCRIPT => ip_script=SCRIPT; ip_source="script" + -t => force_dnstcp=1 (default 0) + -u URL => ip_url=URL; ip_source="web" + -S SECTION SECTION to start + + -h => show this help and exit + -L => use_logfile=1 (default 0) + -v LEVEL => VERBOSE=LEVEL (default 0) + -V => show version and exit + +EOF +} + +usage_err() { + printf %s\\n "$MYPROG: $@" >&2 + usage >&2 + exit 255 +} + +# preset some variables, wrong or not set in ddns-functions.sh +SECTION_ID="lucihelper" +LOGFILE="$ddns_logdir/$SECTION_ID.log" +DATFILE="$ddns_rundir/$SECTION_ID.$$.dat" # save stdout data of WGet and other extern programs called +ERRFILE="$ddns_rundir/$SECTION_ID.$$.err" # save stderr output of WGet and other extern programs called +DDNSPRG="/usr/lib/ddns/dynamic_dns_updater.sh" +VERBOSE=0 # no console logging +# global variables normally set by reading DDNS UCI configuration +use_syslog=0 # no syslog +use_logfile=0 # no logfile + +use_ipv6=0 # Use IPv6 - default IPv4 +force_ipversion=0 # Force IP Version - default 0 - No +force_dnstcp=0 # Force TCP on DNS - default 0 - No +is_glue=0 # Is glue record - default 0 - No +use_https=0 # not needed but must be set + +while getopts ":6d:fghi:l:n:p:s:S:tu:Lv:V" OPT; do + case "$OPT" in + 6) use_ipv6=1;; + d) dns_server="$OPTARG";; + f) force_ipversion=1;; + g) is_glue=1;; + i) ip_interface="$OPTARG"; ip_source="interface";; + l) lookup_host="$OPTARG";; + n) ip_network="$OPTARG"; ip_source="network";; + p) proxy="$OPTARG";; + s) ip_script="$OPTARG"; ip_source="script";; + t) force_dnstcp=1;; + u) ip_url="$OPTARG"; ip_source="web";; + h) usage; exit 255;; + L) use_logfile=1;; + v) VERBOSE=$OPTARG;; + S) SECTION=$OPTARG;; + V) printf %s\\n "ddns-scripts $VERSION"; exit 255;; + :) usage_err "option -$OPTARG missing argument";; + \?) usage_err "invalid option -$OPTARG";; + *) usage_err "unhandled option -$OPT $OPTARG";; + esac +done +shift $((OPTIND - 1 )) # OPTIND is 1 based + +[ $# -eq 0 ] && usage_err "missing command" + +__RET=0 +case "$1" in + get_registered_ip) + [ -z "$lookup_host" ] && usage_err "command 'get_registered_ip': 'lookup_host' not set" + write_log 7 "-----> get_registered_ip IP" + [ -z "$SECTION" ] || IPFILE="$ddns_rundir/$SECTION.ip" + IP="" + get_registered_ip IP + __RET=$? + [ $__RET -ne 0 ] && IP="" + printf "%s" "$IP" + ;; + verify_dns) + [ -z "$dns_server" ] && usage_err "command 'verify_dns': 'dns_server' not set" + write_log 7 "-----> verify_dns '$dns_server'" + verify_dns "$dns_server" + __RET=$? + ;; + verify_proxy) + [ -z "$proxy" ] && usage_err "command 'verify_proxy': 'proxy' not set" + write_log 7 "-----> verify_proxy '$proxy'" + verify_proxy "$proxy" + __RET=$? + ;; + get_local_ip) + [ -z "$ip_source" ] && usage_err "command 'get_local_ip': 'ip_source' not set" + [ -n "$proxy" -a "$ip_source" = "web" ] && { + # proxy defined, used for ip_source=web + export HTTP_PROXY="http://$proxy" + export HTTPS_PROXY="http://$proxy" + export http_proxy="http://$proxy" + export https_proxy="http://$proxy" + } + # don't need IP only the return code + IP="" + if [ "$ip_source" = "web" -o "$ip_source" = "script" ]; then + # we wait only 3 seconds for an + # answer from "web" or "script" + write_log 7 "-----> timeout 3 -- get_local_ip IP" + timeout 3 -- get_local_ip IP + else + write_log 7 "-----> get_local_ip IP" + get_local_ip IP + fi + __RET=$? + ;; + start) + [ -z "$SECTION" ] && usage_err "command 'start': 'SECTION' not set" + if [ $VERBOSE -eq 0 ]; then # start in background + $DDNSPRG -v 0 -S $SECTION -- start & + else + $DDNSPRG -v $VERBOSE -S $SECTION -- start + fi + ;; + reload) + $DDNSPRG -- reload + ;; + restart) + $DDNSPRG -- stop + sleep 1 + $DDNSPRG -- start + ;; + *) + __RET=255 + ;; +esac + +# remove out and err file +[ -f $DATFILE ] && rm -f $DATFILE +[ -f $ERRFILE ] && rm -f $ERRFILE +return $__RET diff --git a/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh new file mode 100644 index 00000000000..8176fa74c63 --- /dev/null +++ b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh @@ -0,0 +1,436 @@ +#!/bin/sh +# /usr/lib/ddns/dynamic_dns_updater.sh +# +#.Distributed under the terms of the GNU General Public License (GPL) version 2.0 +# Original written by Eric Paul Bishop, January 2008 +# (Loosely) based on the script on the one posted by exobyte in the forums here: +# http://forum.openwrt.org/viewtopic.php?id=14040 +# extended and partial rewritten +#.2014-2018 Christian Schoenebeck +# +# variables in small chars are read from /etc/config/ddns +# variables in big chars are defined inside these scripts as global vars +# variables in big chars beginning with "__" are local defined inside functions only +# set -vx #script debugger + +. $(dirname $0)/dynamic_dns_functions.sh # global vars are also defined here + +usage() { + cat << EOF + +Usage: + $MYPROG [options] -- command + +Commands: +start Start SECTION or NETWORK or all +stop Stop NETWORK or all + +Parameters: + -n NETWORK Start/Stop sections in background monitoring NETWORK, force VERBOSE=0 + -S SECTION SECTION to start + use either -N NETWORK or -S SECTION + + -h show this help and exit + -V show version and exit + -v LEVEL VERBOSE=LEVEL (default 1) + '0' NO output to console + '1' output to console + '2' output to console AND logfile + + run once WITHOUT retry on error + '3' output to console AND logfile + + run once WITHOUT retry on error + + NOT sending update to DDNS service + +EOF +} + +usage_err() { + printf %s\\n "$MYPROG: $@" >&2 + usage >&2 + exit 1 +} + +while getopts ":hv:n:S:V" OPT; do + case "$OPT" in + h) usage; exit 0;; + v) VERBOSE=$OPTARG;; + n) NETWORK=$OPTARG;; + S) SECTION_ID=$OPTARG;; + V) printf %s\\n "ddns-scripts $VERSION"; exit 0;; + :) usage_err "option -$OPTARG missing argument";; + \?) usage_err "invalid option -$OPTARG";; + *) usage_err "unhandled option -$OPT $OPTARG";; + esac +done +shift $((OPTIND - 1 )) # OPTIND is 1 based + +[ -n "$NETWORK" -a -n "$SECTION_ID" ] && usage_err "use either option '-N' or '-S' not both" +[ $# -eq 0 ] && usage_err "missing command" +[ $# -gt 1 ] && usage_err "to much commands" + +case "$1" in + start) + if [ -n "$NETWORK" ]; then + start_daemon_for_all_ddns_sections "$NETWORK" + exit 0 + fi + if [ -z "$SECTION_ID" ]; then + start_daemon_for_all_ddns_sections + exit 0 + fi + ;; + stop) + if [ -n "$INTERFACE" ]; then + stop_daemon_for_all_ddns_sections "$NETWORK" + exit 0 + else + stop_daemon_for_all_ddns_sections + exit 0 + fi + exit 1 + ;; + reload) + killall -1 dynamic_dns_updater.sh 2>/dev/null + exit $? + ;; + *) usage_err "unknown command - $1";; +esac + +# set file names +PIDFILE="$ddns_rundir/$SECTION_ID.pid" # Process ID file +UPDFILE="$ddns_rundir/$SECTION_ID.update" # last update successful send (system uptime) +DATFILE="$ddns_rundir/$SECTION_ID.dat" # save stdout data of WGet and other extern programs called +ERRFILE="$ddns_rundir/$SECTION_ID.err" # save stderr output of WGet and other extern programs called +IPFILE="$ddns_rundir/$SECTION_ID.ip" # +LOGFILE="$ddns_logdir/$SECTION_ID.log" # log file + +# VERBOSE > 1 delete logfile if exist to create an empty one +# only with this data of this run for easier diagnostic +# new one created by write_log function +[ $VERBOSE -gt 1 -a -f $LOGFILE ] && rm -f $LOGFILE + +# TRAP handler +trap "trap_handler 0 \$?" 0 # handle script exit with exit status +trap "trap_handler 1" 1 # SIGHUP Hangup / reload config +trap "trap_handler 2" 2 # SIGINT Terminal interrupt +trap "trap_handler 3" 3 # SIGQUIT Terminal quit +# trap "trap_handler 9" 9 # SIGKILL no chance to trap +trap "trap_handler 15" 15 # SIGTERM Termination + +################################################################################ +# Leave this comment here, to clearly document variable names that are expected/possible +# Use load_all_config_options to load config options, which is a much more flexible solution. +# +# config_load "ddns" +# config_get $SECTION_ID