diff --git a/README.md b/README.md index 37d62dc..0a50eaf 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ Internet-detector is an application for checking the availability of the Interne **Features:** - It can run continuously as a system service or only in an open web interface. - - Checking the availability of a host using ping or by connecting via TCP to a specified port. + - Checking the availability of a host using ping (L3) or by connecting via TCP to a specified port (L4). + - Testing URL accessibility via HTTP (L7) (curl). - LED indication of Internet availability. ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/internet-led.jpg) - Performing actions when connecting and disconnecting the Internet: rebooting device, restarting network or modem (internet-detector-mod-modem-restart), executing custom shell scripts. @@ -20,22 +21,22 @@ Internet-detector is an application for checking the availability of the Interne ## Installation notes: opkg update - wget --no-check-certificate -O /tmp/internet-detector_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.6.7-r1_all.ipk - opkg install /tmp/internet-detector_1.6.7-r1_all.ipk - rm /tmp/internet-detector_1.6.7-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector_1.7.0-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.7.0-r1_all.ipk + opkg install /tmp/internet-detector_1.7.0-r1_all.ipk + rm /tmp/internet-detector_1.7.0-r1_all.ipk service internet-detector start service internet-detector enable - wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.6.7-r1_all.ipk - opkg install /tmp/luci-app-internet-detector_1.6.7-r1_all.ipk - rm /tmp/luci-app-internet-detector_1.6.7-r1_all.ipk + wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.7.0-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.7.0-r1_all.ipk + opkg install /tmp/luci-app-internet-detector_1.7.0-r1_all.ipk + rm /tmp/luci-app-internet-detector_1.7.0-r1_all.ipk service rpcd restart i18n-ru: - wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk - opkg install /tmp/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk - rm /tmp/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk + wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.7.0-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.7.0-r1_all.ipk + opkg install /tmp/luci-i18n-internet-detector-ru_1.7.0-r1_all.ipk + rm /tmp/luci-i18n-internet-detector-ru_1.7.0-r1_all.ipk ## Screenshots: @@ -47,9 +48,9 @@ i18n-ru: **Dependences:** modemmanager. - wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk - opkg install /tmp/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk - rm /tmp/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.7.0-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.7.0-r1_all.ipk + opkg install /tmp/internet-detector-mod-modem-restart_1.7.0-r1_all.ipk + rm /tmp/internet-detector-mod-modem-restart_1.7.0-r1_all.ipk service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/04.jpg) @@ -58,9 +59,9 @@ i18n-ru: **Dependences:** mailsend. - wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.6.7-r1_all.ipk - opkg install /tmp/internet-detector-mod-email_1.6.7-r1_all.ipk - rm /tmp/internet-detector-mod-email_1.6.7-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.7.0-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.7.0-r1_all.ipk + opkg install /tmp/internet-detector-mod-email_1.7.0-r1_all.ipk + rm /tmp/internet-detector-mod-email_1.7.0-r1_all.ipk service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/05.jpg) @@ -69,9 +70,9 @@ i18n-ru: **Dependences:** curl. - wget --no-check-certificate -O /tmp/internet-detector-mod-telegram_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-telegram_1.6.7-r1_all.ipk - opkg install /tmp/internet-detector-mod-telegram_1.6.7-r1_all.ipk - rm /tmp/internet-detector-mod-telegram_1.6.7-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector-mod-telegram_1.7.0-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-telegram_1.7.0-r1_all.ipk + opkg install /tmp/internet-detector-mod-telegram_1.7.0-r1_all.ipk + rm /tmp/internet-detector-mod-telegram_1.7.0-r1_all.ipk service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/06.jpg) diff --git a/internet-detector-mod-email/Makefile b/internet-detector-mod-email/Makefile index a83cf98..f343e3d 100644 --- a/internet-detector-mod-email/Makefile +++ b/internet-detector-mod-email/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-email -PKG_VERSION:=1.6.7 +PKG_VERSION:=1.7.0 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector-mod-modem-restart/Makefile b/internet-detector-mod-modem-restart/Makefile index 75fb65d..5cae72a 100644 --- a/internet-detector-mod-modem-restart/Makefile +++ b/internet-detector-mod-modem-restart/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-modem-restart -PKG_VERSION:=1.6.7 +PKG_VERSION:=1.7.0 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector-mod-telegram/Makefile b/internet-detector-mod-telegram/Makefile index 80252b6..af58e52 100644 --- a/internet-detector-mod-telegram/Makefile +++ b/internet-detector-mod-telegram/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-telegram -PKG_VERSION:=1.6.7 +PKG_VERSION:=1.7.0 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector-mod-telegram/files/usr/lib/lua/internet-detector/modules/mod_telegram.lua b/internet-detector-mod-telegram/files/usr/lib/lua/internet-detector/modules/mod_telegram.lua index 9400e34..e217ba5 100644 --- a/internet-detector-mod-telegram/files/usr/lib/lua/internet-detector/modules/mod_telegram.lua +++ b/internet-detector-mod-telegram/files/usr/lib/lua/internet-detector/modules/mod_telegram.lua @@ -28,7 +28,7 @@ local Module = { msgSendAttempts = 3, msgSendTimeout = 5, curlExec = "/usr/bin/curl", - curlParams = "-s", + curlParams = "-s --no-keepalive", status = nil, _enabled = false, _deadCounter = 0, diff --git a/internet-detector/Makefile b/internet-detector/Makefile index 5f9b837..93ec9d3 100644 --- a/internet-detector/Makefile +++ b/internet-detector/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector -PKG_VERSION:=1.6.7 +PKG_VERSION:=1.7.0 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector/files/etc/config/internet-detector b/internet-detector/files/etc/config/internet-detector index 3663853..7cc4785 100644 --- a/internet-detector/files/etc/config/internet-detector +++ b/internet-detector/files/etc/config/internet-detector @@ -8,6 +8,7 @@ config instance 'internet' option description 'Default instance' list hosts '8.8.8.8' list hosts '1.1.1.1' + list urls 'https://www.google.com' option check_type '0' option tcp_port '53' option interval_up '30' diff --git a/internet-detector/files/usr/lib/lua/internet-detector/main.lua b/internet-detector/files/usr/lib/lua/internet-detector/main.lua index 39394e1..55a4eb1 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/main.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/main.lua @@ -12,32 +12,8 @@ local uci = require("uci") -- Default settings local InternetDetector = { - mode = 0, -- 0: disabled, 1: Service, 2: UI detector - loggingLevel = 6, - hostname = "OpenWrt", appName = "internet-detector", libDir = "/usr/lib/lua", - pingCmd = "/bin/ping", - pingParams = "-c 1", - uiRunTime = 30, - noModules = false, - uiAvailModules = { mod_public_ip = true }, - debug = false, - serviceConfig = { - hosts = { - [1] = "8.8.8.8", - [2] = "1.1.1.1", - }, - check_type = 0, -- 0: TCP, 1: ICMP - tcp_port = 53, - icmp_packet_size = 56, - interval_up = 30, - interval_down = 5, - connection_attempts = 2, - connection_timeout = 2, - iface = nil, - instance = nil, - }, logLevels = { emerg = { level = syslog.LOG_EMERG, num = 0 }, alert = { level = syslog.LOG_ALERT, num = 1 }, @@ -48,8 +24,41 @@ local InternetDetector = { info = { level = syslog.LOG_INFO, num = 6 }, debug = { level = syslog.LOG_DEBUG, num = 7 }, }, + pingCmd = "/bin/ping", + pingParams = "-c 1", + curlExec = "/usr/bin/curl", + curlParams = '-s --no-keepalive --head --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0"', + mode = 0, -- 0: disabled, 1: Service, 2: UI detector + loggingLevel = 6, + hostname = "OpenWrt", + uiRunTime = 30, + noModules = false, + uiAvailModules = { mod_public_ip = true }, + debug = false, + serviceConfig = { + hosts = { + [1] = "8.8.8.8", + [2] = "1.1.1.1", + }, + urls = { + [1] = "https://www.google.com", + }, + check_type = 0, -- 0: TCP, 1: ICMP + tcp_port = 53, + icmp_packet_size = 56, + interval_up = 30, + interval_down = 5, + connection_attempts = 2, + connection_timeout = 2, + proxy_type = nil, + proxy_host = nil, + proxy_port = nil, + iface = nil, + instance = nil, + }, modules = {}, parsedHosts = {}, + proxyString = "", uiCounter = 0, pidFile = nil, statusFile = nil, @@ -213,6 +222,13 @@ function InternetDetector:parseHosts() end end +function InternetDetector:parseUrls() + self.parsedHosts = {} + for k, v in ipairs(self.serviceConfig.urls) do + self.parsedHosts[k] = { addr = v } + end +end + function InternetDetector:pingHost(host) local ping = string.format( "%s %s -W %d -s %d%s %s > /dev/null 2>&1", @@ -240,6 +256,7 @@ function InternetDetector:TCPConnectionToHost(host, port) "GETADDRINFO ERROR: %s, %s", errMsg, errNum)) else local family = saTable[1].family + if family then local sock, errMsg, errNum = socket.socket(family, socket.SOCK_STREAM, 0) @@ -307,6 +324,60 @@ function InternetDetector:TCPConnectionToHost(host, port) return retCode end +function InternetDetector:httpRequest(url) + local retCode = 1, data + local curl = string.format( + '%s%s%s --connect-timeout %s %s "%s"; printf "\n$?";', + self.curlExec, + self.serviceConfig.iface and (" --interface " .. self.serviceConfig.iface) or "", + self.proxyString, + self.serviceConfig.connection_timeout, + self.curlParams, + url + ) + local fh = io.popen(curl, "r") + if fh then + data = fh:read("*a") + fh:close() + if data ~= nil then + local s, e = data:find("[0-9]+\n?$") + retCode = tonumber(data:sub(s)) + data = data:sub(0, s - 2) + if not data or data == "" then + data = nil + end + end + else + retCode = 1 + end + + self:debugOutput(string.format( + "--- Curl ---\ntime = %s\n%s\nretCode = %s\ndata = [\n%s]\n", + os.time(), + curl, + retCode, + tostring(data))) + return retCode, data +end + +function InternetDetector:getHTTPCode(data) + local httpCode + local respHeader = data:match("^HTTP/[^%c]+") + if respHeader then + httpCode = respHeader:match("%d%d%d") + end + return tonumber(httpCode) +end + +function InternetDetector:checkURL(url) + local httpCode + local retCode, data = self:httpRequest(url) + if retCode == 0 and data then + httpCode = self:getHTTPCode(data) + end + return (httpCode ~= 200) and 1 or 0 +end + function InternetDetector:exit() for _, e in ipairs(self.modules) do e:onExit() @@ -339,7 +410,25 @@ function InternetDetector:mainLoop() local checking = false local hostNum = 1 local attempt = 1 - local checkFunc = (self.serviceConfig.check_type == 1) and self.pingHost or self.TCPConnectionToHost + + local checkFunc = self.TCPConnectionToHost + if self.serviceConfig.check_type == 1 then + checkFunc = self.pingHost + self:parseHosts() + elseif self.serviceConfig.check_type == 2 then + checkFunc = self.checkURL + self:parseUrls() + if (self.serviceConfig.proxy_type and self.serviceConfig.proxy_host and + self.serviceConfig.proxy_port) then + self.proxyString = string.format( + " --proxy %s://%s:%d", + self.serviceConfig.proxy_type, + self.serviceConfig.proxy_host, + self.serviceConfig.proxy_port) + end + else + self:parseHosts() + end self:writeValueToFile( self.statusFile, self:statusJson(currentStatus, self.serviceConfig.instance)) @@ -599,6 +688,11 @@ function InternetDetector:preRun() os.exit(1) end end + if self.serviceConfig.check_type == 2 and not unistd.access(self.curlExec, "x") then + io.stderr:write(string.format( + "Error, %s is not available. You need to install curl.\n", self.curlExec)) + os.exit(1) + end local ok, commonDir = pcall(dirent.files, self.commonDir) if ok then local instancePattern = "^" .. self.appNamePattern .. "%." .. self.serviceConfig.instance .. "%.[%d]+%.pid$" @@ -689,7 +783,6 @@ end function InternetDetector:setServiceConfig(instance) if self:loadInstanceConfig(instance) then - self:parseHosts() if self.mode == 2 then self.loggingLevel = 0 self.noModules = true diff --git a/internet-detector/files/usr/lib/lua/internet-detector/modules/mod_public_ip.lua b/internet-detector/files/usr/lib/lua/internet-detector/modules/mod_public_ip.lua index 2a8d801..0a60e49 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/modules/mod_public_ip.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/modules/mod_public_ip.lua @@ -10,7 +10,10 @@ local Module = { noModules = false, debug = false, serviceConfig = { - iface = nil, + iface = nil, + proxy_type = nil, + proxy_host = nil, + proxy_port = nil, }, }, syslog = function(level, msg) return true end, @@ -24,7 +27,7 @@ local Module = { requestAttempts = 2, timeout = 3, curlExec = "/usr/bin/curl", - curlParams = "-s", + curlParams = '-s --no-keepalive --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0"', providers = { opendns1 = { name = "opendns1", type = "dns", host = "myip.opendns.com", @@ -88,6 +91,7 @@ local Module = { ipScript = "", enableIpScript = false, status = nil, + _proxyString = "", _provider = nil, _qtype = false, _currentIp = nil, @@ -177,6 +181,7 @@ function Module:sendUDPMessage(message, server, port) "GETADDRINFO ERROR: %s, %s", errMsg, errNum)) else local family = saTable[1].family + if family then local sock, errMsg, errNum = socket.socket(family, socket.SOCK_DGRAM, 0) @@ -266,12 +271,13 @@ function Module:decodeMessage(message) local NSCOUNT = message:sub(17, 20) local ARCOUNT = message:sub(21, 24) + -- Question section local questionSectionStarts = 25 - local questionParts = self:parseParts(message, questionSectionStarts, {}) local qtypeStarts = questionSectionStarts + (#table.concat(questionParts)) + (#questionParts * 2) + 1 local qclassStarts = qtypeStarts + 4 + -- Answer section local answerSectionStarts = qclassStarts + 4 local numAnswers = math.max( tonumber(ANCOUNT, 16), tonumber(NSCOUNT, 16), tonumber(ARCOUNT, 16)) @@ -351,9 +357,10 @@ end function Module:httpRequest(url) local retCode = 1, data local curl = string.format( - '%s%s --connect-timeout %s %s "%s"; printf "\n$?";', + '%s%s%s --connect-timeout %s %s "%s"; printf "\n$?";', self.curlExec, self.config.serviceConfig.iface and (" --interface " .. self.config.serviceConfig.iface) or "", + self._proxyString, self.timeout, self.curlParams, url @@ -373,6 +380,14 @@ function Module:httpRequest(url) else retCode = 1 end + + self.debugOutput(string.format( + "--- Curl ---\ntime = %s\n%s\nretCode = %s\ndata = [\n%s]\n", + os.time(), + curl, + retCode, + tostring(data)) + ) return retCode, data end @@ -454,6 +469,15 @@ function Module:init(t) self._enabled = false end end + if (self.config.serviceConfig.proxy_type and + self.config.serviceConfig.proxy_host and + self.config.serviceConfig.proxy_port) then + self._proxyString = string.format( + " --proxy %s://%s:%d", + self.config.serviceConfig.proxy_type, + self.config.serviceConfig.proxy_host, + self.config.serviceConfig.proxy_port) + end end function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) diff --git a/luci-app-internet-detector/Makefile b/luci-app-internet-detector/Makefile index 6f06fcd..7217fdc 100644 --- a/luci-app-internet-detector/Makefile +++ b/luci-app-internet-detector/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-internet-detector -PKG_VERSION:=1.6.7 +PKG_VERSION:=1.7.0 PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for internet-detector LUCI_DEPENDS:=+internet-detector diff --git a/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js b/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js index e134498..4ca602a 100644 --- a/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js +++ b/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js @@ -173,9 +173,29 @@ return view.extend({ initButton : null, currentAppMode : '0', defaultHosts : [ '8.8.8.8', '1.1.1.1' ], + defaultURLs : [ 'https://www.google.com' ], ledsPath : '/sys/class/leds', ledsPerInstance : 3, leds : [], + publicIPProviders : { + dns : [ + { name: 'opendns1', title: 'opendns1 (DNS)' }, + { name: 'opendns2', title: 'opendns2 (DNS)' }, + { name: 'opendns3', title: 'opendns3 (DNS)' }, + { name: 'opendns4', title: 'opendns4 (DNS)' }, + { name: 'google', title: 'google (DNS)' }, + { name: 'akamai', title: 'akamai (DNS)' }, + ], + http: [ + { name: 'akamai_http', title: 'akamai (HTTP)' }, + { name: 'amazonaws', title: 'amazonaws (HTTP)' }, + { name: 'wgetip', title: 'wgetip.com (HTTP)' }, + { name: 'ifconfig', title: 'ifconfig.me (HTTP)' }, + { name: 'ipecho', title: 'ipecho.net (HTTP)' }, + { name: 'canhazip', title: 'canhazip.com (HTTP)' }, + { name: 'icanhazip', title: 'icanhazip.com (HTTP)' }, + ], + }, tgUpdatesURLPattern : 'https://api.telegram.org/bot%s/getUpdates', mm : false, mmInit : false, @@ -415,6 +435,11 @@ return view.extend({ }); }, + validateUrl(section, value) { + return (/^$|^https?:\/\/[\w.-]+(:[0-9]{2,5})?[\w\/~.&?+=-]*$/.test(value)) ? + true : _('Expecting:') + ` ${_('valid URL')}\n`; + }, + CBITimeInput: form.Value.extend({ __name__ : 'CBI.TimeInput', @@ -771,19 +796,41 @@ return view.extend({ // hosts o = s.taboption('main', form.DynamicList, 'hosts', _('Hosts'), - _('Hosts to check Internet availability. Hosts are polled (in list order) until at least one of them responds.') + _('Hosts for checking Internet availability. Hosts are polled (in list order) until at least one responds.') ); - o.datatype = 'or(host,hostport,ipaddrport(1))'; - o.default = this.defaultHosts; - o.rmempty = false; + o.datatype = 'or(host,hostport,ipaddrport(1))'; + o.default = this.defaultHosts; + o.depends({ check_type: '0' }); + o.depends({ check_type: '1' }); + o.rmempty = false; + o.modalonly = true; + + if(this.curlExec) { + + // urls + o = s.taboption('main', form.DynamicList, + 'urls', _('URLs'), + _('URLs for checking Internet availability. URLs are polled (in list order) until at least one returns HTTP status code 200.') + ); + o.validate = this.validateUrl; + o.default = this.defaultURLs; + o.rmempty = false; + o.depends({ check_type: '2' }); + o.modalonly = true; + }; // check_type o = s.taboption('main', form.ListValue, 'check_type', _('Check type'), - _('Host availability check type.') + _('Host availability check type.') + '
' + + ((this.curlExec) ? '' : + _('To support URL checking, you need to install curl.')) ); - o.value(0, _('TCP port connection')); o.value(1, _('ICMP-echo request (ping)')); + o.value(0, _('TCP port connection')); + if(this.curlExec) { + o.value(2, _('URL test (HTTP)')); + }; o.default = '0'; o.modalonly = true; @@ -792,8 +839,8 @@ return view.extend({ 'tcp_port', _('TCP port'), _('Default port value for TCP connections.') ); - o.datatype = 'port'; - o.default = '53'; + o.datatype = 'port'; + o.default = '53'; o.depends({ check_type: '0' }); o.modalonly = true; @@ -806,16 +853,51 @@ return view.extend({ o.value(248, _('Big: 248 bytes')); o.value(1492, _('Huge: 1492 bytes')); o.value(9000, _('Jumbo: 9000 bytes')); - o.default = '56'; + o.default = '56'; o.depends({ check_type: '1' }); o.modalonly = true; + if(this.curlExec) { + + // proxy_type + o = s.taboption('main', form.ListValue, + 'proxy_type', _('Proxy') + ); + o.value('', _('Disabled')); + o.value('http'); + o.value('socks4'); + o.value('socks4a'); + o.value('socks5'); + o.value('socks5h'); + o.default = ''; + o.depends({ check_type: '2' }); + o.modalonly = true; + + // proxy_host + o = s.taboption('main', form.Value, + 'proxy_host', _('Proxy host') + ); + o.datatype = 'host'; + o.rmempty = false; + o.depends({ proxy_type: /.+/ }); + o.modalonly = true; + + // proxy_port + o = s.taboption('main', form.Value, + 'proxy_port', _('Proxy port') + ); + o.datatype = 'port'; + o.rmempty = false; + o.depends({ proxy_type: /.+/ }); + o.modalonly = true; + }; + // iface o = s.taboption('main', widgets.DeviceSelect, 'iface', _('Device'), _('Network device for Internet access. If not specified, the default device is used.') ); - o.noaliases = true; + o.noaliases = true; // interval_up o = s.taboption('main', form.ListValue, @@ -857,6 +939,11 @@ return view.extend({ o.value(3, '3 ' + _('sec')); o.value(4, '4 ' + _('sec')); o.value(5, '5 ' + _('sec')); + o.value(6, '6 ' + _('sec')); + o.value(7, '7 ' + _('sec')); + o.value(8, '8 ' + _('sec')); + o.value(9, '9 ' + _('sec')); + o.value(10, '10 ' + _('sec')); o.default = '2'; // enabled @@ -1146,6 +1233,7 @@ return view.extend({ ); o.modalonly = true; o.multiple = true; + o.modalonly = true; // attempts o = s.taboption('restart_network', form.ListValue, @@ -1327,25 +1415,18 @@ return view.extend({ 'mod_public_ip_provider', _('Provider'), _('Service for determining the public IP address.') + '
' + ((this.curlExec) ? '' : - _('To support HTTP services you need to install curl.')) + _('To support HTTP services, you need to install curl.')) ); o.modalonly = true; - o.value('opendns1', 'opendns1 (DNS)'); - o.value('opendns2', 'opendns2 (DNS)'); - o.value('opendns3', 'opendns3 (DNS)'); - o.value('opendns4', 'opendns4 (DNS)'); - o.value('google', 'google (DNS)'); - o.value('akamai', 'akamai (DNS)'); - if(this.curlExec) { - o.value('akamai_http', "akamai (HTTP)"); - o.value('amazonaws', "amazonaws (HTTP)"); - o.value('wgetip', "wgetip.com (HTTP)"); - o.value('ifconfig', "ifconfig.me (HTTP)"); - o.value('ipecho', "ipecho.net (HTTP)"); - o.value('canhazip', "canhazip.com (HTTP)"); - o.value('icanhazip', "icanhazip.com (HTTP)"); + for(let i of this.publicIPProviders.dns) { + o.value(i.name, i.title); }; - o.default = 'opendns1'; + if(this.curlExec) { + for(let i of this.publicIPProviders.http) { + o.value(i.name, i.title); + }; + }; + o.default = this.publicIPProviders.dns[0].name; // ipv6 o = s.taboption('public_ip', form.ListValue, @@ -1356,12 +1437,9 @@ return view.extend({ o.value('0', 'A (IPv4)'); o.value('1', 'AAAA (IPv6)'); o.default = '0'; - o.depends({ 'mod_public_ip_provider': 'opendns1' }); - o.depends({ 'mod_public_ip_provider': 'opendns2' }); - o.depends({ 'mod_public_ip_provider': 'opendns3' }); - o.depends({ 'mod_public_ip_provider': 'opendns4' }); - o.depends({ 'mod_public_ip_provider': 'google' }); - o.depends({ 'mod_public_ip_provider': 'akamai' }); + for(let i of this.publicIPProviders.dns) { + o.depends({ mod_public_ip_provider: i.name }); + }; // interval o = s.taboption('public_ip', form.ListValue, @@ -1620,7 +1698,6 @@ return view.extend({ o.password = true; o.modalonly = true; - // tg_chat_id o = s.taboption('telegram', this.CBITextfieldButtonInput, 'mod_telegram_chat_id', _('Chat ID'), _('ID of the Telegram chat to which messages will be sent.') diff --git a/luci-app-internet-detector/po/ru/internet-detector.po b/luci-app-internet-detector/po/ru/internet-detector.po index 791dfa7..f241653 100644 --- a/luci-app-internet-detector/po/ru/internet-detector.po +++ b/luci-app-internet-detector/po/ru/internet-detector.po @@ -212,8 +212,8 @@ msgid "Hosts polling interval when the Internet is up." msgstr "Интервал опроса хостов если Интернет доступен." msgid "" -"Hosts to check Internet availability. Hosts are polled (in list order) until " -"at least one of them responds." +"Hosts for checking Internet availability. Hosts are polled (in list " +"order) until at least one responds." msgstr "" "Хосты для проверки доступности Интернет. Хосты опрашиваются (в порядке " "списка) до тех пор, пока хотя бы один из них не ответит." @@ -444,6 +444,15 @@ msgstr "Интервал опроса" msgid "Provider" msgstr "Провайдер" +msgid "Proxy" +msgstr "Прокси" + +msgid "Proxy host" +msgstr "Хост прокси" + +msgid "Proxy port" +msgstr "Порт прокси" + msgid "Public IP" msgstr "Публичный IP" @@ -600,9 +609,12 @@ msgstr "Таймаут между остановкой и запуском се msgid "Timeout between stopping and starting a ModemManger interface when restarting." msgstr "Таймаут между остановкой и запуском интерфейса ModemManger при перезапуске." -msgid "To support HTTP services you need to install curl." +msgid "To support HTTP services, you need to install curl." msgstr "Для поддержки HTTP сервисов необходимо установить curl." +msgid "To support URL checking, you need to install curl." +msgstr "Для поддержки проверки URL необходимо установить curl." + msgid "Transmit" msgstr "Передача" @@ -621,6 +633,16 @@ msgstr "Неопределён" msgid "Unlock modem bands" msgstr "Освободить частоты модема" +msgid "URL test (HTTP)" +msgstr "Тест URL (HTTP)" + +msgid "" +"URLs for checking Internet availability. URLs are polled (in list " +"order) until at least one returns HTTP status code 200." +msgstr "" +"URL для проверки доступности Интернет. URL опрашиваются (в порядке " +"списка) до тех пор, пока хотя бы один из них не вернёт код статуса HTTP 200." + msgid "User" msgstr "Пользователь" diff --git a/luci-app-internet-detector/po/templates/internet-detector.pot b/luci-app-internet-detector/po/templates/internet-detector.pot index ee56956..b5b59be 100644 --- a/luci-app-internet-detector/po/templates/internet-detector.pot +++ b/luci-app-internet-detector/po/templates/internet-detector.pot @@ -199,8 +199,8 @@ msgid "Hosts polling interval when the Internet is up." msgstr "" msgid "" -"Hosts to check Internet availability. Hosts are polled (in list order) until " -"at least one of them responds." +"Hosts for checking Internet availability. Hosts are polled (in list " +"order) until at least one responds." msgstr "" msgid "Huge: 1492 bytes" @@ -415,6 +415,15 @@ msgstr "" msgid "Provider" msgstr "" +msgid "Proxy" +msgstr "" + +msgid "Proxy host" +msgstr "" + +msgid "Proxy port" +msgstr "" + msgid "Public IP" msgstr "" @@ -571,7 +580,10 @@ msgstr "" msgid "Timeout between stopping and starting a ModemManger interface when restarting." msgstr "" -msgid "To support HTTP services you need to install curl." +msgid "To support HTTP services, you need to install curl." +msgstr "" + +msgid "To support URL checking, you need to install curl." msgstr "" msgid "Transmit" @@ -592,6 +604,14 @@ msgstr "" msgid "Unlock modem bands" msgstr "" +msgid "URL test (HTTP)" +msgstr "" + +msgid "" +"URLs for checking Internet availability. URLs are polled (in list " +"order) until at least one returns HTTP status code 200." +msgstr "" + msgid "User" msgstr "" diff --git a/screenshots/01.jpg b/screenshots/01.jpg index 6a95e18..2dfc49f 100644 Binary files a/screenshots/01.jpg and b/screenshots/01.jpg differ