Giter Club home page Giter Club logo

caddy-dynamicdns-cmd-source's Introduction

Command IP source module for caddy-dynamicdns

This is a IP source for caddy-dynamicdns. You can use it to get your IP via any command line script or program.

E.g. get your IP from your Fritz!BOX Router via this command:

curl -s -H 'Content-Type: text/xml; charset="utf-8"' \
  -H 'SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress' \
  -d '<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1" /></s:Body></s:Envelope>' \
  "http://$FRITZ_BOX_HOSTNAME:49000/igdupnp/control/WANIPConn1" | \
  grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'

Source

Install

You "install" this module by building your own caddy binary via xcaddy.

Example for Cloudflare DNS:

xcaddy build --with github.com/mholt/caddy-dynamicdns --with github.com/mietzen/caddy-dynamicdns-cmd-source --with github.com/caddy-dns/cloudflare 

Config

Here's an example on how to run a custom command to get the IP addresses. If the command returns ipv4 and ipv6 addresses, make sure that they are comma separated.

Caddyfile config (global options):

{
	dynamic_dns {
		provider cloudflare {env.CLOUDFLARE_API_TOKEN}
		domains {
			example.net subdomain
		}
        ip_source command echo 1.2.3.4,2004:1234::1234
        check_interval 5m
        ttl 1h
	}
}

Equivalent JSON config:

{
	"apps": {
		"dynamic_dns": {
			"dns_provider": {
				"name": "cloudflare",
				"api_token": "{env.CLOUDFLARE_API_TOKEN}"
			},
			"domains": {
				"example.net": ["subdomain"]
			},
			"ip_sources": [
				{
					"source": "command",
					"command": "echo",
					"args": ["1.2.3.4,2004:1234::1234"]
				}
			],
			"check_interval": "5m",
			"versions": {
				"ipv4": true,
				"ipv6": true
			},
			"ttl": "1h",
			"dynamic_domains": false
		}
	}
}

caddy-dynamicdns-cmd-source's People

Contributors

mietzen 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.