Loading changelog +2 −1 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ Time-stamp: <2012-05-27> - do not update when fatal error is not cleared by user. - use IP from local router. - only update when IP is different from last successful update. - send email to EMAIL and FATAL_ERROR_EMAIL - send email to EMAIL and FATAL_ERROR_EMAIL. - check IP is a valid public IP. * v0.1.0 - init version. was used to update sylecn01.dnsd.me. src/bin/ddclient-http +22 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ UPDATE_REQUEST_FAILED=3 UPDATE_REJECTED=4 UPDATE_NOCHG=5 FATAL_ERROR_EXISTS=6 BAD_IP_ADDRESS=7 NO_CONF=50 # stores responses from remote DDNS provider's server. usually it will be Loading Loading @@ -77,7 +78,7 @@ get_myip() { exit $GET_MYIP_FAILED fi if echo "$MYIP" | egrep -q -e '^[0-9]{1,3}(.[0-9]{1,3}){3}$'; then if echo "$MYIP" | egrep -q -e '^[0-9]{1,3}(\.[0-9]{1,3}){3}$'; then return 0 else err "Error: IP address $MYIP is not well-formed." Loading Loading @@ -108,6 +109,19 @@ require_update() { fi } # Usage: is_public_ip IP # returns true if IP is not in private address space or some special IP address. is_public_ip() { IP="$1" if [ -z "$IP" ]; then return 1 fi if `echo $IP | egrep -q -e '^(10\.|172\.(1[6-9]|2[0-9]|3[01])\.|192\.168\.|0\.0\.0\.0|127\.0\.0\.1|255\.255\.255\.255|224\.0\.0\.1|169\.254\.)'`; then return 1 fi return 0 } do_update() { log "update $HOSTNAME using IP $MYIP" if [ -f "$FATAL_ERROR_FILE" ]; then Loading @@ -115,6 +129,13 @@ do_update() { Delete $FATAL_ERROR_FILE when you cleared the issue." exit $FATAL_ERROR_EXISTS fi # check IP is a public IP. if ! is_public_ip "$MYIP"; then err "Error: bad IP address: $MYIP." exit $BAD_IP_ADDRESS fi URL=`printf $UPDATE_URL $MYIP` curl -s -o "$HTTP_RESPONSE" "$URL" # check curl EXIT CODES Loading Loading
changelog +2 −1 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ Time-stamp: <2012-05-27> - do not update when fatal error is not cleared by user. - use IP from local router. - only update when IP is different from last successful update. - send email to EMAIL and FATAL_ERROR_EMAIL - send email to EMAIL and FATAL_ERROR_EMAIL. - check IP is a valid public IP. * v0.1.0 - init version. was used to update sylecn01.dnsd.me.
src/bin/ddclient-http +22 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ UPDATE_REQUEST_FAILED=3 UPDATE_REJECTED=4 UPDATE_NOCHG=5 FATAL_ERROR_EXISTS=6 BAD_IP_ADDRESS=7 NO_CONF=50 # stores responses from remote DDNS provider's server. usually it will be Loading Loading @@ -77,7 +78,7 @@ get_myip() { exit $GET_MYIP_FAILED fi if echo "$MYIP" | egrep -q -e '^[0-9]{1,3}(.[0-9]{1,3}){3}$'; then if echo "$MYIP" | egrep -q -e '^[0-9]{1,3}(\.[0-9]{1,3}){3}$'; then return 0 else err "Error: IP address $MYIP is not well-formed." Loading Loading @@ -108,6 +109,19 @@ require_update() { fi } # Usage: is_public_ip IP # returns true if IP is not in private address space or some special IP address. is_public_ip() { IP="$1" if [ -z "$IP" ]; then return 1 fi if `echo $IP | egrep -q -e '^(10\.|172\.(1[6-9]|2[0-9]|3[01])\.|192\.168\.|0\.0\.0\.0|127\.0\.0\.1|255\.255\.255\.255|224\.0\.0\.1|169\.254\.)'`; then return 1 fi return 0 } do_update() { log "update $HOSTNAME using IP $MYIP" if [ -f "$FATAL_ERROR_FILE" ]; then Loading @@ -115,6 +129,13 @@ do_update() { Delete $FATAL_ERROR_FILE when you cleared the issue." exit $FATAL_ERROR_EXISTS fi # check IP is a public IP. if ! is_public_ip "$MYIP"; then err "Error: bad IP address: $MYIP." exit $BAD_IP_ADDRESS fi URL=`printf $UPDATE_URL $MYIP` curl -s -o "$HTTP_RESPONSE" "$URL" # check curl EXIT CODES Loading