mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 04:35:13 +08:00
🏅 Sync 2026-03-24 02:21:05
This commit is contained in:
1 parent
ca3783e295
commit
e665eecc31
14 files changed
+356
-68
No files matched your search
@@ -1,12 +1,12 @@
|
|||||||
#
|
#
|
||||||
# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
# (с) 2026 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||||
#
|
#
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=internet-detector-mod-email
|
PKG_NAME:=internet-detector-mod-email
|
||||||
PKG_VERSION:=1.7.1
|
PKG_VERSION:=1.7.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#
|
#
|
||||||
# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
# (с) 2026 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||||
#
|
#
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=internet-detector-mod-modem-restart
|
PKG_NAME:=internet-detector-mod-modem-restart
|
||||||
PKG_VERSION:=1.7.1
|
PKG_VERSION:=1.7.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#
|
#
|
||||||
# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
# (с) 2026 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||||
#
|
#
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=internet-detector-mod-telegram
|
PKG_NAME:=internet-detector-mod-telegram
|
||||||
PKG_VERSION:=1.7.1
|
PKG_VERSION:=1.7.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
@@ -17,7 +17,7 @@ define Package/$(PKG_NAME)
|
|||||||
TITLE:=Telegram messenger module for internet-detector
|
TITLE:=Telegram messenger module for internet-detector
|
||||||
URL:=https://github.com/gSpotx2f/luci-app-internet-detector
|
URL:=https://github.com/gSpotx2f/luci-app-internet-detector
|
||||||
PKGARCH:=all
|
PKGARCH:=all
|
||||||
DEPENDS:=+internet-detector +curl
|
DEPENDS:=+internet-detector +curl +ucode +ucode-mod-fs
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/description
|
define Package/$(PKG_NAME)/description
|
||||||
@@ -36,6 +36,10 @@ endef
|
|||||||
define Package/$(PKG_NAME)/install
|
define Package/$(PKG_NAME)/install
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua/internet-detector/modules
|
$(INSTALL_DIR) $(1)/usr/lib/lua/internet-detector/modules
|
||||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/modules/mod_telegram.lua $(1)/usr/lib/lua/internet-detector/modules/mod_telegram.lua
|
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/modules/mod_telegram.lua $(1)/usr/lib/lua/internet-detector/modules/mod_telegram.lua
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
|
||||||
|
$(INSTALL_DATA) ./files/usr/share/rpcd/acl.d/luci-app-internet-detector-mod-telegram.json $(1)/usr/share/rpcd/acl.d/luci-app-internet-detector-mod-telegram.json
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/rpcd/ucode
|
||||||
|
$(INSTALL_DATA) ./files/usr/share/rpcd/ucode/luci.internet-detector-mod-telegram $(1)/usr/share/rpcd/ucode/luci.internet-detector-mod-telegram
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
+33
-3
@@ -29,6 +29,8 @@ local Module = {
|
|||||||
msgSendTimeout = 5,
|
msgSendTimeout = 5,
|
||||||
curlExec = "/usr/bin/curl",
|
curlExec = "/usr/bin/curl",
|
||||||
curlParams = "-s -g --no-keepalive",
|
curlParams = "-s -g --no-keepalive",
|
||||||
|
proxyAuthString = "",
|
||||||
|
proxyString = "",
|
||||||
status = nil,
|
status = nil,
|
||||||
_enabled = false,
|
_enabled = false,
|
||||||
_deadCounter = 0,
|
_deadCounter = 0,
|
||||||
@@ -69,6 +71,20 @@ function Module:init(t)
|
|||||||
if t.chat_id ~= nil then
|
if t.chat_id ~= nil then
|
||||||
self.tgChatId = t.chat_id
|
self.tgChatId = t.chat_id
|
||||||
end
|
end
|
||||||
|
if (t.proxy_type and t.proxy_host and t.proxy_port) then
|
||||||
|
if t.proxy_user and t.proxy_passwd then
|
||||||
|
self.proxyAuthString = string.format(
|
||||||
|
' --proxy-user "%s:%s"',
|
||||||
|
t.proxy_user,
|
||||||
|
t.proxy_passwd)
|
||||||
|
end
|
||||||
|
self.proxyString = string.format(
|
||||||
|
" --proxy %s://%s:%d%s",
|
||||||
|
t.proxy_type,
|
||||||
|
t.proxy_host,
|
||||||
|
t.proxy_port,
|
||||||
|
self.proxyAuthString)
|
||||||
|
end
|
||||||
if tonumber(t.message_at_startup) == 1 then
|
if tonumber(t.message_at_startup) == 1 then
|
||||||
self._msgSentDisconnect = false
|
self._msgSentDisconnect = false
|
||||||
self._disconnected = false
|
self._disconnected = false
|
||||||
@@ -119,13 +135,21 @@ end
|
|||||||
|
|
||||||
function Module:httpRequest(url)
|
function Module:httpRequest(url)
|
||||||
local retCode = 1, data
|
local retCode = 1, data
|
||||||
local fh = io.popen(string.format(
|
|
||||||
'%s --connect-timeout %s %s "%s"; printf "\n$?";',
|
self.debugOutput(string.format("--- %s ---", self.name))
|
||||||
|
|
||||||
|
local curl = string.format(
|
||||||
|
'%s%s --connect-timeout %s %s "%s"; printf "\n$?";',
|
||||||
self.curlExec,
|
self.curlExec,
|
||||||
|
self.proxyString,
|
||||||
self.connectTimeout,
|
self.connectTimeout,
|
||||||
self.curlParams,
|
self.curlParams,
|
||||||
url
|
url
|
||||||
), "r")
|
)
|
||||||
|
|
||||||
|
self.debugOutput(curl)
|
||||||
|
|
||||||
|
local fh = io.popen(curl, "r")
|
||||||
if fh then
|
if fh then
|
||||||
data = fh:read("*a")
|
data = fh:read("*a")
|
||||||
fh:close()
|
fh:close()
|
||||||
@@ -140,6 +164,12 @@ function Module:httpRequest(url)
|
|||||||
else
|
else
|
||||||
retCode = 1
|
retCode = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.debugOutput(string.format(
|
||||||
|
"data = %s; retCode = %s\n",
|
||||||
|
tostring(data),
|
||||||
|
tostring(retCode)))
|
||||||
|
|
||||||
return retCode, data
|
return retCode, data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"luci-app-internet-detector-mod-telegram": {
|
||||||
|
"description": "Grant access to internet-detector-mod-telegram procedures",
|
||||||
|
"read": {
|
||||||
|
"ubus": {
|
||||||
|
"luci.internet-detector-mod-telegram": [ "GetTgChatId" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import { popen, stat } from 'fs';
|
||||||
|
|
||||||
|
const curlPath = '/usr/bin/curl';
|
||||||
|
const curlExec = (stat(curlPath)?.perm?.user_exec) ? curlPath : null;
|
||||||
|
const curlParams = '-s -g --no-keepalive';
|
||||||
|
const curlConnectTimeout = 15;
|
||||||
|
const tgUpdatesURLPattern = 'https://api.telegram.org/bot%s/getUpdates';
|
||||||
|
|
||||||
|
if(!curlExec) {
|
||||||
|
die('Error! Curl not found!');
|
||||||
|
}
|
||||||
|
|
||||||
|
function httpRequest(url, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd) {
|
||||||
|
let retCode = 1;
|
||||||
|
let data = '';
|
||||||
|
let proxyAuthString = '';
|
||||||
|
let proxyString = '';
|
||||||
|
|
||||||
|
if(!url) {
|
||||||
|
return { retCode: 1, data };
|
||||||
|
}
|
||||||
|
|
||||||
|
if(proxyType && proxyHost && proxyPort) {
|
||||||
|
if(proxyUser && proxyPasswd) {
|
||||||
|
proxyAuthString = sprintf(
|
||||||
|
' --proxy-user "%s:%s"',
|
||||||
|
proxyUser,
|
||||||
|
proxyPasswd);
|
||||||
|
}
|
||||||
|
proxyString = sprintf(
|
||||||
|
' --proxy %s://%s:%d%s',
|
||||||
|
proxyType,
|
||||||
|
proxyHost,
|
||||||
|
proxyPort,
|
||||||
|
proxyAuthString);
|
||||||
|
}
|
||||||
|
const curl = sprintf(
|
||||||
|
'%s%s --connect-timeout %s %s "%s"; printf "\n$?";',
|
||||||
|
curlExec,
|
||||||
|
proxyString,
|
||||||
|
curlConnectTimeout,
|
||||||
|
curlParams,
|
||||||
|
url
|
||||||
|
);
|
||||||
|
|
||||||
|
const fd = popen(curl, 'r');
|
||||||
|
if(fd) {
|
||||||
|
data = fd.read('all');
|
||||||
|
fd.close();
|
||||||
|
if(data) {
|
||||||
|
const retCodeRegexp = /[0-9]+\n?$/;
|
||||||
|
const r = match(data, retCodeRegexp);
|
||||||
|
if(length(r) > 0) {
|
||||||
|
retCode = r[0];
|
||||||
|
}
|
||||||
|
data = replace(data, retCodeRegexp, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { retCode, data };
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseResponse(str) {
|
||||||
|
let ok = null;
|
||||||
|
let chatId = [];
|
||||||
|
let errCode = null;
|
||||||
|
let errDesc = null;
|
||||||
|
|
||||||
|
const data = json(str);
|
||||||
|
ok = data.ok;
|
||||||
|
if(ok == false) {
|
||||||
|
errCode = data.error_code;
|
||||||
|
errDesc = data.description;
|
||||||
|
} else {
|
||||||
|
let chats = [];
|
||||||
|
if(data.result) {
|
||||||
|
for(let i in data.result) {
|
||||||
|
if(i.message && i.message.chat && i.message.chat.id) {
|
||||||
|
push(chats, i.message.chat.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(length(chats) > 0) {
|
||||||
|
chatId = uniq(chats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { ok, chatId, errCode, errDesc };
|
||||||
|
}
|
||||||
|
|
||||||
|
const methods = {
|
||||||
|
GetTgChatId: {
|
||||||
|
args: {
|
||||||
|
botToken : 'String',
|
||||||
|
proxyType : 'String',
|
||||||
|
proxyHost : 'String',
|
||||||
|
proxyPort : 'String',
|
||||||
|
proxyUser : 'String',
|
||||||
|
proxyPasswd: 'String',
|
||||||
|
},
|
||||||
|
call: function(request) {
|
||||||
|
const botToken = request.args?.botToken;
|
||||||
|
if(botToken) {
|
||||||
|
const ret = httpRequest(
|
||||||
|
sprintf(tgUpdatesURLPattern, botToken),
|
||||||
|
request.args.proxyType,
|
||||||
|
request.args.proxyHost,
|
||||||
|
request.args.proxyPort,
|
||||||
|
request.args.proxyUser,
|
||||||
|
request.args.proxyPasswd
|
||||||
|
);
|
||||||
|
if(ret.retCode == 0 && length(ret.data) > 0) {
|
||||||
|
return parseResponse(ret.data);
|
||||||
|
} else {
|
||||||
|
return { ok: null, chatId: [], errCode: ret.retCode, errDesc: 'Network request error' };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { ok: null, chatId: [], errCode: 1, errDesc: 'Bot token missing' };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return { 'luci.internet-detector-mod-telegram': methods };
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#
|
#
|
||||||
# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
# (с) 2026 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||||
#
|
#
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=internet-detector
|
PKG_NAME:=internet-detector
|
||||||
PKG_VERSION:=1.7.1
|
PKG_VERSION:=1.7.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|||||||
@@ -53,15 +53,18 @@ local InternetDetector = {
|
|||||||
proxy_type = nil,
|
proxy_type = nil,
|
||||||
proxy_host = nil,
|
proxy_host = nil,
|
||||||
proxy_port = nil,
|
proxy_port = nil,
|
||||||
|
proxy_user = nil,
|
||||||
|
proxy_passwd = nil,
|
||||||
iface = nil,
|
iface = nil,
|
||||||
instance = nil,
|
instance = nil,
|
||||||
},
|
},
|
||||||
modules = {},
|
modules = {},
|
||||||
parsedHosts = {},
|
parsedHosts = {},
|
||||||
proxyString = "",
|
proxyAuthString = "",
|
||||||
uiCounter = 0,
|
proxyString = "",
|
||||||
pidFile = nil,
|
uiCounter = 0,
|
||||||
statusFile = nil,
|
pidFile = nil,
|
||||||
|
statusFile = nil,
|
||||||
}
|
}
|
||||||
InternetDetector.configDir = string.format("/etc/%s", InternetDetector.appName)
|
InternetDetector.configDir = string.format("/etc/%s", InternetDetector.appName)
|
||||||
InternetDetector.modulesDir = string.format(
|
InternetDetector.modulesDir = string.format(
|
||||||
@@ -277,6 +280,7 @@ function InternetDetector:TCPConnectionToHost(host, port)
|
|||||||
if not ok then
|
if not ok then
|
||||||
self:debugOutput(string.format(
|
self:debugOutput(string.format(
|
||||||
"SOCKET ERROR: %s, %s", errMsg, errNum))
|
"SOCKET ERROR: %s, %s", errMsg, errNum))
|
||||||
|
|
||||||
unistd.close(sock)
|
unistd.close(sock)
|
||||||
return retCode
|
return retCode
|
||||||
end
|
end
|
||||||
@@ -357,6 +361,7 @@ function InternetDetector:httpRequest(url)
|
|||||||
curl,
|
curl,
|
||||||
retCode,
|
retCode,
|
||||||
tostring(data)))
|
tostring(data)))
|
||||||
|
|
||||||
return retCode, data
|
return retCode, data
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -420,11 +425,18 @@ function InternetDetector:mainLoop()
|
|||||||
self:parseUrls()
|
self:parseUrls()
|
||||||
if (self.serviceConfig.proxy_type and self.serviceConfig.proxy_host and
|
if (self.serviceConfig.proxy_type and self.serviceConfig.proxy_host and
|
||||||
self.serviceConfig.proxy_port) then
|
self.serviceConfig.proxy_port) then
|
||||||
|
if self.serviceConfig.proxy_user and self.serviceConfig.proxy_passwd then
|
||||||
|
self.proxyAuthString = string.format(
|
||||||
|
' --proxy-user "%s:%s"',
|
||||||
|
self.serviceConfig.proxy_user,
|
||||||
|
self.serviceConfig.proxy_passwd)
|
||||||
|
end
|
||||||
self.proxyString = string.format(
|
self.proxyString = string.format(
|
||||||
" --proxy %s://%s:%d",
|
" --proxy %s://%s:%d%s",
|
||||||
self.serviceConfig.proxy_type,
|
self.serviceConfig.proxy_type,
|
||||||
self.serviceConfig.proxy_host,
|
self.serviceConfig.proxy_host,
|
||||||
self.serviceConfig.proxy_port)
|
self.serviceConfig.proxy_port,
|
||||||
|
self.proxyAuthString)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:parseHosts()
|
self:parseHosts()
|
||||||
@@ -516,7 +528,7 @@ function InternetDetector:mainLoop()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mTimeDiff = 0
|
mTimeDiff = 0
|
||||||
for _, e in ipairs(self.modules) do
|
for _, e in ipairs(self.modules) do
|
||||||
mTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec
|
mTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec
|
||||||
if mLastTime then
|
if mLastTime then
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#
|
#
|
||||||
# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
# (с) 2026 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||||
#
|
#
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-internet-detector
|
PKG_NAME:=luci-app-internet-detector
|
||||||
PKG_VERSION:=1.7.1
|
PKG_VERSION:=1.7.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
LUCI_TITLE:=LuCI support for internet-detector
|
LUCI_TITLE:=LuCI support for internet-detector
|
||||||
LUCI_DEPENDS:=+internet-detector
|
LUCI_DEPENDS:=+internet-detector
|
||||||
LUCI_PKGARCH:=all
|
LUCI_PKGARCH:=all
|
||||||
|
|||||||
+118
-25
@@ -196,7 +196,6 @@ return view.extend({
|
|||||||
{ name: 'icanhazip', title: 'icanhazip.com (HTTP)' },
|
{ name: 'icanhazip', title: 'icanhazip.com (HTTP)' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
tgUpdatesURLPattern : 'https://api.telegram.org/bot%s/getUpdates',
|
|
||||||
mm : false,
|
mm : false,
|
||||||
mmInit : false,
|
mmInit : false,
|
||||||
email : false,
|
email : false,
|
||||||
@@ -292,6 +291,20 @@ return view.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
callTgChatId: rpc.declare({
|
||||||
|
object: 'luci.internet-detector-mod-telegram',
|
||||||
|
method: 'GetTgChatId',
|
||||||
|
params: [ 'botToken', 'proxyType', 'proxyHost', 'proxyPort', 'proxyUser', 'proxyPasswd' ],
|
||||||
|
expect: { '': {} }
|
||||||
|
}),
|
||||||
|
|
||||||
|
getTgChatId(botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd) {
|
||||||
|
return this.callTgChatId(
|
||||||
|
botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd).then(data => {
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
setInternetStatus() {
|
setInternetStatus() {
|
||||||
this.inetStatusArea.innerHTML = '';
|
this.inetStatusArea.innerHTML = '';
|
||||||
|
|
||||||
@@ -303,7 +316,6 @@ return view.extend({
|
|||||||
this.inetStatusArea.append(label);
|
this.inetStatusArea.append(label);
|
||||||
} else {
|
} else {
|
||||||
this.inetStatus.instances.sort((a, b) => a.num - b.num);
|
this.inetStatus.instances.sort((a, b) => a.num - b.num);
|
||||||
|
|
||||||
for(let i of this.inetStatus.instances) {
|
for(let i of this.inetStatus.instances) {
|
||||||
let status = _('Disconnected');
|
let status = _('Disconnected');
|
||||||
let className = 'id-label-status id-disconnected';
|
let className = 'id-label-status id-disconnected';
|
||||||
@@ -382,6 +394,7 @@ return view.extend({
|
|||||||
|
|
||||||
getTgChatIdHandler(ev, instance) {
|
getTgChatIdHandler(ev, instance) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
let botToken;
|
let botToken;
|
||||||
let botTokenInput = document.getElementById(
|
let botTokenInput = document.getElementById(
|
||||||
'widget.cbid.%s.%s.mod_telegram_api_token'.format(this.appName, instance));
|
'widget.cbid.%s.%s.mod_telegram_api_token'.format(this.appName, instance));
|
||||||
@@ -392,41 +405,60 @@ return view.extend({
|
|||||||
alert(_('Bot API token is missing!'));
|
alert(_('Bot API token is missing!'));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let apiURL = this.tgUpdatesURLPattern.format(botToken);
|
let proxyType = null;
|
||||||
|
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 proxyHostInput = document.getElementById(
|
||||||
|
'widget.cbid.%s.%s.mod_telegram_proxy_host'.format(this.appName, instance));
|
||||||
|
if(proxyTypeInput) {
|
||||||
|
proxyHost = proxyHostInput.value;
|
||||||
|
};
|
||||||
|
let proxyPort = null;
|
||||||
|
let proxyPortInput = document.getElementById(
|
||||||
|
'widget.cbid.%s.%s.mod_telegram_proxy_port'.format(this.appName, instance));
|
||||||
|
if(proxyTypeInput) {
|
||||||
|
proxyPort = proxyPortInput.value;
|
||||||
|
};
|
||||||
|
let proxyUser = null;
|
||||||
|
let proxyUserInput = document.getElementById(
|
||||||
|
'widget.cbid.%s.%s.mod_telegram_proxy_user'.format(this.appName, instance));
|
||||||
|
if(proxyTypeInput) {
|
||||||
|
proxyUser = proxyUserInput.value;
|
||||||
|
};
|
||||||
|
let proxyPasswd = null;
|
||||||
|
let proxyPasswdInput = document.getElementById(
|
||||||
|
'widget.cbid.%s.%s.mod_telegram_proxy_passwd'.format(this.appName, instance));
|
||||||
|
if(proxyTypeInput) {
|
||||||
|
proxyPasswd = proxyPasswdInput.value;
|
||||||
|
};
|
||||||
|
|
||||||
console.log(`Requesting chat ID: ${apiURL}`);
|
return this.getTgChatId(botToken, proxyType, proxyHost, proxyPort, proxyUser, proxyPasswd).then(r => {
|
||||||
|
|
||||||
return fetch(apiURL).then(r => {
|
|
||||||
if(r.ok) {
|
if(r.ok) {
|
||||||
r.json().then(j => {
|
if(r.chatId) {
|
||||||
let chats = [];
|
|
||||||
if(j.ok && j.result) {
|
|
||||||
j.result.forEach(i => {
|
|
||||||
if(i.message && i.message.chat && i.message.chat.id) {
|
|
||||||
if(!chats.includes(i.message.chat.id)) {
|
|
||||||
chats.push(i.message.chat.id);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
let tgChatIdInput = document.getElementById(
|
let tgChatIdInput = document.getElementById(
|
||||||
'widget.cbid.%s.%s.mod_telegram_chat_id'.format(this.appName, instance));
|
'widget.cbid.%s.%s.mod_telegram_chat_id'.format(this.appName, instance));
|
||||||
if(tgChatIdInput) {
|
if(tgChatIdInput) {
|
||||||
if(chats.length == 0) {
|
if(r.chatId.length == 0) {
|
||||||
alert(_('No messages available. Write something to the bot and try again.'));
|
alert(_('No messages available. Write something to the bot and try again.'));
|
||||||
} else {
|
} else {
|
||||||
tgChatIdInput.value = chats[chats.length - 1];
|
tgChatIdInput.value = r.chatId[r.chatId.length - 1];
|
||||||
tgChatIdInput.focus();
|
tgChatIdInput.focus();
|
||||||
tgChatIdInput.blur();
|
tgChatIdInput.blur();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
|
||||||
} else {
|
|
||||||
let status = r.status;
|
|
||||||
let errorString = `${_('Error')} ${r.status}.`;
|
|
||||||
if(status == 404) {
|
|
||||||
errorString += ` ${_('Incorrect bot token?')}`;
|
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
let errCode = r.errCode;
|
||||||
|
let errorString = `${_('Error')} ${errCode}.`;
|
||||||
|
if(errCode == 401 || errCode == 404) {
|
||||||
|
errorString += ` ${_('Incorrect bot token?')}`;
|
||||||
|
} else {
|
||||||
|
errorString += ` ${r.errDesc}.`;
|
||||||
|
}
|
||||||
alert(errorString);
|
alert(errorString);
|
||||||
};
|
};
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
@@ -890,6 +922,21 @@ return view.extend({
|
|||||||
o.rmempty = false;
|
o.rmempty = false;
|
||||||
o.depends({ proxy_type: /.+/ });
|
o.depends({ proxy_type: /.+/ });
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
|
||||||
|
// proxy_user
|
||||||
|
o = s.taboption('main', form.Value,
|
||||||
|
'proxy_user', _('Proxy user')
|
||||||
|
);
|
||||||
|
o.depends({ proxy_type: /(http|socks5h?)/ });
|
||||||
|
o.modalonly = true;
|
||||||
|
|
||||||
|
// proxy_passwd
|
||||||
|
o = s.taboption('main', form.Value,
|
||||||
|
'proxy_passwd', _('Proxy password')
|
||||||
|
);
|
||||||
|
o.depends({ proxy_type: /(http|socks5h?)/ });
|
||||||
|
o.modalonly = true;
|
||||||
|
o.password = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// iface
|
// iface
|
||||||
@@ -1713,6 +1760,52 @@ return view.extend({
|
|||||||
o.rmempty = false;
|
o.rmempty = false;
|
||||||
o.depends({ 'mod_telegram_api_token': /.+/ });
|
o.depends({ 'mod_telegram_api_token': /.+/ });
|
||||||
|
|
||||||
|
// proxy_type
|
||||||
|
o = s.taboption('telegram', form.ListValue,
|
||||||
|
'mod_telegram_proxy_type', _('Proxy')
|
||||||
|
);
|
||||||
|
o.value('', _('Disabled'));
|
||||||
|
o.value('http');
|
||||||
|
o.value('socks4');
|
||||||
|
o.value('socks4a');
|
||||||
|
o.value('socks5');
|
||||||
|
o.value('socks5h');
|
||||||
|
o.default = '';
|
||||||
|
o.modalonly = true;
|
||||||
|
|
||||||
|
// proxy_host
|
||||||
|
o = s.taboption('telegram', form.Value,
|
||||||
|
'mod_telegram_proxy_host', _('Proxy host')
|
||||||
|
);
|
||||||
|
o.datatype = 'host';
|
||||||
|
o.rmempty = false;
|
||||||
|
o.depends({ mod_telegram_proxy_type: /.+/ });
|
||||||
|
o.modalonly = true;
|
||||||
|
|
||||||
|
// proxy_port
|
||||||
|
o = s.taboption('telegram', form.Value,
|
||||||
|
'mod_telegram_proxy_port', _('Proxy port')
|
||||||
|
);
|
||||||
|
o.datatype = 'port';
|
||||||
|
o.rmempty = false;
|
||||||
|
o.depends({ mod_telegram_proxy_type: /.+/ });
|
||||||
|
o.modalonly = true;
|
||||||
|
|
||||||
|
// proxy_user
|
||||||
|
o = s.taboption('telegram', form.Value,
|
||||||
|
'mod_telegram_proxy_user', _('Proxy user')
|
||||||
|
);
|
||||||
|
o.depends({ mod_telegram_proxy_type: /(http|socks5h?)/ });
|
||||||
|
o.modalonly = true;
|
||||||
|
|
||||||
|
// proxy_passwd
|
||||||
|
o = s.taboption('telegram', form.Value,
|
||||||
|
'mod_telegram_proxy_passwd', _('Proxy password')
|
||||||
|
);
|
||||||
|
o.depends({ mod_telegram_proxy_type: /(http|socks5h?)/ });
|
||||||
|
o.modalonly = true;
|
||||||
|
o.password = true;
|
||||||
|
|
||||||
// message_at_startup
|
// message_at_startup
|
||||||
o = s.taboption('telegram', form.Flag,
|
o = s.taboption('telegram', form.Flag,
|
||||||
'mod_telegram_message_at_startup',
|
'mod_telegram_message_at_startup',
|
||||||
|
|||||||
@@ -435,9 +435,6 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Период времени отсутствия доступа в Интренет перед перезагрузкой устройства."
|
"Период времени отсутствия доступа в Интренет перед перезагрузкой устройства."
|
||||||
|
|
||||||
msgid "Regular script"
|
|
||||||
msgstr "Регулярный скрипт"
|
|
||||||
|
|
||||||
msgid "Polling interval"
|
msgid "Polling interval"
|
||||||
msgstr "Интервал опроса"
|
msgstr "Интервал опроса"
|
||||||
|
|
||||||
@@ -450,9 +447,15 @@ msgstr "Прокси"
|
|||||||
msgid "Proxy host"
|
msgid "Proxy host"
|
||||||
msgstr "Хост прокси"
|
msgstr "Хост прокси"
|
||||||
|
|
||||||
|
msgid "Proxy password"
|
||||||
|
msgstr "Пароль прокси"
|
||||||
|
|
||||||
msgid "Proxy port"
|
msgid "Proxy port"
|
||||||
msgstr "Порт прокси"
|
msgstr "Порт прокси"
|
||||||
|
|
||||||
|
msgid "Proxy user"
|
||||||
|
msgstr "Пользователь прокси"
|
||||||
|
|
||||||
msgid "Public IP"
|
msgid "Public IP"
|
||||||
msgstr "Публичный IP"
|
msgstr "Публичный IP"
|
||||||
|
|
||||||
@@ -471,6 +474,9 @@ msgstr "Приём"
|
|||||||
msgid "Recipient"
|
msgid "Recipient"
|
||||||
msgstr "Получатель"
|
msgstr "Получатель"
|
||||||
|
|
||||||
|
msgid "Regular script"
|
||||||
|
msgstr "Регулярный скрипт"
|
||||||
|
|
||||||
msgid "Request chat ID from bot API"
|
msgid "Request chat ID from bot API"
|
||||||
msgstr "Запросить ID чата через API бота"
|
msgstr "Запросить ID чата через API бота"
|
||||||
|
|
||||||
|
|||||||
@@ -406,9 +406,6 @@ msgid ""
|
|||||||
"Period of time without Internet access until the device is rebooted."
|
"Period of time without Internet access until the device is rebooted."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Regular script"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Polling interval"
|
msgid "Polling interval"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -421,9 +418,15 @@ msgstr ""
|
|||||||
msgid "Proxy host"
|
msgid "Proxy host"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Proxy password"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Proxy port"
|
msgid "Proxy port"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Proxy user"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Public IP"
|
msgid "Public IP"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -442,6 +445,9 @@ msgstr ""
|
|||||||
msgid "Recipient"
|
msgid "Recipient"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Regular script"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Request chat ID from bot API"
|
msgid "Request chat ID from bot API"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ config_file="/etc/config/ksmbd"
|
|||||||
wait_for_init() {
|
wait_for_init() {
|
||||||
for i in `seq 30`
|
for i in `seq 30`
|
||||||
do
|
do
|
||||||
[ -e /tmp/procd.done ] || {
|
if ubus call service list '{"name":"ksmbd"}' 2>/dev/null | grep -q "ksmbd"; then
|
||||||
sleep 1; continue;
|
sleep 2
|
||||||
}
|
return
|
||||||
return
|
fi
|
||||||
|
sleep 1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ config_file="/etc/config/samba4"
|
|||||||
wait_for_init() {
|
wait_for_init() {
|
||||||
for i in `seq 30`
|
for i in `seq 30`
|
||||||
do
|
do
|
||||||
[ -e /tmp/procd.done ] || {
|
if ubus call service list '{"name":"samba4"}' 2>/dev/null | grep -q "samba4"; then
|
||||||
sleep 1; continue;
|
sleep 2
|
||||||
}
|
return
|
||||||
return
|
fi
|
||||||
|
sleep 1
|
||||||
done
|
done
|
||||||
}
|
}}
|
||||||
|
|
||||||
smb_handle() {
|
smb_handle() {
|
||||||
local path
|
local path
|
||||||
|
|||||||
Reference in new issue
Block a user