support domain patterns
authorChristian Weiske <cweiske@cweiske.de>
Tue, 5 Feb 2013 21:01:07 +0000 (22:01 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 5 Feb 2013 21:01:07 +0000 (22:01 +0100)
README.rst
ssh-dyndns
ssh-dyndns.sh.config-dist

index 55947a979c25a439599335afc0d257fbfb273dce..4a456e0fb6f902558344491a37db015957788e97 100644 (file)
@@ -64,6 +64,14 @@ The configuration file may define the following variables:
     DNS entry TTL (time to live) in seconds
 
     Default: 300
     DNS entry TTL (time to live) in seconds
 
     Default: 300
+``domain_patterns``
+    Defines patterns for domains that may be dynamically changed.
+    If the domain name does not match the pattern, the script aborts.
+
+    You may use several patterns by separating them with a space.
+    Shell wildcards are supported (``*`` and ``?``).
+
+    Default: ``home.example.org *.home.example.org``
 
 
 =====
 
 
 =====
index 903e859ad8be693e568bbf04fcc837e01164971d..18fc5d9a14963034b3858472c0ed89c055ba17e9 100755 (executable)
@@ -44,22 +44,34 @@ if [ ! -f "$data_dir/Makefile" ]; then
     exit 6
 fi
 
     exit 6
 fi
 
-#FIXME: check allowed domains, allowed suffixes
+if [ ! -z "$domain_patterns" ]; then
+    ok=0
+    for single_dp in $domain_patterns; do
+        case "$domain" in
+            ($single_dp) ok=1;;
+        esac
+    done
+    if [ $ok -ne 1 ]; then
+        echo "Domain \"$domain\" does not match \$domain_pattern"
+        exit 7
+    fi
+fi
+
 
 file_pattern="${file_pattern:-data-dyndns-%DOMAIN%}"
 timeout=${timeout:-300}
 
 datafile=${data_dir}`echo $file_pattern | sed "s/%DOMAIN%/$domain/"`
 
 file_pattern="${file_pattern:-data-dyndns-%DOMAIN%}"
 timeout=${timeout:-300}
 
 datafile=${data_dir}`echo $file_pattern | sed "s/%DOMAIN%/$domain/"`
-#echo $datafile
 
 if [ `echo "$remoteip"| sed "s/://"` != "$remoteip" ]; then
     echo "IPv6 not supported yet"
     # we need ipv6 address expansion
 
 if [ `echo "$remoteip"| sed "s/://"` != "$remoteip" ]; then
     echo "IPv6 not supported yet"
     # we need ipv6 address expansion
-    exit 7
+    exit 8
 fi
 
 #=cweiske.de:5.35.241.22
 djbdnsline="=${domain}:${remoteip}:${timeout}"
 fi
 
 #=cweiske.de:5.35.241.22
 djbdnsline="=${domain}:${remoteip}:${timeout}"
+#FIXME: do not update if nothing changed
 echo $djbdnsline > $datafile
 
 #compile dns data
 echo $djbdnsline > $datafile
 
 #compile dns data
index 7dd3fa818d4ac4309a04658fcfc57d26b6aa3194..f78934daceb681c7f1d70ac719aeaad4dc12b5a0 100644 (file)
@@ -7,3 +7,4 @@
 data_dir=/tmp/
 file_pattern=data-dyndns-%DOMAIN%
 timeout=300
 data_dir=/tmp/
 file_pattern=data-dyndns-%DOMAIN%
 timeout=300
+domain_patterns="home.example.org *.home.example.org"