diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2016-10-03 10:56:45 +0200 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2016-10-04 11:50:51 +0200 |
commit | a79f3d11b3d7e4441544a2401f129bd055e84034 (patch) | |
tree | 427987debce42dbd45c48750a2374440f4bda629 /package/network/config/gre/files | |
parent | 52974da2bb17ad53596944f58066c08e1af89574 (diff) | |
download | upstream-a79f3d11b3d7e4441544a2401f129bd055e84034.tar.gz upstream-a79f3d11b3d7e4441544a2401f129bd055e84034.tar.bz2 upstream-a79f3d11b3d7e4441544a2401f129bd055e84034.zip |
gre: Support fqdn as remote tunnel endpoint
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'package/network/config/gre/files')
-rwxr-xr-x | package/network/config/gre/files/gre.sh | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/package/network/config/gre/files/gre.sh b/package/network/config/gre/files/gre.sh index cab52d30f2..3f472c4473 100755 --- a/package/network/config/gre/files/gre.sh +++ b/package/network/config/gre/files/gre.sh @@ -44,16 +44,29 @@ gre_generic_setup() { gre_setup() { local cfg="$1" local mode="$2" + local remoteip local ipaddr peeraddr json_get_vars df ipaddr peeraddr tunlink [ -z "$peeraddr" ] && { - proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" proto_block_restart "$cfg" exit } + remoteip=$(resolveip -t 10 -4 "$peeraddr") + + if [ -z "$remoteip" ]; then + proto_notify_error "$cfg" "PEER_RESOLVE_FAIL" + exit + fi + + for ip in $remoteip; do + peeraddr=$ip + break + done + ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) [ -z "$ipaddr" ] && { @@ -101,16 +114,29 @@ proto_gretap_setup() { grev6_setup() { local cfg="$1" local mode="$2" + local remoteip6 local ip6addr peer6addr weakif json_get_vars ip6addr peer6addr tunlink weakif [ -z "$peer6addr" ] && { - proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" proto_block_restart "$cfg" exit } + remoteip6=$(resolveip -t 10 -6 "$peer6addr") + + if [ -z "$remoteip6" ]; then + proto_notify_error "$cfg" "PEER_RESOLVE_FAIL" + exit + fi + + for ip6 in $remoteip6; do + peer6addr=$ip6 + break + done + ( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" ) [ -z "$ip6addr" ] && { |