From b11a4fc95d5af717c25a4a06d6a849a2e5e9418b Mon Sep 17 00:00:00 2001 From: dman776 Date: Mon, 15 Oct 2018 21:58:52 -0500 Subject: [PATCH] bugfix: check to see if internet is reachable before loading external resources (#224) --- files/www/cgi-bin/perlfunc.pm | 6 +++++- files/www/cgi-bin/setup | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/files/www/cgi-bin/perlfunc.pm b/files/www/cgi-bin/perlfunc.pm index bbc91edf..0484f0d5 100644 --- a/files/www/cgi-bin/perlfunc.pm +++ b/files/www/cgi-bin/perlfunc.pm @@ -1704,7 +1704,11 @@ sub is_online() my $online=0; if(get_default_gw() ne "none") { - $online=1; + system("ping -W1 -c1 8.8.8.8 &>/dev/null"); # google DNS + if($? eq 0) + { + $online=1; + } } return $online; } diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index ff7f8e58..8a1dd448 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -473,8 +473,8 @@ my ($rc, $maptiles, $leafletcss, $leafletjs); http_header() unless $debug == 2; html_header(nvram_get("node") . " setup", 0); -print "\n"; -print "\n"; +print "\n" if $pingOk; +print "\n" if $pingOk; print ""; print "
\n";