mirror of
https://github.com/gSpotx2f/luci-app-internet-detector.git
synced 2025-12-15 16:06:51 +03:00
Initial commit
This commit is contained in:
17
Makefile
Normal file
17
Makefile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2020 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the MIT License.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=luci-app-internet-detector
|
||||||
|
LUCI_TITLE:=Internet detector for the LuCI status page
|
||||||
|
LUCI_DEPENDS:=+luci-mod-admin-full
|
||||||
|
LUCI_PKGARCH:=all
|
||||||
|
PKG_LICENSE:=MIT
|
||||||
|
|
||||||
|
include ../../luci.mk
|
||||||
|
|
||||||
|
# call BuildPackage - OpenWrt buildroot signature
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
'use strict';
|
||||||
|
'require fs';
|
||||||
|
|
||||||
|
return L.Class.extend({
|
||||||
|
title: _('Internet'),
|
||||||
|
|
||||||
|
hosts: [
|
||||||
|
'8.8.8.8',
|
||||||
|
'1.1.1.1',
|
||||||
|
'8.8.4.4',
|
||||||
|
],
|
||||||
|
|
||||||
|
checkInterval: 11, // 5 x 11 = 55 sec.
|
||||||
|
|
||||||
|
load: async function() {
|
||||||
|
window.internetDetectorCounter = ('internetDetectorCounter' in window) ?
|
||||||
|
++window.internetDetectorCounter : 0;
|
||||||
|
if(!('internetDetectorState' in window)) {
|
||||||
|
window.internetDetectorState = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(window.internetDetectorState === 0 &&
|
||||||
|
window.internetDetectorCounter % this.checkInterval) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
for(let host of this.hosts) {
|
||||||
|
await fs.exec('/bin/ping', [ '-c', '1', '-W', '1', host ]).then(res => {
|
||||||
|
window.internetDetectorState = res.code;
|
||||||
|
}).catch(e => {});
|
||||||
|
|
||||||
|
if(window.internetDetectorState === 0) {
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
let internetStatus = E('span', { 'class': 'label' });
|
||||||
|
|
||||||
|
if(window.internetDetectorState === 0) {
|
||||||
|
internetStatus.style.background = '#46a546';
|
||||||
|
internetStatus.textContent = _('Internet connected');
|
||||||
|
} else {
|
||||||
|
internetStatus.textContent = _('Internet disconnected');
|
||||||
|
};
|
||||||
|
|
||||||
|
return E('div', {
|
||||||
|
'class': 'cbi-section',
|
||||||
|
'style': 'margin-bottom:1em',
|
||||||
|
}, internetStatus);
|
||||||
|
},
|
||||||
|
});
|
||||||
21
po/ru/internet-detector.po
Normal file
21
po/ru/internet-detector.po
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Project-Id-Version: \n"
|
||||||
|
"POT-Creation-Date: \n"
|
||||||
|
"PO-Revision-Date: \n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Language: ru\n"
|
||||||
|
"X-Generator: Poedit 2.0.6\n"
|
||||||
|
|
||||||
|
msgid "Internet"
|
||||||
|
msgstr "Интернет"
|
||||||
|
|
||||||
|
msgid "Internet connected"
|
||||||
|
msgstr "Интернет подключен"
|
||||||
|
|
||||||
|
msgid "Internet disconnected"
|
||||||
|
msgstr "Интернет отключен"
|
||||||
11
po/templates/internet-detector.pot
Normal file
11
po/templates/internet-detector.pot
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||||
|
|
||||||
|
msgid "Internet"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Internet connected"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Internet disconnected"
|
||||||
|
msgstr ""
|
||||||
10
root/usr/share/rpcd/acl.d/luci-app-internet-detector.json
Normal file
10
root/usr/share/rpcd/acl.d/luci-app-internet-detector.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"luci-app-internet-detector": {
|
||||||
|
"description": "Grant access to internet-detector procedures",
|
||||||
|
"read": {
|
||||||
|
"file": {
|
||||||
|
"/bin/ping -c 1 -W 1 [0-9.]*": [ "exec" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
screenshots/01.jpg
Normal file
BIN
screenshots/01.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
translations/internet-detector.ru.lmo
Normal file
BIN
translations/internet-detector.ru.lmo
Normal file
Binary file not shown.
Reference in New Issue
Block a user