mirror of https://github.com/hak5/openwrt-owl.git
6in4: detect curl and busybox wget
b52053b 6in4: https support for he.net tunnel api introduced HTTPS support using wget. The busybox version of wget, however, doesn't support the -V option, thus poluting logfiles with a full invalid-parameter-output. Redirect stderr to fix that. As libcurl and curl support selecting the SSL library of your choice, also add support for curl which is more commonly used on OpenWrt than "real" wget which needs libopenssl. Also make sure to respect SSL_CERT_DIR and increase timeouts. Signed-off-by: Daniel Golle <daniel@makrotopia.org> SVN-Revision: 43228owl
parent
9809b02dec
commit
c5b5e68879
|
@ -67,23 +67,42 @@ proto_6in4_setup() {
|
||||||
[ -n "$updatekey" ] && password="$updatekey"
|
[ -n "$updatekey" ] && password="$updatekey"
|
||||||
|
|
||||||
local http="http"
|
local http="http"
|
||||||
local wget_opts="-qO/dev/null"
|
local urlget="wget"
|
||||||
if wget --version | grep -qF "+https"; then
|
local urlget_opts="-qO/dev/stdout"
|
||||||
|
local ca_path="${SSL_CERT_DIR-/etc/ssl/certs}"
|
||||||
|
|
||||||
|
if [ -n "$(which curl)" ]; then
|
||||||
|
urlget="curl"
|
||||||
|
urlget_opts="-s -S"
|
||||||
|
if curl -V | grep "Protocols:" | grep -qF "https"; then
|
||||||
http="https"
|
http="https"
|
||||||
[ -z "$(find ${SSL_CERT_DIR-/etc/ssl/certs} -name "*.0" 2>/dev/null)" ] && {
|
urlget_opts="$urlget_opts --capath $ca_path"
|
||||||
wget_opts="$wget_opts --no-check-certificate"
|
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$http" = "http" ] &&
|
||||||
|
wget --version 2>&1 | grep -qF "+https"; then
|
||||||
|
urlget="wget"
|
||||||
|
urlget_opts="-qO/dev/stdout --ca-directory=$ca_path"
|
||||||
|
http="https"
|
||||||
|
fi
|
||||||
|
[ "$http" = "https" -a -z "$(find $ca_path -name "*.0" 2>/dev/null)" ] && {
|
||||||
|
if [ "$urlget" = "curl" ]; then
|
||||||
|
urlget_opts="$urlget_opts -k"
|
||||||
|
else
|
||||||
|
urlget_opts="$urlget_opts --no-check-certificate"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
local url="$http://ipv4.tunnelbroker.net/nic/update?username=$username&password=$password&hostname=$tunnelid"
|
local url="$http://ipv4.tunnelbroker.net/nic/update?username=$username&password=$password&hostname=$tunnelid"
|
||||||
local try=0
|
local try=0
|
||||||
local max=3
|
local max=3
|
||||||
|
|
||||||
while [ $((++try)) -le $max ]; do
|
while [ $((++try)) -le $max ]; do
|
||||||
( exec wget $wget_opts "$url" 2>/dev/null ) &
|
( exec $urlget $urlget_opts "$url" | logger -t "$link" ) &
|
||||||
local pid=$!
|
local pid=$!
|
||||||
( sleep 5; kill $pid 2>/dev/null ) &
|
( sleep 20; kill $pid 2>/dev/null ) &
|
||||||
wait $pid && break
|
wait $pid && break
|
||||||
|
sleep 20;
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue