ipip: Support fqdn as remote tunnel endpoint
authorHans Dedecker <dedeckeh@gmail.com>
Tue, 25 Oct 2016 20:50:04 +0000 (22:50 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 26 Oct 2016 15:53:53 +0000 (17:53 +0200)
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
package/network/config/ipip/Makefile
package/network/config/ipip/files/ipip.sh

index 5aa722d238416cf16c8ad3f61a6a4917534c97ab..9bdb13c6bc7e5f6809a96274916c94715ab045e1 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ipip
 PKG_VERSION:=1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_LICENSE:=GPL-2.0
 
 include $(INCLUDE_DIR)/package.mk
@@ -19,7 +19,7 @@ define Package/ipip
   CATEGORY:=Network
   MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
   TITLE:=IP in IP Tunnel config support
-  DEPENDS:= +kmod-ipip
+  DEPENDS:= +kmod-ipip +resolveip
 endef
 
 define Package/ipip/description
index 51c503f8950eedb9521c26a63866bd5d49acd2d4..f1c94d6eeddbeb47c566764998f4ce6504742b0d 100755 (executable)
@@ -9,16 +9,29 @@
 
 proto_ipip_setup() {
        local cfg="$1"
+       local remoteip
 
        local df ipaddr peeraddr tunlink ttl tos zone mtu
        json_get_vars df ipaddr peeraddr tunlink ttl tos zone mtu
 
        [ -z "$peeraddr" ] && {
-               proto_notify_error "$cfg" "MISSING_ADDRESS"
+               proto_notify_error "$cfg" "MISSING_PEER_ADDRESS"
                proto_block_restart "$cfg"
                return
        }
 
+       remoteip=$(resolveip -t 10 -4 "$peeraddr")
+
+       if [ -z "$remoteip" ]; then
+               proto_notify_error "$cfg" "PEER_RESOLVE_FAIL"
+               return
+       fi
+
+       for ip in $remoteip; do
+               peeraddr=$ip
+               break
+       done
+
        ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" )
 
        [ -z "$ipaddr" ] && {