Documentation of twod

twod is a daemon that updates your TwoDNS entries.

Contents:

Getting started

Configuration

twod will look for a configuration file in /etc/twod/twodrc. Optionally you can tell twod to use a specified configuration file instead by using the -c parameter.

Config format

[general]
user      = USERNAME
token     = TOKEN
host_url  = DNS_HOST_URL
interval  = REFRESH_INTERVAL
timeout   = HTTP_TIMEOUT
redirects = MAX_HTTP_REDIRECTS

[ip_service]
mode      = MODE
ip_urls   = URLS

[logging]
level     = LOGLEVEL
general section
user
Username used to authenticate to TwoDNS.
token
Token used to authenticate to TwoDNS.
host_url
URL of your TwoDNS host.
interval
Refresh interval in seconds.
timeout
Timeout for retrieving and setting your external IP, in seconds.
redirects
Maximum number of redirects to follow on HTTP requests.
ip_service section
mode

Controls after which pattern the ip_service URL will be selected. Possible values:

  • random: Chooses random ip service on every refresh.
  • round_robin: Loop through ip services in the order they are
    defined.
ip_urls
Space-separated list of URLs to fetch your external IP address from. The IP has to be returned as plaintext without any HTML or other extra data.
logging section
level

Log level. Can be one of:

  • DEBUG
  • INFO
  • WARNING
  • ERROR
  • CRITICAL

Example config

# An example configuration file for twod.
# See the twod.conf man page for a more detailed description of each parameter.

[general]
# TwoDNS username
user = my-user@example.com

# TwoDNS token
token = my-token

# Update URL in the form https://api.twodns.de/hosts/<your-host>
# e.g. https://api.twodns.de/hosts/awesomehost.dd-dns.de
host_url = https://api.twodns.de/hosts/my-example-host.dd-dns.de

# Update interval - Check if IP has changed every x seconds.
interval = 3600

# Timeout for retrieving and setting your external IP, in seconds.
timeout = 16

# Maximum number of redirects to follow on HTTP requests.
redirects = 2

[ip_service]
# Method of selecting url to get external IP.
# Possible values are `round_robin` or `random`.
mode = random

# List of URLs to get external ip from.
# Which of these URLs will actually be queried depends on the `mode` setting.
ip_urls = https://icanhazip.com https://ipinfo.io/ip
# Some more URLs you can use if you don't mind not using SSL
;ip_urls = https://icanhazip.com https://ipinfo.io/ip http://ifconfig.me/ip
;       http://ipecho.net/plain


[logging]
# Log level. Possible values: DEBUG | INFO | WARNING | ERROR | CRITICAL
level = WARNING

Changelog

0.5.0

  • Add python 3 compatibility. [#7]
  • Tidy up a bit.

0.4.0

  • Add config setting for maximum number of redirects to follow on HTTP requests.
  • Update man pages.
  • Add CLI argument for pidfile location.
  • Make interval, timeout, redirects, ip_mode and loglevel settings optional.
  • Never exit on errors caused by HTTP requests.

0.3.2

  • Add config setting for HTTP timeout.
  • Fix terminology for token setting. [#1]
  • Catch connection and response timeouts. [#2]
  • Normalise version string in setup.py.
  • Add IP validation.
  • Get rid of “Unexpected error” exceptions.

0.3.1

  • Add python dependencies to setup.py.
  • Implement simpler version handling.
  • Fix capitalisation of TwoDNS.
  • Improve error handling for config parsing.

Indices and tables