pax_global_header00006660000000000000000000000064145736512660014531gustar00rootroot0000000000000052 comment=bbd659e291162e4423336910e1f8a19b7f878db5 Tachi107-cloudflare-ddns-3e1c227/000077500000000000000000000000001457365126600164055ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/.appveyor.yml000066400000000000000000000027231457365126600210570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2017 Jussi Pakkanen # # SPDX-License-Identifier: CC0-1.0 image: Visual Studio 2019 environment: matrix: - arch: x86 compiler: msvc2019 - arch: x64 compiler: msvc2019 api_token: secure: Zo4CXhD9M2XoeZkF1emEcQK/g6PGIFztGZ1FaYaKg7I5YhDbj962xzj0jqUhgW2C zone_id: secure: SQDa4GZsqrxoVemMabChKXvSOt+EM1Ky2EX6dyN0w7zitwTsQeYOEh8gFMkA21in record_name: secure: EElzS3TkDp8Ph6oz3DWAQxtcbuQE9nyxhjlbEgqcOn4= platform: - x64 install: # Set paths to dependencies (based on architecture) - cmd: if %arch%==x86 (set PYTHON_ROOT=C:\Python39) else (set PYTHON_ROOT=C:\Python39-x64) # Add necessary paths to PATH variable - cmd: set PATH=%cd%;%PYTHON_ROOT%;%PYTHON_ROOT%\Scripts;%PATH% # Install meson and ninja - cmd: pip install --quiet ninja meson # Set up the build environment - cmd: if %compiler%==msvc2019 ( call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" %arch% ) build_script: - cmd: meson setup build --default-library=static --buildtype=debugoptimized -Db_vscrt=static_from_buildtype -Db_sanitize=address -Dtests=true -Dtest_api_token=%api_token% -Dtest_zone_id=%zone_id% -Dtest_record_name=%arch%.%record_name% - cmd: type .\build\subprojects\curl-8.4.0\lib\curl_config.h - cmd: meson compile -C build --verbose test_script: - cmd: meson test -C build --verbose artifacts: - path: build\exe\cloudflare-ddns.exe name: cloudflare-ddns-x64 Tachi107-cloudflare-ddns-3e1c227/.clang-tidy000066400000000000000000000024311457365126600204410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP Checks: '*, -modernize-use-trailing-return-type, -cppcoreguidelines-special-member-functions, -hicpp-special-member-functions, -fuchsia-statically-constructed-objects, -fuchsia-default-arguments-calls, -fuchsia-default-arguments-declarations, -google-objc-function-naming, -cppcoreguidelines-non-private-member-variables-in-classes, -misc-non-private-member-variables-in-classes, -readability-implicit-bool-conversion, -readability-else-after-return, -google-runtime-references, -fuchsia-overloaded-operator, -readability-redundant-access-specifiers, -misc-new-delete-overloads, -llvmlibc-callee-namespace, -llvm-else-after-return, -llvmlibc-restrict-system-libc-headers, -llvmlibc-implementation-in-namespace, -altera-unroll-loops, -altera-struct-pack-align, -bugprone-easily-swappable-parameters, -altera-id-dependent-backward-branch, -cppcoreguidelines-pro-type-vararg, -hicpp-vararg, -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -hicpp-no-array-decay, -cppcoreguidelines-pro-bounds-pointer-arithmetic' CheckOptions: - key: llvm-namespace-comment.ShortNamespaceLines value: 10 - key: cppcoreguidelines-macro-usage.CheckCapsOnly value: true Tachi107-cloudflare-ddns-3e1c227/.editorconfig000066400000000000000000000006071457365126600210650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP # EditorConfig is awesome: https://EditorConfig.org root = true [*] indent_style = tab indent_size = 4 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.{markdown,md}] indent_style = space indent_size = 4 [*.{yaml,yml}] indent_style = space indent_size = 2 Tachi107-cloudflare-ddns-3e1c227/.github/000077500000000000000000000000001457365126600177455ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/.github/FUNDING.yml000066400000000000000000000001661457365126600215650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP liberapay: Tachi github: Tachi107 Tachi107-cloudflare-ddns-3e1c227/.github/workflows/000077500000000000000000000000001457365126600220025ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/.github/workflows/codacy.yaml000066400000000000000000000020141457365126600241250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP name: codacy on: push: branches: main pull_request: branches: main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read security-events: write jobs: codacy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Run Codacy Analysis CLI uses: codacy/codacy-analysis-cli-action@4.0.2 with: output: results.sarif format: sarif # Adjust severity of non-security issues gh-code-scanning-compat: true # Force 0 exit code to allow SARIF file generation # This will handover control about PR rejection to the GitHub side max-allowed-issues: 2147483647 # Upload the SARIF file generated in the previous step - name: Upload SARIF results file uses: github/codeql-action/upload-sarif@v2 with: sarif_file: results.sarif Tachi107-cloudflare-ddns-3e1c227/.github/workflows/codeql.yaml000066400000000000000000000030031457365126600241310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: AGPL-3.0-or-later name: codeql on: push: branches: [ main ] pull_request: # The branches below must be a subset of the branches above branches: [ main ] defaults: run: shell: sh concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read security-events: write jobs: analyze: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install dependencies run: | sudo apt-get -y update sudo apt-get -y install python3-pip ninja-build sudo pip3 install meson # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: cpp queries: security-and-quality # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v2 - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 Tachi107-cloudflare-ddns-3e1c227/.github/workflows/conventional-commits.yaml000066400000000000000000000013731457365126600270420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: AGPL-3.0-or-later name: conventional-commits on: pull_request defaults: run: shell: sh permissions: contents: read jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: ${{ github.event.pull_request.commits }} + 1 - uses: actions/setup-node@v3 - name: Install commitlint cli run: | yarn global add @commitlint/cli @commitlint/config-conventional echo "module.exports = { extends: ['@commitlint/config-conventional'] }" > commitlint.config.js - name: Commitlint run: commitlint --from HEAD~${{ github.event.pull_request.commits }} --to HEAD Tachi107-cloudflare-ddns-3e1c227/.github/workflows/linux.yaml000066400000000000000000000116051457365126600240300ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: AGPL-3.0-or-later name: linux on: push defaults: run: shell: sh concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read jobs: linux: strategy: fail-fast: false # memsan is disabled because of https://github.com/openssl/openssl/issues/11013 matrix: os: [ 'debian:stable', 'debian:testing', 'registry.access.redhat.com/ubi8/ubi-minimal', 'registry.access.redhat.com/ubi9/ubi-minimal' ] compiler: [ 'gcc', 'clang' ] sanitizer: [ 'address', 'thread', 'undefined', 'none' ] exclude: - os: 'registry.access.redhat.com/ubi8/ubi-minimal' sanitizer: 'address' - os: 'registry.access.redhat.com/ubi8/ubi-minimal' sanitizer: 'thread' - os: 'registry.access.redhat.com/ubi8/ubi-minimal' sanitizer: 'undefined' - os: 'registry.access.redhat.com/ubi9/ubi-minimal' sanitizer: 'address' - os: 'registry.access.redhat.com/ubi9/ubi-minimal' sanitizer: 'undefined' runs-on: ubuntu-latest container: image: ${{ matrix.os }} steps: # llvm-dev is required because it contains LLVMgold.so in Debian 11 # libclang-rt-dev is required since Debian 12 - name: Install dependencies (Debian) if: contains(matrix.os, 'debian') run: | if [ ${{ matrix.compiler }} = gcc ]; then compiler=g++; else compiler="clang lld ?exact-name(libclang-rt-dev)"; fi apt -y update apt -y install $compiler meson pkg-config libcurl4-openssl-dev libinih-dev git ca-certificates curl gpg gpgv gpg-agent lcov llvm-dev --no-install-recommends # For some reason libasan and libubsan are unavaiable on RHEL 9 - name: Install dependencies (Red Hat) if: contains(matrix.os, 'redhat') run: | if [ ${{ matrix.compiler }} = gcc ]; then compiler=gcc-c++; else compiler=llvm-toolset; fi microdnf -y --refresh --disableplugin=subscription-manager install $compiler pkgconf libcurl-devel libtsan git python3-pip gnupg unzip curl -LO https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip unzip ninja-linux.zip mv ninja /usr/local/bin rm ninja-linux.zip pip3 install meson - uses: actions/checkout@v3 # LTO disabled because of https://github.com/mesonbuild/meson/issues/8371 - name: Configure Meson run: | if expr ${{ matrix.os }} : ".*ubi8" >/dev/null; then enable_tests=false; else enable_tests=true; fi record_name=$(printf '${{ matrix.sanitizer }}.${{ matrix.compiler }}.${{ matrix.os }}.${{ github.workflow }}.ci.${{ secrets.DOMAIN_NAME }}' | tr -dc '[:alnum:].') if [ ${{ matrix.compiler }} = gcc ]; then CXX=g++; else CXX=clang++ CXX_LD=lld; fi export CXX CXX_LD meson setup build -Dtests=$enable_tests -Dtest_api_token='${{ secrets.API_TOKEN }}' -Dtest_zone_id='${{ secrets.ZONE_ID }}' -Dtest_record_name="$record_name" --buildtype=debug -Db_coverage=true -Db_sanitize=${{ matrix.sanitizer }} -Db_lundef=false -Db_lto=false env: CC: ${{ matrix.compiler }} - name: Build run: ninja -C build - name: Test if: ${{ !contains(matrix.os, 'ubi8') }} run: meson test -C build --verbose - name: Coverage if: ${{ !contains(matrix.os, 'redhat') }} run: | mkdir -p $HOME/.local/bin if [ "${{ matrix.compiler }}" = 'clang' ]; then printf 'llvm-cov gcov "$@"' > $HOME/.local/bin/cov.sh; else printf 'gcov "$@"' > $HOME/.local/bin/cov.sh; fi && chmod +x $HOME/.local/bin/cov.sh lcov --capture --output-file coverage.info --directory . --gcov-tool $HOME/.local/bin/cov.sh --exclude '/usr/*' --exclude "${HOME}"'/.cache/*' --exclude '*/tests/*' --exclude '*/subprojects/*' lcov --list coverage.info curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import curl --silent --remote-name https://uploader.codecov.io/latest/linux/codecov curl --silent --remote-name https://uploader.codecov.io/latest/linux/codecov.SHA256SUM curl --silent --remote-name https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig gpgv codecov.SHA256SUM.sig codecov.SHA256SUM sha256sum --check codecov.SHA256SUM chmod +x codecov ./codecov - name: Artifact name if: matrix.sanitizer == 'none' run: printf 'artifact_name=cloudflare-ddns.${{ matrix.os }}.${{ matrix.compiler }}' | tr -dc '[:alnum:]._=-' >> $GITHUB_ENV - name: Store compiled program if: matrix.sanitizer == 'none' uses: actions/upload-artifact@v3 with: name: ${{ env.artifact_name }} path: | build/libcloudflare-ddns.so.* !build/libcloudflare-ddns.so.*.p build/exe/cloudflare-ddns Tachi107-cloudflare-ddns-3e1c227/.github/workflows/muon.yaml000066400000000000000000000021731457365126600236470ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: AGPL-3.0-or-later name: muon on: push defaults: run: shell: sh concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read jobs: muon: strategy: fail-fast: false matrix: compiler: [ 'g++', 'clang' ] runs-on: ubuntu-latest container: image: debian:testing steps: - name: Install dependencies run: | apt-get -y update apt-get -y install ${{ matrix.compiler }} ninja-build libpkgconf-dev pkgconf libarchive-dev libcurl4-openssl-dev libinih-dev git ca-certificates --no-install-recommends - uses: actions/checkout@v3 - name: Install muon run: | git clone --depth=1 --single-branch https://git.sr.ht/~lattis/muon cd muon ./bootstrap.sh build build/muon setup build ninja -C build build/muon -C build install - name: Configure muon run: muon setup -Dmuon=true build env: CC: ${{ matrix.compiler }} - name: Build run: ninja -C build Tachi107-cloudflare-ddns-3e1c227/.github/workflows/reuse.yaml000066400000000000000000000004601457365126600240110ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP name: reuse on: [push, pull_request] defaults: run: shell: sh permissions: contents: read jobs: reuse: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: fsfe/reuse-action@v1 Tachi107-cloudflare-ddns-3e1c227/.gitignore000066400000000000000000000002371457365126600203770ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP # Clangd /.cache/clangd # Meson wraps /subprojects/* !/subprojects/*.wrap Tachi107-cloudflare-ddns-3e1c227/.muon000066400000000000000000000002111457365126600173560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP setup( 'build', options: { 'muon': true }, ) Tachi107-cloudflare-ddns-3e1c227/.vscode/000077500000000000000000000000001457365126600177465ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/.vscode/launch.json000066400000000000000000000006461457365126600221210ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2022 Andrea Pappacoda * * SPDX-License-Identifier: FSFAP */ { "version": "0.2.0", "configurations": [ { "type": "lldb", "expressions": "native", "request": "launch", "name": "Debug", "preLaunchTask": "compile", "program": "${workspaceFolder}/build/exe/${workspaceFolderBasename}", "args": ["--config", "config.ini"], "cwd": "${workspaceFolder}/build" } ] } Tachi107-cloudflare-ddns-3e1c227/.vscode/tasks.json000066400000000000000000000004761457365126600217750ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2022 Andrea Pappacoda * * SPDX-License-Identifier: FSFAP */ { "version": "2.0.0", "tasks": [ { "label": "compile", "type": "process", "command": "meson", "args": ["compile", "-C", "build"], "presentation": { "reveal": "silent", "focus": false } } ] } Tachi107-cloudflare-ddns-3e1c227/LICENSE.md000066400000000000000000001027271457365126600200220ustar00rootroot00000000000000### GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. ### Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. ### TERMS AND CONDITIONS #### 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. #### 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. #### 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. #### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. #### 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. #### 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: - a) The work must carry prominent notices stating that you modified it, and giving a relevant date. - b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". - c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. - d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. #### 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: - a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. - b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. - c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. - d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. - e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. #### 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: - a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or - b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or - c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or - d) Limiting the use for publicity purposes of names of licensors or authors of the material; or - e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or - f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. #### 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. #### 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. #### 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. #### 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. #### 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. #### 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. #### 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. #### 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. #### 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. #### 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS ### How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. cloudflare-ddns - dynamically change a DNS record using Cloudflare API Copyright (C) 2021 Andrea Pappacoda This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . Tachi107-cloudflare-ddns-3e1c227/LICENSES/000077500000000000000000000000001457365126600176125ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/LICENSES/AGPL-3.0-or-later.txt000066400000000000000000001023441457365126600231230ustar00rootroot00000000000000GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . Tachi107-cloudflare-ddns-3e1c227/LICENSES/CC0-1.0.txt000066400000000000000000000156101457365126600212170ustar00rootroot00000000000000Creative Commons Legal Code CC0 1.0 Universal CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; ii. moral rights retained by the original author(s) and/or performer(s); iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; v. rights protecting the extraction, dissemination, use and reuse of data in a Work; vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 4. Limitations and Disclaimers. a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. Tachi107-cloudflare-ddns-3e1c227/LICENSES/FSFAP.txt000066400000000000000000000003411457365126600212100ustar00rootroot00000000000000Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty. Tachi107-cloudflare-ddns-3e1c227/LICENSES/LGPL-3.0-or-later.txt000066400000000000000000000164031457365126600231360ustar00rootroot00000000000000GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. Tachi107-cloudflare-ddns-3e1c227/LICENSES/MIT.txt000066400000000000000000000020661457365126600210100ustar00rootroot00000000000000MIT License Copyright (c) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Tachi107-cloudflare-ddns-3e1c227/README.md000066400000000000000000000071251457365126600176710ustar00rootroot00000000000000 # cloudflare-ddns [![Linux](https://github.com/Tachi107/cloudflare-ddns/actions/workflows/linux.yaml/badge.svg)](https://github.com/Tachi107/cloudflare-ddns/actions/workflows/linux.yaml) [![Windows](https://ci.appveyor.com/api/projects/status/xe5wo63pxht8pd6n?svg=true)](https://ci.appveyor.com/project/Tachi107/cloudflare-ddns) [![codecov](https://codecov.io/gh/Tachi107/cloudflare-ddns/branch/main/graph/badge.svg?token=Y7NI126ZUQ)](https://codecov.io/gh/Tachi107/cloudflare-ddns) [![REUSE status](https://api.reuse.software/badge/github.com/Tachi107/cloudflare-ddns)](https://api.reuse.software/info/github.com/Tachi107/cloudflare-ddns) cloudflare-ddns is a little program that is really useful when you want to host something but your ISP only provides you a dynamic IP address. It uses Cloudflare's API to update a given DNS record when needed. It's super fast and really lightweight, making it a valid choice for constrained environments. ## Usage This tool is a oneshot program: you run it, it updates the DNS record, and it terminates. To make it run periodically you could use a systemd timer or a cron job. To run the tool you'll need an [API token](https://dash.cloudflare.com/profile/api-tokens); cloudflare-ddns only needs the Zone.DNS edit permission. Once you got the executable you can use it in two ways: you can pass the API Token and the record name as command line arguments or you can use a ini configuration file, tipically located in `/etc/cloudflare-ddns/config.ini`, by passing no arguments at all; [here's the template](exe/config.ini). On custom installations the default config path might be different, but you can always locate it by running the tool without arguments. If you prefer, you can even use a configuration file in a custom location, using `--config file-path`. If you're on Debian 12 or Ubuntu 22.10 the recommended install method is via the package manager; simply run `apt install cloudflare-ddns` and you'll automatically get the executable and a systemd timer. On other systems you can download the latest release from the GitHub Releases page, or, if you prefer, you can [build](#Build) the program yourself. ## Library cloudflare-ddns is also a library! In fact, the command line tool is fully based on it. It is regularly tested with CI jobs, so you can be sure that it will always work as expected. ## Build libcloudflare-ddns relies on [libcurl](https://curl.se) only, while the executable also depends on [inih](https://github.com/benhoyt/inih). To build the program, you'll need to install a C++ compiler and [Meson](https://mesonbuild.com); on Debian and derivatives you can do so with `apt install g++ meson`. After installing the dependencies, you can build the program with `meson setup build` and then `meson compile -C build`. Meson will take care of downloading the necessary dependencies like libcurl. If you're interested in only building the library, you can pass `-Dexecutable=false` to `meson setup`. ## systemd timer Here's an example of a systemd service + timer that periodically checks and eventually updates one DNS record ### `cloudflare-ddns.service` ```ini [Unit] Description=Simple utility to dynamically change a DNS record After=network-online.target Requisite=network-online.target [Service] Type=oneshot ExecStart=/usr/local/bin/cloudflare-ddns User=www-data Group=www-data ``` ### `cloudflare-ddns.timer` ```ini [Unit] Description=Run cloudflare-ddns every 5 minutes [Timer] OnBootSec=1m OnUnitActiveSec=5m [Install] WantedBy=timers.target ``` Tachi107-cloudflare-ddns-3e1c227/exe/000077500000000000000000000000001457365126600171665ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/exe/cloudflare-ddns.1.in000066400000000000000000000023411457365126600227230ustar00rootroot00000000000000.\" SPDX-FileCopyrightText: 2022 Andrea Pappacoda .\" SPDX-License-Identifier: AGPL-3.0-or-later .Dd 2022-08-22 .Dt CLOUDFLARE-DDNS 1 .Os . .Sh NAME .Nm cloudflare-ddns .Nd dynamically update a DNS record . .Sh SYNOPSIS .Nm .Op Ar api_token record_name .Op Fl -config Ar file . .Sh DESCRIPTION .Nm is a tool that can be used to dynamically update a DNS record using Cloudflare's API. .Pp This tool is a oneshot program: you run it, it updates the DNS record, and it terminates. To make it run periodically you could use a systemd timer or a cron job. .Pp To run the tool you'll need an .Lk https://dash.cloudflare.com/profile/api-tokens "API token" ; .Nm only needs the Zone.DNS edit permission. .Pp You can run .Nm in two different ways: you can pass the API Token and the record name as command line arguments, or you can use the ini configuration file located in .Pa @sysconfdir@/cloudflare-ddns/config.ini by passing no arguments at all. If you prefer, you can even use a configuration file in a custom location, using .Fl -config Ar file . . .Sh EXIT STATUS .Ex -std . .Sh EXAMPLES .Bd -literal $ cloudflare-ddns New IP: 149.20.4.15 .Ed . .Sh SEE ALSO .Xr cron 8 .Xr systemd.timer 5 . .Sh AUTHORS .An Andrea Pappacoda Aq Mt andrea@pappacoda.it Tachi107-cloudflare-ddns-3e1c227/exe/config.ini000066400000000000000000000002001457365126600211240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP [ddns] api_token = token record_name = name Tachi107-cloudflare-ddns-3e1c227/exe/main.cpp000066400000000000000000000220221457365126600206140ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: AGPL-3.0-or-later */ #include // curl.h redefines fopen on Windows, causing issues. #ifdef _WIN32 namespace std { static const auto& curlx_win32_fopen = fopen; } #endif #include /* std::array */ #include /* std::size_t */ #include /* std::printf, std::fprintf, std::puts, std::fputs */ #include /* std::memchr, std::memcpy */ #include /* std::filesystem::path::preferred_separator */ #include /* std::ifstream, std::ofstream */ #include /* std::optional */ #include /* std::string */ #include /* std::string_view */ #include #include #include "paths.hpp" struct static_buffer { static constexpr std::size_t capacity {CURL_MAX_WRITE_SIZE / 2}; // typical requests are smaller than 2000 bytes std::size_t size {0}; char buffer[capacity]; }; static std::size_t write_data( char* DDNS_RESTRICT incoming_buffer, const std::size_t /*size*/, // size will always be 1 const std::size_t count, static_buffer* DDNS_RESTRICT data ) DDNS_NOEXCEPT { // Check if the static buffer can handle all the new data if (data->size + count >= static_buffer::capacity) { return 0; } // Append to the buffer std::memcpy(data->buffer + data->size, incoming_buffer, /*size **/ count); // Increase the current size data->size += /*size **/ count; // null-terminate the buffer (so that it can be used as a C string) // data->buffer[data->size] = '\0'; return /*size **/ count; } static void curl_cleanup(CURL** curl) { curl_easy_cleanup(*curl); curl_global_cleanup(); } /* * Same as the POSIX strnlen(): * https://pubs.opengroup.org/onlinepubs/9699919799/functions/strnlen.html */ static std::size_t ddns_strnlen(const char* const s, const size_t maxlen) { const char* end = static_cast(std::memchr(s, '\0', maxlen)); if (end == nullptr) { return maxlen; } return end - s; } /* * key must include quotes */ static std::optional get_json_value(const std::string_view json, const std::string_view key) { const size_t key_start = json.find(key); if (key_start == std::string_view::npos) { return {}; } const size_t key_end = key_start + key.length(); if (key_end == std::string_view::npos) { return {}; } const size_t value_start = json.find('"', key_end + 1) + 1; if (value_start == std::string_view::npos) { return {}; } const size_t value_end = json.find('"', value_start + 1); if (value_end == std::string_view::npos) { return {}; } return std::string_view(json.data() + value_start, value_end - value_start); } int main(const int argc, char* argv[]) { std::string api_token; std::string record_name; if (argc == 1 || argc == 3) { if (argc == 3 && std::strcmp(argv[1], "--config") != 0) { api_token = argv[1]; record_name = argv[2]; } else { const std::string config_file {argc == 1 ? config_path : argv[2]}; const INIReader reader {config_file}; if (reader.ParseError() == -1) { std::fprintf(stderr, "Unable to open %s\n", config_file.c_str()); return EXIT_FAILURE; } else if (int error = reader.ParseError(); error > 0) { std::fprintf(stderr, "Error parsing %s on line %d\n", config_file.c_str(), error); return EXIT_FAILURE; } api_token = reader.GetString("ddns", "api_token", "token"); record_name = reader.GetString("ddns", "record_name", "name"); if (api_token == "token" || record_name == "name") { std::fprintf(stderr, "Error parsing %s\n", config_file.c_str()); return EXIT_FAILURE; } } } else { std::fprintf(stderr, "Bad usage! You can run the program without arguments and load the config in %s " "or pass the API token and the DNS record name as arguments\n", config_path.data()); return EXIT_FAILURE; } /* Make sure to avoid path traversal vulnerabilities */ if (record_name.find('/') != std::string::npos || record_name.find(std::filesystem::path::preferred_separator) != std::string::npos) { std::fputs("Record names cannot contain path separators!\n", stderr); return EXIT_FAILURE; } curl_global_init(CURL_GLOBAL_DEFAULT); CURL* curl_handle {curl_easy_init()}; static_buffer dns_response; curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &dns_response); curl_easy_setopt(curl_handle, CURLOPT_TCP_FASTOPEN, 1L); curl_easy_setopt(curl_handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); curl_easy_setopt(curl_handle, CURLOPT_DEFAULT_PROTOCOL, "https"); ddns_error error = DDNS_ERROR_OK; // +1 because of '\0' std::array zone_id; const std::string cache_path = std::string{cache_dir} + record_name; // Here the cache file is opened twice, the first time read-only and // the second time write-only. This is because if the filesystem is // mounted read-only I'm still able to read the cache, if available. const bool cache_miss = std::ifstream{cache_path, std::ios::binary} .read(zone_id.data(), zone_id.size()) .fail(); if (cache_miss || ddns_strnlen(zone_id.data(), zone_id.size()) != DDNS_ZONE_ID_LENGTH) { error = ddns_search_zone_id(api_token.c_str(), record_name.c_str(), zone_id.size(), zone_id.data()); if (error) { std::fputs("Error getting the Zone ID\n", stderr); curl_cleanup(&curl_handle); return EXIT_FAILURE; } // This also writes '\0' std::ofstream{cache_path, std::ios::binary} .write(zone_id.data(), zone_id.size()); } error = ddns_get_record_raw(api_token.c_str(), zone_id.data(), record_name.c_str(), &curl_handle); if (error) { std::fprintf(stderr, "Error getting DNS record info\n" "API response: %.*s\n", static_cast(dns_response.size), dns_response.buffer); curl_cleanup(&curl_handle); return EXIT_FAILURE; } // The first element contains the IPv4 address, while the second // contains the IPv6 one. constexpr const char* ipv_c_str[2] = {"IPv4", "IPv6"}; constexpr const char* type_c_str[2] = {"A", "AAAA"}; std::string_view record_ids[2]; std::string_view record_ips[2]; std::size_t records_count = 0; const char* id_pos = dns_response.buffer; const char* type_pos = dns_response.buffer; const char* dns_ip_pos = dns_response.buffer; while (true) { const std::optional id = get_json_value(std::string_view(id_pos, dns_response.size - (id_pos - dns_response.buffer)), "\"id\""); if (!id.has_value()) { break; } id_pos = id->data(); const std::optional type = get_json_value(std::string_view(type_pos, dns_response.size - (type_pos - dns_response.buffer)), "\"type\""); if (!type.has_value()) { break; } type_pos = type->data(); const std::optional dns_ip = get_json_value(std::string_view(dns_ip_pos, dns_response.size - (dns_ip_pos - dns_response.buffer)), "\"content\""); if (!dns_ip.has_value()) { break; } dns_ip_pos = dns_ip->data(); if (type == "A") { record_ids[0] = *id; record_ips[0] = *dns_ip; records_count++; } else if (type == "AAAA") { record_ids[1] = *id; record_ips[1] = *dns_ip; records_count++; } } if (records_count == 0) { std::fprintf(stderr, "%s doesn't point to any A or AAAA record\n", record_name.c_str()); curl_cleanup(&curl_handle); return EXIT_FAILURE; } else if (records_count > 2) { std::fprintf(stderr, "%s points to more than two records, things might not work as expected\n", record_name.c_str()); } std::array local_ips[2]; unsigned int local_ips_count = 0; for (unsigned int i = 0; i < 2; i++) { if (record_ips[i].empty()) { continue; } error = ddns_get_local_ip(i, local_ips[i].size(), local_ips[i].data()); if (error) { std::fprintf(stderr, "Error getting the local %s address\n", ipv_c_str[i]); continue; } local_ips_count++; if (local_ips[i].data() != record_ips[i]) { // record_ids isn't NULL-terminated since it's just a view of // dns_response, so I need to create a NULL-termiated C string // manually. record_ids.length() and DDNS_RECORD_ID_LENGTH are // the same. char id[DDNS_RECORD_ID_LENGTH + 1]; std::memcpy(id, record_ids[i].data(), DDNS_RECORD_ID_LENGTH); id[DDNS_RECORD_ID_LENGTH] = '\0'; dns_response.size = 0; if (ddns_update_record_raw( api_token.c_str(), zone_id.data(), id, local_ips[i].data(), &curl_handle ) != DDNS_ERROR_OK) { std::fprintf(stderr, "Error updating the %s record\n", type_c_str[i]); curl_cleanup(&curl_handle); return EXIT_FAILURE; } const std::optional new_ip = get_json_value(std::string_view(dns_response.buffer, dns_response.size), "\"content\""); if (!new_ip.has_value()) { fputs("Something went very wrong\n", stderr); return 1; } std::printf("New %s: %.*s\n", ipv_c_str[i], static_cast(new_ip->length()), new_ip->data()); } else { std::printf("The %s record is up to date\n", type_c_str[i]); } } curl_cleanup(&curl_handle); if (local_ips_count == 0) { return EXIT_FAILURE; } } Tachi107-cloudflare-ddns-3e1c227/exe/meson.build000066400000000000000000000050451457365126600213340ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: AGPL-3.0-or-later # If get_option('sysconfdir') returns an absolute path, # get_option('prefix')/get_option('sysconfdir') simply returns the # correct absolute sysconfdir, stripping away the prefix. # This means that concatenating the prefix with the sysconfdir always # yelds an absolute path that is correct, regardless of the fact that # sysconfdir is absolute or not (e.g. /etc vs /usr/local/etc). # Source: https://github.com/mesonbuild/meson/pull/9903#issuecomment-1071118017 # and: https://mesonbuild.com/Reference-manual_functions.html#join_paths sysconfdir = get_option('prefix')/get_option('sysconfdir') INIReader_dep = dependency( 'INIReader', fallback: ['inih', 'INIReader_dep'], default_options: ['default_library=static', 'distro_install=false'] ) executable( 'cloudflare-ddns', 'main.cpp', dependencies: [ cloudflare_ddns_dep, libcurl_dep, INIReader_dep ], gnu_symbol_visibility: 'hidden', install: true, sources: configure_file( input: 'paths.hpp.in', output: 'paths.hpp', configuration: { 'cache_dir': get_option('prefix')/get_option('localstatedir')/'cache', 'sysconfdir': sysconfdir } ) ) install_data( 'config.ini', install_dir: get_option('sysconfdir')/'cloudflare-ddns', install_mode: ['rw-------', 'cloudflare-ddns', 'cloudflare-ddns'] ) # https://github.com/mesonbuild/meson/issues/1550 # https://github.com/mesonbuild/meson/pull/9342 install_man( configure_file( input: 'cloudflare-ddns.1.in', output: 'cloudflare-ddns.1', configuration: { 'sysconfdir': sysconfdir } ) ) systemd = dependency('systemd', required: false) if systemd.found() systemd_system_unit_dir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir') sysusers_dir = systemd.get_variable(pkgconfig: 'sysusersdir') tmpfiles_dir = systemd.get_variable(pkgconfig: 'tmpfilesdir') configure_file( input: 'systemd'/'cloudflare-ddns.service.in', output: 'cloudflare-ddns.service', configuration: { 'bindir': get_option('prefix')/get_option('bindir'), 'libdir': get_option('prefix')/get_option('libdir') }, install: true, install_dir: systemd_system_unit_dir ) install_data( 'systemd'/'cloudflare-ddns.timer', install_dir: systemd_system_unit_dir ) install_data( 'sysusers.d'/'cloudflare-ddns.conf', install_dir: sysusers_dir ) configure_file( input: 'tmpfiles.d'/'cloudflare-ddns.conf.in', output: 'cloudflare-ddns.conf', configuration: { 'sysconfdir': sysconfdir }, install: true, install_dir: tmpfiles_dir ) endif Tachi107-cloudflare-ddns-3e1c227/exe/paths.hpp.in000066400000000000000000000004701457365126600214240ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: AGPL-3.0-or-later */ #pragma once #include inline constexpr std::string_view cache_dir {"@cache_dir@/cloudflare-ddns/"}; inline constexpr std::string_view config_path {"@sysconfdir@/cloudflare-ddns/config.ini"}; Tachi107-cloudflare-ddns-3e1c227/exe/systemd/000077500000000000000000000000001457365126600206565ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/exe/systemd/cloudflare-ddns.service.in000066400000000000000000000020771457365126600257210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP [Unit] Description=Simple utility to dynamically change a DNS record Documentation=man:cloudflare-ddns(1) After=network-online.target Requisite=network-online.target [Service] Type=oneshot ExecStart=@bindir@/cloudflare-ddns User=cloudflare-ddns Group=cloudflare-ddns CacheDirectory=cloudflare-ddns ConfigurationDirectory=cloudflare-ddns ConfigurationDirectoryMode=0700 # Hardening CapabilityBoundingSet= ExecPaths=@bindir@/cloudflare-ddns @libdir@ /usr/lib LockPersonality=true MemoryDenyWriteExecute=true NoExecPaths=/ NoNewPrivileges=true PrivateDevices=true PrivateTmp=true PrivateUsers=true ProcSubset=pid ProtectClock=true ProtectHome=true ProtectHostname=true ProtectKernelLogs=true ProtectKernelTunables=true ProtectProc=invisible ProtectSystem=strict RemoveIPC=true RestrictAddressFamilies=AF_INET AF_INET6 RestrictNamespaces=true RestrictRealtime=true RestrictSUIDSGID=true SystemCallArchitectures=native SystemCallFilter=@system-service SystemCallFilter=~ @privileged @resources UMask=0077 Tachi107-cloudflare-ddns-3e1c227/exe/systemd/cloudflare-ddns.timer000066400000000000000000000003261457365126600247670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP [Unit] Description=Run cloudflare-ddns every 5 minutes [Timer] OnBootSec=1m OnUnitActiveSec=5m [Install] WantedBy=timers.target Tachi107-cloudflare-ddns-3e1c227/exe/sysusers.d/000077500000000000000000000000001457365126600213105ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/exe/sysusers.d/cloudflare-ddns.conf000066400000000000000000000001461457365126600252260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP u cloudflare-ddns Tachi107-cloudflare-ddns-3e1c227/exe/tmpfiles.d/000077500000000000000000000000001457365126600212335ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/exe/tmpfiles.d/cloudflare-ddns.conf.in000066400000000000000000000005701457365126600255570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Andrea Pappacoda # SPDX-License-Identifier: FSFAP # Make sure config files have the correct owner and permissions, since the unit # file's ConfigurationDirectory= setting leaves the owner as root. d @sysconfdir@/cloudflare-ddns 0700 cloudflare-ddns cloudflare-ddns f @sysconfdir@/cloudflare-ddns/config.ini 0600 cloudflare-ddns cloudflare-ddns Tachi107-cloudflare-ddns-3e1c227/include/000077500000000000000000000000001457365126600200305ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/include/ddns/000077500000000000000000000000001457365126600207605ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/include/ddns/cloudflare-ddns.h000066400000000000000000000254541457365126600242110ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: LGPL-3.0-or-later */ /** * There are two kinds of functions; the one that is self contained, thread * safe, that creates and uses its own cURL handle, and the other one that * borrows mutably a cURL handle, a more efficient approach but that is not * thread safe. * * The user of the library is responsable for calling curl_global_init. * * I'm following the C23 conventions for function parameter order, see * http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2611.htm */ #pragma once #ifdef __cplusplus extern "C" { #endif #define DDNS_ZONE_ID_LENGTH 32U #define DDNS_RECORD_ID_LENGTH 32U #define DDNS_RECORD_NAME_MAX_LENGTH 255U #define DDNS_IP_ADDRESS_MAX_LENGTH 46U #define DDNS_API_TOKEN_LENGTH 40U #include /* bool */ #include /* size_t */ /* * When dealing with the shared library on Windows, a few things need * to happen, depending on the situation. When building the shared lib, * all public symbols need to be marked with dllexport, and when using * that shared library users need to import that symbols, and this is * accomplished by marking them with dllimport. So, DDNS_SHARED_LIB * needs to always be present when dealing with shared libraries, * while DDNS_BUILDING_DLL is only needed when building it. * * Thanks https://github.com/myd7349/Ongoing-Study/blob/master/cpp/CMake/libfoo_v2/include/libfoo/foo.h */ #if defined _WIN32 || defined __CYGWIN__ # ifdef DDNS_SHARED_LIB # ifdef DDNS_BUILDING_DLL # ifdef __GNUC__ # define DDNS_PUB __attribute__ ((dllexport)) # else # define DDNS_PUB __declspec(dllexport) # endif # else # ifdef __GNUC__ # define DDNS_PUB __attribute__ ((dllimport)) # else # define DDNS_PUB __declspec(dllimport) # endif # endif # else # define DDNS_PUB # endif # define DDNS_PRIV #else # if defined(__GNUC__) && __GNUC__ >= 4 # define DDNS_PUB __attribute__ ((visibility ("default"))) # define DDNS_PRIV __attribute__ ((visibility ("hidden"))) # else # define DDNS_PUB # define DDNS_PRIV # endif #endif #if defined(__cplusplus) # if __cplusplus >= 201103L # define DDNS_NOEXCEPT noexcept # else # define DDNS_NOEXCEPT throw() # endif #else # if defined(__GNUC__) && __GNUC__ >= 4 # define DDNS_NOEXCEPT __attribute__ ((nothrow)) # else # define DDNS_NOEXCEPT # endif #endif #if !defined(__cplusplus) && (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) # define DDNS_RESTRICT restrict #elif defined(__GNUC__) # define DDNS_RESTRICT __restrict__ #elif defined(_MSC_VER) # define DDNS_RESTRICT __restrict #else # define DDNS_RESTRICT #endif #if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202300L) # define DDNS_NODISCARD [[nodiscard]] #elif (defined(__cplusplus) && __cplusplus >= 201103L) && defined(__GNUC__) # define DDNS_NODISCARD [[gnu::warn_unused_result]] #elif defined(__GNUC__) # define DDNS_NODISCARD __attribute__((warn_unused_result)) #elif defined(_MSC_VER) # define DDNS_NODISCARD _Check_return_ #else # define DDNS_NODISCARD #endif typedef enum ddns_ip_version { DDNS_IP_VERSION_4 = 1U << 4U, DDNS_IP_VERSION_6 = 1U << 6U, } ddns_ip_version; typedef enum ddns_error { DDNS_ERROR_OK, DDNS_ERROR_GENERIC, DDNS_ERROR_USAGE } ddns_error; /** * Get the public IP address of the machine * * With this function you can get the current public IP address of your * machine, so that you can know if the DNS record needs to be updated. * * It creates its own cURL handle under the hood and writes the IP address * in dot-decimal notation in the ip parameter. If ip_size is too small, * the function returns DDNS_ERROR_USAGE; if some other error occurs, it * returns DDNS_ERROR_GENERIC. It uses Cloudflare to determine the public * address, querying https://one.one.one.one/cdn-cgi/trace * * Depending on the value of the ipv6 parameter, the function will either * force the HTTP request to use IPv4 (false) or IPv6 (true), also * determining the kind of IP address returned. */ DDNS_NODISCARD DDNS_PUB ddns_error ddns_get_local_ip( bool ipv6, size_t ip_size, char* DDNS_RESTRICT ip ) DDNS_NOEXCEPT; /** * Get the Zone ID of a DNS record * * This function queries Cloudflare's API to retrieve the Zone ID of a * given DNS record. As the API endpoint does not support fuzzy/partial * search this function needs to potentially query the API several times. * In particular, the supplied record name gets repeatedly truncated once a * "." is encountered, and the remaining string is sent to the API until it * matches the zone name. This means that, for example, a record named * "ddns.andrea.pappacoda.it" will result in three different API queries, * namely with "ddns.andrea.pappacoda.it", "andrea.pappacoda.it", and * "pappacoda.it". The full domain name is tried as well as it is * completely legal to use the root domain name as an A or AAAA record, * while the "it" TLD is not tried as Cloudflare does not allow zones to be * top level domains. * * Due to the slow nature of this lookup, it is recommended to cache the * returned ID, as zone IDs are unlikely to change often. * * If you already know the zone name and simply want to figure out its id, * simply pass it as the "record_name" parameter; the function will query * Cloudflare to get the ID of that zone name. * * The function returns DDNS_ERROR_USAGE if the record name is too long or * zone_id_size is too small, and DDNS_ERROR_GENERIC for other internal * errors, including failure to find the zone ID of the provided record * name. If the zone is found, it is written in the zone_id out parameter. */ DDNS_NODISCARD DDNS_PUB ddns_error ddns_search_zone_id( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT record_name, size_t zone_id_size, char* DDNS_RESTRICT zone_id ) DDNS_NOEXCEPT; /** * Get the Zone ID from a given Zone name * * This function asks Cloudflare's API to return the Zone ID of the zone * whose name is equal to the zone_name parameter. * * The raw JSON response is written in the curl response buffer, and you'll * have to parse it yourself to figure out whether the ID was found or not. * * If the supplied zone name is longer than the maximum allowed by the API, * DDNS_RECORD_NAME_MAX_LENGTH - 2, the function returns DDNS_ERROR_USAGE, * while if something goes wrong with the HTTP request it returns * DDNS_ERROR_GENERIC. */ DDNS_NODISCARD DDNS_PUB ddns_error ddns_get_zone_id_raw( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT zone_name, void** DDNS_RESTRICT curl ) DDNS_NOEXCEPT; /** * Get the current IP address of a given A/AAAA DNS record * * This function queries Cloudflare's API to retrieve the status of a given * A or AAAA record, returning its current IP address, its internal ID that * can be used to refer to it in the API and a boolean indicating whether * it is an A or AAAA record. The three values are written in record_ip, * record_id, and aaaa respectively. If their _size is too small, * the function returns DDNS_ERROR_USAGE; if some other error occurs, it * returns DDNS_ERROR_GENERIC. * * Since the function has to access the response of the HTTP GET request it * has to create and manage its own cURL handle internally, and this hurts * a bit in terms of performance. If you prefer to control your own cURL * handles to get better performance you can use get_record_raw(), but you * will have to parse the result yourself. */ DDNS_NODISCARD DDNS_PUB ddns_error ddns_get_record( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT zone_id, const char* DDNS_RESTRICT record_name, size_t record_ip_size, char* DDNS_RESTRICT record_ip, size_t record_id_size, char* DDNS_RESTRICT record_id, bool* DDNS_RESTRICT aaaa ) DDNS_NOEXCEPT; /** * Query the API for the status of a given A/AAAA DNS record * * This function queries Cloudflare's API to retrieve the status of a given * A or AAAA record, returning the raw JSON response, and allows you to * pass in a preexisting cURL handle, to reuse connections and improve * performance. This also allows greater flexibility compared to * get_record(), but you'll have to consult Cloudflare's API reference and * you'll also need to parse the result yourself. If the length of the zone * id is not DDNS_ZONE_ID_LENGTH, or if the length of the record name is * greater than DDNS_RECORD_NAME_MAX_LENGTH, the function returns * DDNS_ERROR_USAGE; if something goes wrong with the HTTP request, it * returns DDNS_ERROR_GENERIC. */ DDNS_NODISCARD DDNS_PUB ddns_error ddns_get_record_raw( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT zone_id, const char* DDNS_RESTRICT record_name, void** DDNS_RESTRICT curl ) DDNS_NOEXCEPT; /** * Update the IP address of a given A/AAAA DNS record * * This function sends a PATCH request to Cloudflare's API and sets the IP * address of a given A/AAAA record, identified by record_id, to the one * passed as new_ip. It manages its own cURL handle under the hood, and * writes the IP that Cloudflare received and set in record_ip, if * successful. If the size of the out parameter is smaller than the size * of the IP set by Cloudflare, or if the length of the zone id is not * DDNS_ZONE_ID_LENGTH, or if the length of the record name is greater than * DDNS_RECORD_NAME_MAX_LENGTH, the function returns DDNS_ERROR_USAGE; on * any other error, it returns DDNS_ERROR_GENERIC. * * This function is thread safe, but it creates and destroys a cURL handle * by itself, which may be slow. If you want faster performance by reusing * the same handle you can look into update_record_raw(). */ DDNS_NODISCARD DDNS_PUB ddns_error ddns_update_record( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT zone_id, const char* DDNS_RESTRICT record_id, const char* DDNS_RESTRICT new_ip, size_t record_ip_size, char* DDNS_RESTRICT record_ip ) DDNS_NOEXCEPT; /** * Update the IP address of a given A/AAAA DNS record * * This function sends a PATCH request to Cloudflare's API and sets the IP * address of a given A/AAAA record, identified by record_id, to the one * passed as new_ip. You must pass in your own cURL handle, which allows * for better performance but has greater complexity. If the length of the * zone id is not DDNS_ZONE_ID_LENGTH, or if the length of the record name * is greater than DDNS_RECORD_NAME_MAX_LENGTH, the function returns * DDNS_ERROR_USAGE; if something goes wrong with the HTTP request, it * returns DDNS_ERROR_GENERIC. If you don't particularly care about * performance you can use the simpler update_record() function. */ DDNS_NODISCARD DDNS_PUB ddns_error ddns_update_record_raw( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT zone_id, const char* DDNS_RESTRICT record_id, const char* DDNS_RESTRICT new_ip, void** DDNS_RESTRICT curl ) DDNS_NOEXCEPT; #ifdef __cplusplus } /* extern "C" */ #endif Tachi107-cloudflare-ddns-3e1c227/lib/000077500000000000000000000000001457365126600171535ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/lib/cloudflare-ddns.cpp000066400000000000000000000410761457365126600227350ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: LGPL-3.0-or-later */ /* * Define DDNS_BUILDING_DLL in the .cpp file so that DDNS_PUB correctly * expands to __declspec(dllexport) */ #if defined _WIN32 && defined DDNS_SHARED_LIB # define DDNS_BUILDING_DLL #endif #include #include // curl.h redefines fopen on Windows, causing issues. #ifdef _WIN32 namespace std { static const auto& curlx_win32_fopen = fopen; } #endif #include /* std::memcpy, std::size_t, std::strlen */ #include /* std::optional */ #include /* std::string_view */ /* * By reading Cloudflare's docs, I can see what is the maximum allowed * length of every parameter. With this knowledge, I can statically * figure out how much memory I need to make my requests, and I can * thus avoid dynamic memory allocations when creating the request URLs */ namespace priv { /* * key must include quotes */ static std::optional get_json_value(const std::string_view json, const std::string_view key) { const size_t key_start = json.find(key); if (key_start == std::string_view::npos) { return {}; } const size_t key_end = key_start + key.length(); if (key_end == std::string_view::npos) { return {}; } const size_t value_start = json.find('"', key_end + 1) + 1; if (value_start == std::string_view::npos) { return {}; } const size_t value_end = json.find('"', value_start + 1); if (value_end == std::string_view::npos) { return {}; } return std::string_view(json.data() + value_start, value_end - value_start); } } // namespace priv extern "C" { static constexpr std::string_view base_url {"https://api.cloudflare.com/client/v4/zones/"}; namespace priv { struct static_buffer { static constexpr std::size_t capacity {CURL_MAX_WRITE_SIZE}; std::size_t size {0}; char buffer[capacity]; }; static std::size_t write_data( char* DDNS_RESTRICT incoming_buffer, const std::size_t /*size*/, // size will always be 1 const std::size_t count, static_buffer* DDNS_RESTRICT data ) DDNS_NOEXCEPT { // Check if the static buffer can handle all the new data if (data->size + count >= static_buffer::capacity) { return 0; } // Append to the buffer std::memcpy(data->buffer + data->size, incoming_buffer, /*size **/ count); // Increase the current size data->size += /*size **/ count; // null-terminate the buffer (so that it can be used as a C string) // data->buffer[data->size] = '\0'; return /*size **/ count; } static void curl_handle_setup( CURL** DDNS_RESTRICT curl, const static_buffer& response_buffer ) DDNS_NOEXCEPT { // General curl options curl_easy_setopt(*curl, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(*curl, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt(*curl, CURLOPT_TCP_FASTOPEN, 1L); curl_easy_setopt(*curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); curl_easy_setopt(*curl, CURLOPT_DEFAULT_PROTOCOL, "https"); curl_easy_setopt(*curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); curl_easy_setopt(*curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(*curl, CURLOPT_WRITEDATA, &response_buffer); } /* * Returns the curl_slist that must be freed with curl_slist_free_all() */ DDNS_NODISCARD static curl_slist* curl_doh_setup([[maybe_unused]] CURL** DDNS_RESTRICT curl) DDNS_NOEXCEPT { #if LIBCURL_VERSION_NUM >= 0x073e00 struct curl_slist* manual_doh_address {nullptr}; manual_doh_address = curl_slist_append(manual_doh_address, "cloudflare-dns.com:443:104.16.248.249,104.16.249.249,2606:4700::6810:f8f9,2606:4700::6810:f9f9"); curl_easy_setopt(*curl, CURLOPT_RESOLVE, manual_doh_address); curl_easy_setopt(*curl, CURLOPT_DOH_URL, "https://cloudflare-dns.com/dns-query"); return manual_doh_address; #else return nullptr; #endif } DDNS_NODISCARD static curl_slist* curl_auth_setup(CURL** DDNS_RESTRICT curl, const char* DDNS_RESTRICT const api_token) DDNS_NOEXCEPT { curl_easy_setopt(*curl, CURLOPT_HTTPAUTH, CURLAUTH_BEARER); //curl_easy_setopt(*curl, CURLOPT_XOAUTH2_BEARER, api_token); leaks, see https://github.com/curl/curl/issues/8841 // -1 because I have to overwrite the '\0' constexpr std::size_t bearer_length = sizeof "Authorization: Bearer " - 1; char bearer[bearer_length + DDNS_API_TOKEN_LENGTH + 1] = "Authorization: Bearer "; std::memcpy(bearer + bearer_length, api_token, DDNS_API_TOKEN_LENGTH); bearer[bearer_length + DDNS_API_TOKEN_LENGTH] = '\0'; struct curl_slist* headers {nullptr}; headers = curl_slist_append(headers, "Content-Type: application/json"); headers = curl_slist_append(headers, bearer); curl_easy_setopt(*curl, CURLOPT_HTTPHEADER, headers); return headers; } static void curl_get_setup(CURL** DDNS_RESTRICT curl, const char* DDNS_RESTRICT const url) DDNS_NOEXCEPT { curl_easy_setopt(*curl, CURLOPT_HTTPGET, 1L); curl_easy_setopt(*curl, CURLOPT_URL, url); } static void curl_patch_setup(CURL** DDNS_RESTRICT curl, const char* DDNS_RESTRICT const url, const char* DDNS_RESTRICT const body) DDNS_NOEXCEPT { curl_easy_setopt(*curl, CURLOPT_CUSTOMREQUEST, "PATCH"); curl_easy_setopt(*curl, CURLOPT_URL, url); curl_easy_setopt(*curl, CURLOPT_POSTFIELDS, body); } } // namespace priv DDNS_NODISCARD DDNS_PUB ddns_error ddns_get_local_ip( const bool ipv6, const size_t ip_size, char* DDNS_RESTRICT ip ) DDNS_NOEXCEPT { // Creating the handle and the response buffer CURL* curl {curl_easy_init()}; priv::static_buffer response; priv::curl_handle_setup(&curl, response); curl_slist* free_me {priv::curl_doh_setup(&curl)}; priv::curl_get_setup(&curl, "https://one.one.one.one/cdn-cgi/trace"); if (ipv6) { curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); } else { curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } // Performing the request const int curl_error = curl_easy_perform(curl); // Cleaning up the headers curl_slist_free_all(free_me); // Cleaning up the handle as I won't reuse it curl_easy_cleanup(curl); if (curl_error) { // I can return as I've cleaned up everything return DDNS_ERROR_GENERIC; } const std::string_view response_sv {response.buffer, response.size}; // Parsing the response const std::size_t ip_begin {response_sv.find("ip=") + 3U}; // + 3 because "ip=" is 3 chars const std::size_t ip_end {response_sv.find('\n', ip_begin)}; const std::size_t ip_length {ip_end - ip_begin}; if (ip_length >= ip_size) { return DDNS_ERROR_USAGE; } // Copying the ip in the caller's buffer // Using memcpy because I don't need to copy the whole response std::memcpy(ip, response.buffer + ip_begin, ip_length); ip[ip_length] = '\0'; return DDNS_ERROR_OK; } DDNS_NODISCARD DDNS_PUB ddns_error ddns_search_zone_id( const char* const DDNS_RESTRICT api_token, const char* const DDNS_RESTRICT record_name, const size_t zone_id_size, char* DDNS_RESTRICT zone_id ) DDNS_NOEXCEPT { // <= because I also have to write '\0' if (zone_id_size <= DDNS_ZONE_ID_LENGTH) { return DDNS_ERROR_USAGE; } std::string_view record_name_sv = record_name; CURL* curl = curl_easy_init(); priv::static_buffer response; priv::curl_handle_setup(&curl, response); std::optional zone_id_sv; bool found = false; for (auto pos = record_name_sv.find_first_of('.'); !found && pos != std::string_view::npos; pos = record_name_sv.find_first_of('.')) { // before making a new request I have to reset the current buffer size response.size = 0; const ddns_error error = ddns_get_zone_id_raw(api_token, record_name_sv.data(), &curl); // +1 because I also need to remove the leading dot record_name_sv.remove_prefix(pos + 1); if (error == DDNS_ERROR_USAGE) { // a usage error will make the request fail over and over again curl_easy_cleanup(curl); return error; } else if (error) { // here continue acts as "retry" continue; } zone_id_sv = priv::get_json_value(std::string_view(response.buffer, response.size), "\"id\""); if (!zone_id_sv.has_value()) { continue; } if (zone_id_sv->length() != DDNS_ZONE_ID_LENGTH) { continue; } found = true; } curl_easy_cleanup(curl); if (!found) { return DDNS_ERROR_GENERIC; } std::memcpy(zone_id, zone_id_sv->data(), zone_id_sv->length()); zone_id[zone_id_sv->length()] = '\0'; return DDNS_ERROR_OK; } DDNS_NODISCARD DDNS_PUB ddns_error ddns_get_zone_id_raw( const char* const DDNS_RESTRICT api_token, const char* const DDNS_RESTRICT zone_name, void** DDNS_RESTRICT curl ) DDNS_NOEXCEPT { const std::size_t zone_name_length = std::strlen(zone_name); // -2 because this endpoint has a maximum record name length of 253 constexpr std::size_t zone_name_max_length = DDNS_RECORD_NAME_MAX_LENGTH - 2U; if (std::strlen(api_token) != DDNS_API_TOKEN_LENGTH || zone_name_length > zone_name_max_length) { return DDNS_ERROR_USAGE; } constexpr std::string_view zones_url = "?per_page=1&name="; constexpr std::size_t request_url_capacity = base_url.length() + zones_url.length() + zone_name_max_length ; // +1 because of '\0' char request_url[request_url_capacity + 1]; // create the request url std::memcpy(request_url, base_url.data(), base_url.length()); std::memcpy(request_url + base_url.length(), zones_url.data(), zones_url.length()); std::memcpy(request_url + base_url.length() + zones_url.length(), zone_name, zone_name_length); request_url[base_url.length() + zones_url.length() + zone_name_length] = '\0'; curl_slist* free_me_doh = priv::curl_doh_setup(curl); curl_slist* free_me_headers = priv::curl_auth_setup(curl, api_token); priv::curl_get_setup(curl, request_url); const int curl_error = curl_easy_perform(*curl); curl_easy_setopt(*curl, CURLOPT_HTTPHEADER, nullptr); curl_slist_free_all(free_me_headers); curl_easy_setopt(*curl, CURLOPT_RESOLVE, nullptr); curl_slist_free_all(free_me_doh); if (curl_error) { return DDNS_ERROR_GENERIC; } return DDNS_ERROR_OK; } DDNS_NODISCARD ddns_error ddns_get_record( const char* const DDNS_RESTRICT api_token, const char* const DDNS_RESTRICT zone_id, const char* const DDNS_RESTRICT record_name, const size_t record_ip_size, char* DDNS_RESTRICT record_ip, const size_t record_id_size, char* DDNS_RESTRICT record_id, bool* aaaa ) DDNS_NOEXCEPT { CURL* curl {curl_easy_init()}; priv::static_buffer response; priv::curl_handle_setup(&curl, response); const ddns_error error = ddns_get_record_raw(api_token, zone_id, record_name, &curl); curl_easy_cleanup(curl); if (error) { return error; } const std::string_view response_sv {response.buffer, response.size}; const std::optional record_id_sv = priv::get_json_value(response_sv, "\"id\""); if (!record_id_sv.has_value()) { return DDNS_ERROR_GENERIC; } const std::optional type = priv::get_json_value(response_sv, "\"type\""); if (!type.has_value()) { return DDNS_ERROR_GENERIC; } const std::optional record_ip_sv = priv::get_json_value(response_sv, "\"content\""); if (!record_ip_sv.has_value()) { return DDNS_ERROR_GENERIC; } if (record_ip_sv->length() >= record_ip_size || record_id_sv->length() >= record_id_size) { return DDNS_ERROR_USAGE; } std::memcpy(record_ip, record_ip_sv->data(), record_ip_sv->length()); record_ip[record_ip_sv->length()] = '\0'; std::memcpy(record_id, record_id_sv->data(), record_id_sv->length()); record_id[record_id_sv->length()] = '\0'; *aaaa = (type == "AAAA"); return DDNS_ERROR_OK; } DDNS_NODISCARD ddns_error ddns_get_record_raw( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT zone_id, const char* DDNS_RESTRICT record_name, void** DDNS_RESTRICT curl ) DDNS_NOEXCEPT { const std::size_t record_name_length {std::strlen(record_name)}; if (std::strlen(api_token) != DDNS_API_TOKEN_LENGTH || std::strlen(zone_id) != DDNS_ZONE_ID_LENGTH || record_name_length > DDNS_RECORD_NAME_MAX_LENGTH) { return DDNS_ERROR_USAGE; } constexpr std::string_view dns_records_url {"/dns_records?type=A,AAAA&name="}; constexpr std::size_t request_url_capacity { base_url.length() + DDNS_ZONE_ID_LENGTH + dns_records_url.length() + DDNS_RECORD_NAME_MAX_LENGTH }; const std::size_t request_url_length { base_url.length() + DDNS_ZONE_ID_LENGTH + dns_records_url.length() + record_name_length }; // +1 because of '\0' char request_url[request_url_capacity + 1U]; // Concatenate strings std::memcpy(request_url, base_url.data(), base_url.length()); std::memcpy(request_url + base_url.length(), zone_id, DDNS_ZONE_ID_LENGTH); std::memcpy(request_url + base_url.length() + DDNS_ZONE_ID_LENGTH, dns_records_url.data(), dns_records_url.length()); std::memcpy(request_url + base_url.length() + DDNS_ZONE_ID_LENGTH + dns_records_url.length(), record_name, record_name_length); request_url[request_url_length] = '\0'; curl_slist* free_me_doh {priv::curl_doh_setup(curl)}; curl_slist* free_me_headers {priv::curl_auth_setup(curl, api_token)}; priv::curl_get_setup(curl, request_url); const int curl_error = curl_easy_perform(*curl); curl_easy_setopt(*curl, CURLOPT_HTTPHEADER, nullptr); curl_slist_free_all(free_me_headers); curl_easy_setopt(*curl, CURLOPT_RESOLVE, nullptr); curl_slist_free_all(free_me_doh); if (curl_error) { return DDNS_ERROR_GENERIC; } return DDNS_ERROR_OK; } DDNS_NODISCARD ddns_error ddns_update_record( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT zone_id, const char* DDNS_RESTRICT record_id, const char* DDNS_RESTRICT new_ip, const size_t record_ip_size, char* DDNS_RESTRICT record_ip ) DDNS_NOEXCEPT { CURL* curl {curl_easy_init()}; priv::static_buffer response; priv::curl_handle_setup(&curl, response); const ddns_error error = ddns_update_record_raw(api_token, zone_id, record_id, new_ip, &curl); curl_easy_cleanup(curl); if (error) { return error; } const std::optional record_ip_sv = priv::get_json_value(std::string_view(response.buffer, response.size), "\"content\""); if (!record_ip_sv.has_value()) { return DDNS_ERROR_GENERIC; } if (record_ip_sv->length() >= record_ip_size) { return DDNS_ERROR_USAGE; } std::memcpy(record_ip, record_ip_sv->data(), record_ip_sv->length()); record_ip[record_ip_sv->length()] = '\0'; return DDNS_ERROR_OK; } DDNS_NODISCARD ddns_error ddns_update_record_raw( const char* DDNS_RESTRICT api_token, const char* DDNS_RESTRICT zone_id, const char* DDNS_RESTRICT record_id, const char* DDNS_RESTRICT new_ip, void** DDNS_RESTRICT curl ) DDNS_NOEXCEPT { const std::size_t new_ip_length {std::strlen(new_ip)}; if (std::strlen(api_token) != DDNS_API_TOKEN_LENGTH || std::strlen(zone_id) != DDNS_ZONE_ID_LENGTH || std::strlen(record_id) != DDNS_RECORD_ID_LENGTH || new_ip_length > DDNS_IP_ADDRESS_MAX_LENGTH) { return DDNS_ERROR_USAGE; } curl_slist* free_me_doh {priv::curl_doh_setup(curl)}; curl_slist* free_me_headers {priv::curl_auth_setup(curl, api_token)}; constexpr std::string_view dns_records_url {"/dns_records/"}; constexpr std::size_t request_url_length { base_url.length() + DDNS_ZONE_ID_LENGTH + dns_records_url.length() + DDNS_RECORD_ID_LENGTH }; // +1 because of '\0' char request_url[request_url_length + 1U]; // Concatenate the strings to make the request url std::memcpy(request_url, base_url.data(), base_url.length()); std::memcpy(request_url + base_url.length(), zone_id, DDNS_ZONE_ID_LENGTH); std::memcpy(request_url + base_url.length() + DDNS_ZONE_ID_LENGTH, dns_records_url.data(), dns_records_url.length()); std::memcpy(request_url + base_url.length() + DDNS_ZONE_ID_LENGTH + dns_records_url.length(), record_id, DDNS_RECORD_ID_LENGTH); request_url[request_url_length] = '\0'; constexpr std::string_view request_body_start {R"({"content": ")"}; constexpr std::string_view request_body_end {"\"}"}; constexpr std::size_t request_body_capacity { request_body_start.length() + DDNS_IP_ADDRESS_MAX_LENGTH + request_body_end.length() }; const std::size_t request_body_length { request_body_start.length() + new_ip_length + request_body_end.length() }; // This request buffer needs to be valid when calling curl_easy_perform() char request_body [request_body_capacity + 1]; // Concatenate the strings to make the request body std::memcpy(request_body, request_body_start.data(), request_body_start.length()); std::memcpy(request_body + request_body_start.length(), new_ip, new_ip_length); std::memcpy(request_body + request_body_start.length() + new_ip_length, request_body_end.data(), request_body_end.length()); request_body[request_body_length] = '\0'; priv::curl_patch_setup( curl, request_url, request_body ); const int curl_error {curl_easy_perform(*curl)}; curl_easy_setopt(*curl, CURLOPT_HTTPHEADER, nullptr); curl_slist_free_all(free_me_headers); curl_easy_setopt(*curl, CURLOPT_RESOLVE, nullptr); curl_slist_free_all(free_me_doh); if (curl_error) { return DDNS_ERROR_GENERIC; } return DDNS_ERROR_OK; } } // extern "C" Tachi107-cloudflare-ddns-3e1c227/meson.build000066400000000000000000000064641457365126600205610ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: AGPL-3.0-or-later project( 'cloudflare-ddns', 'cpp', default_options: [ 'buildtype=release', 'cpp_std=c++17', 'warning_level=3', 'b_lto=true', 'b_ndebug=if-release', 'cpp_rtti=false' ], version: '2.1.0', license: 'AGPL-3.0-or-later OR LGPL-3.0-or-later', meson_version: '>=0.53.0' ) compiler = meson.get_compiler('cpp') libcurl_dep = dependency('libcurl', default_options: [ 'default_library=static', 'tool=disabled', 'tests=disabled', 'unittests=disabled', 'bindlocal=disabled', 'brotli=disabled', 'cookies=disabled', 'doh=enabled', 'form-api=disabled', 'getoptions=disabled', 'gsasl=disabled', 'http2=auto', 'ipv6=auto', 'libcurl-option=enabled', 'libz=disabled', 'mime=disabled', 'netrc=disabled', 'parsedate=disabled', 'progress-meter=disabled', 'proxy=disabled', 'psl=disabled', 'shuffle-dns=disabled', 'socketpair=disabled', 'sspi=auto', 'unixsockets=disabled', 'verbose-strings=enabled', 'zstd=disabled', 'asynchdns=disabled', 'aws=disabled', 'basic-auth=disabled', 'bearer-auth=enabled', 'digest-auth=disabled', 'kerberos-auth=disabled', 'negotiate-auth=disabled', 'gss-api=disabled', 'idn=disabled', 'alt-svc=disabled', 'headers-api=enabled', 'hsts=disabled', 'http-auth=enabled', 'ntlm=disabled', 'ntlm-wb=disabled', 'ssh=disabled', 'ssl=enabled', 'tls-srp=disabled', 'ssl-default-backend=' + (host_machine.system() == 'windows' ? 'schannel' : 'implicit'), 'openssl=' + (host_machine.system() == 'windows' ? 'disabled' : 'auto'), 'schannel=' + (host_machine.system() == 'windows' ? 'enabled' : 'disabled'), 'dict=disabled', 'file=disabled', 'ftp=disabled', 'gopher=disabled', 'http=enabled', 'imap=disabled', 'ldap=disabled', 'ldaps=disabled', 'mqtt=disabled', 'pop3=disabled', 'rtmp=disabled', 'rtsp=disabled', 'smb=disabled', 'smtp=disabled', 'telnet=disabled', 'tftp=disabled' ]) extra_args = [] if host_machine.system() == 'windows' default_library = get_option('default_library') if default_library == 'both' error('default_library=both is not supported on Windows') elif default_library == 'shared' extra_args += '-DDDNS_SHARED_LIB' endif endif # Put kwargs unsupported by muon in a dictionary so that they get used only # when building with meson muon_unsupported_kwargs = {} if not get_option('muon') muon_unsupported_kwargs = { 'override_options': 'cpp_eh=none' } endif libcloudflare_ddns = library( 'cloudflare-ddns', 'lib'/'cloudflare-ddns.cpp', cpp_args: extra_args, dependencies: [libcurl_dep], extra_files: 'include'/'ddns'/'cloudflare-ddns.h', gnu_symbol_visibility: 'hidden', include_directories: 'include', install: true, version: meson.project_version(), kwargs: muon_unsupported_kwargs ) cloudflare_ddns_dep = declare_dependency( compile_args: extra_args, include_directories: 'include', link_with: libcloudflare_ddns, version: meson.project_version() ) install_subdir( 'include'/'ddns', install_dir: get_option('includedir') ) if get_option('executable') subdir('exe') endif if get_option('tests') subdir('tests') endif import('pkgconfig').generate( libcloudflare_ddns, description: 'Simple utility to dynamically change a DNS record using Cloudflare', extra_cflags: extra_args, url: 'https://github.com/Tachi107/cloudflare-ddns' ) Tachi107-cloudflare-ddns-3e1c227/meson_options.txt000066400000000000000000000012161457365126600220420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: AGPL-3.0-or-later option('executable', type: 'boolean', value: true, description: 'Build the cloudflare-ddns executable') option('tests', type: 'boolean', value: false, description: 'Build tests') option('test_api_token', type: 'string', description: 'API token to use for tests') option('test_zone_id', type: 'string', description: 'Zone ID to use for tests') option('test_record_name', type: 'string', description: 'Record name to use for tests') option('muon', type: 'boolean', value: false, description: 'Enable if building with muon') Tachi107-cloudflare-ddns-3e1c227/subprojects/000077500000000000000000000000001457365126600207505ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/subprojects/curl.wrap000066400000000000000000000012561457365126600226140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023 The Meson development team # SPDX-License-Identifier: MIT [wrap-file] directory = curl-8.6.0 source_url = https://github.com/curl/curl/releases/download/curl-8_6_0/curl-8.6.0.tar.xz source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/curl_8.6.0-1/curl-8.6.0.tar.xz source_filename = curl-8.6.0.tar.xz source_hash = 3ccd55d91af9516539df80625f818c734dc6f2ecf9bada33c76765e99121db15 patch_filename = curl_8.6.0-1_patch.zip patch_url = https://wrapdb.mesonbuild.com/v2/curl_8.6.0-1/get_patch patch_hash = 050d9e0d70c94c29b4f6b230161380abaed0b736833ad544ae2d184f9cfeb923 wrapdb_version = 8.6.0-1 [provide] dependency_names = libcurl Tachi107-cloudflare-ddns-3e1c227/subprojects/inih.wrap000066400000000000000000000007401457365126600225730ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 The Meson development team # SPDX-License-Identifier: MIT [wrap-file] directory = inih-r57 source_url = https://github.com/benhoyt/inih/archive/r57.tar.gz source_filename = inih-r57.tar.gz source_hash = f03f98ca35c3adb56b2358573c8d3eda319ccd5287243d691e724b7eafa970b3 source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/inih_r57-1/inih-r57.tar.gz wrapdb_version = r57-1 [provide] inih = inih_dep inireader = INIReader_dep Tachi107-cloudflare-ddns-3e1c227/subprojects/ut.wrap000066400000000000000000000004631457365126600222760ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022 Andrea Pappacoda # # SPDX-License-Identifier: FSFAP [wrap-file] source_url = https://github.com/boost-ext/ut/archive/refs/tags/v1.1.9.tar.gz source_filename = ut-1.1.9.tar.gz directory = ut-1.1.9 source_hash = 1a666513157905aa0e53a13fac602b5673dcafb04a869100a85cd3f000c2ed0d Tachi107-cloudflare-ddns-3e1c227/tests/000077500000000000000000000000001457365126600175475ustar00rootroot00000000000000Tachi107-cloudflare-ddns-3e1c227/tests/common.hpp000066400000000000000000000004101457365126600215430ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: AGPL-3.0-or-later */ #pragma once #define BOOST_UT_DISABLE_MODULE #include #include #include "credentials.hpp" using namespace boost::ut; Tachi107-cloudflare-ddns-3e1c227/tests/credentials.hpp.in000066400000000000000000000005551457365126600231670ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: AGPL-3.0-or-later */ #pragma once #include inline constexpr const char* const test_api_token = "@test_api_token@"; inline constexpr const char* const test_zone_id = "@test_zone_id@"; inline constexpr const char* const test_record_name = "@test_record_name@"; Tachi107-cloudflare-ddns-3e1c227/tests/get_local_ip.cpp000066400000000000000000000021111457365126600226670ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: AGPL-3.0-or-later */ #include "common.hpp" #include #include extern "C" { static std::size_t write_data(char* incoming_buffer, const std::size_t size, const std::size_t count, std::string* data) { data->append(incoming_buffer, size * count); return size * count; } } int main() { curl_global_init(CURL_GLOBAL_DEFAULT); "get_local_ip"_test = [] { std::string response; CURL* curl {curl_easy_init()}; curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); curl_easy_setopt(curl, CURLOPT_URL, "https://icanhazip.com"); curl_easy_perform(curl); response.pop_back(); // remove \n character std::array local_ip; expect(eq(ddns_get_local_ip(false, local_ip.size(), local_ip.data()), DDNS_ERROR_OK)); expect(eq( std::string_view{local_ip.data()}, response )); curl_easy_cleanup(curl); }; curl_global_cleanup(); } Tachi107-cloudflare-ddns-3e1c227/tests/get_record.cpp000066400000000000000000000056421457365126600223770ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: AGPL-3.0-or-later */ #include "common.hpp" #ifdef DDNS_HAS_GETADDRINFO #if __has_include() #include /* getaddrinfo, getnameinfo, freeaddrinfo, addrinfo, NI_NUMERICHOST */ #endif #if __has_include() #include /* INET6_ADDRSTRLEN */ #endif #if __has_include() #include #endif #else #error "Test not implemented on this platform" #endif #include int main() { /** * Get the current IP of an A record and compare if against the * return value of ddns_get_record() */ "get_record"_test = [] { #if __has_include() WSADATA wsaData; // Manually setting the version to 2.2 instead of using MAKEWORD WSAStartup(0b00000010'00000010, &wsaData); #endif struct addrinfo* dns_response {nullptr}; const int error { getaddrinfo(test_record_name, nullptr, nullptr, &dns_response) }; expect(eq(error, 0)) << "getaddrinfo: " << gai_strerror(error); std::array address; getnameinfo( dns_response->ai_addr, dns_response->ai_addrlen, address.data(), address.size(), nullptr, 0, NI_NUMERICHOST ); freeaddrinfo(dns_response); std::array record_ip; std::array record_id; bool aaaa; expect(eq(ddns_get_record( test_api_token, test_zone_id, test_record_name, record_ip.size(), record_ip.data(), record_id.size(), record_id.data(), &aaaa ), DDNS_ERROR_OK)); expect(eq( std::string_view{address.data()}, std::string_view{record_ip.data()} )); expect(eq(aaaa, false)); }; "get_record_bad_usage"_test = [] { std::array record_ip; std::array record_id; bool aaaa; expect(eq( ddns_get_record( "invalid api token", test_zone_id, test_record_name, record_ip.size(), record_ip.data(), record_id.size(), record_id.data(), &aaaa ), DDNS_ERROR_USAGE )); expect(eq( ddns_get_record( test_api_token, "invalid zone id", test_record_name, record_ip.size(), record_ip.data(), record_id.size(), record_id.data(), &aaaa ), DDNS_ERROR_USAGE )); expect(eq( ddns_get_record( test_api_token, test_zone_id, "Ciao a tutti ragazzi e bentornati in questo nuovo video io sono Tachi_107" "ed oggi siamo qui nell'aspettatissimo -egh- guerra verso il drago e il wither" "una roba che penso che nessuno abbia mai fatto perché è una roba malsana che non riusciremo mai a fare." "In pratica, ceh, adesso noi entriamo e ci sarà il nostro bellissimo drago" "e uccideremo anche il wither nello stesso momento -non spingetemi- è una roba malsas", record_ip.size(), record_ip.data(), record_id.size(), record_id.data(), &aaaa ), DDNS_ERROR_USAGE )); }; } Tachi107-cloudflare-ddns-3e1c227/tests/meson.build000066400000000000000000000025721457365126600217170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021 Andrea Pappacoda # # SPDX-License-Identifier: AGPL-3.0-or-later credentials_hpp = configure_file( input: 'credentials.hpp.in', output: 'credentials.hpp', configuration: { 'test_api_token': get_option('test_api_token'), 'test_zone_id': get_option('test_zone_id'), 'test_record_name': get_option('test_record_name') } ) boost_ut_dep = dependency('boost.ut', fallback: ['ut', 'boostut_dep']) test_args = [] test_deps = [] test_opts = ['b_ndebug=false'] if compiler.get_argument_syntax() == 'msvc' test_opts += 'cpp_std=c++latest' elif meson.version().version_compare('>=0.57.0') test_opts += 'cpp_std=c++20' else test_opts += 'cpp_std=c++2a' endif if compiler.has_function('getaddrinfo') test_args += '-DDDNS_HAS_GETADDRINFO' endif if compiler.has_header('ws2tcpip.h') test_deps += compiler.find_library('Ws2_32') if compiler.has_function('getaddrinfo', prefix: '#include ', dependencies: test_deps) test_args += '-DDDNS_HAS_GETADDRINFO' endif endif tests = [ 'get_local_ip', 'get_record', 'search_zone_id', 'update_record' ] foreach test : tests test( test, executable( test, test + '.cpp', cpp_args: test_args, dependencies: [ boost_ut_dep, cloudflare_ddns_dep, libcurl_dep ], gnu_symbol_visibility: 'hidden', override_options: test_opts, sources: credentials_hpp ) ) endforeach Tachi107-cloudflare-ddns-3e1c227/tests/search_zone_id.cpp000066400000000000000000000026311457365126600232310ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: AGPL-3.0-or-later */ #include "common.hpp" #include "credentials.hpp" #include #include #include int main() { "search_zone_id"_test = [] { // +1 because of '\0' std::array zone_id; expect(eq( ddns_search_zone_id( test_api_token, test_record_name, zone_id.size(), zone_id.data() ), DDNS_ERROR_OK )); // ut can't compare C strings expect(eq( std::string_view{zone_id.data()}, std::string_view{test_zone_id} )); }; "search_zone_id_bad_usage"_test = [] { std::array zone_id; expect(eq( ddns_search_zone_id( "invalid api token", test_record_name, zone_id.size(), zone_id.data() ), DDNS_ERROR_USAGE )); expect(eq( ddns_search_zone_id( test_api_token, "Ciao a tutti ragazzi e bentornati in questo nuovo video io sono Tachi_107" "ed oggi siamo qui nell'aspettatissimo -egh- guerra verso il drago e il wither" "una roba che penso che nessuno abbia mai fatto perché è una roba malsana che non riusciremo mai a fare." "In pratica, ceh, adesso noi entriamo e ci sarà il nostro bellissimo drago" "e uccideremo anche il wither nello stesso momento -non spingetemi- è una roba malsas", zone_id.size(), zone_id.data() ), DDNS_ERROR_USAGE )); }; } Tachi107-cloudflare-ddns-3e1c227/tests/update_record.cpp000066400000000000000000000035641457365126600231030ustar00rootroot00000000000000/* * SPDX-FileCopyrightText: 2021 Andrea Pappacoda * * SPDX-License-Identifier: AGPL-3.0-or-later */ #include "common.hpp" #include int main() { "update_record"_test = [] { std::array local_ip; expect(eq(ddns_get_local_ip(false, local_ip.size(), local_ip.data()), DDNS_ERROR_OK)); std::array record_ip; std::array record_id; bool aaaa; expect(eq(ddns_get_record( test_api_token, test_zone_id, test_record_name, record_ip.size(), record_ip.data(), record_id.size(), record_id.data(), &aaaa ), DDNS_ERROR_OK)); expect(eq(ddns_update_record( test_api_token, test_zone_id, record_id.data(), local_ip.data(), record_ip.size(), record_ip.data() ), DDNS_ERROR_OK)); expect(eq( std::string_view{local_ip.data()}, std::string_view{record_ip.data()} )); }; "update_record_bad_usage"_test = [] { std::array record_ip; expect(eq( ddns_update_record( "an invalid token", test_zone_id, "a string that is 32 chars looong", "1.2.3.4", record_ip.size(), record_ip.data() ), DDNS_ERROR_USAGE )); expect(eq( ddns_update_record( test_api_token, "an invalid zone id", "a string that is 32 chars looong", "1.2.3.4", record_ip.size(), record_ip.data() ), DDNS_ERROR_USAGE )); expect(eq( ddns_update_record( test_api_token, test_zone_id, "a string that is not 32 characters long", "1.2.3.4", record_ip.size(), record_ip.data() ), DDNS_ERROR_USAGE )); expect(eq( ddns_update_record( test_api_token, test_zone_id, "a string that is 32 chars looong", "Ciao a tutti ragazzi e bentornati in questo nuovo video io sono Tachi_107", record_ip.size(), record_ip.data() ), DDNS_ERROR_USAGE )); }; }