Coder Social home page Coder Social logo

dnspod-client's Introduction

dnspod-client

Dnspod client with c++, dynamically update domain name records when your public IP changes by get the current IP periodically. For example, I deploy it at my own Raspberry Pi 4.

build

git clone https://github.com/maywine/dnspod-client.git

cd dnspod-client

git submodule init

git submodule update

mkdir build

cd build

cmake ../

make && make install

usage

dnspod-client read config from json file:

dnspod  /your/config/path/config.json

run in the background:

setsid dnspod /your/config/path/config.json >> ~/log/dns_pod.log 2>&1 &

or use systemctl for management by create the /etc/systemd/system/dnspod.service file and enter the following:

[Unit]
Description=dnspod-client
After=network.target network-online.target nss-lookup.target

[Service]
Type=simple
StandardError=journal
User=nobody
ExecStart=/usr/local/bin/dnspod /usr/local/etc/dnspod-client/config.json
Restart=on-failure
RestartSec=15s

[Install]
WantedBy=multi-user.target

then start dnspod:

sudo systemctl enable dnspod.service
sudo systemctl start dnspod.service

config format

a example config:

{
    // you can get this at https://console.dnspod.cn/account/token
    "token": "123456,aaaaabbbbbcccccc", // dnspod api id and token

    // the domain info
    // you need add the domain record to dnspod firstly
    "domain_list":[
        {
            "domain": "domain.com", // domain name
            "sub_domain": "@" // http:://domain.com is @
                              // http:://www.domain.com is wwww
                              // http:://abc.domain.com is abc
        }
    ],

    // execute interval, default 10 second
    "execute_interval": 10
}

the default url to check what your public IP is is https://ifconfig.me/ip, equivalent to call with curl:

curl --http1.1 -X GET -L https://ifconfig.me/ip

you can set up the query url:

{
    // you can get this at https://console.dnspod.cn/account/token
    "dnspod_token": "123456,aaaaabbbbbcccccc", // dnspod api id and token: "$api_id,$api_token"

    // the domain info
    // you need add the domain record to dnspod firstly
    "domain_list":[
        {
            "domain": "domain.com", // domain name
            "sub_domain": "@", // http:://domain.com is @
                               // http:://www.domain.com is wwww
                               // http:://abc.domain.com is abc
            "ttl": 600 // option
        }
    ],

    // the query url info
    "query_self_request": {
        "method": "GET", // http method
        "host": "ifconfig.me", // the host
        "port": 443, // port
        "path": "/ip", // url
        "body": "" // optional body
    },

    // execute interval, default 10 second
    "execute_interval": 10
}

equivalent to call with curl:

curl --http1.1 -X GET -L https://ifconfig.me:443/ip

you can also use command to get the public IP :

{
    // you can get this at https://console.dnspod.cn/account/token
    "dnspod_token": "123456,aaaaabbbbbcccccc", // dnspod api id and token: "$api_id,$api_token"

    // the domain info
    // you need add the domain record to dnspod firstly
    "domain_list":[
        {
            "domain": "domain.com", // domain name
            "sub_domain": "@", // http:://domain.com is @
                               // http:://www.domain.com is wwww
                               // http:://abc.domain.com is abc
            "ttl": 600 // optional ttl
        }
    ],

    // command
    "query_self_cmd": "curl -s -X GET -L https://1.1.1.1/cdn-cgi/trace | awk -F '=' '{if (NR==3){print $2}}'",

    // execute interval, default 10 second
    "execute_interval": 10
}

dnspod-client's People

Contributors

maywine avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.