mod-telegram: added network device option.

This commit is contained in:
gSpot
2026-04-13 20:02:51 +03:00
parent a72aa496f0
commit 181635f426
11 changed files with 104 additions and 66 deletions

View File

@@ -23,42 +23,42 @@ Internet-detector is an application for checking the availability of the Interne
**OpenWrt >= 25.12:**
apk update
wget --no-check-certificate -O /tmp/internet-detector-1.7.2-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/internet-detector-1.7.2-r1.apk
apk --allow-untrusted add /tmp/internet-detector-1.7.2-r1.apk
rm /tmp/internet-detector-1.7.2-r1.apk
wget --no-check-certificate -O /tmp/internet-detector-1.7.3-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/internet-detector-1.7.3-r1.apk
apk --allow-untrusted add /tmp/internet-detector-1.7.3-r1.apk
rm /tmp/internet-detector-1.7.3-r1.apk
service internet-detector start
service internet-detector enable
wget --no-check-certificate -O /tmp/luci-app-internet-detector-1.7.2-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/luci-app-internet-detector-1.7.2-r1.apk
apk --allow-untrusted add /tmp/luci-app-internet-detector-1.7.2-r1.apk
rm /tmp/luci-app-internet-detector-1.7.2-r1.apk
wget --no-check-certificate -O /tmp/luci-app-internet-detector-1.7.3-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/luci-app-internet-detector-1.7.3-r1.apk
apk --allow-untrusted add /tmp/luci-app-internet-detector-1.7.3-r1.apk
rm /tmp/luci-app-internet-detector-1.7.3-r1.apk
service rpcd restart
i18n-ru:
wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru-1.7.2-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/luci-i18n-internet-detector-ru-1.7.2-r1.apk
apk --allow-untrusted add /tmp/luci-i18n-internet-detector-ru-1.7.2-r1.apk
rm /tmp/luci-i18n-internet-detector-ru-1.7.2-r1.apk
wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru-1.7.3-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/luci-i18n-internet-detector-ru-1.7.3-r1.apk
apk --allow-untrusted add /tmp/luci-i18n-internet-detector-ru-1.7.3-r1.apk
rm /tmp/luci-i18n-internet-detector-ru-1.7.3-r1.apk
**OpenWrt <= 24.10:**
opkg update
wget --no-check-certificate -O /tmp/internet-detector_1.7.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/internet-detector_1.7.2-r1_all.ipk
opkg install /tmp/internet-detector_1.7.2-r1_all.ipk
rm /tmp/internet-detector_1.7.2-r1_all.ipk
wget --no-check-certificate -O /tmp/internet-detector_1.7.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/internet-detector_1.7.3-r1_all.ipk
opkg install /tmp/internet-detector_1.7.3-r1_all.ipk
rm /tmp/internet-detector_1.7.3-r1_all.ipk
service internet-detector start
service internet-detector enable
wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.7.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/luci-app-internet-detector_1.7.2-r1_all.ipk
opkg install /tmp/luci-app-internet-detector_1.7.2-r1_all.ipk
rm /tmp/luci-app-internet-detector_1.7.2-r1_all.ipk
wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.7.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/luci-app-internet-detector_1.7.3-r1_all.ipk
opkg install /tmp/luci-app-internet-detector_1.7.3-r1_all.ipk
rm /tmp/luci-app-internet-detector_1.7.3-r1_all.ipk
service rpcd restart
i18n-ru:
wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.7.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/luci-i18n-internet-detector-ru_1.7.2-r1_all.ipk
opkg install /tmp/luci-i18n-internet-detector-ru_1.7.2-r1_all.ipk
rm /tmp/luci-i18n-internet-detector-ru_1.7.2-r1_all.ipk
wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.7.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/luci-i18n-internet-detector-ru_1.7.3-r1_all.ipk
opkg install /tmp/luci-i18n-internet-detector-ru_1.7.3-r1_all.ipk
rm /tmp/luci-i18n-internet-detector-ru_1.7.3-r1_all.ipk
## Screenshots:
@@ -72,16 +72,16 @@ i18n-ru:
**OpenWrt >= 25.12:**
wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart-1.7.2-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/internet-detector-mod-modem-restart-1.7.2-r1.apk
apk --allow-untrusted add /tmp/internet-detector-mod-modem-restart-1.7.2-r1.apk
rm /tmp/internet-detector-mod-modem-restart-1.7.2-r1.apk
wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart-1.7.3-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/internet-detector-mod-modem-restart-1.7.3-r1.apk
apk --allow-untrusted add /tmp/internet-detector-mod-modem-restart-1.7.3-r1.apk
rm /tmp/internet-detector-mod-modem-restart-1.7.3-r1.apk
service internet-detector restart
**OpenWrt <= 24.10:**
wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.7.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/internet-detector-mod-modem-restart_1.7.2-r1_all.ipk
opkg install /tmp/internet-detector-mod-modem-restart_1.7.2-r1_all.ipk
rm /tmp/internet-detector-mod-modem-restart_1.7.2-r1_all.ipk
wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.7.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/internet-detector-mod-modem-restart_1.7.3-r1_all.ipk
opkg install /tmp/internet-detector-mod-modem-restart_1.7.3-r1_all.ipk
rm /tmp/internet-detector-mod-modem-restart_1.7.3-r1_all.ipk
service internet-detector restart
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/04.jpg)
@@ -92,16 +92,16 @@ i18n-ru:
**OpenWrt >= 25.12:**
wget --no-check-certificate -O /tmp/internet-detector-mod-email-1.7.2-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/internet-detector-mod-email-1.7.2-r1.apk
apk --allow-untrusted add /tmp/internet-detector-mod-email-1.7.2-r1.apk
rm /tmp/internet-detector-mod-email-1.7.2-r1.apk
wget --no-check-certificate -O /tmp/internet-detector-mod-email-1.7.3-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/internet-detector-mod-email-1.7.3-r1.apk
apk --allow-untrusted add /tmp/internet-detector-mod-email-1.7.3-r1.apk
rm /tmp/internet-detector-mod-email-1.7.3-r1.apk
service internet-detector restart
**OpenWrt <= 24.10:**
wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.7.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/internet-detector-mod-email_1.7.2-r1_all.ipk
opkg install /tmp/internet-detector-mod-email_1.7.2-r1_all.ipk
rm /tmp/internet-detector-mod-email_1.7.2-r1_all.ipk
wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.7.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/internet-detector-mod-email_1.7.3-r1_all.ipk
opkg install /tmp/internet-detector-mod-email_1.7.3-r1_all.ipk
rm /tmp/internet-detector-mod-email_1.7.3-r1_all.ipk
service internet-detector restart
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/05.jpg)
@@ -112,17 +112,17 @@ i18n-ru:
**OpenWrt >= 25.12:**
wget --no-check-certificate -O /tmp/internet-detector-mod-telegram-1.7.2-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/internet-detector-mod-telegram-1.7.2-r1.apk
apk --allow-untrusted add /tmp/internet-detector-mod-telegram-1.7.2-r1.apk
rm /tmp/internet-detector-mod-telegram-1.7.2-r1.apk
wget --no-check-certificate -O /tmp/internet-detector-mod-telegram-1.7.3-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/internet-detector-mod-telegram-1.7.3-r1.apk
apk --allow-untrusted add /tmp/internet-detector-mod-telegram-1.7.3-r1.apk
rm /tmp/internet-detector-mod-telegram-1.7.3-r1.apk
service internet-detector restart
service rpcd restart
**OpenWrt <= 24.10:**
wget --no-check-certificate -O /tmp/internet-detector-mod-telegram_1.7.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/internet-detector-mod-telegram_1.7.2-r1_all.ipk
opkg install /tmp/internet-detector-mod-telegram_1.7.2-r1_all.ipk
rm /tmp/internet-detector-mod-telegram_1.7.2-r1_all.ipk
wget --no-check-certificate -O /tmp/internet-detector-mod-telegram_1.7.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/internet-detector-mod-telegram_1.7.3-r1_all.ipk
opkg install /tmp/internet-detector-mod-telegram_1.7.3-r1_all.ipk
rm /tmp/internet-detector-mod-telegram_1.7.3-r1_all.ipk
service internet-detector restart
service rpcd restart

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-email
PKG_VERSION:=1.7.2
PKG_VERSION:=1.7.3
PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-modem-restart
PKG_VERSION:=1.7.2
PKG_VERSION:=1.7.3
PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-telegram
PKG_VERSION:=1.7.2
PKG_VERSION:=1.7.3
PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -31,6 +31,7 @@ local Module = {
curlParams = "-s -g --no-keepalive",
proxyAuthString = "",
proxyString = "",
ifaceString = "",
status = nil,
_enabled = false,
_deadCounter = 0,
@@ -85,6 +86,9 @@ function Module:init(t)
t.proxy_port,
self.proxyAuthString)
end
if t.iface then
self.ifaceString = " --interface " .. t.iface
end
if tonumber(t.message_at_startup) == 1 then
self._msgSentDisconnect = false
self._disconnected = false
@@ -138,9 +142,10 @@ function Module:httpRequest(url)
self.debugOutput(string.format("--- %s ---", self.name))
local curl = string.format(
'%s%s --connect-timeout %s %s "%s"; printf "\n$?";',
local curl = string.format(
'%s%s%s --connect-timeout %s %s "%s"; printf "\n$?";',
self.curlExec,
self.ifaceString,
self.proxyString,
self.connectTimeout,
self.curlParams,

View File

@@ -13,11 +13,12 @@ if(!curlExec) {
die('Error! Curl not found!');
}
function httpRequest(url, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd) {
function httpRequest(url, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd, iface) {
let retCode = 1;
let data = '';
let proxyAuthString = '';
let proxyString = '';
let ifaceString = iface ? (' --interface ' + iface) : '';
if(!url) {
return { retCode: 1, data };
@@ -38,14 +39,14 @@ function httpRequest(url, proxyType, proxyHost, proxyPort, proxyUser, proxyPassw
proxyAuthString);
}
const curl = sprintf(
'%s%s --connect-timeout %s %s "%s"; printf "\n$?";',
'%s%s%s --connect-timeout %s %s "%s"; printf "\n$?";',
curlExec,
ifaceString,
proxyString,
curlConnectTimeout,
curlParams,
url
);
const fd = popen(curl, 'r');
if(fd) {
data = fd.read('all');
@@ -98,6 +99,7 @@ const methods = {
proxyPort : 'String',
proxyUser : 'String',
proxyPasswd: 'String',
iface : 'String',
},
call: function(request) {
const botToken = request.args?.botToken;
@@ -108,7 +110,8 @@ const methods = {
request.args.proxyHost,
request.args.proxyPort,
request.args.proxyUser,
request.args.proxyPasswd
request.args.proxyPasswd,
request.args.iface
);
if(ret.retCode == 0 && length(ret.data) > 0) {
return parseResponse(ret.data);

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector
PKG_VERSION:=1.7.2
PKG_VERSION:=1.7.3
PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-internet-detector
PKG_VERSION:=1.7.2
PKG_VERSION:=1.7.3
PKG_RELEASE:=1
LUCI_TITLE:=LuCI support for internet-detector
LUCI_DEPENDS:=+internet-detector

View File

@@ -294,13 +294,13 @@ return view.extend({
callTgChatId: rpc.declare({
object: 'luci.internet-detector-mod-telegram',
method: 'GetTgChatId',
params: [ 'botToken', 'proxyType', 'proxyHost', 'proxyPort', 'proxyUser', 'proxyPasswd' ],
params: [ 'botToken', 'proxyType', 'proxyHost', 'proxyPort', 'proxyUser', 'proxyPasswd', 'iface' ],
expect: { '': {} }
}),
getTgChatId(botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd) {
getTgChatId(botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd, iface) {
return this.callTgChatId(
botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd).then(data => {
botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd, iface).then(data => {
return data;
});
},
@@ -405,38 +405,47 @@ return view.extend({
alert(_('Bot API token is missing!'));
return;
};
let proxyType = null;
let proxyType = '';
let proxyTypeInput = document.getElementById(
'widget.cbid.%s.%s.mod_telegram_proxy_type'.format(this.appName, instance));
if(proxyTypeInput) {
proxyType = proxyTypeInput.value;
};
let proxyHost = null;
let proxyHost = '';
let proxyHostInput = document.getElementById(
'widget.cbid.%s.%s.mod_telegram_proxy_host'.format(this.appName, instance));
if(proxyTypeInput) {
if(proxyHostInput) {
proxyHost = proxyHostInput.value;
};
let proxyPort = null;
let proxyPort = '';
let proxyPortInput = document.getElementById(
'widget.cbid.%s.%s.mod_telegram_proxy_port'.format(this.appName, instance));
if(proxyTypeInput) {
if(proxyPortInput) {
proxyPort = proxyPortInput.value;
};
let proxyUser = null;
let proxyUser = '';
let proxyUserInput = document.getElementById(
'widget.cbid.%s.%s.mod_telegram_proxy_user'.format(this.appName, instance));
if(proxyTypeInput) {
if(proxyUserInput) {
proxyUser = proxyUserInput.value;
};
let proxyPasswd = null;
let proxyPasswd = '';
let proxyPasswdInput = document.getElementById(
'widget.cbid.%s.%s.mod_telegram_proxy_passwd'.format(this.appName, instance));
if(proxyTypeInput) {
if(proxyPasswdInput) {
proxyPasswd = proxyPasswdInput.value;
};
let iface = '';
let ifaceInput = document.getElementById(
'cbid.%s.%s.mod_telegram_iface'.format(this.appName, instance));
if(ifaceInput) {
let li = ifaceInput.querySelector('li[selected]');
if(li) {
iface = li.dataset.value || '';
};
};
return this.getTgChatId(botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd).then(r => {
return this.getTgChatId(botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd, iface).then(r => {
if(r.ok) {
if(r.chatId) {
let tgChatIdInput = document.getElementById(
@@ -945,6 +954,7 @@ return view.extend({
_('Network device for Internet access. If not specified, the default device is used.')
);
o.noaliases = true;
o.modalonly = true;
// interval_up
o = s.taboption('main', form.ListValue,
@@ -1806,6 +1816,14 @@ return view.extend({
o.modalonly = true;
o.password = true;
// iface
o = s.taboption('telegram', widgets.DeviceSelect,
'mod_telegram_iface', _('Device'),
_('Network device for sending messages. If not specified, the default device is used.')
);
o.noaliases = true;
o.modalonly = true;
// message_at_startup
o = s.taboption('telegram', form.Flag,
'mod_telegram_message_at_startup',

View File

@@ -339,6 +339,9 @@ msgstr ""
"Интерфейс ModemManager. Если задан, то будет перезапущен после перезапуска "
"ModemManger."
msgid "Network device activity (kernel: netdev)"
msgstr "Активность сетевого устройства (kernel: netdev)"
msgid ""
"Network device for Internet access. If not specified, the default "
"device is used."
@@ -346,8 +349,12 @@ msgstr ""
"Сетевое устройство для доступа в Интернет. Если не указано, используется "
"устройство по умолчанию."
msgid "Network device activity (kernel: netdev)"
msgstr "Активность сетевого устройства (kernel: netdev)"
msgid ""
"Network device for sending messages. If not specified, the default "
"device is used."
msgstr ""
"Сетевое устройство для отправки сообщений. Если не указано, используется "
"устройство по умолчанию."
msgid ""
"Network device or interface to restart. If not specified, then the network service is restarted."

View File

@@ -317,12 +317,17 @@ msgid ""
"ModemManager."
msgstr ""
msgid ""
"Network device for Internet access. If not specified, the default "
"interface is used."
msgid "Network device activity (kernel: netdev)"
msgstr ""
msgid "Network device activity (kernel: netdev)"
msgid ""
"Network device for Internet access. If not specified, the default "
"device is used."
msgstr ""
msgid ""
"Network device for sending messages. If not specified, the default "
"device is used."
msgstr ""
msgid ""