Commit d7d737de authored by Yuanle Song's avatar Yuanle Song
Browse files

before rewrite to conform to Dyn client Policies.

- added changelog;
- added bts;
- split config file from ddclient-http;
  example-config-file shipped with project;
- crontab gap increased to 4 minutes;
parent 97d9abfd
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
Date: 2012-05-10
Time-stamp: <2012-05-10>
Time-stamp: <2012-05-27>

the ddclient package seems *weak*.
it does not keep the domain up-to-date.
@@ -32,16 +32,6 @@ it does not report errors.
  dig
  make

* TODO split config from source code.
  config variables should be set in /etc/ddclient-http.conf
  and it can be sourced by the source code.

  move username, password, domain name, update URL to $HOME/.ddclient-httprc

  then source that at run time.

* TODO BUG when I just updated my domain.
  I do a dig, I get the old IP. I try a new update. I get "nochg".
  will I be blocked?

  extend crontab gap to 3 minutes?
* start to use bugzilla to track feature requests and bugs.
  for open bugs see
  http://localhost/bugzilla3/buglist.cgi?product=ddclient-http&component=core&resolution=---

changelog

0 → 100644
+11 −0
Original line number Diff line number Diff line
# -*- mode: org -*-
Date: 2012-05-27
Time-stamp: <2012-05-27>

* 
* v0.1.1
  - split config from executable.
  - update app according to Dyn policies and guidelines.
  - 
* v0.1.0
  - init version. was used to update sylecn01.dnsd.me.
+14 −0
Original line number Diff line number Diff line
# -*- mode: sh -*-
# config file should be saved to $HOME/.ddclient-http

# example config file for dyn.com. for other hosts, you need to modify
# UPDATE_URL.
#
# Note: you should always use https URL if it's available. If you use http,
# your username and password can be sniffed very easily.

USERNAME=
PASSWORD=
HOSTNAME=
# using printf syntax, with %s being the new IP.
UPDATE_URL="https://$USERNAME:$PASSWORD@members.dyndns.org/nic/update?hostname=$HOSTNAME&myip=%s&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"

done

0 → 100644
+14 −0
Original line number Diff line number Diff line
* DONE split config from source code.
  config variables should be set in /etc/ddclient-http.conf
  and it can be sourced by the source code.

  move username, password, domain name, update URL to $HOME/.ddclient-httprc

  then source that at run time.

* DONE BUG when I just updated my domain. I do a dig, I get the old IP. 
  I try a new update. I get "nochg". I might get blocked if this happens
  often.

  extended crontab gap to 4 minutes. Since most Dynamic host has a TTL of 60s,
  this should be OK.
+17 −9
Original line number Diff line number Diff line
@@ -4,23 +4,20 @@
# run 'make install' to install this program.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
CONFIG_FILE="$HOME/.ddclient-http"

# exit codes
GET_MYIP_FAILED=1
DIG_FAILED=2
UPDATE_REQUEST_FAILED=3
UPDATE_REJECTED=4
NO_CONF=50

# stores responses from remote DDNS provider's server.  usually it will be
# very short, like a word or two. but if there is a server error, it could be
# long.
HTTP_RESPONSE=/tmp/ddclient-http-api.html

# which host to update and it's credentials.
USERNAME=s12nospam@hotmail.com
PASSWORD=songyl
HOSTNAME=sylecn01.dnsd.me

# Usage: log [MESSAGE..]
log() {
	logger -t ddclient_http "$@"
@@ -31,6 +28,15 @@ err() {
	logger -t ddclient_http -p user.err "$@"
}

# which host to update and it's credentials.
if [ -f "$CONFIG_FILE" ]; then
	. "$CONFIG_FILE"
else
	err "Error: No config file found at $CONFIG_FILE."
	echo "Error: No config file found at $CONFIG_FILE." > /dev/stderr
	exit $NO_CONF
fi

# set MYIP variable to my internet IP address.
# Returns true on success, false on failure.
get_myip() {
@@ -46,7 +52,7 @@ get_myip() {

# returns true if domain is outdated. returns false otherwise.
require_update() {
	OLDIP=`dig +short sylecn01.dnsd.me`
	OLDIP=`dig +short $HOSTNAME`
	# TODO dig can fail when network is down or DNS server is blocked by
	# GFW. check dig command's exit code.
	#
@@ -66,8 +72,10 @@ require_update() {

do_update() {
	log "update $HOSTNAME using IP $MYIP"
	curl -s -o "$HTTP_RESPONSE" -u "$USERNAME":"$PASSWORD" \
		"https://www.dnsdynamic.org/api/?hostname=$HOSTNAME&myip=$MYIP"
	URL=`printf $UPDATE_URL $MYIP`
	curl -s -o "$HTTP_RESPONSE" "$URL"
	exit 0

	# check curl EXIT CODES
	CURL_EXIT_CODE=$?
	case $CURL_EXIT_CODE in
@@ -86,7 +94,7 @@ do_update() {
	case "$KEYWORD" in
		good) log "good: update accepted."
			return 0 ;;
		nochg) log "nochg: IP not changed." ;;
		nochg) err "nochg: IP not changed." ;;
		badauth) err "badauth: user or password incorrect." ;;
		abuse) err "abuse: hostname is blocked for update abuse." ;;
		dnserr) err "dnserr: DNS error encountered." ;;
Loading