mirror of
https://github.com/kenzok8/small-package
synced 2025-01-05 11:36:47 +08:00
update 2024-02-20 00:22:53
This commit is contained in:
parent
99ccb18711
commit
257bc92008
@ -1,49 +1,63 @@
|
||||
# Internet detector for OpenWrt.
|
||||
Internet-detector is an application for checking the availability of the Internet. Performs periodic connections to a known public host (8.8.8.8, 1.1.1.1) and determines the actual Internet availability.
|
||||
|
||||
**OpenWrt** >= 19.07.
|
||||
|
||||
**Dependences:** lua, luaposix, libuci-lua.
|
||||
Internet-detector is an application for checking the availability of the Internet. Performs periodic connections to a known public host and determines the actual Internet availability.
|
||||
|
||||
**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.
|
||||
- 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 (Restarting network, modem or device. Executing custom shell scripts).
|
||||
- Sending email notification when Internet access is restored.
|
||||
- Performing actions when connecting and disconnecting the Internet: rebooting device, restarting network or modem (internet-detector-mod-modem-restart), executing custom shell scripts.
|
||||
- Sending email notification when Internet access is restored (internet-detector-mod-email).
|
||||
- The daemon is written entirely in Lua using the luaposix library.
|
||||
|
||||
## Installation notes
|
||||
**Dependences:** lua, luaposix, libuci-lua.
|
||||
|
||||
**OpenWrt >= 21.02:**
|
||||
## Installation notes (OpenWrt >= 21.02)
|
||||
|
||||
opkg update
|
||||
wget --no-check-certificate -O /tmp/internet-detector_1.2-0_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.2-0_all.ipk
|
||||
opkg install /tmp/internet-detector_1.2-0_all.ipk
|
||||
rm /tmp/internet-detector_1.2-0_all.ipk
|
||||
wget --no-check-certificate -O /tmp/internet-detector_1.3-0_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.3-0_all.ipk
|
||||
opkg install /tmp/internet-detector_1.3-0_all.ipk
|
||||
rm /tmp/internet-detector_1.3-0_all.ipk
|
||||
/etc/init.d/internet-detector start
|
||||
/etc/init.d/internet-detector enable
|
||||
|
||||
wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.2-0_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.2-0_all.ipk
|
||||
opkg install /tmp/luci-app-internet-detector_1.2-0_all.ipk
|
||||
rm /tmp/luci-app-internet-detector_1.2-0_all.ipk
|
||||
wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.3-0_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.3-0_all.ipk
|
||||
opkg install /tmp/luci-app-internet-detector_1.3-0_all.ipk
|
||||
rm /tmp/luci-app-internet-detector_1.3-0_all.ipk
|
||||
/etc/init.d/rpcd restart
|
||||
|
||||
Email notification:
|
||||
|
||||
opkg install mailsend
|
||||
|
||||
i18n-ru:
|
||||
|
||||
wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.2-0_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.2-0_all.ipk
|
||||
opkg install /tmp/luci-i18n-internet-detector-ru_1.2-0_all.ipk
|
||||
rm /tmp/luci-i18n-internet-detector-ru_1.2-0_all.ipk
|
||||
|
||||
**[OpenWrt 19.07](https://github.com/gSpotx2f/luci-app-internet-detector/tree/19.07)**
|
||||
wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.3-0_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.3-0_all.ipk
|
||||
opkg install /tmp/luci-i18n-internet-detector-ru_1.3-0_all.ipk
|
||||
rm /tmp/luci-i18n-internet-detector-ru_1.3-0_all.ipk
|
||||
|
||||
## Screenshots:
|
||||
|
||||
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/01.jpg)
|
||||
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/02.jpg)
|
||||
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/03.jpg)
|
||||
|
||||
## Modem restart module (internet-detector-mod-modem-restart):
|
||||
|
||||
**Dependences:** modemmanager.
|
||||
|
||||
wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.3-0_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.3-0_all.ipk
|
||||
opkg install /tmp/internet-detector-mod-modem-restart_1.3-0_all.ipk
|
||||
rm /tmp/internet-detector-mod-modem-restart_1.3-0_all.ipk
|
||||
/etc/init.d/internet-detector restart
|
||||
|
||||
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/04.jpg)
|
||||
|
||||
## Email notification module (internet-detector-mod-email):
|
||||
|
||||
**Dependences:** mailsend.
|
||||
|
||||
wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.3-0_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.3-0_all.ipk
|
||||
opkg install /tmp/internet-detector-mod-email_1.3-0_all.ipk
|
||||
rm /tmp/internet-detector-mod-email_1.3-0_all.ipk
|
||||
/etc/init.d/internet-detector restart
|
||||
|
||||
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/05.jpg)
|
||||
|
||||
## [OpenWrt 19.07](https://github.com/gSpotx2f/luci-app-internet-detector/tree/19.07)
|
||||
|
@ -0,0 +1,41 @@
|
||||
#
|
||||
# (с) 2024 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=internet-detector-mod-email
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=0
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Email module for internet-detector
|
||||
URL:=https://github.com/gSpotx2f/luci-app-internet-detector
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+internet-detector +mailsend
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
Email support for internet-detector.
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/internet-detector
|
||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/mod_email.lua $(1)/usr/lib/lua/internet-detector/mod_email.lua
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
@ -13,27 +13,42 @@ local Module = {
|
||||
syslog = function(level, msg) return true end,
|
||||
writeValue = function(filePath, str) return false end,
|
||||
readValue = function(filePath) return nil end,
|
||||
deadPeriod = 0,
|
||||
alivePeriod = 0,
|
||||
mode = 0, -- 0: connected, 1: disconnected, 2: both
|
||||
hostAlias = "OpenWrt",
|
||||
mta = "/usr/bin/mailsend",
|
||||
mailRecipient = "email@gmail.com",
|
||||
mailSender = "email@gmail.com",
|
||||
mailUser = "email@gmail.com",
|
||||
mailPassword = "password",
|
||||
mailSmtp = "smtp.gmail.com",
|
||||
mailSmtpPort = '587',
|
||||
mtaConnectTimeout = 5, -- default = 5
|
||||
mtaReadTimeout = 5, -- default = 5
|
||||
mailRecipient = nil,
|
||||
mailSender = nil,
|
||||
mailUser = nil,
|
||||
mailPassword = nil,
|
||||
mailSmtp = nil,
|
||||
mailSmtpPort = nil,
|
||||
mailSecurity = "tls",
|
||||
status = nil,
|
||||
_enabled = false,
|
||||
_deadCounter = 0,
|
||||
_aliveCounter = 0,
|
||||
_msgSent = true,
|
||||
_msgSentDisconnect = true,
|
||||
_msgSentConnect = true,
|
||||
_disconnected = true,
|
||||
_lastDisconnection = nil,
|
||||
_lastConnection = nil,
|
||||
_message = {},
|
||||
}
|
||||
|
||||
function Module:init(t)
|
||||
self.alivePeriod = tonumber(t.alive_period)
|
||||
if t.mode ~= nil then
|
||||
self.mode = tonumber(t.mode)
|
||||
end
|
||||
if t.dead_period ~= nil then
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
end
|
||||
if t.alive_period ~= nil then
|
||||
self.alivePeriod = tonumber(t.alive_period)
|
||||
end
|
||||
if t.host_alias then
|
||||
self.hostAlias = t.host_alias
|
||||
else
|
||||
@ -46,7 +61,10 @@ function Module:init(t)
|
||||
self.mailPassword = t.mail_password
|
||||
self.mailSmtp = t.mail_smtp
|
||||
self.mailSmtpPort = t.mail_smtp_port
|
||||
self.mailSecurity = t.mail_security
|
||||
|
||||
if t.mail_security ~= nil then
|
||||
self.mailSecurity = t.mail_security
|
||||
end
|
||||
|
||||
if unistd.access(self.mta, "x") then
|
||||
self._enabled = true
|
||||
@ -83,11 +101,19 @@ function Module:sendMessage(msg)
|
||||
end
|
||||
|
||||
local mtaCmd = string.format(
|
||||
'%s%s %s -smtp "%s" -port %s -cs utf-8 -user "%s" -pass "%s" -f "%s" -t "%s" -sub "%s" -M "%s"',
|
||||
'%s%s %s -smtp "%s" -port %s -ct %s -read-timeout %s -cs utf-8 -user "%s" -pass "%s" -f "%s" -t "%s" -sub "%s" -M "%s"',
|
||||
self.mta, verboseArg, securityArgs, self.mailSmtp, self.mailSmtpPort,
|
||||
self.mtaConnectTimeout, self.mtaReadTimeout,
|
||||
self.mailUser, self.mailPassword, self.mailSender, self.mailRecipient,
|
||||
string.format("%s notification", self.hostAlias),
|
||||
string.format("%s:\n%s", self.hostAlias, msg))
|
||||
string.format("[%s]: %s:\n%s", self.hostAlias, self.config.serviceConfig.instance, msg))
|
||||
|
||||
-- Debug
|
||||
if self.config.debug then
|
||||
io.stdout:write(string.format("%s: %s\n", self.name, mtaCmd))
|
||||
io.stdout:flush()
|
||||
self.syslog("debug", string.format("%s: %s", self.name, mtaCmd))
|
||||
end
|
||||
|
||||
if os.execute(mtaCmd) ~= 0 then
|
||||
self.syslog("err", string.format(
|
||||
@ -102,44 +128,46 @@ function Module:run(currentStatus, lastStatus, timeDiff)
|
||||
if not self._enabled then
|
||||
return
|
||||
end
|
||||
|
||||
if currentStatus == 1 then
|
||||
self._aliveCounter = 0
|
||||
self._msgSent = false
|
||||
self._msgSentConnect = false
|
||||
self._lastConnection = nil
|
||||
if not self._disconnected then
|
||||
self._disconnected = true
|
||||
if not self._lastDisconnection then
|
||||
self._lastDisconnection = os.date("%Y.%m.%d %H:%M:%S", os.time())
|
||||
end
|
||||
self._message[#self._message + 1] = string.format(
|
||||
"Internet disconnected: %s", self._lastDisconnection)
|
||||
end
|
||||
if not self._msgSentDisconnect and (self.mode == 1 or self.mode == 2) then
|
||||
if self._deadCounter >= self.deadPeriod then
|
||||
self._lastDisconnection = nil
|
||||
self:sendMessage(table.concat(self._message, ", "))
|
||||
self._message = {}
|
||||
self._msgSentDisconnect = true
|
||||
else
|
||||
self._deadCounter = self._deadCounter + timeDiff
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if not self._msgSent then
|
||||
|
||||
self._deadCounter = 0
|
||||
self._msgSentDisconnect = false
|
||||
if not self._msgSentConnect and (self.mode == 0 or self.mode == 2) then
|
||||
if not self._lastConnection then
|
||||
self._lastConnection = os.date("%Y.%m.%d %H:%M:%S", os.time())
|
||||
end
|
||||
|
||||
if self._aliveCounter >= self.alivePeriod then
|
||||
local message = {}
|
||||
if self._lastDisconnection then
|
||||
message[#message + 1] = string.format(
|
||||
"Internet disconnected: %s", self._lastDisconnection)
|
||||
self._lastDisconnection = nil
|
||||
end
|
||||
if self._lastConnection then
|
||||
message[#message + 1] = string.format(
|
||||
self._message[#self._message + 1] = string.format(
|
||||
"Internet connected: %s", self._lastConnection)
|
||||
self:sendMessage(table.concat(message, ", "))
|
||||
self._msgSent = true
|
||||
end
|
||||
self:sendMessage(table.concat(self._message, "; "))
|
||||
self._message = {}
|
||||
self._msgSentConnect = true
|
||||
else
|
||||
self._aliveCounter = self._aliveCounter + timeDiff
|
||||
end
|
||||
end
|
||||
|
||||
self._disconnected = false
|
||||
end
|
||||
end
|
@ -0,0 +1,41 @@
|
||||
#
|
||||
# (с) 2024 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=internet-detector-mod-modem-restart
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=0
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Modem restart module for internet-detector
|
||||
URL:=https://github.com/gSpotx2f/luci-app-internet-detector
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+internet-detector +modemmanager
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
Support modem restart for internet detector.
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/internet-detector
|
||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/mod_modem_restart.lua $(1)/usr/lib/lua/internet-detector/mod_modem_restart.lua
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
@ -13,7 +13,7 @@ local Module = {
|
||||
readValue = function(filePath) return nil end,
|
||||
mmcli = "/usr/bin/mmcli",
|
||||
mmInit = "/etc/init.d/modemmanager",
|
||||
deadPeriod = 0,
|
||||
deadPeriod = 600,
|
||||
iface = nil,
|
||||
anyBand = false,
|
||||
status = nil,
|
||||
@ -23,12 +23,21 @@ local Module = {
|
||||
}
|
||||
|
||||
function Module:toggleIface(flag)
|
||||
if not self.iface then
|
||||
return
|
||||
end
|
||||
return os.execute(
|
||||
string.format("%s %s", (flag and "/sbin/ifup" or "/sbin/ifdown"), self.iface)
|
||||
)
|
||||
end
|
||||
|
||||
function Module:restartMM()
|
||||
if os.execute(string.format("%s enabled", self.mmInit)) ~= 0 then
|
||||
self.syslog("warning", string.format(
|
||||
"%s: modemmanager service is disabled", self.name))
|
||||
return
|
||||
end
|
||||
|
||||
if self.anyBand then
|
||||
self.syslog("info", string.format(
|
||||
"%s: resetting current-bands to 'any'", self.name))
|
||||
@ -47,15 +56,22 @@ function Module:restartMM()
|
||||
end
|
||||
|
||||
function Module:init(t)
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
self.iface = t.iface
|
||||
self.anyBand = (tonumber(t.any_band) ~= 0)
|
||||
if t.dead_period ~= nil then
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
end
|
||||
if t.iface ~= nil then
|
||||
self.iface = t.iface
|
||||
end
|
||||
if t.any_band ~= nil then
|
||||
self.anyBand = (tonumber(t.any_band) ~= 0)
|
||||
end
|
||||
|
||||
if not unistd.access(self.mmcli, "x") then
|
||||
self.anyBand = false
|
||||
end
|
||||
|
||||
if unistd.access(self.mmInit, "x") then
|
||||
if (unistd.access(self.mmInit, "x")
|
||||
and os.execute(string.format("%s enabled", self.mmInit)) == 0) then
|
||||
self._enabled = true
|
||||
else
|
||||
self._enabled = false
|
@ -5,7 +5,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=internet-detector
|
||||
PKG_VERSION:=1.2
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=0
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
|
||||
|
||||
@ -50,14 +50,13 @@ define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_BIN) ./files/etc/init.d/internet-detector $(1)/etc/init.d/internet-detector
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) ./files/usr/bin/internet-detector $(1)/usr/bin/internet-detector
|
||||
$(INSTALL_DIR) $(1)/usr/lib/internet-detector
|
||||
$(INSTALL_DATA) ./files/usr/lib/internet-detector/mod_email.lua $(1)/usr/lib/internet-detector/mod_email.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/internet-detector/mod_public_ip.lua $(1)/usr/lib/internet-detector/mod_public_ip.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/internet-detector/mod_led_control.lua $(1)/usr/lib/internet-detector/mod_led_control.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/internet-detector/mod_modem_restart.lua $(1)/usr/lib/internet-detector/mod_modem_restart.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/internet-detector/mod_network_restart.lua $(1)/usr/lib/internet-detector/mod_network_restart.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/internet-detector/mod_reboot.lua $(1)/usr/lib/internet-detector/mod_reboot.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/internet-detector/mod_user_scripts.lua $(1)/usr/lib/internet-detector/mod_user_scripts.lua
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/internet-detector
|
||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/main.lua $(1)/usr/lib/lua/internet-detector/main.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/mod_led_control.lua $(1)/usr/lib/lua/internet-detector/mod_led_control.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/mod_reboot.lua $(1)/usr/lib/lua/internet-detector/mod_reboot.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/mod_network_restart.lua $(1)/usr/lib/lua/internet-detector/mod_network_restart.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/mod_public_ip.lua $(1)/usr/lib/lua/internet-detector/mod_public_ip.lua
|
||||
$(INSTALL_DATA) ./files/usr/lib/lua/internet-detector/mod_user_scripts.lua $(1)/usr/lib/lua/internet-detector/mod_user_scripts.lua
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
config main 'config'
|
||||
option mode '1'
|
||||
option enable_logger '1'
|
||||
@ -12,7 +13,6 @@ config instance 'internet'
|
||||
option interval_down '5'
|
||||
option connection_attempts '2'
|
||||
option connection_timeout '2'
|
||||
option mod_led_control_enabled '0'
|
||||
option mod_reboot_enabled '0'
|
||||
option mod_reboot_dead_period '3600'
|
||||
option mod_reboot_force_reboot_delay '300'
|
||||
@ -30,9 +30,8 @@ config instance 'internet'
|
||||
option mod_public_ip_timeout '3'
|
||||
option mod_public_ip_enable_ip_script '0'
|
||||
option mod_email_enabled '0'
|
||||
option mod_email_mode '0'
|
||||
option mod_email_alive_period '0'
|
||||
option mod_email_mail_smtp 'smtp.gmail.com'
|
||||
option mod_email_mail_smtp_port '587'
|
||||
option mod_email_mail_security 'tls'
|
||||
option mod_user_scripts_enabled '0'
|
||||
option mod_user_scripts_alive_period '0'
|
||||
|
@ -11,633 +11,7 @@
|
||||
(с) 2024 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
|
||||
--]]
|
||||
|
||||
-- Importing packages
|
||||
|
||||
local dirent = require("posix.dirent")
|
||||
local fcntl = require("posix.fcntl")
|
||||
local signal = require("posix.signal")
|
||||
local socket = require("posix.sys.socket")
|
||||
local stat = require("posix.sys.stat")
|
||||
local syslog = require("posix.syslog")
|
||||
local time = require("posix.time")
|
||||
local unistd = require("posix.unistd")
|
||||
local uci = require("uci")
|
||||
|
||||
-- Default settings
|
||||
|
||||
local InternetDetector = {
|
||||
mode = 0, -- 0: disabled, 1: Service, 2: UI detector
|
||||
enableLogger = true,
|
||||
hostname = "OpenWrt",
|
||||
appName = "internet-detector",
|
||||
commonDir = "/tmp/run",
|
||||
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,
|
||||
},
|
||||
modules = {},
|
||||
parsedHosts = {},
|
||||
uiCounter = 0,
|
||||
}
|
||||
InternetDetector.configDir = string.format("/etc/%s", InternetDetector.appName)
|
||||
InternetDetector.modulesDir = string.format("/usr/lib/%s", InternetDetector.appName)
|
||||
|
||||
-- Loading settings from UCI
|
||||
|
||||
local uciCursor = uci.cursor()
|
||||
InternetDetector.mode = tonumber(
|
||||
uciCursor:get(InternetDetector.appName, "config", "mode"))
|
||||
InternetDetector.enableLogger = (tonumber(
|
||||
uciCursor:get(InternetDetector.appName, "config", "enable_logger")) ~= 0)
|
||||
local hostname = uciCursor:get("system", "@[0]", "hostname")
|
||||
if hostname ~= nil then
|
||||
InternetDetector.hostname = hostname
|
||||
end
|
||||
|
||||
local RUNNING
|
||||
|
||||
function InternetDetector:prequire(package)
|
||||
local retVal, pkg = pcall(require, package)
|
||||
return retVal and pkg
|
||||
end
|
||||
|
||||
function InternetDetector:loadUCIConfig(sType, instance)
|
||||
local success
|
||||
local num = 0
|
||||
uciCursor:foreach(
|
||||
self.appName,
|
||||
sType,
|
||||
function(s)
|
||||
if s[".name"] == instance then
|
||||
for k, v in pairs(s) do
|
||||
if type(v) == "string" and v:match("^[%d]+$") then
|
||||
v = tonumber(v)
|
||||
end
|
||||
self.serviceConfig[k] = v
|
||||
end
|
||||
success = true
|
||||
self.serviceConfig.instanceNum = num
|
||||
end
|
||||
num = num + 1
|
||||
end
|
||||
)
|
||||
self.serviceConfig.instance = instance
|
||||
self.pidFile = string.format(
|
||||
"%s/%s.%s.pid", self.commonDir, self.appName, instance)
|
||||
self.statusFile = string.format(
|
||||
"%s/%s.%s.status", self.commonDir, self.appName, instance)
|
||||
return success
|
||||
end
|
||||
|
||||
function InternetDetector:writeValueToFile(filePath, str)
|
||||
local retValue = false
|
||||
local fh = io.open(filePath, "w")
|
||||
if fh then
|
||||
fh:setvbuf("no")
|
||||
fh:write(string.format("%s\n", str))
|
||||
fh:close()
|
||||
retValue = true
|
||||
end
|
||||
return retValue
|
||||
end
|
||||
|
||||
function InternetDetector:readValueFromFile(filePath)
|
||||
local retValue
|
||||
local fh = io.open(filePath, "r")
|
||||
if fh then
|
||||
retValue = fh:read("*l")
|
||||
fh:close()
|
||||
end
|
||||
return retValue
|
||||
end
|
||||
|
||||
function InternetDetector:statusJson(inet, instance, t)
|
||||
local lines = { [1] = string.format(
|
||||
'{"instance":"%s","num":"%d","inet":%d',
|
||||
instance,
|
||||
self.serviceConfig.instanceNum,
|
||||
inet)}
|
||||
if t then
|
||||
for k, v in pairs(t) do
|
||||
lines[#lines + 1] = string.format('"%s":"%s"', k, v)
|
||||
end
|
||||
end
|
||||
return table.concat(lines, ",") .. "}"
|
||||
end
|
||||
|
||||
function InternetDetector:writeLogMessage(level, msg)
|
||||
if self.enableLogger then
|
||||
local levels = {
|
||||
emerg = syslog.LOG_EMERG,
|
||||
alert = syslog.LOG_ALERT,
|
||||
crit = syslog.LOG_CRIT,
|
||||
err = syslog.LOG_ERR,
|
||||
warning = syslog.LOG_WARNING,
|
||||
notice = syslog.LOG_NOTICE,
|
||||
info = syslog.LOG_INFO,
|
||||
debug = syslog.LOG_DEBUG,
|
||||
}
|
||||
syslog.syslog(levels[level] or syslog.LOG_INFO, string.format(
|
||||
"%s: %s", self.serviceConfig.instance or "", msg))
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:loadModules()
|
||||
package.path = string.format("%s;%s/?.lua", package.path, self.modulesDir)
|
||||
self.modules = {}
|
||||
local ok, modulesDir = pcall(dirent.files, self.modulesDir)
|
||||
if ok then
|
||||
for item in modulesDir do
|
||||
if item:match("^mod_") then
|
||||
local modName = item:gsub("%.lua$", "")
|
||||
if self.noModules and not self.uiAvailModules[modName] then
|
||||
else
|
||||
local modConfig = {}
|
||||
for k, v in pairs(self.serviceConfig) do
|
||||
if k:match("^" .. modName) then
|
||||
modConfig[k:gsub("^" .. modName .. "_", "")] = v
|
||||
end
|
||||
end
|
||||
if modConfig.enabled == 1 then
|
||||
local m = self:prequire(modName)
|
||||
if m then
|
||||
m.config = self
|
||||
m.syslog = function(level, msg) self:writeLogMessage(level, msg) end
|
||||
m.writeValue = function(filePath, str) return self:writeValueToFile(filePath, str) end
|
||||
m.readValue = function(filePath) return self:readValueFromFile(filePath) end
|
||||
m:init(modConfig)
|
||||
self.modules[#self.modules + 1] = m
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(self.modules, function(a, b) return a.runPrio < b.runPrio end)
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:parseHost(host)
|
||||
local addr, port = host:match("^([^%[%]:]+):?(%d?%d?%d?%d?%d?)$")
|
||||
if not addr then
|
||||
addr, port = host:match("^%[?([^%[%]]+)%]?:?(%d?%d?%d?%d?%d?)$")
|
||||
end
|
||||
return addr, tonumber(port)
|
||||
end
|
||||
|
||||
function InternetDetector:parseHosts()
|
||||
self.parsedHosts = {}
|
||||
for k, v in ipairs(self.serviceConfig.hosts) do
|
||||
local addr, port = self:parseHost(v)
|
||||
self.parsedHosts[k] = { addr = addr, port = port }
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:pingHost(host)
|
||||
local ping = string.format(
|
||||
"%s %s -W %d -s %d%s %s > /dev/null 2>&1",
|
||||
self.pingCmd,
|
||||
self.pingParams,
|
||||
self.serviceConfig.connection_timeout,
|
||||
self.serviceConfig.icmp_packet_size,
|
||||
self.serviceConfig.iface and (" -I " .. self.serviceConfig.iface) or "",
|
||||
host
|
||||
)
|
||||
local retCode = os.execute(ping)
|
||||
|
||||
if self.debug then
|
||||
io.stdout:write(string.format(
|
||||
"--- Ping ---\ntime = %s\n%s\nretCode = %s\n", os.time(), ping, retCode)
|
||||
)
|
||||
io.stdout:flush()
|
||||
end
|
||||
|
||||
return retCode
|
||||
end
|
||||
|
||||
function InternetDetector:TCPConnectionToHost(host, port)
|
||||
local retCode = 1
|
||||
local saTable, errMsg, errNum = socket.getaddrinfo(host, port or self.serviceConfig.tcp_port)
|
||||
|
||||
if not saTable then
|
||||
if self.debug then
|
||||
io.stdout:write(string.format(
|
||||
"GETADDRINFO ERROR: %s, %s\n", errMsg, errNum))
|
||||
end
|
||||
else
|
||||
local family = saTable[1].family
|
||||
|
||||
if family then
|
||||
local sock, errMsg, errNum = socket.socket(family, socket.SOCK_STREAM, 0)
|
||||
|
||||
if not sock then
|
||||
if self.debug then
|
||||
io.stdout:write(string.format(
|
||||
"SOCKET ERROR: %s, %s\n", errMsg, errNum))
|
||||
end
|
||||
return retCode
|
||||
end
|
||||
|
||||
socket.setsockopt(sock, socket.SOL_SOCKET,
|
||||
socket.SO_SNDTIMEO, self.serviceConfig.connection_timeout, 0)
|
||||
socket.setsockopt(sock, socket.SOL_SOCKET,
|
||||
socket.SO_RCVTIMEO, self.serviceConfig.connection_timeout, 0)
|
||||
|
||||
if self.serviceConfig.iface then
|
||||
local ok, errMsg, errNum = socket.setsockopt(sock, socket.SOL_SOCKET,
|
||||
socket.SO_BINDTODEVICE, self.serviceConfig.iface)
|
||||
if not ok then
|
||||
if self.debug then
|
||||
io.stdout:write(string.format(
|
||||
"SOCKET ERROR: %s, %s\n", errMsg, errNum))
|
||||
end
|
||||
unistd.close(sock)
|
||||
return retCode
|
||||
end
|
||||
end
|
||||
|
||||
local success = socket.connect(sock, saTable[1])
|
||||
|
||||
if self.debug then
|
||||
if not success then
|
||||
io.stdout:write(string.format(
|
||||
"SOCKET CONNECT ERROR: %s\n", tostring(success)))
|
||||
end
|
||||
local sockTable, err_s, e_s = socket.getsockname(sock)
|
||||
local peerTable, err_p, e_p = socket.getpeername(sock)
|
||||
if not sockTable then
|
||||
sockTable = {}
|
||||
io.stdout:write(
|
||||
string.format("SOCKET ERROR: %s, %s\n", err_s, e_s))
|
||||
end
|
||||
if not peerTable then
|
||||
peerTable = {}
|
||||
io.stdout:write(
|
||||
string.format("SOCKET ERROR: %s, %s\n", err_p, e_p))
|
||||
end
|
||||
io.stdout:write(string.format(
|
||||
"--- TCP ---\ntime = %s\nconnection_timeout = %s\niface = %s\nhost:port = [%s]:%s\nsockname = [%s]:%s\npeername = [%s]:%s\nsuccess = %s\n",
|
||||
os.time(),
|
||||
self.serviceConfig.connection_timeout,
|
||||
tostring(self.serviceConfig.iface),
|
||||
host,
|
||||
port or self.serviceConfig.tcp_port,
|
||||
tostring(sockTable.addr),
|
||||
tostring(sockTable.port),
|
||||
tostring(peerTable.addr),
|
||||
tostring(peerTable.port),
|
||||
tostring(success))
|
||||
)
|
||||
io.stdout:flush()
|
||||
end
|
||||
|
||||
socket.shutdown(sock, socket.SHUT_RDWR)
|
||||
unistd.close(sock)
|
||||
retCode = success and 0 or 1
|
||||
end
|
||||
end
|
||||
return retCode
|
||||
end
|
||||
|
||||
function InternetDetector:checkHosts()
|
||||
local checkFunc = (self.serviceConfig.check_type == 1) and self.pingHost or self.TCPConnectionToHost
|
||||
local retCode = 1
|
||||
for k, v in ipairs(self.parsedHosts) do
|
||||
for i = 1, self.serviceConfig.connection_attempts do
|
||||
if checkFunc(self, v.addr, v.port) == 0 then
|
||||
retCode = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
if retCode == 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
return retCode
|
||||
end
|
||||
|
||||
function InternetDetector:breakMain(signo)
|
||||
RUNNING = false
|
||||
end
|
||||
|
||||
function InternetDetector:resetUiCounter(signo)
|
||||
self.uiCounter = 0
|
||||
end
|
||||
|
||||
function InternetDetector:main()
|
||||
signal.signal(signal.SIGTERM, function(signo) self:breakMain(signo) end)
|
||||
signal.signal(signal.SIGINT, function(signo) self:breakMain(signo) end)
|
||||
signal.signal(signal.SIGQUIT, function(signo) self:breakMain(signo) end)
|
||||
signal.signal(signal.SIGUSR1, function(signo) self:resetUiCounter(signo) end)
|
||||
|
||||
local lastStatus, currentStatus, mTimeNow, mTimeDiff, mLastTime, uiTimeNow, uiLastTime
|
||||
local interval = self.serviceConfig.interval_up
|
||||
local counter = 0
|
||||
local onStart = true
|
||||
RUNNING = true
|
||||
while RUNNING do
|
||||
if counter == 0 or counter >= interval then
|
||||
currentStatus = self:checkHosts()
|
||||
if onStart or not stat.stat(self.statusFile) then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance))
|
||||
onStart = false
|
||||
end
|
||||
|
||||
if currentStatus == 0 then
|
||||
interval = self.serviceConfig.interval_up
|
||||
if lastStatus ~= nil and currentStatus ~= lastStatus then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance))
|
||||
self:writeLogMessage("notice", "Connected")
|
||||
end
|
||||
else
|
||||
interval = self.serviceConfig.interval_down
|
||||
if lastStatus ~= nil and currentStatus ~= lastStatus then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance))
|
||||
self:writeLogMessage("notice", "Disconnected")
|
||||
end
|
||||
end
|
||||
|
||||
counter = 0
|
||||
end
|
||||
|
||||
mTimeDiff = 0
|
||||
for _, e in ipairs(self.modules) do
|
||||
mTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec
|
||||
if mLastTime then
|
||||
mTimeDiff = mTimeDiff + mTimeNow - mLastTime
|
||||
else
|
||||
mTimeDiff = 1
|
||||
end
|
||||
mLastTime = mTimeNow
|
||||
e:run(currentStatus, lastStatus, mTimeDiff)
|
||||
end
|
||||
|
||||
local modulesStatus = {}
|
||||
for k, v in ipairs(self.modules) do
|
||||
if v.status ~= nil then
|
||||
modulesStatus[v.name] = v.status
|
||||
end
|
||||
end
|
||||
if next(modulesStatus) then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance, modulesStatus))
|
||||
end
|
||||
|
||||
lastStatus = currentStatus
|
||||
unistd.sleep(1)
|
||||
counter = counter + 1
|
||||
|
||||
if self.mode == 2 then
|
||||
uiTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec
|
||||
if uiLastTime then
|
||||
self.uiCounter = self.uiCounter + uiTimeNow - uiLastTime
|
||||
else
|
||||
self.uiCounter = self.uiCounter + 1
|
||||
end
|
||||
uiLastTime = uiTimeNow
|
||||
if self.uiCounter >= self.uiRunTime then
|
||||
self:breakMain(signal.SIGTERM)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:removeProcessFiles()
|
||||
os.remove(string.format(
|
||||
"%s/%s.%s.pid", self.commonDir, self.appName, self.serviceConfig.instance))
|
||||
os.remove(string.format(
|
||||
"%s/%s.%s.status", self.commonDir, self.appName, self.serviceConfig.instance))
|
||||
end
|
||||
|
||||
function InternetDetector:status()
|
||||
local ok, commonDir = pcall(dirent.files, self.commonDir)
|
||||
if ok then
|
||||
local appName = self.appName:gsub("-", "%%-")
|
||||
for item in commonDir do
|
||||
if item:match("^" .. appName .. ".-%.pid$") then
|
||||
return "running"
|
||||
end
|
||||
end
|
||||
end
|
||||
return "stoped"
|
||||
end
|
||||
|
||||
function InternetDetector:inetStatus()
|
||||
local inetStat = '{"instances":[]}'
|
||||
local ok, commonDir = pcall(dirent.files, self.commonDir)
|
||||
if ok then
|
||||
local appName = self.appName:gsub("-", "%%-")
|
||||
local lines = {}
|
||||
for item in commonDir do
|
||||
if item:match("^" .. appName .. ".-%.status$") then
|
||||
lines[#lines + 1] = self:readValueFromFile(
|
||||
string.format("%s/%s", self.commonDir, item))
|
||||
end
|
||||
end
|
||||
inetStat = '{"instances":[' .. table.concat(lines, ",") .. "]}"
|
||||
end
|
||||
return inetStat
|
||||
end
|
||||
|
||||
function InternetDetector:stopInstance(pidFile)
|
||||
local retVal
|
||||
if stat.stat(pidFile) then
|
||||
pidValue = self:readValueFromFile(pidFile)
|
||||
if pidValue then
|
||||
local ok, errMsg, errNum
|
||||
for i = 0, 10 do
|
||||
ok, errMsg, errNum = signal.kill(tonumber(pidValue), signal.SIGTERM)
|
||||
if ok then
|
||||
break
|
||||
end
|
||||
end
|
||||
if not ok then
|
||||
io.stderr:write(string.format(
|
||||
'Process stop error: %s (%s). PID: "%s"\n', errMsg, errNum, pidValue))
|
||||
end
|
||||
if errNum == 3 then
|
||||
os.remove(pidFile)
|
||||
end
|
||||
retVal = true
|
||||
end
|
||||
end
|
||||
if not pidValue then
|
||||
io.stderr:write(
|
||||
string.format('PID file "%s" does not exist. %s not running?\n',
|
||||
pidFile, self.appName))
|
||||
end
|
||||
return retVal
|
||||
end
|
||||
|
||||
function InternetDetector:stop()
|
||||
local appName = self.appName:gsub("-", "%%-")
|
||||
local success
|
||||
for i = 0, 10 do
|
||||
success = true
|
||||
local ok, commonDir = pcall(dirent.files, self.commonDir)
|
||||
if ok then
|
||||
for item in commonDir do
|
||||
if item:match("^" .. appName .. ".-%.pid$") then
|
||||
self:stopInstance(string.format("%s/%s", self.commonDir, item))
|
||||
success = false
|
||||
end
|
||||
end
|
||||
if success then
|
||||
break
|
||||
end
|
||||
unistd.sleep(1)
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:setSIGUSR()
|
||||
local appName = self.appName:gsub("-", "%%-")
|
||||
local ok, commonDir = pcall(dirent.files, self.commonDir)
|
||||
if ok then
|
||||
for item in commonDir do
|
||||
if item:match("^" .. appName .. ".-%.pid$") then
|
||||
pidValue = self:readValueFromFile(string.format("%s/%s", self.commonDir, item))
|
||||
if pidValue then
|
||||
signal.kill(tonumber(pidValue), signal.SIGUSR1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:preRun()
|
||||
-- Exit if internet-detector mode != (1 or 2)
|
||||
if self.mode ~= 1 and self.mode ~= 2 then
|
||||
io.stderr:write(string.format('Start failed, mode != (1 or 2)\n', self.appName))
|
||||
os.exit(0)
|
||||
end
|
||||
if stat.stat(self.pidFile) then
|
||||
io.stderr:write(
|
||||
string.format('PID file "%s" already exist. %s already running?\n',
|
||||
self.pidFile, self.appName))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function InternetDetector:run()
|
||||
local pidValue = unistd.getpid()
|
||||
self:writeValueToFile(self.pidFile, pidValue)
|
||||
if self.enableLogger then
|
||||
syslog.openlog(self.appName, syslog.LOG_PID, syslog.LOG_DAEMON)
|
||||
end
|
||||
self:writeLogMessage("info", "started")
|
||||
self:loadModules()
|
||||
|
||||
-- Loaded modules
|
||||
local modules = {}
|
||||
for _, v in ipairs(self.modules) do
|
||||
modules[#modules + 1] = string.format("%s", v.name)
|
||||
end
|
||||
if #modules > 0 then
|
||||
self:writeLogMessage(
|
||||
"info", string.format("Loaded modules: %s", table.concat(modules, ", "))
|
||||
)
|
||||
end
|
||||
|
||||
if self.debug then
|
||||
local function inspectTable()
|
||||
local tables = {}, f
|
||||
f = function(t, prefix)
|
||||
tables[t] = true
|
||||
for k, v in pairs(t) do
|
||||
io.stdout:write(string.format(
|
||||
"%s%s = %s\n", prefix, k, tostring(v))
|
||||
)
|
||||
if type(v) == "table" and not tables[v] then
|
||||
f(v, string.format("%s%s.", prefix, k))
|
||||
end
|
||||
end
|
||||
end
|
||||
return f
|
||||
end
|
||||
|
||||
io.stdout:write("--- Config ---\n")
|
||||
inspectTable()(self, "self.")
|
||||
io.stdout:flush()
|
||||
end
|
||||
|
||||
self:writeValueToFile(
|
||||
self.statusFile, self:statusJson(-1, self.serviceConfig.instance))
|
||||
|
||||
self:main()
|
||||
|
||||
self:removeProcessFiles()
|
||||
if self.enableLogger then
|
||||
self:writeLogMessage("info", "stoped")
|
||||
syslog.closelog()
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:noDaemon()
|
||||
if not self:preRun() then
|
||||
return
|
||||
end
|
||||
self:run()
|
||||
end
|
||||
|
||||
function InternetDetector:daemon()
|
||||
if not self:preRun() then
|
||||
return
|
||||
end
|
||||
-- UNIX double fork
|
||||
if unistd.fork() == 0 then
|
||||
unistd.setpid("s")
|
||||
if unistd.fork() == 0 then
|
||||
unistd.chdir("/")
|
||||
stat.umask(0)
|
||||
local devnull = fcntl.open("/dev/null", fcntl.O_RDWR)
|
||||
io.stdout:flush()
|
||||
io.stderr:flush()
|
||||
unistd.dup2(devnull, 0) -- io.stdin
|
||||
unistd.dup2(devnull, 1) -- io.stdout
|
||||
unistd.dup2(devnull, 2) -- io.stderr
|
||||
self:run()
|
||||
unistd.close(devnull)
|
||||
end
|
||||
os.exit(0)
|
||||
end
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
function InternetDetector:setServiceConfig(instance)
|
||||
if self:loadUCIConfig("instance", instance) then
|
||||
self:parseHosts()
|
||||
if self.mode == 2 then
|
||||
self.enableLogger = false
|
||||
self.noModules = true
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- Main section
|
||||
local InternetDetector = require("internet-detector.main")
|
||||
|
||||
local function help()
|
||||
return string.format(
|
||||
|
@ -0,0 +1,643 @@
|
||||
|
||||
local dirent = require("posix.dirent")
|
||||
local fcntl = require("posix.fcntl")
|
||||
local signal = require("posix.signal")
|
||||
local socket = require("posix.sys.socket")
|
||||
local stat = require("posix.sys.stat")
|
||||
local syslog = require("posix.syslog")
|
||||
local time = require("posix.time")
|
||||
local unistd = require("posix.unistd")
|
||||
local uci = require("uci")
|
||||
|
||||
-- Default settings
|
||||
|
||||
local InternetDetector = {
|
||||
mode = 0, -- 0: disabled, 1: Service, 2: UI detector
|
||||
enableLogger = true,
|
||||
hostname = "OpenWrt",
|
||||
appName = "internet-detector",
|
||||
commonDir = "/tmp/run",
|
||||
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,
|
||||
},
|
||||
modules = {},
|
||||
parsedHosts = {},
|
||||
uiCounter = 0,
|
||||
}
|
||||
InternetDetector.configDir = string.format("/etc/%s", InternetDetector.appName)
|
||||
InternetDetector.modulesDir = string.format(
|
||||
"%s/%s", InternetDetector.libDir, InternetDetector.appName)
|
||||
|
||||
-- Loading settings from UCI
|
||||
|
||||
local uciCursor = uci.cursor()
|
||||
local mode, err = uciCursor:get(InternetDetector.appName, "config", "mode")
|
||||
if mode ~= nil then
|
||||
InternetDetector.mode = tonumber(mode)
|
||||
elseif err then
|
||||
io.stderr:write(string.format("Error: %s\n", err))
|
||||
end
|
||||
local enableLogger, err = uciCursor:get(InternetDetector.appName, "config", "enable_logger")
|
||||
if enableLogger ~= nil then
|
||||
InternetDetector.enableLogger = (tonumber(enableLogger) ~= 0)
|
||||
elseif err then
|
||||
io.stderr:write(string.format("Error: %s\n", err))
|
||||
end
|
||||
local hostname, err = uciCursor:get("system", "@[0]", "hostname")
|
||||
if hostname ~= nil then
|
||||
InternetDetector.hostname = hostname
|
||||
elseif err then
|
||||
io.stderr:write(string.format("Error: %s\n", err))
|
||||
end
|
||||
|
||||
local _RUNNING
|
||||
|
||||
function InternetDetector:prequire(package)
|
||||
local retVal, pkg = pcall(require, package)
|
||||
return retVal and pkg
|
||||
end
|
||||
|
||||
function InternetDetector:loadUCIConfig(sType, instance)
|
||||
local success
|
||||
local num = 0
|
||||
uciCursor:foreach(
|
||||
self.appName,
|
||||
sType,
|
||||
function(s)
|
||||
if s[".name"] == instance then
|
||||
for k, v in pairs(s) do
|
||||
if type(v) == "string" and v:match("^[%d]+$") then
|
||||
v = tonumber(v)
|
||||
end
|
||||
self.serviceConfig[k] = v
|
||||
end
|
||||
success = true
|
||||
self.serviceConfig.instanceNum = num
|
||||
end
|
||||
num = num + 1
|
||||
end
|
||||
)
|
||||
self.serviceConfig.instance = instance
|
||||
self.pidFile = string.format(
|
||||
"%s/%s.%s.pid", self.commonDir, self.appName, instance)
|
||||
self.statusFile = string.format(
|
||||
"%s/%s.%s.status", self.commonDir, self.appName, instance)
|
||||
return success
|
||||
end
|
||||
|
||||
function InternetDetector:writeValueToFile(filePath, str)
|
||||
local retValue = false
|
||||
local fh = io.open(filePath, "w")
|
||||
if fh then
|
||||
fh:setvbuf("no")
|
||||
fh:write(string.format("%s\n", str))
|
||||
fh:close()
|
||||
retValue = true
|
||||
end
|
||||
return retValue
|
||||
end
|
||||
|
||||
function InternetDetector:readValueFromFile(filePath)
|
||||
local retValue
|
||||
local fh = io.open(filePath, "r")
|
||||
if fh then
|
||||
retValue = fh:read("*l")
|
||||
fh:close()
|
||||
end
|
||||
return retValue
|
||||
end
|
||||
|
||||
function InternetDetector:statusJson(inet, instance, t)
|
||||
local lines = { [1] = string.format(
|
||||
'{"instance":"%s","num":"%d","inet":%d',
|
||||
instance,
|
||||
self.serviceConfig.instanceNum,
|
||||
inet)}
|
||||
if t then
|
||||
for k, v in pairs(t) do
|
||||
lines[#lines + 1] = string.format('"%s":"%s"', k, v)
|
||||
end
|
||||
end
|
||||
return table.concat(lines, ",") .. "}"
|
||||
end
|
||||
|
||||
function InternetDetector:writeLogMessage(level, msg)
|
||||
if self.enableLogger then
|
||||
local levels = {
|
||||
emerg = syslog.LOG_EMERG,
|
||||
alert = syslog.LOG_ALERT,
|
||||
crit = syslog.LOG_CRIT,
|
||||
err = syslog.LOG_ERR,
|
||||
warning = syslog.LOG_WARNING,
|
||||
notice = syslog.LOG_NOTICE,
|
||||
info = syslog.LOG_INFO,
|
||||
debug = syslog.LOG_DEBUG,
|
||||
}
|
||||
syslog.syslog(levels[level] or syslog.LOG_INFO, string.format(
|
||||
"%s: %s", self.serviceConfig.instance or "", msg))
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:loadModules()
|
||||
self.modules = {}
|
||||
local ok, modulesDir = pcall(dirent.files, self.modulesDir)
|
||||
if ok then
|
||||
for item in modulesDir do
|
||||
if item:match("^mod_") then
|
||||
local modName = item:gsub("%.lua$", "")
|
||||
if self.noModules and not self.uiAvailModules[modName] then
|
||||
else
|
||||
local modConfig = {}
|
||||
for k, v in pairs(self.serviceConfig) do
|
||||
if k:match("^" .. modName) then
|
||||
modConfig[k:gsub("^" .. modName .. "_", "")] = v
|
||||
end
|
||||
end
|
||||
if modConfig.enabled == 1 then
|
||||
local m
|
||||
if self.debug then
|
||||
m = require(string.format("%s.%s", self.appName, modName))
|
||||
else
|
||||
m = self:prequire(string.format("%s.%s", self.appName, modName))
|
||||
end
|
||||
if m then
|
||||
m.config = self
|
||||
m.syslog = function(level, msg) self:writeLogMessage(level, msg) end
|
||||
m.writeValue = function(filePath, str) return self:writeValueToFile(filePath, str) end
|
||||
m.readValue = function(filePath) return self:readValueFromFile(filePath) end
|
||||
m:init(modConfig)
|
||||
self.modules[#self.modules + 1] = m
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(self.modules, function(a, b) return a.runPrio < b.runPrio end)
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:parseHost(host)
|
||||
local addr, port = host:match("^([^%[%]:]+):?(%d?%d?%d?%d?%d?)$")
|
||||
if not addr then
|
||||
addr, port = host:match("^%[?([^%[%]]+)%]?:?(%d?%d?%d?%d?%d?)$")
|
||||
end
|
||||
return addr, tonumber(port)
|
||||
end
|
||||
|
||||
function InternetDetector:parseHosts()
|
||||
self.parsedHosts = {}
|
||||
for k, v in ipairs(self.serviceConfig.hosts) do
|
||||
local addr, port = self:parseHost(v)
|
||||
self.parsedHosts[k] = { addr = addr, port = port }
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:pingHost(host)
|
||||
local ping = string.format(
|
||||
"%s %s -W %d -s %d%s %s > /dev/null 2>&1",
|
||||
self.pingCmd,
|
||||
self.pingParams,
|
||||
self.serviceConfig.connection_timeout,
|
||||
self.serviceConfig.icmp_packet_size,
|
||||
self.serviceConfig.iface and (" -I " .. self.serviceConfig.iface) or "",
|
||||
host
|
||||
)
|
||||
local retCode = os.execute(ping)
|
||||
|
||||
if self.debug then
|
||||
io.stdout:write(string.format(
|
||||
"--- Ping ---\ntime = %s\n%s\nretCode = %s\n", os.time(), ping, retCode)
|
||||
)
|
||||
io.stdout:flush()
|
||||
end
|
||||
|
||||
return retCode
|
||||
end
|
||||
|
||||
function InternetDetector:TCPConnectionToHost(host, port)
|
||||
local retCode = 1
|
||||
local saTable, errMsg, errNum = socket.getaddrinfo(host, port or self.serviceConfig.tcp_port)
|
||||
|
||||
if not saTable then
|
||||
if self.debug then
|
||||
io.stdout:write(string.format(
|
||||
"GETADDRINFO ERROR: %s, %s\n", errMsg, errNum))
|
||||
end
|
||||
else
|
||||
local family = saTable[1].family
|
||||
if family then
|
||||
local sock, errMsg, errNum = socket.socket(family, socket.SOCK_STREAM, 0)
|
||||
|
||||
if not sock then
|
||||
if self.debug then
|
||||
io.stdout:write(string.format(
|
||||
"SOCKET ERROR: %s, %s\n", errMsg, errNum))
|
||||
end
|
||||
return retCode
|
||||
end
|
||||
|
||||
socket.setsockopt(sock, socket.SOL_SOCKET,
|
||||
socket.SO_SNDTIMEO, self.serviceConfig.connection_timeout, 0)
|
||||
socket.setsockopt(sock, socket.SOL_SOCKET,
|
||||
socket.SO_RCVTIMEO, self.serviceConfig.connection_timeout, 0)
|
||||
|
||||
if self.serviceConfig.iface then
|
||||
local ok, errMsg, errNum = socket.setsockopt(sock, socket.SOL_SOCKET,
|
||||
socket.SO_BINDTODEVICE, self.serviceConfig.iface)
|
||||
if not ok then
|
||||
if self.debug then
|
||||
io.stdout:write(string.format(
|
||||
"SOCKET ERROR: %s, %s\n", errMsg, errNum))
|
||||
end
|
||||
|
||||
unistd.close(sock)
|
||||
return retCode
|
||||
end
|
||||
end
|
||||
|
||||
local success = socket.connect(sock, saTable[1])
|
||||
|
||||
if self.debug then
|
||||
if not success then
|
||||
io.stdout:write(string.format(
|
||||
"SOCKET CONNECT ERROR: %s\n", tostring(success)))
|
||||
end
|
||||
local sockTable, err_s, e_s = socket.getsockname(sock)
|
||||
local peerTable, err_p, e_p = socket.getpeername(sock)
|
||||
if not sockTable then
|
||||
sockTable = {}
|
||||
io.stdout:write(
|
||||
string.format("SOCKET ERROR: %s, %s\n", err_s, e_s))
|
||||
end
|
||||
if not peerTable then
|
||||
peerTable = {}
|
||||
io.stdout:write(
|
||||
string.format("SOCKET ERROR: %s, %s\n", err_p, e_p))
|
||||
end
|
||||
io.stdout:write(string.format(
|
||||
"--- TCP ---\ntime = %s\nconnection_timeout = %s\niface = %s\nhost:port = [%s]:%s\nsockname = [%s]:%s\npeername = [%s]:%s\nsuccess = %s\n",
|
||||
os.time(),
|
||||
self.serviceConfig.connection_timeout,
|
||||
tostring(self.serviceConfig.iface),
|
||||
host,
|
||||
port or self.serviceConfig.tcp_port,
|
||||
tostring(sockTable.addr),
|
||||
tostring(sockTable.port),
|
||||
tostring(peerTable.addr),
|
||||
tostring(peerTable.port),
|
||||
tostring(success))
|
||||
)
|
||||
io.stdout:flush()
|
||||
end
|
||||
|
||||
socket.shutdown(sock, socket.SHUT_RDWR)
|
||||
unistd.close(sock)
|
||||
retCode = success and 0 or 1
|
||||
end
|
||||
end
|
||||
return retCode
|
||||
end
|
||||
|
||||
function InternetDetector:checkHosts()
|
||||
local checkFunc = (self.serviceConfig.check_type == 1) and self.pingHost or self.TCPConnectionToHost
|
||||
local retCode = 1
|
||||
for k, v in ipairs(self.parsedHosts) do
|
||||
for i = 1, self.serviceConfig.connection_attempts do
|
||||
if checkFunc(self, v.addr, v.port) == 0 then
|
||||
retCode = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
if retCode == 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
return retCode
|
||||
end
|
||||
|
||||
function InternetDetector:breakMainLoop(signo)
|
||||
_RUNNING = false
|
||||
end
|
||||
|
||||
function InternetDetector:resetUiCounter(signo)
|
||||
self.uiCounter = 0
|
||||
end
|
||||
|
||||
function InternetDetector:mainLoop()
|
||||
signal.signal(signal.SIGTERM, function(signo) self:breakMainLoop(signo) end)
|
||||
signal.signal(signal.SIGINT, function(signo) self:breakMainLoop(signo) end)
|
||||
signal.signal(signal.SIGQUIT, function(signo) self:breakMainLoop(signo) end)
|
||||
signal.signal(signal.SIGUSR1, function(signo) self:resetUiCounter(signo) end)
|
||||
|
||||
local lastStatus, currentStatus, mTimeNow, mTimeDiff, mLastTime, uiTimeNow, uiLastTime
|
||||
local interval = self.serviceConfig.interval_up
|
||||
local counter = 0
|
||||
local onStart = true
|
||||
_RUNNING = true
|
||||
while _RUNNING do
|
||||
if counter == 0 or counter >= interval then
|
||||
currentStatus = self:checkHosts()
|
||||
if onStart or not stat.stat(self.statusFile) then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance))
|
||||
onStart = false
|
||||
end
|
||||
|
||||
if currentStatus == 0 then
|
||||
interval = self.serviceConfig.interval_up
|
||||
if lastStatus ~= nil and currentStatus ~= lastStatus then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance))
|
||||
self:writeLogMessage("notice", "Connected")
|
||||
end
|
||||
else
|
||||
interval = self.serviceConfig.interval_down
|
||||
if lastStatus ~= nil and currentStatus ~= lastStatus then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance))
|
||||
self:writeLogMessage("notice", "Disconnected")
|
||||
end
|
||||
end
|
||||
|
||||
counter = 0
|
||||
end
|
||||
|
||||
mTimeDiff = 0
|
||||
for _, e in ipairs(self.modules) do
|
||||
mTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec
|
||||
if mLastTime then
|
||||
mTimeDiff = mTimeDiff + mTimeNow - mLastTime
|
||||
else
|
||||
mTimeDiff = 1
|
||||
end
|
||||
mLastTime = mTimeNow
|
||||
e:run(currentStatus, lastStatus, mTimeDiff)
|
||||
end
|
||||
|
||||
local modulesStatus = {}
|
||||
for k, v in ipairs(self.modules) do
|
||||
if v.status ~= nil then
|
||||
modulesStatus[v.name] = v.status
|
||||
end
|
||||
end
|
||||
if next(modulesStatus) then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance, modulesStatus))
|
||||
end
|
||||
|
||||
lastStatus = currentStatus
|
||||
unistd.sleep(1)
|
||||
counter = counter + 1
|
||||
|
||||
if self.mode == 2 then
|
||||
uiTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec
|
||||
if uiLastTime then
|
||||
self.uiCounter = self.uiCounter + uiTimeNow - uiLastTime
|
||||
else
|
||||
self.uiCounter = self.uiCounter + 1
|
||||
end
|
||||
uiLastTime = uiTimeNow
|
||||
|
||||
if self.uiCounter >= self.uiRunTime then
|
||||
self:breakMainLoop(signal.SIGTERM)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:removeProcessFiles()
|
||||
os.remove(string.format(
|
||||
"%s/%s.%s.pid", self.commonDir, self.appName, self.serviceConfig.instance))
|
||||
os.remove(string.format(
|
||||
"%s/%s.%s.status", self.commonDir, self.appName, self.serviceConfig.instance))
|
||||
end
|
||||
|
||||
function InternetDetector:status()
|
||||
local ok, commonDir = pcall(dirent.files, self.commonDir)
|
||||
if ok then
|
||||
local appName = self.appName:gsub("-", "%%-")
|
||||
for item in commonDir do
|
||||
if item:match("^" .. appName .. ".-%.pid$") then
|
||||
return "running"
|
||||
end
|
||||
end
|
||||
end
|
||||
return "stoped"
|
||||
end
|
||||
|
||||
function InternetDetector:inetStatus()
|
||||
local inetStat = '{"instances":[]}'
|
||||
local ok, commonDir = pcall(dirent.files, self.commonDir)
|
||||
if ok then
|
||||
local appName = self.appName:gsub("-", "%%-")
|
||||
local lines = {}
|
||||
for item in commonDir do
|
||||
if item:match("^" .. appName .. ".-%.status$") then
|
||||
lines[#lines + 1] = self:readValueFromFile(
|
||||
string.format("%s/%s", self.commonDir, item))
|
||||
end
|
||||
end
|
||||
inetStat = '{"instances":[' .. table.concat(lines, ",") .. "]}"
|
||||
end
|
||||
return inetStat
|
||||
end
|
||||
|
||||
function InternetDetector:stopInstance(pidFile)
|
||||
local retVal
|
||||
if stat.stat(pidFile) then
|
||||
pidValue = self:readValueFromFile(pidFile)
|
||||
if pidValue then
|
||||
local ok, errMsg, errNum
|
||||
for i = 0, 10 do
|
||||
ok, errMsg, errNum = signal.kill(tonumber(pidValue), signal.SIGTERM)
|
||||
if ok then
|
||||
break
|
||||
end
|
||||
end
|
||||
if not ok then
|
||||
io.stderr:write(string.format(
|
||||
'Process stop error: %s (%s). PID: "%s"\n', errMsg, errNum, pidValue))
|
||||
end
|
||||
if errNum == 3 then
|
||||
os.remove(pidFile)
|
||||
end
|
||||
retVal = true
|
||||
end
|
||||
end
|
||||
if not pidValue then
|
||||
io.stderr:write(
|
||||
string.format('PID file "%s" does not exist. %s not running?\n',
|
||||
pidFile, self.appName))
|
||||
end
|
||||
return retVal
|
||||
end
|
||||
|
||||
function InternetDetector:stop()
|
||||
local appName = self.appName:gsub("-", "%%-")
|
||||
local success
|
||||
for i = 0, 10 do
|
||||
success = true
|
||||
local ok, commonDir = pcall(dirent.files, self.commonDir)
|
||||
if ok then
|
||||
for item in commonDir do
|
||||
if item:match("^" .. appName .. ".-%.pid$") then
|
||||
self:stopInstance(string.format("%s/%s", self.commonDir, item))
|
||||
success = false
|
||||
end
|
||||
end
|
||||
if success then
|
||||
break
|
||||
end
|
||||
unistd.sleep(1)
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:setSIGUSR()
|
||||
local appName = self.appName:gsub("-", "%%-")
|
||||
local ok, commonDir = pcall(dirent.files, self.commonDir)
|
||||
if ok then
|
||||
for item in commonDir do
|
||||
if item:match("^" .. appName .. ".-%.pid$") then
|
||||
pidValue = self:readValueFromFile(string.format("%s/%s", self.commonDir, item))
|
||||
if pidValue then
|
||||
signal.kill(tonumber(pidValue), signal.SIGUSR1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:preRun()
|
||||
-- Exit if internet-detector mode != (1 or 2)
|
||||
if self.mode ~= 1 and self.mode ~= 2 then
|
||||
io.stderr:write(string.format('Start failed, mode != (1 or 2)\n', self.appName))
|
||||
os.exit(0)
|
||||
end
|
||||
if stat.stat(self.pidFile) then
|
||||
io.stderr:write(
|
||||
string.format('PID file "%s" already exist. %s already running?\n',
|
||||
self.pidFile, self.appName))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function InternetDetector:run()
|
||||
local pidValue = unistd.getpid()
|
||||
self:writeValueToFile(self.pidFile, pidValue)
|
||||
if self.enableLogger then
|
||||
syslog.openlog(self.appName, syslog.LOG_PID, syslog.LOG_DAEMON)
|
||||
end
|
||||
self:writeLogMessage("info", "started")
|
||||
self:loadModules()
|
||||
|
||||
-- Loaded modules
|
||||
local modules = {}
|
||||
for _, v in ipairs(self.modules) do
|
||||
modules[#modules + 1] = string.format("%s", v.name)
|
||||
end
|
||||
if #modules > 0 then
|
||||
self:writeLogMessage(
|
||||
"info", string.format("Loaded modules: %s", table.concat(modules, ", "))
|
||||
)
|
||||
end
|
||||
|
||||
if self.debug then
|
||||
local function inspectTable()
|
||||
local tables = {}, f
|
||||
f = function(t, prefix)
|
||||
tables[t] = true
|
||||
for k, v in pairs(t) do
|
||||
io.stdout:write(string.format(
|
||||
"%s%s = %s\n", prefix, k, tostring(v))
|
||||
)
|
||||
if type(v) == "table" and not tables[v] then
|
||||
f(v, string.format("%s%s.", prefix, k))
|
||||
end
|
||||
end
|
||||
end
|
||||
return f
|
||||
end
|
||||
|
||||
io.stdout:write("--- Config ---\n")
|
||||
inspectTable()(self, "self.")
|
||||
io.stdout:flush()
|
||||
end
|
||||
|
||||
self:writeValueToFile(
|
||||
self.statusFile, self:statusJson(-1, self.serviceConfig.instance))
|
||||
|
||||
self:mainLoop()
|
||||
|
||||
self:removeProcessFiles()
|
||||
if self.enableLogger then
|
||||
self:writeLogMessage("info", "stoped")
|
||||
syslog.closelog()
|
||||
end
|
||||
end
|
||||
|
||||
function InternetDetector:noDaemon()
|
||||
if not self:preRun() then
|
||||
return
|
||||
end
|
||||
self:run()
|
||||
end
|
||||
|
||||
function InternetDetector:daemon()
|
||||
if not self:preRun() then
|
||||
return
|
||||
end
|
||||
-- UNIX double fork
|
||||
if unistd.fork() == 0 then
|
||||
unistd.setpid("s")
|
||||
if unistd.fork() == 0 then
|
||||
unistd.chdir("/")
|
||||
stat.umask(0)
|
||||
local devnull = fcntl.open("/dev/null", fcntl.O_RDWR)
|
||||
io.stdout:flush()
|
||||
io.stderr:flush()
|
||||
unistd.dup2(devnull, 0) -- io.stdin
|
||||
unistd.dup2(devnull, 1) -- io.stdout
|
||||
unistd.dup2(devnull, 2) -- io.stderr
|
||||
self:run()
|
||||
unistd.close(devnull)
|
||||
end
|
||||
os.exit(0)
|
||||
end
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
function InternetDetector:setServiceConfig(instance)
|
||||
if self:loadUCIConfig("instance", instance) then
|
||||
self:parseHosts()
|
||||
if self.mode == 2 then
|
||||
self.enableLogger = false
|
||||
self.noModules = true
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return InternetDetector
|
@ -38,12 +38,17 @@ function Module:resetLeds()
|
||||
end
|
||||
|
||||
function Module:init(t)
|
||||
self.ledName = t.led_name
|
||||
if not self.ledName then
|
||||
if not t.led_name then
|
||||
return
|
||||
else
|
||||
self.ledName = t.led_name
|
||||
end
|
||||
if t.led_action_1 ~= nil then
|
||||
self.ledAction1 = tonumber(t.led_action_1)
|
||||
end
|
||||
if t.led_action_2 ~= nil then
|
||||
self.ledAction2 = tonumber(t.led_action_2)
|
||||
end
|
||||
self.ledAction1 = tonumber(t.led_action_1)
|
||||
self.ledAction2 = tonumber(t.led_action_2)
|
||||
self._ledDir = string.format("%s/%s", self.sysLedsDir, self.ledName)
|
||||
self._ledMaxBrightnessFile = string.format("%s/max_brightness", self._ledDir)
|
||||
self._ledBrightnessFile = string.format("%s/brightness", self._ledDir)
|
@ -8,9 +8,9 @@ local Module = {
|
||||
syslog = function(level, msg) return true end,
|
||||
writeValue = function(filePath, str) return false end,
|
||||
readValue = function(filePath) return nil end,
|
||||
iface = false,
|
||||
attempts = 0,
|
||||
deadPeriod = 0,
|
||||
deadPeriod = 900,
|
||||
attempts = 1,
|
||||
iface = nil,
|
||||
restartTimeout = 0,
|
||||
status = nil,
|
||||
_attemptsCounter = 0,
|
||||
@ -22,6 +22,9 @@ function Module:toggleFunc(flag)
|
||||
end
|
||||
|
||||
function Module:toggleDevice(flag)
|
||||
if not self.iface then
|
||||
return
|
||||
end
|
||||
local ip = "/sbin/ip"
|
||||
if unistd.access(ip, "x") then
|
||||
return os.execute(string.format(
|
||||
@ -31,6 +34,9 @@ function Module:toggleDevice(flag)
|
||||
end
|
||||
|
||||
function Module:toggleIface(flag)
|
||||
if not self.iface then
|
||||
return
|
||||
end
|
||||
return os.execute(
|
||||
string.format("%s %s", (flag and "/sbin/ifup" or "/sbin/ifdown"), self.iface)
|
||||
)
|
||||
@ -59,9 +65,15 @@ function Module:init(t)
|
||||
self.toggleFunc = self.toggleDevice
|
||||
end
|
||||
end
|
||||
self.attempts = tonumber(t.attempts)
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
self.restartTimeout = tonumber(t.restart_timeout)
|
||||
if t.attempts ~= nil then
|
||||
self.attempts = tonumber(t.attempts)
|
||||
end
|
||||
if t.dead_period ~= nil then
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
end
|
||||
if t.restart_timeout ~= nil then
|
||||
self.restartTimeout = tonumber(t.restart_timeout)
|
||||
end
|
||||
end
|
||||
|
||||
function Module:run(currentStatus, lastStatus, timeDiff)
|
@ -20,7 +20,6 @@ local Module = {
|
||||
runInterval = 600,
|
||||
runIntervalFailed = 60,
|
||||
timeout = 3,
|
||||
reqAttempts = 3,
|
||||
providers = {
|
||||
opendns1 = {
|
||||
name = "opendns1", host = "myip.opendns.com",
|
||||
@ -333,13 +332,13 @@ function Module:resolveIP()
|
||||
end
|
||||
|
||||
function Module:init(t)
|
||||
if t.interval then
|
||||
if t.interval ~= nil then
|
||||
self.runInterval = tonumber(t.interval)
|
||||
end
|
||||
if t.timeout then
|
||||
if t.timeout ~= nil then
|
||||
self.timeout = tonumber(t.timeout)
|
||||
end
|
||||
if t.provider then
|
||||
if t.provider ~= nil then
|
||||
self._provider = self.providers[t.provider]
|
||||
else
|
||||
self._provider = self.providers.opendns1
|
||||
@ -347,11 +346,13 @@ function Module:init(t)
|
||||
if self.config.configDir then
|
||||
self.ipScript = string.format(
|
||||
"%s/public-ip-script.%s", self.config.configDir, self.config.serviceConfig.instance)
|
||||
if t.enable_ip_script then
|
||||
if t.enable_ip_script ~= nil then
|
||||
self.enableIpScript = (tonumber(t.enable_ip_script) ~= 0)
|
||||
end
|
||||
end
|
||||
self._qtype = (tonumber(t.qtype) ~= 0)
|
||||
if t.qtype ~= nil then
|
||||
self._qtype = (tonumber(t.qtype) ~= 0)
|
||||
end
|
||||
self._currentIp = nil
|
||||
self._DNSPacket = nil
|
||||
self._interval = self.runInterval
|
@ -8,8 +8,8 @@ local Module = {
|
||||
syslog = function(level, msg) return true end,
|
||||
writeValue = function(filePath, str) return false end,
|
||||
readValue = function(filePath) return nil end,
|
||||
deadPeriod = 0,
|
||||
forceRebootDelay = 0,
|
||||
deadPeriod = 3600,
|
||||
forceRebootDelay = 300,
|
||||
status = nil,
|
||||
_deadCounter = 0,
|
||||
}
|
||||
@ -26,8 +26,12 @@ function Module:rebootDevice()
|
||||
end
|
||||
|
||||
function Module:init(t)
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
self.forceRebootDelay = tonumber(t.force_reboot_delay)
|
||||
if t.dead_period ~= nil then
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
end
|
||||
if t.force_reboot_delay ~= nil then
|
||||
self.forceRebootDelay = tonumber(t.force_reboot_delay)
|
||||
end
|
||||
end
|
||||
|
||||
function Module:run(currentStatus, lastStatus, timeDiff)
|
@ -3,7 +3,7 @@ local unistd = require("posix.unistd")
|
||||
|
||||
local Module = {
|
||||
name = "mod_user_scripts",
|
||||
runPrio = 70,
|
||||
runPrio = 80,
|
||||
config = {},
|
||||
syslog = function(level, msg) return true end,
|
||||
writeValue = function(filePath, str) return false end,
|
||||
@ -26,8 +26,12 @@ function Module:runExternalScript(scriptPath)
|
||||
end
|
||||
|
||||
function Module:init(t)
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
self.alivePeriod = tonumber(t.alive_period)
|
||||
if t.dead_period ~= nil then
|
||||
self.deadPeriod = tonumber(t.dead_period)
|
||||
end
|
||||
if t.alive_period ~= nil then
|
||||
self.alivePeriod = tonumber(t.alive_period)
|
||||
end
|
||||
if self.config.configDir then
|
||||
self.upScript = string.format(
|
||||
"%s/up-script.%s", self.config.configDir, self.config.serviceConfig.instance)
|
@ -4,7 +4,7 @@
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=1.2-0
|
||||
PKG_VERSION:=1.3-0
|
||||
LUCI_TITLE:=LuCI support for internet-detector
|
||||
LUCI_DEPENDS:=+internet-detector
|
||||
LUCI_PKGARCH:=all
|
||||
|
@ -129,10 +129,8 @@ var Timefield = ui.Textfield.extend({
|
||||
|
||||
return view.extend({
|
||||
appName : 'internet-detector',
|
||||
execPath : '/usr/bin/internet-detector',
|
||||
configDir : '/etc/internet-detector',
|
||||
ledsPath : '/sys/class/leds',
|
||||
mtaPath : '/usr/bin/mailsend',
|
||||
pollInterval : L.env.pollinterval,
|
||||
appStatus : 'stoped',
|
||||
initStatus : null,
|
||||
@ -144,7 +142,9 @@ return view.extend({
|
||||
defaultHosts : [ '8.8.8.8', '1.1.1.1' ],
|
||||
leds : [],
|
||||
mm : false,
|
||||
mta : false,
|
||||
mmInit : false,
|
||||
email : false,
|
||||
emailExec : false,
|
||||
|
||||
callInitStatus: rpc.declare({
|
||||
object: 'luci',
|
||||
@ -185,6 +185,18 @@ return view.extend({
|
||||
});
|
||||
},
|
||||
|
||||
callInit: rpc.declare({
|
||||
object: 'luci.internet-detector',
|
||||
method: 'Init',
|
||||
expect: { '': {} }
|
||||
}),
|
||||
|
||||
getInit() {
|
||||
return this.callInit().then(data => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
callUIPoll: rpc.declare({
|
||||
object: 'luci.internet-detector',
|
||||
method: 'UIPoll',
|
||||
@ -197,6 +209,30 @@ return view.extend({
|
||||
});
|
||||
},
|
||||
|
||||
callStatus: rpc.declare({
|
||||
object: 'luci.internet-detector',
|
||||
method: 'Status',
|
||||
expect: { '': {} }
|
||||
}),
|
||||
|
||||
getStatus() {
|
||||
return this.callStatus().then(data => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
callInetStatus: rpc.declare({
|
||||
object: 'luci.internet-detector',
|
||||
method: 'InetStatus',
|
||||
expect: { '': {} }
|
||||
}),
|
||||
|
||||
getInetStatus() {
|
||||
return this.callInetStatus().then(data => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
setInternetStatus() {
|
||||
this.inetStatusArea.innerHTML = '';
|
||||
|
||||
@ -240,25 +276,13 @@ return view.extend({
|
||||
};
|
||||
},
|
||||
|
||||
inetStatusFromJson(res) {
|
||||
let inetStatData = null;
|
||||
if(res.code === 0) {
|
||||
try {
|
||||
inetStatData = JSON.parse(res.stdout.trim());
|
||||
} catch(e) {};
|
||||
};
|
||||
return inetStatData;
|
||||
},
|
||||
|
||||
servicePoll() {
|
||||
return Promise.all([
|
||||
fs.exec(this.execPath, [ 'status' ]),
|
||||
fs.exec(this.execPath, [ 'inet-status' ]),
|
||||
this.getStatus(),
|
||||
this.getInetStatus(),
|
||||
]).then(stat => {
|
||||
let curAppStatus = (stat[0].code === 0) ? stat[0].stdout.trim() : null;
|
||||
let inetStatData = this.inetStatusFromJson(stat[1]);
|
||||
this.appStatus = curAppStatus;
|
||||
this.inetStatus = inetStatData;
|
||||
this.appStatus = stat[0].status;
|
||||
this.inetStatus = stat[1];
|
||||
this.setInternetStatus();
|
||||
}).catch(e => {
|
||||
this.appStatus = 'stoped';
|
||||
@ -467,11 +491,10 @@ return view.extend({
|
||||
|
||||
load() {
|
||||
return Promise.all([
|
||||
fs.exec(this.execPath, [ 'status' ]),
|
||||
this.getStatus(),
|
||||
this.getInitStatus(),
|
||||
L.resolveDefault(fs.list(this.ledsPath), []),
|
||||
this.callInitStatus('modemmanager'),
|
||||
L.resolveDefault(fs.stat(this.mtaPath), null),
|
||||
this.getInit(),
|
||||
uci.load(this.appName),
|
||||
]).catch(e => {
|
||||
ui.addNotification(null, E('p', _('An error has occurred') + ': %s'.format(e.message)));
|
||||
@ -482,16 +505,24 @@ return view.extend({
|
||||
if(!data) {
|
||||
return;
|
||||
};
|
||||
this.appStatus = (data[0].code === 0) ? data[0].stdout.trim() : null;
|
||||
this.initStatus = data[1];
|
||||
this.leds = data[2];
|
||||
if(data[3].modemmanager) {
|
||||
this.mm = true;
|
||||
this.appStatus = (data[0].code === 0) ? data[0].stdout.trim() : null;
|
||||
this.initStatus = data[1];
|
||||
this.leds = data[2];
|
||||
if(data[3]) {
|
||||
if(data[3].mm_mod) {
|
||||
this.mm = true;
|
||||
};
|
||||
if(data[3].mm_init) {
|
||||
this.mmInit = true;
|
||||
};
|
||||
if(data[3].email_mod) {
|
||||
this.email = true;
|
||||
};
|
||||
if(data[3].email_exec) {
|
||||
this.emailExec = true;
|
||||
};
|
||||
};
|
||||
if(data[4]) {
|
||||
this.mta = true;
|
||||
};
|
||||
this.currentAppMode = uci.get(this.appName, 'config', 'mode');
|
||||
this.currentAppMode = uci.get(this.appName, 'config', 'mode');
|
||||
|
||||
let s, o, ss;
|
||||
let m = new form.Map(this.appName,
|
||||
@ -539,6 +570,7 @@ return view.extend({
|
||||
_('Service: detector always runs as a system service.'),
|
||||
_('Web UI only: detector works only when the Web UI is open (UI detector).')
|
||||
);
|
||||
mode.default = '0';
|
||||
|
||||
|
||||
/* Service instances configuration */
|
||||
@ -551,6 +583,7 @@ return view.extend({
|
||||
_('Write messages to the system log.')
|
||||
);
|
||||
o.rmempty = false;
|
||||
o.default = '1';
|
||||
};
|
||||
|
||||
s = m.section(form.GridSection, 'instance');
|
||||
@ -591,7 +624,6 @@ return view.extend({
|
||||
'hosts', _('Hosts'),
|
||||
_('Hosts to check Internet availability. Hosts are polled (in list order) until at least one of them responds.')
|
||||
);
|
||||
//o.datatype = 'or(host,hostport)';
|
||||
o.datatype = 'or(or(host,hostport),ipaddrport(1))';
|
||||
o.default = this.defaultHosts;
|
||||
o.rmempty = false;
|
||||
@ -692,13 +724,17 @@ return view.extend({
|
||||
s.tab('led_control', _('LED control'));
|
||||
s.tab('reboot_device', _('Reboot device'));
|
||||
s.tab('restart_network', _('Restart network'));
|
||||
s.tab('restart_modem', _('Restart modem'));
|
||||
if(this.mm) {
|
||||
s.tab('restart_modem', _('Restart modem'));
|
||||
};
|
||||
};
|
||||
|
||||
s.tab('public_ip', _('Public IP address'));
|
||||
|
||||
if(this.currentAppMode !== '2') {
|
||||
s.tab('email', _('Email notification'));
|
||||
if(this.email) {
|
||||
s.tab('email', _('Email notification'));
|
||||
};
|
||||
s.tab('user_scripts', _('User scripts'));
|
||||
};
|
||||
|
||||
@ -777,7 +813,7 @@ return view.extend({
|
||||
// dead_period
|
||||
o = s.taboption('reboot_device', this.CBITimeInput,
|
||||
'mod_reboot_dead_period', _('Dead period'),
|
||||
_('Longest period of time without Internet access until the device is rebooted.')
|
||||
_('Period of time without Internet access until the device is rebooted.')
|
||||
);
|
||||
o.default = '3600';
|
||||
o.rmempty = false;
|
||||
@ -816,7 +852,7 @@ return view.extend({
|
||||
// dead_period
|
||||
o = s.taboption('restart_network', this.CBITimeInput,
|
||||
'mod_network_restart_dead_period', _('Dead period'),
|
||||
_('Longest period of time without Internet access before network restart.')
|
||||
_('Period of time without Internet access before network restart.')
|
||||
);
|
||||
o.default = '900';
|
||||
o.rmempty = false;
|
||||
@ -863,57 +899,56 @@ return view.extend({
|
||||
|
||||
// Restart modem
|
||||
|
||||
o = s.taboption('restart_modem', form.DummyValue, '_dummy');
|
||||
o.rawhtml = true;
|
||||
o.default = '<div class="cbi-section-descr">' +
|
||||
_('Modem will be restarted when the Internet is disconnected.') +
|
||||
'</div>';
|
||||
o.modalonly = true;
|
||||
|
||||
if(this.mm) {
|
||||
if(this.mmInit) {
|
||||
o = s.taboption('restart_modem', form.DummyValue, '_dummy');
|
||||
o.rawhtml = true;
|
||||
o.default = '<div class="cbi-section-descr">' +
|
||||
_('Modem will be restarted when the Internet is disconnected.') +
|
||||
'</div>';
|
||||
o.modalonly = true;
|
||||
|
||||
// enabled
|
||||
o = s.taboption('restart_modem', form.Flag, 'mod_modem_restart_enabled',
|
||||
_('Enabled'),
|
||||
);
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
// enabled
|
||||
o = s.taboption('restart_modem', form.Flag, 'mod_modem_restart_enabled',
|
||||
_('Enabled'),
|
||||
);
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
|
||||
// dead_period
|
||||
o = s.taboption('restart_modem', this.CBITimeInput,
|
||||
'mod_modem_restart_dead_period', _('Dead period'),
|
||||
_('Longest period of time without Internet access before modem restart.')
|
||||
);
|
||||
o.default = '600';
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
// dead_period
|
||||
o = s.taboption('restart_modem', this.CBITimeInput,
|
||||
'mod_modem_restart_dead_period', _('Dead period'),
|
||||
_('Period of time without Internet access before modem restart.')
|
||||
);
|
||||
o.default = '600';
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
|
||||
// any_band
|
||||
o = s.taboption('restart_modem', form.Flag,
|
||||
'mod_modem_restart_any_band', _('Unlock modem bands'),
|
||||
_('Set the modem to be allowed to use any band.')
|
||||
);
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
// any_band
|
||||
o = s.taboption('restart_modem', form.Flag,
|
||||
'mod_modem_restart_any_band', _('Unlock modem bands'),
|
||||
_('Set the modem to be allowed to use any band.')
|
||||
);
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
|
||||
// iface
|
||||
o = s.taboption('restart_modem', widgets.NetworkSelect, 'mod_modem_restart_iface',
|
||||
_('Interface'),
|
||||
_('ModemManger interface. If specified, it will be restarted after restarting ModemManager.')
|
||||
);
|
||||
o.multiple = false;
|
||||
o.nocreate = true;
|
||||
o.modalonly = true;
|
||||
|
||||
} else {
|
||||
o = s.taboption('restart_modem', form.DummyValue, '_dummy');
|
||||
o.rawhtml = true;
|
||||
o.default = '<label class="cbi-value-title"></label><div class="cbi-value-field"><em>' +
|
||||
_('ModemManager is not available...') +
|
||||
'</em></div>';
|
||||
o.modalonly = true;
|
||||
// iface
|
||||
o = s.taboption('restart_modem', widgets.NetworkSelect, 'mod_modem_restart_iface',
|
||||
_('Interface'),
|
||||
_('ModemManger interface. If specified, it will be restarted after restarting ModemManager.')
|
||||
);
|
||||
o.multiple = false;
|
||||
o.nocreate = true;
|
||||
o.modalonly = true;
|
||||
} else {
|
||||
o = s.taboption('restart_modem', form.DummyValue, '_dummy');
|
||||
o.rawhtml = true;
|
||||
o.default = '<label class="cbi-value-title"></label><div class="cbi-value-field"><em>' +
|
||||
_('ModemManager is not available...') +
|
||||
'</em></div>';
|
||||
o.modalonly = true;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// Public IP address
|
||||
@ -996,97 +1031,118 @@ return view.extend({
|
||||
);
|
||||
o.modalonly = true;
|
||||
|
||||
|
||||
// Email notification
|
||||
|
||||
o = s.taboption('email', form.DummyValue, '_dummy');
|
||||
o.rawhtml = true;
|
||||
o.default = '<div class="cbi-section-descr">' +
|
||||
_('An email will be sent when the internet connection is restored after being disconnected.') +
|
||||
'</div>';
|
||||
o.modalonly = true;
|
||||
if(this.email) {
|
||||
if(this.emailExec) {
|
||||
o = s.taboption('email', form.DummyValue, '_dummy');
|
||||
o.rawhtml = true;
|
||||
o.default = '<div class="cbi-section-descr">' +
|
||||
_('An email will be sent when connected or disconnected from the Internet.') +
|
||||
'</div>';
|
||||
o.modalonly = true;
|
||||
|
||||
if(this.mta) {
|
||||
// enabled
|
||||
o = s.taboption('email', form.Flag, 'mod_email_enabled',
|
||||
_('Enabled'));
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
|
||||
// enabled
|
||||
o = s.taboption('email', form.Flag, 'mod_email_enabled',
|
||||
_('Enabled'));
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
// mode
|
||||
o = s.taboption('email', form.ListValue,
|
||||
'mod_email_mode', _('When email will be sent')
|
||||
);
|
||||
o.modalonly = true;
|
||||
o.value(0, _('after connection'));
|
||||
o.value(1, _('after disconnection'));
|
||||
o.value(2, _('after connection or disconnection'));
|
||||
o.default = '0';
|
||||
|
||||
// alive_period
|
||||
o = s.taboption('email', this.CBITimeInput,
|
||||
'mod_email_alive_period', _('Alive period'),
|
||||
_('Longest period of time after connecting to the Internet before sending a message.')
|
||||
);
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
// alive_period
|
||||
o = s.taboption('email', this.CBITimeInput,
|
||||
'mod_email_alive_period', _('Alive period'),
|
||||
_('Period of time after connecting to the Internet before sending a message.')
|
||||
);
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
o.depends({ 'mod_email_mode': '0' });
|
||||
o.depends({ 'mod_email_mode': '2' });
|
||||
o.default = '0';
|
||||
|
||||
// host_alias
|
||||
o = s.taboption('email', form.Value, 'mod_email_host_alias',
|
||||
_('Host alias'),
|
||||
_('Host identifier in messages. If not specified, hostname will be used.'));
|
||||
o.modalonly = true;
|
||||
// dead_period
|
||||
o = s.taboption('email', this.CBITimeInput,
|
||||
'mod_email_dead_period', _('Dead period'),
|
||||
_('Period of time after disconnecting from Internet before sending a message.')
|
||||
);
|
||||
o.rmempty = false;
|
||||
o.modalonly = true;
|
||||
o.depends({ 'mod_email_mode': '1' });
|
||||
o.depends({ 'mod_email_mode': '2' });
|
||||
o.default = '0';
|
||||
|
||||
// mail_recipient
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_recipient', _('Recipient'));
|
||||
o.description = _('Email address of the recipient.');
|
||||
o.modalonly = true;
|
||||
// host_alias
|
||||
o = s.taboption('email', form.Value, 'mod_email_host_alias',
|
||||
_('Host alias'),
|
||||
_('Host identifier in messages. If not specified, hostname will be used.'));
|
||||
o.modalonly = true;
|
||||
|
||||
// mail_sender
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_sender', _('Sender'));
|
||||
o.description = _('Email address of the sender.');
|
||||
o.modalonly = true;
|
||||
// mail_recipient
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_recipient', _('Recipient'));
|
||||
o.description = _('Email address of the recipient.');
|
||||
o.modalonly = true;
|
||||
|
||||
// mail_user
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_user', _('User'));
|
||||
o.description = _('Username for SMTP authentication.');
|
||||
o.modalonly = true;
|
||||
// mail_sender
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_sender', _('Sender'));
|
||||
o.description = _('Email address of the sender.');
|
||||
o.modalonly = true;
|
||||
|
||||
// mail_password
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_password', _('Password'));
|
||||
o.description = _('Password for SMTP authentication.');
|
||||
o.password = true;
|
||||
o.modalonly = true;
|
||||
// mail_user
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_user', _('User'));
|
||||
o.description = _('Username for SMTP authentication.');
|
||||
o.modalonly = true;
|
||||
|
||||
// mail_smtp
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_smtp', _('SMTP server'));
|
||||
o.description = _('Hostname/IP address of the SMTP server.');
|
||||
o.datatype = 'host';
|
||||
o.default = 'smtp.gmail.com';
|
||||
o.modalonly = true;
|
||||
// mail_password
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_password', _('Password'));
|
||||
o.description = _('Password for SMTP authentication.');
|
||||
o.password = true;
|
||||
o.modalonly = true;
|
||||
|
||||
// mail_smtp_port
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_smtp_port', _('SMTP server port'));
|
||||
o.datatype = 'port';
|
||||
o.default = '587';
|
||||
o.modalonly = true;
|
||||
// mail_smtp
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_smtp', _('SMTP server'));
|
||||
o.description = _('Hostname/IP address of the SMTP server.');
|
||||
o.datatype = 'host';
|
||||
o.modalonly = true;
|
||||
|
||||
// mail_security
|
||||
o = s.taboption('email', form.ListValue,
|
||||
'mod_email_mail_security', _('Security'));
|
||||
o.description = '%s<br />%s'.format(
|
||||
_('TLS: use STARTTLS if the server supports it.'),
|
||||
_('SSL: SMTP over SSL.'),
|
||||
);
|
||||
o.value('tls', 'TLS');
|
||||
o.value('ssl', 'SSL');
|
||||
o.default = 'tls';
|
||||
o.modalonly = true;
|
||||
// mail_smtp_port
|
||||
o = s.taboption('email', form.Value,
|
||||
'mod_email_mail_smtp_port', _('SMTP server port'));
|
||||
o.datatype = 'port';
|
||||
o.modalonly = true;
|
||||
|
||||
} else {
|
||||
o = s.taboption('email', form.DummyValue, '_dummy');
|
||||
o.rawhtml = true;
|
||||
o.default = '<label class="cbi-value-title"></label><div class="cbi-value-field"><em>' +
|
||||
_('Mailsend is not available...') +
|
||||
'</em></div>';
|
||||
o.modalonly = true;
|
||||
// mail_security
|
||||
o = s.taboption('email', form.ListValue,
|
||||
'mod_email_mail_security', _('Security'));
|
||||
o.description = '%s<br />%s'.format(
|
||||
_('TLS: use STARTTLS if the server supports it.'),
|
||||
_('SSL: SMTP over SSL.'),
|
||||
);
|
||||
o.value('tls', 'TLS');
|
||||
o.value('ssl', 'SSL');
|
||||
o.default = 'tls';
|
||||
o.modalonly = true;
|
||||
} else {
|
||||
o = s.taboption('email', form.DummyValue, '_dummy');
|
||||
o.rawhtml = true;
|
||||
o.default = '<label class="cbi-value-title"></label><div class="cbi-value-field"><em>' +
|
||||
_('Mailsend is not available...') +
|
||||
'</em></div>';
|
||||
o.modalonly = true;
|
||||
};
|
||||
};
|
||||
|
||||
// User scripts
|
||||
@ -1116,7 +1172,7 @@ return view.extend({
|
||||
// alive_period
|
||||
o = s.taboption('user_scripts', this.CBITimeInput,
|
||||
'mod_user_scripts_alive_period', _('Alive period'),
|
||||
_('Longest period of time after connecting to Internet before "up-script" runs.')
|
||||
_('Period of time after connecting to Internet before "up-script" runs.')
|
||||
);
|
||||
o.default = '0';
|
||||
o.rmempty = false;
|
||||
@ -1134,7 +1190,7 @@ return view.extend({
|
||||
// dead_period
|
||||
o = s.taboption('user_scripts', this.CBITimeInput,
|
||||
'mod_user_scripts_dead_period', _('Dead period'),
|
||||
_('Longest period of time after disconnecting from Internet before "down-script" runs.')
|
||||
_('Period of time after disconnecting from Internet before "down-script" runs.')
|
||||
);
|
||||
o.default = '0';
|
||||
o.rmempty = false;
|
||||
@ -1156,7 +1212,6 @@ return view.extend({
|
||||
},
|
||||
|
||||
handleSaveApply(ev, mode) {
|
||||
poll.stop();
|
||||
return this.handleSave(ev).then(() => {
|
||||
ui.changes.apply(mode == '0');
|
||||
window.setTimeout(() => this.serviceRestart(), 3000);
|
||||
|
@ -57,7 +57,6 @@ document.head.append(E('style', {'type': 'text/css'},
|
||||
return baseclass.extend({
|
||||
title : _('Internet'),
|
||||
appName : 'internet-detector',
|
||||
execPath : '/usr/bin/internet-detector',
|
||||
currentAppMode : null,
|
||||
inetStatus : null,
|
||||
|
||||
@ -73,14 +72,16 @@ return baseclass.extend({
|
||||
});
|
||||
},
|
||||
|
||||
inetStatusFromJson(res) {
|
||||
let inetStatData = null;
|
||||
if(res.code === 0) {
|
||||
try {
|
||||
inetStatData = JSON.parse(res.stdout.trim());
|
||||
} catch(e) {};
|
||||
};
|
||||
return inetStatData;
|
||||
callInetStatus: rpc.declare({
|
||||
object: 'luci.internet-detector',
|
||||
method: 'InetStatus',
|
||||
expect: { '': {} }
|
||||
}),
|
||||
|
||||
getInetStatus() {
|
||||
return this.callInetStatus().then(data => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
async load() {
|
||||
@ -94,7 +95,7 @@ return baseclass.extend({
|
||||
return this.getUIPoll();
|
||||
}
|
||||
else if(this.currentAppMode === '1') {
|
||||
return L.resolveDefault(fs.exec(this.execPath, [ 'inet-status' ]), null);
|
||||
return L.resolveDefault(this.getInetStatus(), null);
|
||||
};
|
||||
},
|
||||
|
||||
@ -102,9 +103,7 @@ return baseclass.extend({
|
||||
if(this.currentAppMode === '0') {
|
||||
return;
|
||||
}
|
||||
else if(this.currentAppMode === '1' && data) {
|
||||
data = this.inetStatusFromJson(data);
|
||||
};
|
||||
|
||||
this.inetStatus = data;
|
||||
|
||||
let inetStatusArea = E('div', {});
|
||||
|
@ -38,10 +38,8 @@ msgstr "Интервал при подключении"
|
||||
msgid "Alive period"
|
||||
msgstr "Период после подключения"
|
||||
|
||||
msgid ""
|
||||
"An email will be sent when the internet connection is restored after being "
|
||||
"disconnected."
|
||||
msgstr "Сообщение будет отправлено при восстановлении соединения с Интернет после отключения."
|
||||
msgid "An email will be sent when connected or disconnected from the Internet."
|
||||
msgstr "Сообщение будет отправлено при подключении или отключении от Интернет."
|
||||
|
||||
msgid "An error has occurred"
|
||||
msgstr "Произошла ошибка"
|
||||
@ -221,41 +219,8 @@ msgstr "Управление LED"
|
||||
msgid "Loading"
|
||||
msgstr "Загрузка"
|
||||
|
||||
msgid ""
|
||||
"Longest period of time after connecting to Internet before \"up-script\" "
|
||||
"runs."
|
||||
msgstr ""
|
||||
"Максимальный промежуток времени после подключения к Интернет перед запуском "
|
||||
"\"up-script\"."
|
||||
|
||||
msgid ""
|
||||
"Longest period of time after connecting to the Internet before sending a "
|
||||
"message."
|
||||
msgstr "Максимальный промежуток времени после подключения Интернет перед отправкой сообщения."
|
||||
|
||||
msgid ""
|
||||
"Longest period of time after disconnecting from Internet before \"down-script"
|
||||
"\" runs."
|
||||
msgstr ""
|
||||
"Максимальный промежуток времени после отключения Интернет перед запуском "
|
||||
"\"down-script\"."
|
||||
|
||||
msgid "Longest period of time without Internet access before modem restart."
|
||||
msgstr ""
|
||||
"Максимальное время отсутствия доступа в Интренет перед перезапуском модема."
|
||||
|
||||
msgid "Longest period of time without Internet access before network restart."
|
||||
msgstr ""
|
||||
"Максимальное время отсутствия доступа в Интренет перед перезапуском сети."
|
||||
|
||||
msgid ""
|
||||
"Longest period of time without Internet access until the device is rebooted."
|
||||
msgstr ""
|
||||
"Максимальное время отсутствия доступа в Интренет перед перезагрузкой "
|
||||
"устройства."
|
||||
|
||||
msgid "Mailsend is not available..."
|
||||
msgstr "Mailsend недоступен..."
|
||||
msgstr "Mailsend не доступен..."
|
||||
|
||||
msgid "Main settings"
|
||||
msgstr "Основные настройки"
|
||||
@ -273,12 +238,12 @@ msgstr ""
|
||||
msgid "Maximum timeout for waiting for a response from the host."
|
||||
msgstr "Максимальный таймаут ожидания ответа от хоста."
|
||||
|
||||
msgid "ModemManager is not available..."
|
||||
msgstr "ModemManager не доступен..."
|
||||
|
||||
msgid "Modem will be restarted when the Internet is disconnected."
|
||||
msgstr "Модем будет перезапущен при отключении Интернет."
|
||||
|
||||
msgid "ModemManager is not available..."
|
||||
msgstr "ModemManager недоступен..."
|
||||
|
||||
msgid ""
|
||||
"ModemManger interface. If specified, it will be restarted after restarting "
|
||||
"ModemManager."
|
||||
@ -320,6 +285,35 @@ msgstr "Пароль"
|
||||
msgid "Password for SMTP authentication."
|
||||
msgstr "Пароль для SMTP-аутентификации."
|
||||
|
||||
msgid ""
|
||||
"Period of time after connecting to Internet before \"up-script\" runs."
|
||||
msgstr ""
|
||||
"Период времени после подключения к Интернет перед запуском \"up-script\"."
|
||||
|
||||
msgid ""
|
||||
"Period of time after connecting to the Internet before sending a message."
|
||||
msgstr "Период времени после подключения к Интернет перед отправкой сообщения."
|
||||
|
||||
msgid ""
|
||||
"Period of time after disconnecting from Internet before \"down-script\" runs."
|
||||
msgstr ""
|
||||
"Период времени после отключения от Интернет перед запуском \"down-script\"."
|
||||
|
||||
msgid ""
|
||||
"Period of time after disconnecting from Internet before sending a message."
|
||||
msgstr "Период времени отсутствия доступа в Интренет перед отправкой сообщения."
|
||||
|
||||
msgid "Period of time without Internet access before modem restart."
|
||||
msgstr "Период времени отсутствия доступа в Интренет перед перезапуском модема."
|
||||
|
||||
msgid "Period of time without Internet access before network restart."
|
||||
msgstr "Период времени отсутствия доступа в Интренет перед перезапуском сети."
|
||||
|
||||
msgid ""
|
||||
"Period of time without Internet access until the device is rebooted."
|
||||
msgstr ""
|
||||
"Период времени отсутствия доступа в Интренет перед перезагрузкой устройства."
|
||||
|
||||
msgid "Polling interval"
|
||||
msgstr "Интервал опроса"
|
||||
|
||||
@ -468,12 +462,24 @@ msgstr ""
|
||||
"Только web-интерфейс: детектор работает только в web-интерфейсе (UI "
|
||||
"детектор)."
|
||||
|
||||
msgid "When email will be sent"
|
||||
msgstr "Когда будет отправлено сообщение"
|
||||
|
||||
msgid "Windows: 32 bytes"
|
||||
msgstr "Windows: 32 байта"
|
||||
|
||||
msgid "Write messages to the system log."
|
||||
msgstr "Записывать сообщения в системный журнал."
|
||||
|
||||
msgid "after connection"
|
||||
msgstr "после подключения"
|
||||
|
||||
msgid "after disconnection"
|
||||
msgstr "после отключения"
|
||||
|
||||
msgid "after connection or disconnection"
|
||||
msgstr "после подключения или отключения"
|
||||
|
||||
msgid "down-script"
|
||||
msgstr "down-script"
|
||||
|
||||
|
@ -26,9 +26,7 @@ msgstr ""
|
||||
msgid "Alive period"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"An email will be sent when the internet connection is restored after being "
|
||||
"disconnected."
|
||||
msgid "An email will be sent when connected or disconnected from the Internet."
|
||||
msgstr ""
|
||||
|
||||
msgid "An error has occurred"
|
||||
@ -207,31 +205,6 @@ msgstr ""
|
||||
msgid "Loading"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Longest period of time after connecting to Internet before \"up-script\" "
|
||||
"runs."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Longest period of time after connecting to the Internet before sending a "
|
||||
"message."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Longest period of time after disconnecting from Internet before \"down-script"
|
||||
"\" runs."
|
||||
msgstr ""
|
||||
|
||||
msgid "Longest period of time without Internet access before modem restart."
|
||||
msgstr ""
|
||||
|
||||
msgid "Longest period of time without Internet access before network restart."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Longest period of time without Internet access until the device is rebooted."
|
||||
msgstr ""
|
||||
|
||||
msgid "Mailsend is not available..."
|
||||
msgstr ""
|
||||
|
||||
@ -249,10 +222,10 @@ msgstr ""
|
||||
msgid "Maximum timeout for waiting for a response from the host."
|
||||
msgstr ""
|
||||
|
||||
msgid "Modem will be restarted when the Internet is disconnected."
|
||||
msgid "ModemManager is not available..."
|
||||
msgstr ""
|
||||
|
||||
msgid "ModemManager is not available..."
|
||||
msgid "Modem will be restarted when the Internet is disconnected."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
@ -290,6 +263,32 @@ msgstr ""
|
||||
msgid "Password for SMTP authentication."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Period of time after connecting to Internet before \"up-script\" runs."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Period of time after connecting to the Internet before sending a message."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Period of time after disconnecting from Internet before \"down-script\" runs."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Period of time after disconnecting from Internet before sending a message."
|
||||
msgstr ""
|
||||
|
||||
msgid "Period of time without Internet access before modem restart."
|
||||
msgstr ""
|
||||
|
||||
msgid "Period of time without Internet access before network restart."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Period of time without Internet access until the device is rebooted."
|
||||
msgstr ""
|
||||
|
||||
msgid "Polling interval"
|
||||
msgstr ""
|
||||
|
||||
@ -434,12 +433,24 @@ msgstr ""
|
||||
msgid "Web UI only: detector works only when the Web UI is open (UI detector)."
|
||||
msgstr ""
|
||||
|
||||
msgid "When email will be sent"
|
||||
msgstr ""
|
||||
|
||||
msgid "Windows: 32 bytes"
|
||||
msgstr ""
|
||||
|
||||
msgid "Write messages to the system log."
|
||||
msgstr ""
|
||||
|
||||
msgid "after connection"
|
||||
msgstr ""
|
||||
|
||||
msgid "after disconnection"
|
||||
msgstr ""
|
||||
|
||||
msgid "both"
|
||||
msgstr ""
|
||||
|
||||
msgid "down-script"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1,46 +1,86 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env lua
|
||||
|
||||
. /lib/functions.sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
local appName = "internet-detector"
|
||||
local appExec = "/usr/bin/internet-detector"
|
||||
local mailsendExec = "/usr/bin/mailsend"
|
||||
local modemManagerInit = "/etc/init.d/modemmanager"
|
||||
|
||||
readonly ID_EXEC="/usr/bin/internet-detector"
|
||||
local InternetDetector = require(appName .. ".main")
|
||||
local uci = require("uci")
|
||||
local unistd = require("posix.unistd")
|
||||
|
||||
run_instance() {
|
||||
config_get enabled "$1" enabled "0"
|
||||
if [ $enabled = "1" ]; then
|
||||
$ID_EXEC service "$1" > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
local function prequire(package)
|
||||
local retVal, pkg = pcall(require, package)
|
||||
return retVal and pkg
|
||||
end
|
||||
|
||||
start_ui_instances() {
|
||||
config_load internet-detector
|
||||
config_get mode "config" mode "0"
|
||||
if [ $mode = "2" ]; then
|
||||
config_foreach run_instance "instance"
|
||||
fi
|
||||
}
|
||||
local function init()
|
||||
local lines = {}
|
||||
if prequire(appName .. ".mod_modem_restart") then
|
||||
lines[#lines + 1] = '"mm_mod":true'
|
||||
if (unistd.access(modemManagerInit, "x") and
|
||||
os.execute(modemManagerInit .. " enabled") == 0) then
|
||||
lines[#lines + 1] = '"mm_init":true'
|
||||
else
|
||||
lines[#lines + 1] = '"mm_init":false'
|
||||
end
|
||||
else
|
||||
lines[#lines + 1] = '"mm_mod":false'
|
||||
end
|
||||
if prequire(appName .. ".mod_email") then
|
||||
lines[#lines + 1] = '"email_mod":true'
|
||||
if unistd.access(mailsendExec, "x") then
|
||||
lines[#lines + 1] = '"email_exec":true'
|
||||
else
|
||||
lines[#lines + 1] = '"email_exec":false'
|
||||
end
|
||||
else
|
||||
lines[#lines + 1] = '"email_mod":false'
|
||||
end
|
||||
return string.format("{%s}", table.concat(lines, ","))
|
||||
end
|
||||
|
||||
ui_poll() {
|
||||
$ID_EXEC uipoll
|
||||
if [ $? -eq 126 ]; then
|
||||
start_ui_instances
|
||||
$ID_EXEC inet-status
|
||||
fi
|
||||
}
|
||||
local function startUiInstances()
|
||||
local uciCursor = uci.cursor()
|
||||
local mode = tonumber(uciCursor:get(appName, "config", "mode"))
|
||||
if mode == 2 then
|
||||
uciCursor:foreach(
|
||||
appName,
|
||||
"instance",
|
||||
function(s)
|
||||
if s.enabled == "1" then
|
||||
os.execute(string.format("%s service %s", appExec, s[".name"]))
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
case "$1" in
|
||||
list)
|
||||
json_init
|
||||
json_add_object "UIPoll"
|
||||
json_close_object
|
||||
json_dump
|
||||
json_cleanup
|
||||
;;
|
||||
call)
|
||||
case "$2" in
|
||||
UIPoll)
|
||||
ui_poll
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
local function uiPoll()
|
||||
if InternetDetector:status() == "stoped" then
|
||||
startUiInstances()
|
||||
else
|
||||
InternetDetector:setSIGUSR()
|
||||
end
|
||||
return InternetDetector:inetStatus()
|
||||
end
|
||||
|
||||
local function list()
|
||||
io.write('{"Init":{},"Status":{},"InetStatus":{},"UIPoll":{}}')
|
||||
end
|
||||
|
||||
if arg[1] == "list" then
|
||||
list()
|
||||
elseif arg[1] == "call" then
|
||||
if arg[2] == "Init" then
|
||||
io.write(init())
|
||||
elseif arg[2] == "Status" then
|
||||
io.write(string.format('{"status":"%s"}', tostring(InternetDetector:status())))
|
||||
elseif arg[2] == "InetStatus" then
|
||||
io.write(InternetDetector:inetStatus())
|
||||
elseif arg[2] == "UIPoll" then
|
||||
io.write(uiPoll())
|
||||
end
|
||||
end
|
||||
|
||||
os.exit(0)
|
||||
|
@ -6,14 +6,12 @@
|
||||
"/sys/class/leds": [ "list" ],
|
||||
"/etc/internet-detector/up-script*": [ "read" ],
|
||||
"/etc/internet-detector/down-script*": [ "read" ],
|
||||
"/etc/internet-detector/public-ip-script*": [ "read" ],
|
||||
"/usr/bin/internet-detector*": [ "exec" ],
|
||||
"/usr/bin/mailsend": [ "exec" ]
|
||||
"/etc/internet-detector/public-ip-script*": [ "read" ]
|
||||
},
|
||||
"uci": [ "internet-detector" ],
|
||||
"ubus": {
|
||||
"luci": [ "getInitList", "setInitAction" ],
|
||||
"luci.internet-detector": [ "UIPoll" ]
|
||||
"luci.internet-detector": [ "Init", "Status", "InetStatus", "UIPoll" ]
|
||||
}
|
||||
},
|
||||
"write": {
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 129 KiB |
BIN
luci-app-internet-detector/screenshots/04.jpg
Normal file
BIN
luci-app-internet-detector/screenshots/04.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
BIN
luci-app-internet-detector/screenshots/05.jpg
Normal file
BIN
luci-app-internet-detector/screenshots/05.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 146 KiB |
@ -7,7 +7,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=IstoreX
|
||||
PKG_VERSION:=0.6.5
|
||||
PKG_VERSION:=0.6.6
|
||||
LUCI_DEPENDS:=+luci-app-quickstart +luci-app-store +luci-lib-taskd
|
||||
LUCI_EXTRA_DEPENDS:=luci-lib-taskd (>=1.0.15)
|
||||
LUCI_MINIFY_CSS:=0
|
||||
|
@ -1 +1 @@
|
||||
import{d as y,i as p,r as x,o as t,c as n,a as s,b as C,l as a,H as B,_ as D,p as $,q as I,u as S,F as _,E as k,m as v,e as h}from"./index.js?v=1e18a786";const b=e=>($("data-v-f0f8da84"),e=e(),I(),e),F={class:"disk-item"},E={class:"disk-item_contanier"},z={class:"disk-item_icon"},N={class:"disk-item_name"},w=b(()=>s("div",{class:"auto"},null,-1)),O={class:"disk-item_used"},V={key:0,class:"disk-item_info"},j={class:"label-msg.warning"},q={key:1,class:"disk-item_info"},M=b(()=>s("div",{class:"auto"},null,-1)),A=y({__name:"item",props:{disk:{type:Object,required:!0}},setup(e){const l=e;p(()=>{var o;return((o=l.disk.childrens)==null?void 0:o.length)||0}),p(()=>{var u,c;let o=0;return(c=(u=l.disk)==null?void 0:u.childrens)==null||c.forEach(i=>{if(!i.mountPoint){const r=Number(i.sizeInt),g=(1<<30)*2;r>g&&o++}}),o});const d=()=>{B.OpenDisk({disk:l.disk})};return(o,u)=>{const c=x("icon-disk");return t(),n("div",F,[s("div",E,[s("div",z,[C(c)]),s("div",N,[s("span",null,a(e.disk.name)+" \u3010"+a(e.disk.size)+"\u3011"+a(e.disk.venderModel),1)]),w,s("div",O,[s("span",null,a(e.disk.used)+" / "+a(e.disk.total),1)])]),e.disk.errorInfo?(t(),n("div",V,[s("span",j,a(e.disk.errorInfo),1)])):(t(),n("div",q,[s("span",null,a(e.disk.path),1),M,s("a",{onClick:u[0]||(u[0]=i=>d())}," \u67E5\u770B ")]))])}}});var m=D(A,[["__scopeId","data-v-f0f8da84"]]);const f=e=>($("data-v-bf0d8af0"),e=e(),I(),e),H={key:0,class:"ul-container"},L=f(()=>s("div",{class:"ul-container_title"},[s("span",null,"\u7CFB\u7EDF\u78C1\u76D8")],-1)),P={class:"ul-container_body"},G={key:1,class:"ul-container"},J=f(()=>s("div",{class:"ul-container_title"},[s("span",null,"\u5DF2\u6302\u8F7D\u78C1\u76D8")],-1)),K={class:"ul-container_body"},Q={key:2,class:"ul-container"},R=f(()=>s("div",{class:"ul-container_title"},[s("span",null,"\u672A\u8BC6\u522B\u78C1\u76D8")],-1)),T={class:"ul-container_body"},U={key:3,class:"ul-container"},W=f(()=>s("div",{class:"ul-container_title"},[s("span",null,"raid")],-1)),X={class:"ul-container_body"},Y=y({__name:"index",setup(e){const l=S(),d=p(()=>l.disk),o=p(()=>l.raid.disks);return(u,c)=>(t(),n("main",null,[d.value.rootDisks.length>0?(t(),n("ul",H,[L,s("div",P,[(t(!0),n(_,null,k(d.value.rootDisks,(i,r)=>(t(),h(m,{disk:i},null,8,["disk"]))),256))])])):v("",!0),d.value.mountedDisks.length>0?(t(),n("ul",G,[J,s("div",K,[(t(!0),n(_,null,k(d.value.mountedDisks,(i,r)=>(t(),h(m,{disk:i},null,8,["disk"]))),256))])])):v("",!0),d.value.errorDisks.length>0?(t(),n("ul",Q,[R,s("div",T,[(t(!0),n(_,null,k(d.value.errorDisks,(i,r)=>(t(),h(m,{disk:i},null,8,["disk"]))),256))])])):v("",!0),o.value.length>0?(t(),n("ul",U,[W,s("div",X,[(t(!0),n(_,null,k(o.value,(i,r)=>(t(),h(m,{disk:i},null,8,["disk"]))),256))])])):v("",!0)]))}});var ss=D(Y,[["__scopeId","data-v-bf0d8af0"]]);export{ss as default};
|
||||
import{d as y,i as p,r as x,o as t,c as n,a as s,b as C,l as a,H as B,_ as D,p as $,q as I,u as S,F as _,E as k,m as v,e as h}from"./index.js?v=5b4be379";const b=e=>($("data-v-f0f8da84"),e=e(),I(),e),F={class:"disk-item"},E={class:"disk-item_contanier"},z={class:"disk-item_icon"},N={class:"disk-item_name"},w=b(()=>s("div",{class:"auto"},null,-1)),O={class:"disk-item_used"},V={key:0,class:"disk-item_info"},j={class:"label-msg.warning"},q={key:1,class:"disk-item_info"},M=b(()=>s("div",{class:"auto"},null,-1)),A=y({__name:"item",props:{disk:{type:Object,required:!0}},setup(e){const l=e;p(()=>{var o;return((o=l.disk.childrens)==null?void 0:o.length)||0}),p(()=>{var u,c;let o=0;return(c=(u=l.disk)==null?void 0:u.childrens)==null||c.forEach(i=>{if(!i.mountPoint){const r=Number(i.sizeInt),g=(1<<30)*2;r>g&&o++}}),o});const d=()=>{B.OpenDisk({disk:l.disk})};return(o,u)=>{const c=x("icon-disk");return t(),n("div",F,[s("div",E,[s("div",z,[C(c)]),s("div",N,[s("span",null,a(e.disk.name)+" \u3010"+a(e.disk.size)+"\u3011"+a(e.disk.venderModel),1)]),w,s("div",O,[s("span",null,a(e.disk.used)+" / "+a(e.disk.total),1)])]),e.disk.errorInfo?(t(),n("div",V,[s("span",j,a(e.disk.errorInfo),1)])):(t(),n("div",q,[s("span",null,a(e.disk.path),1),M,s("a",{onClick:u[0]||(u[0]=i=>d())}," \u67E5\u770B ")]))])}}});var m=D(A,[["__scopeId","data-v-f0f8da84"]]);const f=e=>($("data-v-bf0d8af0"),e=e(),I(),e),H={key:0,class:"ul-container"},L=f(()=>s("div",{class:"ul-container_title"},[s("span",null,"\u7CFB\u7EDF\u78C1\u76D8")],-1)),P={class:"ul-container_body"},G={key:1,class:"ul-container"},J=f(()=>s("div",{class:"ul-container_title"},[s("span",null,"\u5DF2\u6302\u8F7D\u78C1\u76D8")],-1)),K={class:"ul-container_body"},Q={key:2,class:"ul-container"},R=f(()=>s("div",{class:"ul-container_title"},[s("span",null,"\u672A\u8BC6\u522B\u78C1\u76D8")],-1)),T={class:"ul-container_body"},U={key:3,class:"ul-container"},W=f(()=>s("div",{class:"ul-container_title"},[s("span",null,"raid")],-1)),X={class:"ul-container_body"},Y=y({__name:"index",setup(e){const l=S(),d=p(()=>l.disk),o=p(()=>l.raid.disks);return(u,c)=>(t(),n("main",null,[d.value.rootDisks.length>0?(t(),n("ul",H,[L,s("div",P,[(t(!0),n(_,null,k(d.value.rootDisks,(i,r)=>(t(),h(m,{disk:i},null,8,["disk"]))),256))])])):v("",!0),d.value.mountedDisks.length>0?(t(),n("ul",G,[J,s("div",K,[(t(!0),n(_,null,k(d.value.mountedDisks,(i,r)=>(t(),h(m,{disk:i},null,8,["disk"]))),256))])])):v("",!0),d.value.errorDisks.length>0?(t(),n("ul",Q,[R,s("div",T,[(t(!0),n(_,null,k(d.value.errorDisks,(i,r)=>(t(),h(m,{disk:i},null,8,["disk"]))),256))])])):v("",!0),o.value.length>0?(t(),n("ul",U,[W,s("div",X,[(t(!0),n(_,null,k(o.value,(i,r)=>(t(),h(m,{disk:i},null,8,["disk"]))),256))])])):v("",!0)]))}});var ss=D(Y,[["__scopeId","data-v-bf0d8af0"]]);export{ss as default};
|
@ -1 +1 @@
|
||||
import{d as u,r as e,o as r,e as s,w as i,b as c,P as t}from"./index.js?v=1e18a786";const _=u({__name:"index",setup(l){const a=[{name:"disk",title:"\u6211\u7684\u78C1\u76D8",path:"/router/disk"},{name:"disk-raid",title:"\u78C1\u76D8\u9635\u5217",fn:()=>{t({full:!0,title:"\u78C1\u76D8\u9635\u5217",src:"/cgi-bin/luci/admin/nas/raid"})}},{name:"disk-smart",title:"S.M.A.R.T",fn:()=>{t({full:!0,title:"S.M.A.R.T",src:"/cgi-bin/luci/admin/nas/smart"})}}];return(m,d)=>{const n=e("router-loading"),o=e("layout-page");return r(),s(o,{menus:a},{default:i(()=>[c(n)]),_:1})}}});export{_ as default};
|
||||
import{d as u,r as e,o as r,e as s,w as i,b as c,P as t}from"./index.js?v=5b4be379";const _=u({__name:"index",setup(l){const a=[{name:"disk",title:"\u6211\u7684\u78C1\u76D8",path:"/router/disk"},{name:"disk-raid",title:"\u78C1\u76D8\u9635\u5217",fn:()=>{t({full:!0,title:"\u78C1\u76D8\u9635\u5217",src:"/cgi-bin/luci/admin/nas/raid"})}},{name:"disk-smart",title:"S.M.A.R.T",fn:()=>{t({full:!0,title:"S.M.A.R.T",src:"/cgi-bin/luci/admin/nas/smart"})}}];return(m,d)=>{const n=e("router-loading"),o=e("layout-page");return r(),s(o,{menus:a},{default:i(()=>[c(n)]),_:1})}}});export{_ as default};
|
@ -0,0 +1 @@
|
||||
import{_ as o,r as n,o as r,c as t,b as a}from"./index.js?v=5b4be379";const c={},s={id:"page",class:"page-container"};function _(d,i){const e=n("router-loading");return r(),t("div",s,[a(e)])}var p=o(c,[["render",_]]);export{p as default};
|
@ -1 +1 @@
|
||||
var C=(r,h,d)=>new Promise((k,c)=>{var F=l=>{try{E(d.next(l))}catch(v){c(v)}},t=l=>{try{E(d.throw(l))}catch(v){c(v)}},E=l=>l.done?k(l.value):Promise.resolve(l.value).then(F,t);E((d=d.apply(r,h)).next())});import{_ as S,d as w,s as m,j as I,v as N,o,c as n,F as _,a as s,x,D as g,E as y,m as D,l as p,B as T,p as G,q as U,C as A,T as B}from"./index.js?v=1e18a786";const i=r=>(G("data-v-6bbc1a4d"),r=r(),U(),r),V=["onSubmit"],M=i(()=>s("p",null,"\u4E00\u4E2A\u7B80\u6613\u6C99\u7BB1\uFF0C\u65B9\u4FBF\u7528\u6765\u5B9E\u9A8C\u7CFB\u7EDF\u914D\u7F6E\u548C\u7A0B\u5E8F\uFF0C\u65B9\u4FBF\u5F00\u53D1\u672A\u5B8C\u6210\u7684\u8F6F\u4EF6\uFF0C\u4F46\u4E0D\u4FDD\u62A4Docker\u548C\u786C\u76D8\u7684\u6570\u636E",-1)),q={key:0,class:"label-msg warning"},z=i(()=>s("div",{class:"label-value"},null,-1)),L=i(()=>s("div",{class:"label-name"},[s("span",null,"\u72B6\u6001")],-1)),P={class:"label-value"},$=["value"],j=i(()=>s("option",{disabled:"",selected:"true"},"\u83B7\u53D6\u4E2D...",-1)),O=i(()=>s("option",{disabled:"",value:"stopped"},"\u672A\u5F00\u542F",-1)),W=i(()=>s("option",{disabled:"",value:"running"},"\u5F00\u542F\u4E2D",-1)),H=[j,O,W],J={key:0,class:"label-btns"},K=i(()=>s("div",{class:"label-name"},[s("span",null,"\u76EE\u6807\u78C1\u76D8\uFF08\u5EFA\u8BAE\u9009\u62E9U\u76D8\u6216\u8005\u79FB\u52A8\u786C\u76D8\uFF0C\u65B9\u4FBF\u88C5\u5378\uFF09")],-1)),Q={class:"label-value"},R=i(()=>s("option",{value:""},"\u8BF7\u9009\u62E9\u76EE\u6807\u78C1\u76D8",-1)),X=["value"],Y=i(()=>s("div",{class:"label-name"},[s("span",null,"\u76EE\u6807\u5206\u533A\uFF08\u5206\u533A\u5927\u5C0F\u987B\u5927\u4E8E8G\uFF0C\u5C06\u6B64\u5206\u533A\u4F5C\u4E3A\u5916\u90E8 overlay \u4F7F\u7528\uFF09")],-1)),Z={class:"label-value"},uu=i(()=>s("option",{selected:"true",value:""},"\u8BF7\u9009\u62E9\u76EE\u6807\u5206\u533A",-1)),su=["value","disabled"],tu={key:1,class:"label-btns"},eu=["disabled"],au={key:2,class:"label-msg warning"},ou=w({__name:"index",setup(r){return C(this,null,function*(){let h,d;const k=m(!1),c=m(""),F=m(0),t=I({status:"stopped",diskpath:"",partition:"",sandboxDisks:{disks:[]}}),E=()=>C(this,null,function*(){const b=yield Promise.all([A.Nas.SandboxDisks.GET(),A.Nas.GetSandbox.GET()]);try{const u=b[0];if(u!=null&&u.data){const{result:e,error:a}=u.data;e&&(t.sandboxDisks.disks=e.disks||[]),a&&(c.value=a)}}catch(u){c.value=u,F.value=3}try{const u=b[1];if(u!=null&&u.data){const{result:e}=u.data;e&&(t.status=e.status)}}catch(u){console.log(u)}});[h,d]=N(()=>E()),yield h,d();const l=()=>{t.partition=""},v=()=>C(this,null,function*(){if(confirm("\u6B64\u64CD\u4F5C\u4F1A\u5C06\u4F1A\u5220\u9664\u8BE5\u5206\u533A\u5168\u90E8\u6570\u636E,\u662F\u5426\u7EE7\u7EED?")){const b=B.Loading("\u914D\u7F6E\u4E2D...");try{const u=yield A.Nas.Sandbox.POST({path:t.partition});if(u!=null&&u.data){const{result:e,error:a,success:f}=u.data;a&&B.Warning(a),(u.data.success||0)==0&&B.Success("\u914D\u7F6E\u6210\u529F")}}catch(u){B.Error(`${u}`)}b.Close()}});return(b,u)=>(o(),n("form",{class:"form-container",onSubmit:T(v,["prevent"])},[M,t.sandboxDisks.disks.length==0?(o(),n("div",q," \u68C0\u6D4B\u4E0D\u5230\u6302\u8F7D\u7684\u78C1\u76D8\u4FE1\u606F\uFF0C\u8BF7\u5148\u63D2\u4E0A\u78C1\u76D8\uFF0C\u5EFA\u8BAE\u4F7F\u7528U\u76D8\u6216\u8005\u79FB\u52A8\u786C\u76D8\uFF0C\u65B9\u4FBF\u88C5\u5378 ")):(o(),n(_,{key:1},[z,L,s("div",P,[s("select",{value:t.status,disabled:""},H,8,$)]),F.value==0?(o(),n("div",J,[s("button",{class:"sumbit",type:"button",onClick:u[0]||(u[0]=e=>F.value=1)},"\u914D\u7F6E")])):F.value==1?(o(),n(_,{key:1},[K,s("div",Q,[x(s("select",{"onUpdate:modelValue":u[1]||(u[1]=e=>t.diskpath=e),onChange:l},[R,(o(!0),n(_,null,y(t.sandboxDisks.disks,(e,a)=>(o(),n("option",{value:e.path,key:a},p(e.venderModel)+"\uFF08"+p(e.size)+"\uFF09 ",9,X))),128))],544),[[g,t.diskpath]])]),t.diskpath?(o(),n(_,{key:0},[Y,(o(!0),n(_,null,y(t.sandboxDisks.disks,e=>(o(),n("div",Z,[e.path==t.diskpath?x((o(),n("select",{key:0,"onUpdate:modelValue":u[2]||(u[2]=a=>t.partition=a)},[uu,(o(!0),n(_,null,y(e.childrens,(a,f)=>(o(),n("option",{value:a.path,key:f,disabled:a.sizeInt<8192e6},p(a.name)+"\uFF08"+p(a.filesystem||"\u672A\u683C\u5F0F\u5316")+"\uFF09"+p(a.total),9,su))),128))],512)),[[g,t.partition]]):D("",!0)]))),256))],64)):D("",!0),t.diskpath&&t.partition?(o(),n("div",tu,[s("button",{class:"sumbit",disabled:k.value},"\u4FDD\u5B58",8,eu)])):D("",!0)],64)):D("",!0)],64)),c.value?(o(),n("div",au,p(c.value),1)):D("",!0)],40,V))})}});var lu=S(ou,[["__scopeId","data-v-6bbc1a4d"]]);export{lu as default};
|
||||
var C=(r,h,d)=>new Promise((k,c)=>{var F=l=>{try{E(d.next(l))}catch(v){c(v)}},t=l=>{try{E(d.throw(l))}catch(v){c(v)}},E=l=>l.done?k(l.value):Promise.resolve(l.value).then(F,t);E((d=d.apply(r,h)).next())});import{_ as S,d as w,s as m,j as I,v as N,o,c as n,F as _,a as s,x,D as g,E as y,m as D,l as p,B as T,p as G,q as U,C as A,T as B}from"./index.js?v=5b4be379";const i=r=>(G("data-v-6bbc1a4d"),r=r(),U(),r),V=["onSubmit"],M=i(()=>s("p",null,"\u4E00\u4E2A\u7B80\u6613\u6C99\u7BB1\uFF0C\u65B9\u4FBF\u7528\u6765\u5B9E\u9A8C\u7CFB\u7EDF\u914D\u7F6E\u548C\u7A0B\u5E8F\uFF0C\u65B9\u4FBF\u5F00\u53D1\u672A\u5B8C\u6210\u7684\u8F6F\u4EF6\uFF0C\u4F46\u4E0D\u4FDD\u62A4Docker\u548C\u786C\u76D8\u7684\u6570\u636E",-1)),q={key:0,class:"label-msg warning"},z=i(()=>s("div",{class:"label-value"},null,-1)),L=i(()=>s("div",{class:"label-name"},[s("span",null,"\u72B6\u6001")],-1)),P={class:"label-value"},$=["value"],j=i(()=>s("option",{disabled:"",selected:"true"},"\u83B7\u53D6\u4E2D...",-1)),O=i(()=>s("option",{disabled:"",value:"stopped"},"\u672A\u5F00\u542F",-1)),W=i(()=>s("option",{disabled:"",value:"running"},"\u5F00\u542F\u4E2D",-1)),H=[j,O,W],J={key:0,class:"label-btns"},K=i(()=>s("div",{class:"label-name"},[s("span",null,"\u76EE\u6807\u78C1\u76D8\uFF08\u5EFA\u8BAE\u9009\u62E9U\u76D8\u6216\u8005\u79FB\u52A8\u786C\u76D8\uFF0C\u65B9\u4FBF\u88C5\u5378\uFF09")],-1)),Q={class:"label-value"},R=i(()=>s("option",{value:""},"\u8BF7\u9009\u62E9\u76EE\u6807\u78C1\u76D8",-1)),X=["value"],Y=i(()=>s("div",{class:"label-name"},[s("span",null,"\u76EE\u6807\u5206\u533A\uFF08\u5206\u533A\u5927\u5C0F\u987B\u5927\u4E8E8G\uFF0C\u5C06\u6B64\u5206\u533A\u4F5C\u4E3A\u5916\u90E8 overlay \u4F7F\u7528\uFF09")],-1)),Z={class:"label-value"},uu=i(()=>s("option",{selected:"true",value:""},"\u8BF7\u9009\u62E9\u76EE\u6807\u5206\u533A",-1)),su=["value","disabled"],tu={key:1,class:"label-btns"},eu=["disabled"],au={key:2,class:"label-msg warning"},ou=w({__name:"index",setup(r){return C(this,null,function*(){let h,d;const k=m(!1),c=m(""),F=m(0),t=I({status:"stopped",diskpath:"",partition:"",sandboxDisks:{disks:[]}}),E=()=>C(this,null,function*(){const b=yield Promise.all([A.Nas.SandboxDisks.GET(),A.Nas.GetSandbox.GET()]);try{const u=b[0];if(u!=null&&u.data){const{result:e,error:a}=u.data;e&&(t.sandboxDisks.disks=e.disks||[]),a&&(c.value=a)}}catch(u){c.value=u,F.value=3}try{const u=b[1];if(u!=null&&u.data){const{result:e}=u.data;e&&(t.status=e.status)}}catch(u){console.log(u)}});[h,d]=N(()=>E()),yield h,d();const l=()=>{t.partition=""},v=()=>C(this,null,function*(){if(confirm("\u6B64\u64CD\u4F5C\u4F1A\u5C06\u4F1A\u5220\u9664\u8BE5\u5206\u533A\u5168\u90E8\u6570\u636E,\u662F\u5426\u7EE7\u7EED?")){const b=B.Loading("\u914D\u7F6E\u4E2D...");try{const u=yield A.Nas.Sandbox.POST({path:t.partition});if(u!=null&&u.data){const{result:e,error:a,success:f}=u.data;a&&B.Warning(a),(u.data.success||0)==0&&B.Success("\u914D\u7F6E\u6210\u529F")}}catch(u){B.Error(`${u}`)}b.Close()}});return(b,u)=>(o(),n("form",{class:"form-container",onSubmit:T(v,["prevent"])},[M,t.sandboxDisks.disks.length==0?(o(),n("div",q," \u68C0\u6D4B\u4E0D\u5230\u6302\u8F7D\u7684\u78C1\u76D8\u4FE1\u606F\uFF0C\u8BF7\u5148\u63D2\u4E0A\u78C1\u76D8\uFF0C\u5EFA\u8BAE\u4F7F\u7528U\u76D8\u6216\u8005\u79FB\u52A8\u786C\u76D8\uFF0C\u65B9\u4FBF\u88C5\u5378 ")):(o(),n(_,{key:1},[z,L,s("div",P,[s("select",{value:t.status,disabled:""},H,8,$)]),F.value==0?(o(),n("div",J,[s("button",{class:"sumbit",type:"button",onClick:u[0]||(u[0]=e=>F.value=1)},"\u914D\u7F6E")])):F.value==1?(o(),n(_,{key:1},[K,s("div",Q,[x(s("select",{"onUpdate:modelValue":u[1]||(u[1]=e=>t.diskpath=e),onChange:l},[R,(o(!0),n(_,null,y(t.sandboxDisks.disks,(e,a)=>(o(),n("option",{value:e.path,key:a},p(e.venderModel)+"\uFF08"+p(e.size)+"\uFF09 ",9,X))),128))],544),[[g,t.diskpath]])]),t.diskpath?(o(),n(_,{key:0},[Y,(o(!0),n(_,null,y(t.sandboxDisks.disks,e=>(o(),n("div",Z,[e.path==t.diskpath?x((o(),n("select",{key:0,"onUpdate:modelValue":u[2]||(u[2]=a=>t.partition=a)},[uu,(o(!0),n(_,null,y(e.childrens,(a,f)=>(o(),n("option",{value:a.path,key:f,disabled:a.sizeInt<8192e6},p(a.name)+"\uFF08"+p(a.filesystem||"\u672A\u683C\u5F0F\u5316")+"\uFF09"+p(a.total),9,su))),128))],512)),[[g,t.partition]]):D("",!0)]))),256))],64)):D("",!0),t.diskpath&&t.partition?(o(),n("div",tu,[s("button",{class:"sumbit",disabled:k.value},"\u4FDD\u5B58",8,eu)])):D("",!0)],64)):D("",!0)],64)),c.value?(o(),n("div",au,p(c.value),1)):D("",!0)],40,V))})}});var lu=S(ou,[["__scopeId","data-v-6bbc1a4d"]]);export{lu as default};
|
@ -1 +1 @@
|
||||
var f=Object.defineProperty;var F=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var v=(s,t,u)=>t in s?f(s,t,{enumerable:!0,configurable:!0,writable:!0,value:u}):s[t]=u,b=(s,t)=>{for(var u in t||(t={}))h.call(t,u)&&v(s,u,t[u]);if(F)for(var u of F(t))A.call(t,u)&&v(s,u,t[u]);return s};var E=(s,t,u)=>new Promise((r,d)=>{var c=n=>{try{a(u.next(n))}catch(o){d(o)}},l=n=>{try{a(u.throw(n))}catch(o){d(o)}},a=n=>n.done?r(n.value):Promise.resolve(n.value).then(c,l);a((u=u.apply(s,t)).next())});import{d as y,s as m,j as x,o as D,c as _,a as e,x as i,A as p,y as B,z as C,l as V,m as g,B as I,G as w,T as S,C as k}from"./index.js?v=1e18a786";const M=["onSubmit"],N=w('<div class="label-info"> \u65C1\u8DEF\u7531\u6A21\u5F0F\uFF0C\u4E5F\u53EB\u5355\u81C2\u8DEF\u7531\u6A21\u5F0F\u3002\u60A8\u53EF\u4EE5\u7528\u4E0A\u4E00\u7EA7\u8DEF\u7531\u62E8\u53F7\uFF0C\u7136\u540E\u7531\u8BE5\u8BBE\u5907\u6765\u5B9E\u73B0\u4E00\u4E9B\u9AD8\u7EA7\u529F\u80FD\u3002 </div><div class="label-name"><span>LAN \u63A5\u53E3\u914D\u7F6E\u65B9\u5F0F</span></div><div class="label-value"><select disabled><option> \u65C1\u8DEF\u7531\u6A21\u5F0F\u4EC5\u652F\u6301\u9759\u6001IP\u5730\u5740 </option></select></div><div class="label-name"><span>IP \u5730\u5740\uFF08\u8BF7\u548C\u4E0A\u4E00\u6B65\u8BB0\u5F55\u7684\u4E3B\u8DEF\u7531\u5730\u5740\u5728\u540C\u4E00\u7F51\u6BB5\uFF09</span></div>',4),P={class:"label-value"},U=e("div",{class:"label-name"},[e("span",null,"\u5B50\u7F51\u63A9\u7801")],-1),q={class:"label-value"},L=e("div",{class:"label-name"},[e("span",null,"\u7F51\u5173\u5730\u5740")],-1),T={class:"label-value"},G=e("div",{class:"label-name"},[e("span",null,"DNS\u670D\u52A1\u5668")],-1),H={class:"label-value"},R=e("div",{class:"label-name"},[e("span",null,"\u662F\u5426\u63D0\u4F9B DHCP\uFF08\u5982\u679C\u662F\u63D0\u4F9B DHCP\uFF0C\u5219\u9700\u8981\u5173\u95ED\u4E3B\u8DEF\u7531 DHCP\uFF09")],-1),j={class:"label-value"},z={class:"label-flex"},O={class:"label-btns"},J=["disabled"],K={key:0,class:"label-msg"},X=y({__name:"index",setup(s){const t=m(""),u=x({subnetMask:"255.255.255.0",staticDnsIp:"223.5.5.5",staticLanIp:"",gateway:"",enableDhcp:!0}),r=m(!1),d=()=>E(this,null,function*(){const c=b({},u),l=S.Loading("\u914D\u7F6E\u4E2D...");try{const a=yield k.Guide.GatewayRouter.POST(c);if(a!=null&&a.data){const{success:n,error:o}=a==null?void 0:a.data;o&&(t.value=o),(n==null||n==0)&&(t.value="\u914D\u7F6E\u6210\u529F")}}catch(a){t.value=a}l.Close()});return(c,l)=>(D(),_("form",{class:"form-container",onSubmit:I(d,["prevent"])},[N,e("div",P,[i(e("input",{type:"text",placeholder:"ip\u5730\u5740","onUpdate:modelValue":l[0]||(l[0]=a=>u.staticLanIp=a),required:""},null,512),[[p,u.staticLanIp,void 0,{trim:!0}]])]),U,e("div",q,[i(e("input",{type:"text",placeholder:"\u5B50\u7F51\u63A9\u7801\u5730\u5740","onUpdate:modelValue":l[1]||(l[1]=a=>u.subnetMask=a),required:""},null,512),[[p,u.subnetMask,void 0,{trim:!0}]])]),L,e("div",T,[i(e("input",{type:"text",placeholder:"\u7F51\u5173\u5730\u5740","onUpdate:modelValue":l[2]||(l[2]=a=>u.gateway=a),required:""},null,512),[[p,u.gateway,void 0,{trim:!0}]])]),G,e("div",H,[i(e("input",{type:"text",placeholder:"dns\u670D\u52A1\u5668\u5730\u5740","onUpdate:modelValue":l[3]||(l[3]=a=>u.staticDnsIp=a),required:""},null,512),[[p,u.staticDnsIp,void 0,{trim:!0}]])]),R,e("div",j,[e("div",z,[e("label",null,[i(e("input",{type:"radio",value:!1,"onUpdate:modelValue":l[4]||(l[4]=a=>u.enableDhcp=a)},null,512),[[B,u.enableDhcp]]),C("\u5173\u95ED")]),e("label",null,[i(e("input",{type:"radio",value:!0,"onUpdate:modelValue":l[5]||(l[5]=a=>u.enableDhcp=a)},null,512),[[B,u.enableDhcp]]),C("\u542F\u7528")])])]),e("div",O,[e("button",{class:"sumbit",disabled:r.value},"\u4FDD\u5B58",8,J)]),t.value?(D(),_("div",K,[e("span",null,V(t.value),1)])):g("",!0)],40,M))}});export{X as default};
|
||||
var f=Object.defineProperty;var F=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var v=(s,t,u)=>t in s?f(s,t,{enumerable:!0,configurable:!0,writable:!0,value:u}):s[t]=u,b=(s,t)=>{for(var u in t||(t={}))h.call(t,u)&&v(s,u,t[u]);if(F)for(var u of F(t))A.call(t,u)&&v(s,u,t[u]);return s};var E=(s,t,u)=>new Promise((r,d)=>{var c=n=>{try{a(u.next(n))}catch(o){d(o)}},l=n=>{try{a(u.throw(n))}catch(o){d(o)}},a=n=>n.done?r(n.value):Promise.resolve(n.value).then(c,l);a((u=u.apply(s,t)).next())});import{d as y,s as m,j as x,o as D,c as _,a as e,x as i,A as p,y as B,z as C,l as V,m as g,B as I,G as w,T as S,C as k}from"./index.js?v=5b4be379";const M=["onSubmit"],N=w('<div class="label-info"> \u65C1\u8DEF\u7531\u6A21\u5F0F\uFF0C\u4E5F\u53EB\u5355\u81C2\u8DEF\u7531\u6A21\u5F0F\u3002\u60A8\u53EF\u4EE5\u7528\u4E0A\u4E00\u7EA7\u8DEF\u7531\u62E8\u53F7\uFF0C\u7136\u540E\u7531\u8BE5\u8BBE\u5907\u6765\u5B9E\u73B0\u4E00\u4E9B\u9AD8\u7EA7\u529F\u80FD\u3002 </div><div class="label-name"><span>LAN \u63A5\u53E3\u914D\u7F6E\u65B9\u5F0F</span></div><div class="label-value"><select disabled><option> \u65C1\u8DEF\u7531\u6A21\u5F0F\u4EC5\u652F\u6301\u9759\u6001IP\u5730\u5740 </option></select></div><div class="label-name"><span>IP \u5730\u5740\uFF08\u8BF7\u548C\u4E0A\u4E00\u6B65\u8BB0\u5F55\u7684\u4E3B\u8DEF\u7531\u5730\u5740\u5728\u540C\u4E00\u7F51\u6BB5\uFF09</span></div>',4),P={class:"label-value"},U=e("div",{class:"label-name"},[e("span",null,"\u5B50\u7F51\u63A9\u7801")],-1),q={class:"label-value"},L=e("div",{class:"label-name"},[e("span",null,"\u7F51\u5173\u5730\u5740")],-1),T={class:"label-value"},G=e("div",{class:"label-name"},[e("span",null,"DNS\u670D\u52A1\u5668")],-1),H={class:"label-value"},R=e("div",{class:"label-name"},[e("span",null,"\u662F\u5426\u63D0\u4F9B DHCP\uFF08\u5982\u679C\u662F\u63D0\u4F9B DHCP\uFF0C\u5219\u9700\u8981\u5173\u95ED\u4E3B\u8DEF\u7531 DHCP\uFF09")],-1),j={class:"label-value"},z={class:"label-flex"},O={class:"label-btns"},J=["disabled"],K={key:0,class:"label-msg"},X=y({__name:"index",setup(s){const t=m(""),u=x({subnetMask:"255.255.255.0",staticDnsIp:"223.5.5.5",staticLanIp:"",gateway:"",enableDhcp:!0}),r=m(!1),d=()=>E(this,null,function*(){const c=b({},u),l=S.Loading("\u914D\u7F6E\u4E2D...");try{const a=yield k.Guide.GatewayRouter.POST(c);if(a!=null&&a.data){const{success:n,error:o}=a==null?void 0:a.data;o&&(t.value=o),(n==null||n==0)&&(t.value="\u914D\u7F6E\u6210\u529F")}}catch(a){t.value=a}l.Close()});return(c,l)=>(D(),_("form",{class:"form-container",onSubmit:I(d,["prevent"])},[N,e("div",P,[i(e("input",{type:"text",placeholder:"ip\u5730\u5740","onUpdate:modelValue":l[0]||(l[0]=a=>u.staticLanIp=a),required:""},null,512),[[p,u.staticLanIp,void 0,{trim:!0}]])]),U,e("div",q,[i(e("input",{type:"text",placeholder:"\u5B50\u7F51\u63A9\u7801\u5730\u5740","onUpdate:modelValue":l[1]||(l[1]=a=>u.subnetMask=a),required:""},null,512),[[p,u.subnetMask,void 0,{trim:!0}]])]),L,e("div",T,[i(e("input",{type:"text",placeholder:"\u7F51\u5173\u5730\u5740","onUpdate:modelValue":l[2]||(l[2]=a=>u.gateway=a),required:""},null,512),[[p,u.gateway,void 0,{trim:!0}]])]),G,e("div",H,[i(e("input",{type:"text",placeholder:"dns\u670D\u52A1\u5668\u5730\u5740","onUpdate:modelValue":l[3]||(l[3]=a=>u.staticDnsIp=a),required:""},null,512),[[p,u.staticDnsIp,void 0,{trim:!0}]])]),R,e("div",j,[e("div",z,[e("label",null,[i(e("input",{type:"radio",value:!1,"onUpdate:modelValue":l[4]||(l[4]=a=>u.enableDhcp=a)},null,512),[[B,u.enableDhcp]]),C("\u5173\u95ED")]),e("label",null,[i(e("input",{type:"radio",value:!0,"onUpdate:modelValue":l[5]||(l[5]=a=>u.enableDhcp=a)},null,512),[[B,u.enableDhcp]]),C("\u542F\u7528")])])]),e("div",O,[e("button",{class:"sumbit",disabled:r.value},"\u4FDD\u5B58",8,J)]),t.value?(D(),_("div",K,[e("span",null,V(t.value),1)])):g("",!0)],40,M))}});export{X as default};
|
@ -1 +0,0 @@
|
||||
import{_ as o,r as n,o as r,c as t,b as a}from"./index.js?v=1e18a786";const c={},s={id:"page",class:"page-container"};function _(d,i){const e=n("router-loading");return r(),t("div",s,[a(e)])}var p=o(c,[["render",_]]);export{p as default};
|
@ -1 +1 @@
|
||||
var c=(p,t,a)=>new Promise((n,o)=>{var r=e=>{try{s(a.next(e))}catch(_){o(_)}},d=e=>{try{s(a.throw(e))}catch(_){o(_)}},s=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,d);s((a=a.apply(p,t)).next())});import{_ as i,d as u,I as l,o as x,c as g,b as m,J as v}from"./index.js?v=1e18a786";const f={id:"page",class:"page-top-container"},b=u({__name:"index",setup(p){const t=l();return(()=>c(this,null,function*(){yield t.getApp()}))(),(n,o)=>(x(),g("div",f,[m(v)]))}});var h=i(b,[["__scopeId","data-v-701aba0b"]]);export{h as default};
|
||||
var c=(p,t,a)=>new Promise((n,o)=>{var r=e=>{try{s(a.next(e))}catch(_){o(_)}},d=e=>{try{s(a.throw(e))}catch(_){o(_)}},s=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,d);s((a=a.apply(p,t)).next())});import{_ as i,d as u,I as l,o as x,c as g,b as m,J as v}from"./index.js?v=5b4be379";const f={id:"page",class:"page-top-container"},b=u({__name:"index",setup(p){const t=l();return(()=>c(this,null,function*(){yield t.getApp()}))(),(n,o)=>(x(),g("div",f,[m(v)]))}});var h=i(b,[["__scopeId","data-v-701aba0b"]]);export{h as default};
|
@ -1 +1 @@
|
||||
import{_ as o,r,o as t,e as n,w as s,S as a,b as c}from"./index.js?v=1e18a786";const _={};function u(f,i){const e=r("router-view");return t(),n(a,null,{default:s(()=>[c(e)]),_:1})}var p=o(_,[["render",u]]);export{p as default};
|
||||
import{_ as o,r,o as t,e as n,w as s,S as a,b as c}from"./index.js?v=5b4be379";const _={};function u(f,i){const e=r("router-view");return t(),n(a,null,{default:s(()=>[c(e)]),_:1})}var p=o(_,[["render",u]]);export{p as default};
|
@ -1 +1 @@
|
||||
import{_ as r}from"./index.js?v=1e18a786";const e={};function n(_,c){return null}var a=r(e,[["render",n]]);export{a as default};
|
||||
import{_ as r}from"./index.js?v=5b4be379";const e={};function n(_,c){return null}var a=r(e,[["render",n]]);export{a as default};
|
@ -1 +1 @@
|
||||
var _=(p,d,a)=>new Promise((c,n)=>{var o=s=>{try{i(a.next(s))}catch(e){n(e)}},f=s=>{try{i(a.throw(s))}catch(e){n(e)}},i=s=>s.done?c(s.value):Promise.resolve(s.value).then(o,f);i((a=a.apply(p,d)).next())});import{d as g,s as b,j as E,v as w,o as S,c as m,a as r,F as x,E as F,l as h,m as L,B,x as D,y as G,z as T,C as y,T as v}from"./index.js?v=1e18a786";const C=["onSubmit"],k=r("div",{class:"label-name"},[r("span",null,"\u9009\u62E9\u8F6F\u4EF6\u6E90 ")],-1),I={class:"label-value"},V={class:"label-flex"},N=["value"],M={class:"label-btns"},j=["disabled"],q={key:0,class:"label-msg"},O=g({__name:"index",setup(p){return _(this,null,function*(){let d,a;const c=b(!1),n=b(""),o=E({softsourceListIfo:[],softSource:{},currSoftSource:{}}),f=()=>_(this,null,function*(){var s,e,u;try{const t=yield y.Guide.SoftSourceList.GET();if((s=t==null?void 0:t.data)!=null&&s.result){const l=(e=t==null?void 0:t.data)==null?void 0:e.result;o.softsourceListIfo=l.softSourceList||[]}}catch(t){console.log(t)}try{const t=yield y.Guide.GetSoftSource.GET();if((u=t==null?void 0:t.data)!=null&&u.result){const l=t.data.result;o.softSource=l.softSource,o.currSoftSource=l.softSource}}catch(t){console.log(t)}});[d,a]=w(()=>f()),yield d,a();const i=()=>_(this,null,function*(){const s=v.Loading("\u6B63\u5728\u5207\u6362\u4E2D...");c.value=!0;try{const e=yield y.Guide.SoftSource.POST({softSourceIdentity:o.softSource.identity});if(e!=null&&e.data){const{result:u,error:t,success:l}=e.data;t&&v.Warning(t),(e.data.success||0)==0&&(v.Success("\u5207\u6362\u6210\u529F"),yield f())}}catch(e){v.Error(`${e}`)}finally{c.value=!1,s.Close()}});return(s,e)=>(S(),m("form",{class:"form-container",onSubmit:B(i,["prevent"])},[k,r("div",I,[(S(!0),m(x,null,F(o.softsourceListIfo,u=>(S(),m("label",V,[D(r("input",{type:"radio",value:u.identity,"onUpdate:modelValue":e[0]||(e[0]=t=>o.softSource.identity=t)},null,8,N),[[G,o.softSource.identity,void 0,{trim:!0}]]),T(" "+h(u.name),1)]))),256))]),r("div",M,[r("button",{class:"sumbit",disabled:c.value},"\u4FDD\u5B58",8,j)]),n.value?(S(),m("div",q,[r("span",null,h(n.value),1)])):L("",!0)],40,C))})}});export{O as default};
|
||||
var _=(p,d,a)=>new Promise((c,n)=>{var o=s=>{try{i(a.next(s))}catch(e){n(e)}},f=s=>{try{i(a.throw(s))}catch(e){n(e)}},i=s=>s.done?c(s.value):Promise.resolve(s.value).then(o,f);i((a=a.apply(p,d)).next())});import{d as g,s as b,j as E,v as w,o as S,c as m,a as r,F as x,E as F,l as h,m as L,B,x as D,y as G,z as T,C as y,T as v}from"./index.js?v=5b4be379";const C=["onSubmit"],k=r("div",{class:"label-name"},[r("span",null,"\u9009\u62E9\u8F6F\u4EF6\u6E90 ")],-1),I={class:"label-value"},V={class:"label-flex"},N=["value"],M={class:"label-btns"},j=["disabled"],q={key:0,class:"label-msg"},O=g({__name:"index",setup(p){return _(this,null,function*(){let d,a;const c=b(!1),n=b(""),o=E({softsourceListIfo:[],softSource:{},currSoftSource:{}}),f=()=>_(this,null,function*(){var s,e,u;try{const t=yield y.Guide.SoftSourceList.GET();if((s=t==null?void 0:t.data)!=null&&s.result){const l=(e=t==null?void 0:t.data)==null?void 0:e.result;o.softsourceListIfo=l.softSourceList||[]}}catch(t){console.log(t)}try{const t=yield y.Guide.GetSoftSource.GET();if((u=t==null?void 0:t.data)!=null&&u.result){const l=t.data.result;o.softSource=l.softSource,o.currSoftSource=l.softSource}}catch(t){console.log(t)}});[d,a]=w(()=>f()),yield d,a();const i=()=>_(this,null,function*(){const s=v.Loading("\u6B63\u5728\u5207\u6362\u4E2D...");c.value=!0;try{const e=yield y.Guide.SoftSource.POST({softSourceIdentity:o.softSource.identity});if(e!=null&&e.data){const{result:u,error:t,success:l}=e.data;t&&v.Warning(t),(e.data.success||0)==0&&(v.Success("\u5207\u6362\u6210\u529F"),yield f())}}catch(e){v.Error(`${e}`)}finally{c.value=!1,s.Close()}});return(s,e)=>(S(),m("form",{class:"form-container",onSubmit:B(i,["prevent"])},[k,r("div",I,[(S(!0),m(x,null,F(o.softsourceListIfo,u=>(S(),m("label",V,[D(r("input",{type:"radio",value:u.identity,"onUpdate:modelValue":e[0]||(e[0]=t=>o.softSource.identity=t)},null,8,N),[[G,o.softSource.identity,void 0,{trim:!0}]]),T(" "+h(u.name),1)]))),256))]),r("div",M,[r("button",{class:"sumbit",disabled:c.value},"\u4FDD\u5B58",8,j)]),n.value?(S(),m("div",q,[r("span",null,h(n.value),1)])):L("",!0)],40,C))})}});export{O as default};
|
@ -1 +1 @@
|
||||
var r=(c,m,i)=>new Promise((w,t)=>{var n=l=>{try{o(i.next(l))}catch(v){t(v)}},s=l=>{try{o(i.throw(l))}catch(v){t(v)}},o=l=>l.done?w(l.value):Promise.resolve(l.value).then(n,s);o((i=i.apply(c,m)).next())});import{_ as V,d as T,u as I,s as f,j as A,v as M,o as E,c as b,a as u,x as _,y as h,z as D,A as k,m as y,l as U,B as q,p as G,q as N,C as B,T as x}from"./index.js?v=1e18a786";const p=c=>(G("data-v-c5783954"),c=c(),N(),c),L=["onSubmit"],O=p(()=>u("p",null,[D(" \u6B22\u8FCE\u4F7F\u7528\u5FEB\u901F\u7F51\u7EDC\u914D\u7F6E\u5411\u5BFC\uFF0C\u8BF7\u9009\u62E9\u4E00\u79CD\u8FDE\u63A5\u65B9\u5F0F\u4EE5\u5F00\u59CB\u8054\u7F51\uFF0C\u6216\u4F7F\u7528\u5DE6\u4FA7\u83DC\u5355\u8FDB\u884C\u8054\u7F51\u914D\u7F6E "),u("br"),D(" \u6CA1\u627E\u5230\u60F3\u8981\u7684\u914D\u7F6E\uFF1F\u8BF7\u4F7F\u7528 "),u("a",{href:"/cgi-bin/luci/admin/network/network",target:"_blank"},"\u9AD8\u7EA7\u6A21\u5F0F")],-1)),j=p(()=>u("div",{class:"label-name"},[u("span",null,"\u8054\u7F51\u65B9\u5F0F")],-1)),z={class:"label-value"},R={class:"label-flex"},H={style:{display:"none"}},J={key:0,class:"ul-container"},K=p(()=>u("div",{class:"ul-container_title"},[u("span",null,"\u62E8\u53F7\u8054\u7F51\u914D\u7F6E")],-1)),Q=p(()=>u("div",{class:"label-value"},null,-1)),W=p(()=>u("div",{class:"label-name"},[u("span",null,"\u8D26\u53F7")],-1)),X={class:"label-value"},Y=p(()=>u("div",{class:"label-name"},[u("span",null,"\u5BC6\u7801")],-1)),Z={class:"label-value"},$={key:1,class:"label-btns"},uu=["disabled"],eu={key:2,class:"label-msg"},au=T({__name:"index",setup(c){return r(this,null,function*(){let m,i;const w=I(),t=f(""),n=f(!1),s=f(""),o=A({account:"",password:""}),l=A({wanProto:"dhcp",dnsProto:"auto",staticIp:"",subnetMask:"",manualDnsIp:[],gateway:""}),v=()=>r(this,null,function*(){n.value=!0;try{const d=yield B.Guide.Pppoe.GET(),{result:e}=d.data;e&&(o.account=e.account||"",o.password=e.password||"")}catch(d){s.value=d}t.value=yield w.getAsyncNetworkProto,n.value=!1});[m,i]=M(()=>v()),yield m,i();const P=()=>r(this,null,function*(){switch(t.value){case"pppoe":yield S();break;case"dhcp":yield g();break;default:s.value="\u627E\u4E0D\u5230\u4F60\u8981\u7684\u914D\u7F6E";break}}),S=()=>r(this,null,function*(){if(o.account==""){s.value="\u8D26\u53F7\u4E0D\u80FD\u4E3A\u7A7A";return}if(o.password==""){s.value="\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A";return}n.value=!0;const d=x.Loading("\u4FDD\u5B58\u4E2D...");try{const e=yield B.Guide.Pppoe.POST({account:o.account,password:o.password});if(e.data){const{error:a,success:F}=e.data;a&&(s.value=a),(F==null||F==0)&&(s.value="\u914D\u7F6E\u5B8C\u6210")}}catch(e){s.value=e}finally{}n.value=!1,d.Close()}),g=()=>r(this,null,function*(){const d={wanProto:l.wanProto,dnsProto:l.dnsProto};n.value=!0;const e=x.Loading("\u4FDD\u5B58\u4E2D...");try{const a=yield B.Guide.ClientModel.POST(d);if(a!=null&&a.data){const{success:F,error:C}=a==null?void 0:a.data;C&&(s.value=C),(F==null||F==0)&&(s.value="\u914D\u7F6E\u5B8C\u6210")}}catch(a){s.value=a}n.value=!1,e.Close()});return(d,e)=>(E(),b("form",{class:"form-container",onSubmit:q(P,["prevent"])},[O,j,u("div",z,[u("div",R,[u("label",null,[_(u("input",{type:"radio",value:"pppoe","onUpdate:modelValue":e[0]||(e[0]=a=>t.value=a)},null,512),[[h,t.value]]),D("\u8D26\u53F7\u5BC6\u7801")]),u("label",null,[_(u("input",{type:"radio",value:"dhcp","onUpdate:modelValue":e[1]||(e[1]=a=>t.value=a)},null,512),[[h,t.value]]),D("\u81EA\u52A8\u8054\u7F51")]),u("label",H,[_(u("input",{type:"radio",value:"static",hidden:"true","onUpdate:modelValue":e[2]||(e[2]=a=>t.value=a)},null,512),[[h,t.value]]),D("\u7F51\u5173\u8054\u7F51")])])]),t.value=="pppoe"?(E(),b("ul",J,[K,Q,W,u("div",X,[_(u("input",{type:"text",placeholder:"\u5BBD\u5E26\u8D26\u53F7","onUpdate:modelValue":e[3]||(e[3]=a=>o.account=a),required:""},null,512),[[k,o.account,void 0,{trim:!0}]])]),Y,u("div",Z,[_(u("input",{type:"password",placeholder:"\u5BBD\u5E26\u5BC6\u7801","onUpdate:modelValue":e[4]||(e[4]=a=>o.password=a),required:""},null,512),[[k,o.password,void 0,{trim:!0}]])])])):y("",!0),t.value=="pppoe"||t.value=="dhcp"?(E(),b("div",$,[u("button",{class:"sumbit",disabled:n.value},"\u4FDD\u5B58",8,uu)])):y("",!0),s.value?(E(),b("div",eu,[u("span",null,U(s.value),1)])):y("",!0)],40,L))})}});var ou=V(au,[["__scopeId","data-v-c5783954"]]);export{ou as default};
|
||||
var r=(c,m,i)=>new Promise((w,t)=>{var n=l=>{try{o(i.next(l))}catch(v){t(v)}},s=l=>{try{o(i.throw(l))}catch(v){t(v)}},o=l=>l.done?w(l.value):Promise.resolve(l.value).then(n,s);o((i=i.apply(c,m)).next())});import{_ as V,d as T,u as I,s as f,j as A,v as M,o as E,c as b,a as u,x as _,y as h,z as D,A as k,m as y,l as U,B as q,p as G,q as N,C as B,T as x}from"./index.js?v=5b4be379";const p=c=>(G("data-v-c5783954"),c=c(),N(),c),L=["onSubmit"],O=p(()=>u("p",null,[D(" \u6B22\u8FCE\u4F7F\u7528\u5FEB\u901F\u7F51\u7EDC\u914D\u7F6E\u5411\u5BFC\uFF0C\u8BF7\u9009\u62E9\u4E00\u79CD\u8FDE\u63A5\u65B9\u5F0F\u4EE5\u5F00\u59CB\u8054\u7F51\uFF0C\u6216\u4F7F\u7528\u5DE6\u4FA7\u83DC\u5355\u8FDB\u884C\u8054\u7F51\u914D\u7F6E "),u("br"),D(" \u6CA1\u627E\u5230\u60F3\u8981\u7684\u914D\u7F6E\uFF1F\u8BF7\u4F7F\u7528 "),u("a",{href:"/cgi-bin/luci/admin/network/network",target:"_blank"},"\u9AD8\u7EA7\u6A21\u5F0F")],-1)),j=p(()=>u("div",{class:"label-name"},[u("span",null,"\u8054\u7F51\u65B9\u5F0F")],-1)),z={class:"label-value"},R={class:"label-flex"},H={style:{display:"none"}},J={key:0,class:"ul-container"},K=p(()=>u("div",{class:"ul-container_title"},[u("span",null,"\u62E8\u53F7\u8054\u7F51\u914D\u7F6E")],-1)),Q=p(()=>u("div",{class:"label-value"},null,-1)),W=p(()=>u("div",{class:"label-name"},[u("span",null,"\u8D26\u53F7")],-1)),X={class:"label-value"},Y=p(()=>u("div",{class:"label-name"},[u("span",null,"\u5BC6\u7801")],-1)),Z={class:"label-value"},$={key:1,class:"label-btns"},uu=["disabled"],eu={key:2,class:"label-msg"},au=T({__name:"index",setup(c){return r(this,null,function*(){let m,i;const w=I(),t=f(""),n=f(!1),s=f(""),o=A({account:"",password:""}),l=A({wanProto:"dhcp",dnsProto:"auto",staticIp:"",subnetMask:"",manualDnsIp:[],gateway:""}),v=()=>r(this,null,function*(){n.value=!0;try{const d=yield B.Guide.Pppoe.GET(),{result:e}=d.data;e&&(o.account=e.account||"",o.password=e.password||"")}catch(d){s.value=d}t.value=yield w.getAsyncNetworkProto,n.value=!1});[m,i]=M(()=>v()),yield m,i();const P=()=>r(this,null,function*(){switch(t.value){case"pppoe":yield S();break;case"dhcp":yield g();break;default:s.value="\u627E\u4E0D\u5230\u4F60\u8981\u7684\u914D\u7F6E";break}}),S=()=>r(this,null,function*(){if(o.account==""){s.value="\u8D26\u53F7\u4E0D\u80FD\u4E3A\u7A7A";return}if(o.password==""){s.value="\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A";return}n.value=!0;const d=x.Loading("\u4FDD\u5B58\u4E2D...");try{const e=yield B.Guide.Pppoe.POST({account:o.account,password:o.password});if(e.data){const{error:a,success:F}=e.data;a&&(s.value=a),(F==null||F==0)&&(s.value="\u914D\u7F6E\u5B8C\u6210")}}catch(e){s.value=e}finally{}n.value=!1,d.Close()}),g=()=>r(this,null,function*(){const d={wanProto:l.wanProto,dnsProto:l.dnsProto};n.value=!0;const e=x.Loading("\u4FDD\u5B58\u4E2D...");try{const a=yield B.Guide.ClientModel.POST(d);if(a!=null&&a.data){const{success:F,error:C}=a==null?void 0:a.data;C&&(s.value=C),(F==null||F==0)&&(s.value="\u914D\u7F6E\u5B8C\u6210")}}catch(a){s.value=a}n.value=!1,e.Close()});return(d,e)=>(E(),b("form",{class:"form-container",onSubmit:q(P,["prevent"])},[O,j,u("div",z,[u("div",R,[u("label",null,[_(u("input",{type:"radio",value:"pppoe","onUpdate:modelValue":e[0]||(e[0]=a=>t.value=a)},null,512),[[h,t.value]]),D("\u8D26\u53F7\u5BC6\u7801")]),u("label",null,[_(u("input",{type:"radio",value:"dhcp","onUpdate:modelValue":e[1]||(e[1]=a=>t.value=a)},null,512),[[h,t.value]]),D("\u81EA\u52A8\u8054\u7F51")]),u("label",H,[_(u("input",{type:"radio",value:"static",hidden:"true","onUpdate:modelValue":e[2]||(e[2]=a=>t.value=a)},null,512),[[h,t.value]]),D("\u7F51\u5173\u8054\u7F51")])])]),t.value=="pppoe"?(E(),b("ul",J,[K,Q,W,u("div",X,[_(u("input",{type:"text",placeholder:"\u5BBD\u5E26\u8D26\u53F7","onUpdate:modelValue":e[3]||(e[3]=a=>o.account=a),required:""},null,512),[[k,o.account,void 0,{trim:!0}]])]),Y,u("div",Z,[_(u("input",{type:"password",placeholder:"\u5BBD\u5E26\u5BC6\u7801","onUpdate:modelValue":e[4]||(e[4]=a=>o.password=a),required:""},null,512),[[k,o.password,void 0,{trim:!0}]])])])):y("",!0),t.value=="pppoe"||t.value=="dhcp"?(E(),b("div",$,[u("button",{class:"sumbit",disabled:n.value},"\u4FDD\u5B58",8,uu)])):y("",!0),s.value?(E(),b("div",eu,[u("span",null,U(s.value),1)])):y("",!0)],40,L))})}});var ou=V(au,[["__scopeId","data-v-c5783954"]]);export{ou as default};
|
@ -1 +1 @@
|
||||
import{_ as r}from"./index.js?v=1e18a786";const e={};function n(_,c){return null}var a=r(e,[["render",n]]);export{a as default};
|
||||
import{_ as r}from"./index.js?v=5b4be379";const e={};function n(_,c){return null}var a=r(e,[["render",n]]);export{a as default};
|
@ -1 +1 @@
|
||||
var g=Object.defineProperty;var y=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var C=(o,u,s)=>u in o?g(o,u,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[u]=s,k=(o,u)=>{for(var s in u||(u={}))w.call(u,s)&&C(o,s,u[s]);if(y)for(var s of y(u))A.call(u,s)&&C(o,s,u[s]);return o};var b=(o,u,s)=>new Promise((i,t)=>{var p=d=>{try{c(s.next(d))}catch(l){t(l)}},m=d=>{try{c(s.throw(d))}catch(l){t(l)}},c=d=>d.done?i(d.value):Promise.resolve(d.value).then(p,m);c((s=s.apply(o,u)).next())});import{d as T,s as E,j as U,v as q,o as _,c as f,a as e,x as r,A as D,F as V,y as P,z as x,m as B,l as G,B as H,C as M,T as F}from"./index.js?v=1e18a786";import{i as v}from"./chunk.6d3585bb.js";const L=["onSubmit"],N=e("div",{class:"label-name"},[e("span",null,"\u5185\u7F51\u5730\u5740")],-1),R={class:"label-value"},j=e("div",{class:"label-name"},[e("span",null,"\u5B50\u7F51\u63A9\u7801")],-1),z={class:"label-value"},O=e("div",{class:"label-name"},[e("span",null,"DHCP\u670D\u52A1")],-1),$={class:"label-value"},J={class:"label-flex"},K=e("div",{class:"label-name"},[e("span",null,"IP\u6C60\u8D77\u59CB\u5730\u5740")],-1),Q={class:"label-value"},W=e("div",{class:"label-name"},[e("span",null,"IP\u6C60\u7ED3\u675F\u5730\u5740")],-1),X={class:"label-value"},Y={class:"label-btns"},Z=["disabled"],ee={key:2,class:"label-msg"},ue=T({__name:"index",setup(o){return b(this,null,function*(){let u,s;const i=E(""),t=U({lanIp:"",netMask:"255.255.255.0",enableDhcp:!1,dhcpStart:"",dhcpEnd:""}),p=E(!1),m=E(!1),c=()=>b(this,null,function*(){p.value=!0;const l=yield M.Guide.GetLan.GET();if(l.data){const{result:a}=l.data;a&&(t.lanIp=a.lanIp,t.netMask=a.netMask,m.value=a.enableDhcp||!1,t.dhcpStart=a.dhcpStart,t.dhcpEnd=a.dhcpEnd,a.lanIp,location.hostname)}p.value=!1});[u,s]=q(()=>c()),yield u,s();const d=()=>b(this,null,function*(){const l=k({},t);if(!v.isValidIP(l.lanIp)){F.Error("IPv4\u5730\u5740\u683C\u5F0F\u9519\u8BEF");return}if(!v.isValidMask(l.netMask)){F.Error("IPv4\u5B50\u7F51\u63A9\u7801\u683C\u5F0F\u9519\u8BEF");return}if(l.enableDhcp&&!v.isValidIP(l.dhcpStart)||!v.isValidIP(l.dhcpEnd)||!v.isValidMaskRange(l.lanIp,l.netMask,l.dhcpStart,l.dhcpEnd)){F.Error("DHCP\u7684IP\u6C60\u683C\u5F0F\u9519\u8BEF\u6216\u8D85\u51FA\u5B50\u7F51\u8303\u56F4");return}const a=F.Loading("\u6B63\u5728\u914D\u7F6E,\u8BF7\u7A0D\u7B49\u2026");let n=!1;try{const h=yield M.Guide.LanIp.POST(l);if(h.data){const{result:ae,success:S,error:I}=h.data;if(I){i.value=I;return}(S||0)==0&&(n=!0)}}catch(h){i.value=h}finally{a.Close()}n&&(i.value=`\u66F4\u65B0\u6210\u529F,\u8BF7\u8FDB\u5165 ${l.lanIp} \u8DEF\u7531\u5668\u5730\u5740`)});return(l,a)=>(_(),f("form",{class:"form-container",onSubmit:H(d,["prevent"])},[N,e("div",R,[r(e("input",{type:"text",placeholder:"192.168.100.1","onUpdate:modelValue":a[0]||(a[0]=n=>t.lanIp=n),required:""},null,512),[[D,t.lanIp,void 0,{trim:!0}]])]),j,e("div",z,[r(e("input",{type:"text",placeholder:"255.255.255.0","onUpdate:modelValue":a[1]||(a[1]=n=>t.netMask=n),required:""},null,512),[[D,t.netMask,void 0,{trim:!0}]])]),m.value?(_(),f(V,{key:0},[O,e("div",$,[e("div",J,[e("label",null,[r(e("input",{type:"radio",value:!1,"onUpdate:modelValue":a[2]||(a[2]=n=>t.enableDhcp=n)},null,512),[[P,t.enableDhcp]]),x("\u4FDD\u6301DHCP")]),e("label",null,[r(e("input",{type:"radio",value:!0,"onUpdate:modelValue":a[3]||(a[3]=n=>t.enableDhcp=n)},null,512),[[P,t.enableDhcp]]),x("\u4FEE\u6539DHCP")])])])],64)):B("",!0),t.enableDhcp?(_(),f(V,{key:1},[K,e("div",Q,[r(e("input",{type:"text",placeholder:"192.168.100.100","onUpdate:modelValue":a[4]||(a[4]=n=>t.dhcpStart=n),required:""},null,512),[[D,t.dhcpStart,void 0,{trim:!0}]])]),W,e("div",X,[r(e("input",{type:"text",placeholder:"192.168.100.100","onUpdate:modelValue":a[5]||(a[5]=n=>t.dhcpEnd=n),required:""},null,512),[[D,t.dhcpEnd,void 0,{trim:!0}]])])],64)):B("",!0),e("div",Y,[e("button",{class:"sumbit",disabled:p.value},"\u4FDD\u5B58",8,Z)]),i.value?(_(),f("div",ee,[e("span",null,G(i.value),1)])):B("",!0)],40,L))})}});export{ue as default};
|
||||
var g=Object.defineProperty;var y=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var C=(o,u,s)=>u in o?g(o,u,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[u]=s,k=(o,u)=>{for(var s in u||(u={}))w.call(u,s)&&C(o,s,u[s]);if(y)for(var s of y(u))A.call(u,s)&&C(o,s,u[s]);return o};var b=(o,u,s)=>new Promise((i,t)=>{var p=d=>{try{c(s.next(d))}catch(l){t(l)}},m=d=>{try{c(s.throw(d))}catch(l){t(l)}},c=d=>d.done?i(d.value):Promise.resolve(d.value).then(p,m);c((s=s.apply(o,u)).next())});import{d as T,s as E,j as U,v as q,o as _,c as f,a as e,x as r,A as D,F as V,y as P,z as x,m as B,l as G,B as H,C as M,T as F}from"./index.js?v=5b4be379";import{i as v}from"./chunk.6d3585bb.js";const L=["onSubmit"],N=e("div",{class:"label-name"},[e("span",null,"\u5185\u7F51\u5730\u5740")],-1),R={class:"label-value"},j=e("div",{class:"label-name"},[e("span",null,"\u5B50\u7F51\u63A9\u7801")],-1),z={class:"label-value"},O=e("div",{class:"label-name"},[e("span",null,"DHCP\u670D\u52A1")],-1),$={class:"label-value"},J={class:"label-flex"},K=e("div",{class:"label-name"},[e("span",null,"IP\u6C60\u8D77\u59CB\u5730\u5740")],-1),Q={class:"label-value"},W=e("div",{class:"label-name"},[e("span",null,"IP\u6C60\u7ED3\u675F\u5730\u5740")],-1),X={class:"label-value"},Y={class:"label-btns"},Z=["disabled"],ee={key:2,class:"label-msg"},ue=T({__name:"index",setup(o){return b(this,null,function*(){let u,s;const i=E(""),t=U({lanIp:"",netMask:"255.255.255.0",enableDhcp:!1,dhcpStart:"",dhcpEnd:""}),p=E(!1),m=E(!1),c=()=>b(this,null,function*(){p.value=!0;const l=yield M.Guide.GetLan.GET();if(l.data){const{result:a}=l.data;a&&(t.lanIp=a.lanIp,t.netMask=a.netMask,m.value=a.enableDhcp||!1,t.dhcpStart=a.dhcpStart,t.dhcpEnd=a.dhcpEnd,a.lanIp,location.hostname)}p.value=!1});[u,s]=q(()=>c()),yield u,s();const d=()=>b(this,null,function*(){const l=k({},t);if(!v.isValidIP(l.lanIp)){F.Error("IPv4\u5730\u5740\u683C\u5F0F\u9519\u8BEF");return}if(!v.isValidMask(l.netMask)){F.Error("IPv4\u5B50\u7F51\u63A9\u7801\u683C\u5F0F\u9519\u8BEF");return}if(l.enableDhcp&&!v.isValidIP(l.dhcpStart)||!v.isValidIP(l.dhcpEnd)||!v.isValidMaskRange(l.lanIp,l.netMask,l.dhcpStart,l.dhcpEnd)){F.Error("DHCP\u7684IP\u6C60\u683C\u5F0F\u9519\u8BEF\u6216\u8D85\u51FA\u5B50\u7F51\u8303\u56F4");return}const a=F.Loading("\u6B63\u5728\u914D\u7F6E,\u8BF7\u7A0D\u7B49\u2026");let n=!1;try{const h=yield M.Guide.LanIp.POST(l);if(h.data){const{result:ae,success:S,error:I}=h.data;if(I){i.value=I;return}(S||0)==0&&(n=!0)}}catch(h){i.value=h}finally{a.Close()}n&&(i.value=`\u66F4\u65B0\u6210\u529F,\u8BF7\u8FDB\u5165 ${l.lanIp} \u8DEF\u7531\u5668\u5730\u5740`)});return(l,a)=>(_(),f("form",{class:"form-container",onSubmit:H(d,["prevent"])},[N,e("div",R,[r(e("input",{type:"text",placeholder:"192.168.100.1","onUpdate:modelValue":a[0]||(a[0]=n=>t.lanIp=n),required:""},null,512),[[D,t.lanIp,void 0,{trim:!0}]])]),j,e("div",z,[r(e("input",{type:"text",placeholder:"255.255.255.0","onUpdate:modelValue":a[1]||(a[1]=n=>t.netMask=n),required:""},null,512),[[D,t.netMask,void 0,{trim:!0}]])]),m.value?(_(),f(V,{key:0},[O,e("div",$,[e("div",J,[e("label",null,[r(e("input",{type:"radio",value:!1,"onUpdate:modelValue":a[2]||(a[2]=n=>t.enableDhcp=n)},null,512),[[P,t.enableDhcp]]),x("\u4FDD\u6301DHCP")]),e("label",null,[r(e("input",{type:"radio",value:!0,"onUpdate:modelValue":a[3]||(a[3]=n=>t.enableDhcp=n)},null,512),[[P,t.enableDhcp]]),x("\u4FEE\u6539DHCP")])])])],64)):B("",!0),t.enableDhcp?(_(),f(V,{key:1},[K,e("div",Q,[r(e("input",{type:"text",placeholder:"192.168.100.100","onUpdate:modelValue":a[4]||(a[4]=n=>t.dhcpStart=n),required:""},null,512),[[D,t.dhcpStart,void 0,{trim:!0}]])]),W,e("div",X,[r(e("input",{type:"text",placeholder:"192.168.100.100","onUpdate:modelValue":a[5]||(a[5]=n=>t.dhcpEnd=n),required:""},null,512),[[D,t.dhcpEnd,void 0,{trim:!0}]])])],64)):B("",!0),e("div",Y,[e("button",{class:"sumbit",disabled:p.value},"\u4FDD\u5B58",8,Z)]),i.value?(_(),f("div",ee,[e("span",null,G(i.value),1)])):B("",!0)],40,L))})}});export{ue as default};
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
import{d as a,r as e,o as u,e as r,w as p,b as s}from"./index.js?v=1e18a786";const _=a({__name:"index",setup(c){const t=[{name:"index",title:"\u7F51\u7EDC\u914D\u7F6E",path:"/router/network"},{name:"pppoe",title:"\u62E8\u53F7\u8FDE\u63A5",path:"/router/network/pppoe"},{name:"dhcp",title:"DHCP\u8FDE\u63A5",path:"/router/network/dhcp"},{name:"gateway",title:"\u65C1\u8DEF\u7531\u8FDE\u63A5",path:"/router/network/gateway"},{name:"intranet",title:"\u5185\u7F51\u914D\u7F6E",path:"/router/network/intranet"},{name:"dns",title:"DNS\u914D\u7F6E",path:"/router/network/dns"}];return(i,l)=>{const o=e("router-loading"),n=e("layout-page");return u(),r(n,{menus:t},{default:p(()=>[s(o)]),_:1})}}});export{_ as default};
|
||||
import{d as a,r as e,o as u,e as r,w as p,b as s}from"./index.js?v=5b4be379";const _=a({__name:"index",setup(c){const t=[{name:"index",title:"\u7F51\u7EDC\u914D\u7F6E",path:"/router/network"},{name:"pppoe",title:"\u62E8\u53F7\u8FDE\u63A5",path:"/router/network/pppoe"},{name:"dhcp",title:"DHCP\u8FDE\u63A5",path:"/router/network/dhcp"},{name:"gateway",title:"\u65C1\u8DEF\u7531\u8FDE\u63A5",path:"/router/network/gateway"},{name:"intranet",title:"\u5185\u7F51\u914D\u7F6E",path:"/router/network/intranet"},{name:"dns",title:"DNS\u914D\u7F6E",path:"/router/network/dns"}];return(i,l)=>{const o=e("router-loading"),n=e("layout-page");return u(),r(n,{menus:t},{default:p(()=>[s(o)]),_:1})}}});export{_ as default};
|
@ -1 +1 @@
|
||||
var d=(_,i,l)=>new Promise((t,e)=>{var n=o=>{try{c(l.next(o))}catch(u){e(u)}},p=o=>{try{c(l.throw(o))}catch(u){e(u)}},c=o=>o.done?t(o.value):Promise.resolve(o.value).then(n,p);c((l=l.apply(_,i)).next())});import{d as E,s as v,j as h,v as F,o as D,c as f,a,x as b,A as B,l as y,m as A,B as C,C as w,T as x}from"./index.js?v=1e18a786";const g=["onSubmit"],S=a("div",{class:"label-info"}," \u8BF7\u786E\u4FDD\u60A8\u5DF2\u5C06\u8DEF\u7531 WAN \u53E3\u8FDE\u63A5\u5230\u5149\u732B ",-1),T=a("div",{class:"label-name"},[a("span",null,"\u8D26\u53F7")],-1),V={class:"label-value"},k=a("div",{class:"label-name"},[a("span",null,"\u5BC6\u7801")],-1),q={class:"label-value"},G={class:"label-btns"},N=["disabled"],P={key:0,class:"label-msg"},j=E({__name:"index",setup(_){return d(this,null,function*(){let i,l;const t=v(""),e=h({account:"",password:""}),n=v(!1),p=v(!1),c=()=>d(this,null,function*(){n.value=!0;try{const u=yield w.Guide.Pppoe.GET(),{result:s}=u.data;s&&(e.account=s.account||"",e.password=s.password||"")}catch(u){t.value=u}finally{}n.value=!1,p.value=!0});[i,l]=F(()=>c()),yield i,l();const o=()=>d(this,null,function*(){if(e.account==""){t.value="\u8D26\u53F7\u4E0D\u80FD\u4E3A\u7A7A";return}if(e.password==""){t.value="\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A";return}n.value=!0;const u=x.Loading("\u4FDD\u5B58\u4E2D...");try{const s=yield w.Guide.Pppoe.POST({account:e.account,password:e.password});if(s.data){const{error:r,success:m}=s.data;r&&(t.value=r),(m==null||m==0)&&(t.value="\u914D\u7F6E\u5B8C\u6210")}}catch(s){t.value=s}finally{}n.value=!1,u.Close()});return(u,s)=>(D(),f("form",{class:"form-container",onSubmit:C(o,["prevent"])},[S,T,a("div",V,[b(a("input",{type:"text",placeholder:"\u5BBD\u5E26\u8D26\u53F7","onUpdate:modelValue":s[0]||(s[0]=r=>e.account=r),required:""},null,512),[[B,e.account,void 0,{trim:!0}]])]),k,a("div",q,[b(a("input",{type:"password",placeholder:"\u5BBD\u5E26\u5BC6\u7801","onUpdate:modelValue":s[1]||(s[1]=r=>e.password=r),required:""},null,512),[[B,e.password,void 0,{trim:!0}]])]),a("div",G,[a("button",{class:"sumbit",disabled:n.value},"\u4FDD\u5B58",8,N)]),t.value?(D(),f("div",P,[a("span",null,y(t.value),1)])):A("",!0)],40,g))})}});export{j as default};
|
||||
var d=(_,i,l)=>new Promise((t,e)=>{var n=o=>{try{c(l.next(o))}catch(u){e(u)}},p=o=>{try{c(l.throw(o))}catch(u){e(u)}},c=o=>o.done?t(o.value):Promise.resolve(o.value).then(n,p);c((l=l.apply(_,i)).next())});import{d as E,s as v,j as h,v as F,o as D,c as f,a,x as b,A as B,l as y,m as A,B as C,C as w,T as x}from"./index.js?v=5b4be379";const g=["onSubmit"],S=a("div",{class:"label-info"}," \u8BF7\u786E\u4FDD\u60A8\u5DF2\u5C06\u8DEF\u7531 WAN \u53E3\u8FDE\u63A5\u5230\u5149\u732B ",-1),T=a("div",{class:"label-name"},[a("span",null,"\u8D26\u53F7")],-1),V={class:"label-value"},k=a("div",{class:"label-name"},[a("span",null,"\u5BC6\u7801")],-1),q={class:"label-value"},G={class:"label-btns"},N=["disabled"],P={key:0,class:"label-msg"},j=E({__name:"index",setup(_){return d(this,null,function*(){let i,l;const t=v(""),e=h({account:"",password:""}),n=v(!1),p=v(!1),c=()=>d(this,null,function*(){n.value=!0;try{const u=yield w.Guide.Pppoe.GET(),{result:s}=u.data;s&&(e.account=s.account||"",e.password=s.password||"")}catch(u){t.value=u}finally{}n.value=!1,p.value=!0});[i,l]=F(()=>c()),yield i,l();const o=()=>d(this,null,function*(){if(e.account==""){t.value="\u8D26\u53F7\u4E0D\u80FD\u4E3A\u7A7A";return}if(e.password==""){t.value="\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A";return}n.value=!0;const u=x.Loading("\u4FDD\u5B58\u4E2D...");try{const s=yield w.Guide.Pppoe.POST({account:e.account,password:e.password});if(s.data){const{error:r,success:m}=s.data;r&&(t.value=r),(m==null||m==0)&&(t.value="\u914D\u7F6E\u5B8C\u6210")}}catch(s){t.value=s}finally{}n.value=!1,u.Close()});return(u,s)=>(D(),f("form",{class:"form-container",onSubmit:C(o,["prevent"])},[S,T,a("div",V,[b(a("input",{type:"text",placeholder:"\u5BBD\u5E26\u8D26\u53F7","onUpdate:modelValue":s[0]||(s[0]=r=>e.account=r),required:""},null,512),[[B,e.account,void 0,{trim:!0}]])]),k,a("div",q,[b(a("input",{type:"password",placeholder:"\u5BBD\u5E26\u5BC6\u7801","onUpdate:modelValue":s[1]||(s[1]=r=>e.password=r),required:""},null,512),[[B,e.password,void 0,{trim:!0}]])]),a("div",G,[a("button",{class:"sumbit",disabled:n.value},"\u4FDD\u5B58",8,N)]),t.value?(D(),f("div",P,[a("span",null,y(t.value),1)])):A("",!0)],40,g))})}});export{j as default};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
var p=(o,u,s)=>new Promise((h,c)=>{var f=r=>{try{t(s.next(r))}catch(l){c(l)}},x=r=>{try{t(s.throw(r))}catch(l){c(l)}},t=r=>r.done?h(r.value):Promise.resolve(r.value).then(f,x);t((s=s.apply(o,u)).next())});import{_ as v,d as w,j as B,v as m,k as g,o as a,c as i,a as e,F as k,E as y,z as _,l as n,p as A,q as C,C as M}from"./index.js?v=1e18a786";const d=o=>(A("data-v-16a9b49b"),o=o(),C(),o),D={class:"page-table"},F=d(()=>e("colgroup",null,[e("col"),e("col"),e("col"),e("col"),e("col"),e("col")],-1)),E=d(()=>e("thead",null,[e("tr",null,[e("th",null," \u72B6\u6001 "),e("th",null," \u63A5\u53E3 "),e("th",null," \u7C7B\u578B "),e("th",null," mac "),e("th",null," \u63A5\u6536 "),e("th",null," \u53D1\u9001 ")])],-1)),b={class:"flex-icon"},z=d(()=>e("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","xmlns:v":"https://vecta.io/nano",width:"48",height:"38",viewBox:"0 0 12.7 10.05"},[e("defs",null,[e("filter",{id:"A","color-interpolation-filters":"sRGB"},[e("feColorMatrix",{result:"A",values:"2 -0.5 -0.5 0 0 -0.5 2 -0.5 0 0 -0.5 -0.5 2 0 0 0 0 0 1 0 "}),e("feColorMatrix",{values:"0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"}),e("feColorMatrix",{in:"A",values:"2 -0.5 -0.5 0 0 -0.5 2 -0.5 0 0 -0.5 -0.5 2 0 0 0 0 0 1 0 "})]),e("path",{id:"B",d:"M80.56 75.75h3.91v22.79h-3.91z"})]),e("g",{transform:"translate(0 -286.95)"},[e("rect",{x:".21",y:"287.25",width:"12.33",height:"9.5",ry:".57",fill:"#e6e6e6",stroke:"#e6e6e6","stroke-linejoin":"round","stroke-width":".37","paint-order":"normal"}),e("path",{transform:"matrix(.105 0 0 .0989 -6.0834 280.6)",d:"M73.96 75.66h89.41c2.31 0 4.17 1.86 4.17 4.17v52.65h-21.74v9.41h-8.69v12.59h-36.87v-12.59h-8.69v-9.41H69.79V79.83c0-2.31 1.86-4.17 4.17-4.17z",fill:"#999",filter:"url(#A)",stroke:"#999","stroke-width":"2.5"}),e("g",{transform:"matrix(.1048 0 0 .1048 -6.0999 280.7)",fill:"#fff",filter:"url(#A)",stroke:"#fff"},[e("use",{"xlink:href":"#B"}),e("use",{"xlink:href":"#B",x:"73.04"}),e("use",{"xlink:href":"#B",x:"52.17"}),e("use",{"xlink:href":"#B",x:"41.74"}),e("use",{"xlink:href":"#B",x:"31.3"}),e("use",{"xlink:href":"#B",x:"20.87"}),e("use",{"xlink:href":"#B",x:"10.43"}),e("use",{"xlink:href":"#B",x:"62.61"})]),e("rect",{x:"1.24",y:"294.55",width:"1.6",height:"1.38",ry:".11",fill:"#ccc",stroke:"#ccc","stroke-width":".22","paint-order":"normal"})])],-1)),N=d(()=>e("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",width:"48",height:"38",viewBox:"0 0 12.7 10.05","xmlns:v":"https://vecta.io/nano"},[e("defs",null,[e("filter",{id:"A","color-interpolation-filters":"sRGB"},[e("feColorMatrix",{result:"A",values:"2 -0.5 -0.5 0 0 -0.5 2 -0.5 0 0 -0.5 -0.5 2 0 0 0 0 0 1 0 "}),e("feColorMatrix",{values:"0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"}),e("feColorMatrix",{in:"A",values:"2 -0.5 -0.5 0 0 -0.5 2 -0.5 0 0 -0.5 -0.5 2 0 0 0 0 0 1 0 "})]),e("path",{id:"B",d:"M80.56 75.75h3.91v22.79h-3.91z"})]),e("g",{transform:"translate(-.03 -287.07)"},[e("rect",{x:".24",y:"287.36",width:"12.33",height:"9.5",ry:".57",fill:"#e6e6e6",stroke:"#e6e6e6","stroke-linejoin":"round","stroke-width":".37","paint-order":"normal"}),e("path",{transform:"matrix(.105 0 0 .0989 -6.0532 280.72)",d:"M73.96 75.66h89.41c2.31 0 4.17 1.86 4.17 4.17v52.65h-21.74v9.41h-8.69v12.59h-36.87v-12.59h-8.69v-9.41H69.79V79.83c0-2.31 1.86-4.17 4.17-4.17z",fill:"#4d4d4d",filter:"url(#A)",stroke:"#4d4d4d","stroke-width":"2.5"}),e("g",{transform:"matrix(.1048 0 0 .1048 -6.0697 280.81)",fill:"#fff",filter:"url(#A)",stroke:"#fff"},[e("use",{"xlink:href":"#B"}),e("use",{"xlink:href":"#B",x:"73.04"}),e("use",{"xlink:href":"#B",x:"52.17"}),e("use",{"xlink:href":"#B",x:"41.74"}),e("use",{"xlink:href":"#B",x:"31.3"}),e("use",{"xlink:href":"#B",x:"20.87"}),e("use",{"xlink:href":"#B",x:"10.43"}),e("use",{"xlink:href":"#B",x:"62.61"})]),e("rect",{x:"1.27",y:"294.67",width:"1.6",height:"1.38",ry:".11",fill:"#55d400",stroke:"#55d400","stroke-width":".22","paint-order":"normal"})])],-1)),S=w({__name:"index",setup(o){return p(this,null,function*(){let u,s;const h=B({ports:[]}),c=t=>{switch(t){case"full":return"\u5168\u53CC\u5DE5";case"half":return"\u534A\u53CC\u5DE5"}};let f=!1;const x=()=>p(this,null,function*(){try{const t=yield M.Network.PortList.GET();if(t!=null&&t.data){const{result:r}=t==null?void 0:t.data;r&&(h.ports=r.ports||[])}}catch(t){console.log(t)}setTimeout(()=>{f||x()},1e4)});return[u,s]=m(()=>x()),yield u,s(),g(()=>{f=!0}),(t,r)=>(a(),i("table",D,[F,E,e("tbody",null,[(a(!0),i(k,null,y(h.ports,l=>(a(),i("tr",null,[e("th",b,[l.linkState=="DOWN"?(a(),i(k,{key:0},[z,_("\u672A\u8FDE\u63A5 ")],64)):(a(),i(k,{key:1},[N,_(" \u5DF2\u8FDE\u63A5 ")],64))]),e("th",null,n(l.name)+"\uFF08"+n(l.interfaceNames.join(",").toLocaleUpperCase())+"\uFF09 ",1),e("th",null,n(c(l.duplex)),1),e("th",null,n(l.macAddress||"--"),1),e("th",null,n(l.rx_packets||"--"),1),e("th",null,n(l.tx_packets||"--"),1)]))),256))])]))})}});var L=v(S,[["__scopeId","data-v-16a9b49b"]]);export{L as default};
|
||||
var p=(o,u,s)=>new Promise((h,c)=>{var f=r=>{try{t(s.next(r))}catch(l){c(l)}},x=r=>{try{t(s.throw(r))}catch(l){c(l)}},t=r=>r.done?h(r.value):Promise.resolve(r.value).then(f,x);t((s=s.apply(o,u)).next())});import{_ as v,d as w,j as B,v as m,k as g,o as a,c as i,a as e,F as k,E as y,z as _,l as n,p as A,q as C,C as M}from"./index.js?v=5b4be379";const d=o=>(A("data-v-16a9b49b"),o=o(),C(),o),D={class:"page-table"},F=d(()=>e("colgroup",null,[e("col"),e("col"),e("col"),e("col"),e("col"),e("col")],-1)),E=d(()=>e("thead",null,[e("tr",null,[e("th",null," \u72B6\u6001 "),e("th",null," \u63A5\u53E3 "),e("th",null," \u7C7B\u578B "),e("th",null," mac "),e("th",null," \u63A5\u6536 "),e("th",null," \u53D1\u9001 ")])],-1)),b={class:"flex-icon"},z=d(()=>e("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","xmlns:v":"https://vecta.io/nano",width:"48",height:"38",viewBox:"0 0 12.7 10.05"},[e("defs",null,[e("filter",{id:"A","color-interpolation-filters":"sRGB"},[e("feColorMatrix",{result:"A",values:"2 -0.5 -0.5 0 0 -0.5 2 -0.5 0 0 -0.5 -0.5 2 0 0 0 0 0 1 0 "}),e("feColorMatrix",{values:"0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"}),e("feColorMatrix",{in:"A",values:"2 -0.5 -0.5 0 0 -0.5 2 -0.5 0 0 -0.5 -0.5 2 0 0 0 0 0 1 0 "})]),e("path",{id:"B",d:"M80.56 75.75h3.91v22.79h-3.91z"})]),e("g",{transform:"translate(0 -286.95)"},[e("rect",{x:".21",y:"287.25",width:"12.33",height:"9.5",ry:".57",fill:"#e6e6e6",stroke:"#e6e6e6","stroke-linejoin":"round","stroke-width":".37","paint-order":"normal"}),e("path",{transform:"matrix(.105 0 0 .0989 -6.0834 280.6)",d:"M73.96 75.66h89.41c2.31 0 4.17 1.86 4.17 4.17v52.65h-21.74v9.41h-8.69v12.59h-36.87v-12.59h-8.69v-9.41H69.79V79.83c0-2.31 1.86-4.17 4.17-4.17z",fill:"#999",filter:"url(#A)",stroke:"#999","stroke-width":"2.5"}),e("g",{transform:"matrix(.1048 0 0 .1048 -6.0999 280.7)",fill:"#fff",filter:"url(#A)",stroke:"#fff"},[e("use",{"xlink:href":"#B"}),e("use",{"xlink:href":"#B",x:"73.04"}),e("use",{"xlink:href":"#B",x:"52.17"}),e("use",{"xlink:href":"#B",x:"41.74"}),e("use",{"xlink:href":"#B",x:"31.3"}),e("use",{"xlink:href":"#B",x:"20.87"}),e("use",{"xlink:href":"#B",x:"10.43"}),e("use",{"xlink:href":"#B",x:"62.61"})]),e("rect",{x:"1.24",y:"294.55",width:"1.6",height:"1.38",ry:".11",fill:"#ccc",stroke:"#ccc","stroke-width":".22","paint-order":"normal"})])],-1)),N=d(()=>e("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",width:"48",height:"38",viewBox:"0 0 12.7 10.05","xmlns:v":"https://vecta.io/nano"},[e("defs",null,[e("filter",{id:"A","color-interpolation-filters":"sRGB"},[e("feColorMatrix",{result:"A",values:"2 -0.5 -0.5 0 0 -0.5 2 -0.5 0 0 -0.5 -0.5 2 0 0 0 0 0 1 0 "}),e("feColorMatrix",{values:"0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"}),e("feColorMatrix",{in:"A",values:"2 -0.5 -0.5 0 0 -0.5 2 -0.5 0 0 -0.5 -0.5 2 0 0 0 0 0 1 0 "})]),e("path",{id:"B",d:"M80.56 75.75h3.91v22.79h-3.91z"})]),e("g",{transform:"translate(-.03 -287.07)"},[e("rect",{x:".24",y:"287.36",width:"12.33",height:"9.5",ry:".57",fill:"#e6e6e6",stroke:"#e6e6e6","stroke-linejoin":"round","stroke-width":".37","paint-order":"normal"}),e("path",{transform:"matrix(.105 0 0 .0989 -6.0532 280.72)",d:"M73.96 75.66h89.41c2.31 0 4.17 1.86 4.17 4.17v52.65h-21.74v9.41h-8.69v12.59h-36.87v-12.59h-8.69v-9.41H69.79V79.83c0-2.31 1.86-4.17 4.17-4.17z",fill:"#4d4d4d",filter:"url(#A)",stroke:"#4d4d4d","stroke-width":"2.5"}),e("g",{transform:"matrix(.1048 0 0 .1048 -6.0697 280.81)",fill:"#fff",filter:"url(#A)",stroke:"#fff"},[e("use",{"xlink:href":"#B"}),e("use",{"xlink:href":"#B",x:"73.04"}),e("use",{"xlink:href":"#B",x:"52.17"}),e("use",{"xlink:href":"#B",x:"41.74"}),e("use",{"xlink:href":"#B",x:"31.3"}),e("use",{"xlink:href":"#B",x:"20.87"}),e("use",{"xlink:href":"#B",x:"10.43"}),e("use",{"xlink:href":"#B",x:"62.61"})]),e("rect",{x:"1.27",y:"294.67",width:"1.6",height:"1.38",ry:".11",fill:"#55d400",stroke:"#55d400","stroke-width":".22","paint-order":"normal"})])],-1)),S=w({__name:"index",setup(o){return p(this,null,function*(){let u,s;const h=B({ports:[]}),c=t=>{switch(t){case"full":return"\u5168\u53CC\u5DE5";case"half":return"\u534A\u53CC\u5DE5"}};let f=!1;const x=()=>p(this,null,function*(){try{const t=yield M.Network.PortList.GET();if(t!=null&&t.data){const{result:r}=t==null?void 0:t.data;r&&(h.ports=r.ports||[])}}catch(t){console.log(t)}setTimeout(()=>{f||x()},1e4)});return[u,s]=m(()=>x()),yield u,s(),g(()=>{f=!0}),(t,r)=>(a(),i("table",D,[F,E,e("tbody",null,[(a(!0),i(k,null,y(h.ports,l=>(a(),i("tr",null,[e("th",b,[l.linkState=="DOWN"?(a(),i(k,{key:0},[z,_("\u672A\u8FDE\u63A5 ")],64)):(a(),i(k,{key:1},[N,_(" \u5DF2\u8FDE\u63A5 ")],64))]),e("th",null,n(l.name)+"\uFF08"+n(l.interfaceNames.join(",").toLocaleUpperCase())+"\uFF09 ",1),e("th",null,n(c(l.duplex)),1),e("th",null,n(l.macAddress||"--"),1),e("th",null,n(l.rx_packets||"--"),1),e("th",null,n(l.tx_packets||"--"),1)]))),256))])]))})}});var L=v(S,[["__scopeId","data-v-16a9b49b"]]);export{L as default};
|
@ -1 +1 @@
|
||||
import{_ as u,d as l,u as p,r as t,o as e,c as i,a as m,b as o,w as a,e as s,f as v,S as f,t as x,g as y}from"./index.js?v=1e18a786";const h={class:"body"},k=l({__name:"index",setup(C){const n=p();return(w,B)=>{const _=t("layout-header"),r=t("router-view");return e(),i("div",{id:"main",key:y(n).reloadCount},[m("div",h,[o(_),o(r,null,{default:a(({Component:c,route:d})=>[(e(),s(f,null,{default:a(()=>[(e(),s(v(c),{key:d.path}))]),_:2},1024))]),_:1}),o(x)])])}}});var S=u(k,[["__scopeId","data-v-5f4eb506"]]);export{S as default};
|
||||
import{_ as u,d as l,u as p,r as t,o as e,c as i,a as m,b as o,w as a,e as s,f as v,S as f,t as x,g as y}from"./index.js?v=5b4be379";const h={class:"body"},k=l({__name:"index",setup(C){const n=p();return(w,B)=>{const _=t("layout-header"),r=t("router-view");return e(),i("div",{id:"main",key:y(n).reloadCount},[m("div",h,[o(_),o(r,null,{default:a(({Component:c,route:d})=>[(e(),s(f,null,{default:a(()=>[(e(),s(v(c),{key:d.path}))]),_:2},1024))]),_:1}),o(x)])])}}});var S=u(k,[["__scopeId","data-v-5f4eb506"]]);export{S as default};
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
import{d as a,r as e,o as u,e as r,w as s,b as p}from"./index.js?v=1e18a786";const m=a({__name:"index",setup(i){const t=[{name:"setting-index",title:"\u529F\u80FD\u4FE1\u606F",path:"/router/setting"},{name:"opkg",title:"\u8F6F\u4EF6\u6E90\u914D\u7F6E",path:"/router/setting/opkg"},{name:"opkg",title:"\u5411\u5BFC\u6A21\u5F0F",path:"/wizard"}];return(_,c)=>{const o=e("router-loading"),n=e("layout-page");return u(),r(n,{menus:t},{default:s(()=>[p(o)]),_:1})}}});export{m as default};
|
||||
import{d as a,r as e,o as u,e as r,w as s,b as p}from"./index.js?v=5b4be379";const m=a({__name:"index",setup(i){const t=[{name:"setting-index",title:"\u529F\u80FD\u4FE1\u606F",path:"/router/setting"},{name:"opkg",title:"\u8F6F\u4EF6\u6E90\u914D\u7F6E",path:"/router/setting/opkg"},{name:"opkg",title:"\u5411\u5BFC\u6A21\u5F0F",path:"/wizard"}];return(_,c)=>{const o=e("router-loading"),n=e("layout-page");return u(),r(n,{menus:t},{default:s(()=>[p(o)]),_:1})}}});export{m as default};
|
@ -1 +1 @@
|
||||
import{d as c,u,i as r,s as d,o as l,c as e,a as t,F as _,E as i,l as s}from"./index.js?v=1e18a786";const h={class:"ul-container"},p={class:"ul-container_body"},m={class:"page-table"},v=t("colgroup",null,[t("col"),t("col"),t("col"),t("col")],-1),f=t("thead",null,[t("tr",null,[t("th",null,"Mac"),t("th",null,"IPv4"),t("th",null,"IPv6"),t("th")])],-1),b=t("th",null,null,-1),g=t("th",null,null,-1),E=c({__name:"index",setup(x){const o=u(),a=r(()=>o.device.devices);return d(),(y,B)=>(l(),e("main",null,[t("ul",h,[t("div",p,[t("table",m,[v,f,t("tbody",null,[(l(!0),e(_,null,i(a.value,n=>(l(),e("tr",null,[t("th",null,s(n.mac),1),t("th",null,s(n.ipv4addr),1),b,g]))),256))])])])])]))}});export{E as default};
|
||||
import{d as c,u,i as r,s as d,o as l,c as e,a as t,F as _,E as i,l as s}from"./index.js?v=5b4be379";const h={class:"ul-container"},p={class:"ul-container_body"},m={class:"page-table"},v=t("colgroup",null,[t("col"),t("col"),t("col"),t("col")],-1),f=t("thead",null,[t("tr",null,[t("th",null,"Mac"),t("th",null,"IPv4"),t("th",null,"IPv6"),t("th")])],-1),b=t("th",null,null,-1),g=t("th",null,null,-1),E=c({__name:"index",setup(x){const o=u(),a=r(()=>o.device.devices);return d(),(y,B)=>(l(),e("main",null,[t("ul",h,[t("div",p,[t("table",m,[v,f,t("tbody",null,[(l(!0),e(_,null,i(a.value,n=>(l(),e("tr",null,[t("th",null,s(n.mac),1),t("th",null,s(n.ipv4addr),1),b,g]))),256))])])])])]))}});export{E as default};
|
@ -1 +1 @@
|
||||
var m=(v,c,d)=>new Promise((l,e)=>{var u=o=>{try{r(d.next(o))}catch(a){e(a)}},i=o=>{try{r(d.throw(o))}catch(a){e(a)}},r=o=>o.done?l(o.value):Promise.resolve(o.value).then(u,i);r((d=d.apply(v,c)).next())});import{d as S,s as h,j as F,v as N,o as p,c as D,a as n,x as _,D as P,F as B,A as I,m as g,l as x,B as k,C as y,T as w}from"./index.js?v=1e18a786";const C=["onSubmit"],E=n("div",{class:"label-name"},[n("span",null,"DNS\u9009\u9879")],-1),A={class:"label-value"},T=n("option",{value:"auto"},"\u4F7F\u7528\u8FD0\u8425\u5546\u63D0\u4F9B\u7684DNS",-1),V=n("option",{value:"manual"},"\u81EA\u5B9A\u4E49DNS",-1),G=[T,V],M=n("div",{class:"label-name"},[n("span",null,"DNS\u670D\u52A1\u5668\u5730\u5740")],-1),U={class:"label-value"},q=n("div",{class:"label-name"}," \u5907\u7528DNS\u670D\u52A1\u5668\u5730\u5740 ",-1),j={class:"label-value"},L={class:"label-btns"},O=["disabled"],z={key:1,class:"label-msg"},K=S({__name:"index",setup(v){return m(this,null,function*(){let c,d;const l=h(""),e=F({interfaceName:"",dnsProto:"auto",manualDnsIp:[]}),u=F({dns1:"",dns2:""}),i=h(!1),r=()=>m(this,null,function*(){i.value=!0;try{const a=yield y.Guide.DnsConfig.GET();if(a!=null&&a.data){const{result:t}=a.data;if(t){e.dnsProto=t.dnsProto,e.manualDnsIp=t.manualDnsIp||[];for(let s=0;s<e.manualDnsIp.length;s++){s==0?u.dns1=e.manualDnsIp[s]:s==1&&(u.dns2=e.manualDnsIp[s]);break}}}}catch(a){l.value=a}i.value=!1});[c,d]=N(()=>r()),yield c,d();const o=()=>m(this,null,function*(){let a={};switch(e.dnsProto){case"auto":break;case"manual":a.manualDnsIp=[],e.manualDnsIp!=null&&e.manualDnsIp.length>0?a.manualDnsIp=e.manualDnsIp:(a.manualDnsIp.push(u.dns1),u.dns2&&a.manualDnsIp.push(u.dns2));break}a.dnsProto=e.dnsProto,a.interfaceName=e.interfaceName;const t=w.Loading("\u914D\u7F6E\u4E2D...");try{const s=yield y.Guide.DnsConfig.POST(a);if(s!=null&&s.data){const{success:f,error:b}=s==null?void 0:s.data;b&&(l.value=b),(f==null||f==0)&&(l.value="\u914D\u7F6E\u6210\u529F")}}catch(s){l.value=s}t.Close()});return(a,t)=>(p(),D("form",{class:"form-container",onSubmit:k(o,["prevent"])},[E,n("div",A,[_(n("select",{"onUpdate:modelValue":t[0]||(t[0]=s=>e.dnsProto=s)},G,512),[[P,e.dnsProto]])]),e.dnsProto=="manual"?(p(),D(B,{key:0},[M,n("div",U,[_(n("input",{type:"text",placeholder:"\u8BF7\u8F93\u5165 dns \u5730\u5740","onUpdate:modelValue":t[1]||(t[1]=s=>u.dns1=s),required:""},null,512),[[I,u.dns1,void 0,{trim:!0}]])]),q,n("div",j,[_(n("input",{type:"text",placeholder:"\u8BF7\u8F93\u5165\u5907\u7528 dns \u5730\u5740","onUpdate:modelValue":t[2]||(t[2]=s=>u.dns2=s)},null,512),[[I,u.dns2,void 0,{trim:!0}]])])],64)):g("",!0),n("div",L,[n("button",{class:"sumbit",disabled:i.value},"\u4FDD\u5B58",8,O)]),l.value?(p(),D("div",z,[n("span",null,x(l.value),1)])):g("",!0)],40,C))})}});export{K as default};
|
||||
var m=(v,c,d)=>new Promise((l,e)=>{var u=o=>{try{r(d.next(o))}catch(a){e(a)}},i=o=>{try{r(d.throw(o))}catch(a){e(a)}},r=o=>o.done?l(o.value):Promise.resolve(o.value).then(u,i);r((d=d.apply(v,c)).next())});import{d as S,s as h,j as F,v as N,o as p,c as D,a as n,x as _,D as P,F as B,A as I,m as g,l as x,B as k,C as y,T as w}from"./index.js?v=5b4be379";const C=["onSubmit"],E=n("div",{class:"label-name"},[n("span",null,"DNS\u9009\u9879")],-1),A={class:"label-value"},T=n("option",{value:"auto"},"\u4F7F\u7528\u8FD0\u8425\u5546\u63D0\u4F9B\u7684DNS",-1),V=n("option",{value:"manual"},"\u81EA\u5B9A\u4E49DNS",-1),G=[T,V],M=n("div",{class:"label-name"},[n("span",null,"DNS\u670D\u52A1\u5668\u5730\u5740")],-1),U={class:"label-value"},q=n("div",{class:"label-name"}," \u5907\u7528DNS\u670D\u52A1\u5668\u5730\u5740 ",-1),j={class:"label-value"},L={class:"label-btns"},O=["disabled"],z={key:1,class:"label-msg"},K=S({__name:"index",setup(v){return m(this,null,function*(){let c,d;const l=h(""),e=F({interfaceName:"",dnsProto:"auto",manualDnsIp:[]}),u=F({dns1:"",dns2:""}),i=h(!1),r=()=>m(this,null,function*(){i.value=!0;try{const a=yield y.Guide.DnsConfig.GET();if(a!=null&&a.data){const{result:t}=a.data;if(t){e.dnsProto=t.dnsProto,e.manualDnsIp=t.manualDnsIp||[];for(let s=0;s<e.manualDnsIp.length;s++){s==0?u.dns1=e.manualDnsIp[s]:s==1&&(u.dns2=e.manualDnsIp[s]);break}}}}catch(a){l.value=a}i.value=!1});[c,d]=N(()=>r()),yield c,d();const o=()=>m(this,null,function*(){let a={};switch(e.dnsProto){case"auto":break;case"manual":a.manualDnsIp=[],e.manualDnsIp!=null&&e.manualDnsIp.length>0?a.manualDnsIp=e.manualDnsIp:(a.manualDnsIp.push(u.dns1),u.dns2&&a.manualDnsIp.push(u.dns2));break}a.dnsProto=e.dnsProto,a.interfaceName=e.interfaceName;const t=w.Loading("\u914D\u7F6E\u4E2D...");try{const s=yield y.Guide.DnsConfig.POST(a);if(s!=null&&s.data){const{success:f,error:b}=s==null?void 0:s.data;b&&(l.value=b),(f==null||f==0)&&(l.value="\u914D\u7F6E\u6210\u529F")}}catch(s){l.value=s}t.Close()});return(a,t)=>(p(),D("form",{class:"form-container",onSubmit:k(o,["prevent"])},[E,n("div",A,[_(n("select",{"onUpdate:modelValue":t[0]||(t[0]=s=>e.dnsProto=s)},G,512),[[P,e.dnsProto]])]),e.dnsProto=="manual"?(p(),D(B,{key:0},[M,n("div",U,[_(n("input",{type:"text",placeholder:"\u8BF7\u8F93\u5165 dns \u5730\u5740","onUpdate:modelValue":t[1]||(t[1]=s=>u.dns1=s),required:""},null,512),[[I,u.dns1,void 0,{trim:!0}]])]),q,n("div",j,[_(n("input",{type:"text",placeholder:"\u8BF7\u8F93\u5165\u5907\u7528 dns \u5730\u5740","onUpdate:modelValue":t[2]||(t[2]=s=>u.dns2=s)},null,512),[[I,u.dns2,void 0,{trim:!0}]])])],64)):g("",!0),n("div",L,[n("button",{class:"sumbit",disabled:i.value},"\u4FDD\u5B58",8,O)]),l.value?(p(),D("div",z,[n("span",null,x(l.value),1)])):g("",!0)],40,C))})}});export{K as default};
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
var m=(_,v,l)=>new Promise((n,r)=>{var F=i=>{try{c(l.next(i))}catch(u){r(u)}},h=i=>{try{c(l.throw(i))}catch(u){r(u)}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(F,h);c((l=l.apply(_,v)).next())});import{_ as g,d as y,j as k,v as E,i as x,o,c as a,a as e,l as d,F as A,K as S,L as B,p as b,q as N,C as w}from"./index.js?v=1e18a786";const D=_=>(b("data-v-613b66e3"),_=_(),N(),_),$={id:"page",class:"page-container"},I=D(()=>e("div",{class:"notice_info"},[e("li",null," \u52A8\u6001 DNS \uFF08DDNS\uFF09\u8BA9\u60A8\u5373\u4F7F\u5728\u6CA1\u6709\u9759\u6001 IP \u5730\u5740\u7684\u60C5\u51B5\u4E0B\uFF0C\u4ECD\u53EF\u5C06\u670D\u52A1\u5668\u8FDE\u540C\u7ED1\u5B9A\u7684\u57DF\u540D\u6620\u5C04\u81F3\u516C\u7F51\u4E0A\u3002 "),e("li",null," \u5982\u679C\u60A8\u6CA1\u6709\u516C\u7F51 IP \u8BF7\u4F7F\u7528 DDNSTO \uFF0C\u521D\u6B21\u4F7F\u7528 DDNSTO \u9700\u8981\u521D\u59CB\u5316\u914D\u7F6E ")],-1)),P={class:"text-container"},T={class:"text-container_item"},O=D(()=>e("div",{class:"text-container_item_title"},[e("span",null,"DDNSTO\uFF1A")],-1)),q={class:"text-container_item_flex"},G={class:"text-container_item_block"},j=["href"],K={key:0,class:"domain"},L={key:1,class:"domain"},V={class:"text-container_item"},z=D(()=>e("div",{class:"text-container_item_title"},[e("span",null,"myddns_ipv4\uFF1A")],-1)),H={class:"text-container_item_flex"},J={class:"text-container_item_block"},M=["href"],Q={key:1,class:"domain"},R={class:"text-container_item"},U=D(()=>e("div",{class:"text-container_item_title"},[e("span",null,"myddns_ipv6\uFF1A")],-1)),W={class:"text-container_item_flex"},X={class:"text-container_item_block"},Y=["href"],Z={key:1,class:"domain"},tt=y({__name:"index",setup(_){return m(this,null,function*(){let v,l;k({ipv4:"",ipv6:""});const n=k({ddnstoDomain:"",ipv4Domain:"",ipv6Domain:""}),r=k({install:!0,error:null}),F=()=>m(this,null,function*(){yield Promise.all([h()])}),h=()=>m(this,null,function*(){try{const t=yield w.Guide.Ddns.GET(),{result:s,error:p}=t.data;if(p)throw p;s&&(n.ddnstoDomain=s.ddnstoDomain,n.ipv4Domain=s.ipv4Domain,n.ipv6Domain=s.ipv6Domain)}catch(t){console.log(t)}});[v,l]=E(()=>F()),yield v,l();const c=x(()=>n.ddnstoDomain),i=x(()=>{const t=n.ipv4Domain;return t!=null&&t!=""&&t!="Stopped"?{url:`http://${t}`,title:t,ok:!0}:{url:`http://${t}`,title:"\u672A\u914D\u7F6E",ok:!1}}),u=x(()=>{const t=n.ipv6Domain;return t!=null&&t!=""&&t!="Stopped"?{url:`http://${t}`,title:t,ok:!0}:{url:`http://${t}`,title:"\u672A\u914D\u7F6E",ok:!1}}),C=()=>{S({domain:c.value,callback:t=>{}})},f=t=>{B({setup:t,callback:s=>{switch(t){case"ipv4":n.ipv4Domain=s.domain;break;case"ipv6":n.ipv6Domain=s.domain;break}}})};return(t,s)=>(o(),a("div",$,[I,e("div",P,[e("div",T,[O,e("div",q,[e("div",G,[r.install?(o(),a("a",{key:0,href:c.value,target:"_blank",class:"domain"},d(c.value),9,j)):(o(),a(A,{key:1},[r.error?(o(),a("a",K,d(r.error),1)):(o(),a("a",L,"\u672A\u5B89\u88C5"))],64)),e("a",{class:"setting",onClick:s[0]||(s[0]=p=>C())},"\u5FEB\u901F\u914D\u7F6E")])])]),e("div",V,[z,e("div",H,[e("div",J,[i.value.ok?(o(),a("a",{key:0,href:i.value.url,target:"_blank",class:"domain"},d(i.value.title),9,M)):(o(),a("a",Q,d(i.value.title),1)),e("a",{class:"setting",onClick:s[1]||(s[1]=p=>f("ipv4"))},"\u5FEB\u901F\u914D\u7F6E")])])]),e("div",R,[U,e("div",W,[e("div",X,[u.value.ok?(o(),a("a",{key:0,href:u.value.url,target:"_blank",class:"domain"},d(u.value.title),9,Y)):(o(),a("a",Z,d(u.value.title),1)),e("a",{class:"setting",onClick:s[2]||(s[2]=p=>f("ipv6"))},"\u5FEB\u901F\u914D\u7F6E")])])])])]))})}});var it=g(tt,[["__scopeId","data-v-613b66e3"]]);export{it as default};
|
||||
var m=(_,v,l)=>new Promise((n,r)=>{var F=i=>{try{c(l.next(i))}catch(u){r(u)}},h=i=>{try{c(l.throw(i))}catch(u){r(u)}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(F,h);c((l=l.apply(_,v)).next())});import{_ as g,d as y,j as k,v as E,i as x,o,c as a,a as e,l as d,F as A,K as S,L as B,p as b,q as N,C as w}from"./index.js?v=5b4be379";const D=_=>(b("data-v-613b66e3"),_=_(),N(),_),$={id:"page",class:"page-container"},I=D(()=>e("div",{class:"notice_info"},[e("li",null," \u52A8\u6001 DNS \uFF08DDNS\uFF09\u8BA9\u60A8\u5373\u4F7F\u5728\u6CA1\u6709\u9759\u6001 IP \u5730\u5740\u7684\u60C5\u51B5\u4E0B\uFF0C\u4ECD\u53EF\u5C06\u670D\u52A1\u5668\u8FDE\u540C\u7ED1\u5B9A\u7684\u57DF\u540D\u6620\u5C04\u81F3\u516C\u7F51\u4E0A\u3002 "),e("li",null," \u5982\u679C\u60A8\u6CA1\u6709\u516C\u7F51 IP \u8BF7\u4F7F\u7528 DDNSTO \uFF0C\u521D\u6B21\u4F7F\u7528 DDNSTO \u9700\u8981\u521D\u59CB\u5316\u914D\u7F6E ")],-1)),P={class:"text-container"},T={class:"text-container_item"},O=D(()=>e("div",{class:"text-container_item_title"},[e("span",null,"DDNSTO\uFF1A")],-1)),q={class:"text-container_item_flex"},G={class:"text-container_item_block"},j=["href"],K={key:0,class:"domain"},L={key:1,class:"domain"},V={class:"text-container_item"},z=D(()=>e("div",{class:"text-container_item_title"},[e("span",null,"myddns_ipv4\uFF1A")],-1)),H={class:"text-container_item_flex"},J={class:"text-container_item_block"},M=["href"],Q={key:1,class:"domain"},R={class:"text-container_item"},U=D(()=>e("div",{class:"text-container_item_title"},[e("span",null,"myddns_ipv6\uFF1A")],-1)),W={class:"text-container_item_flex"},X={class:"text-container_item_block"},Y=["href"],Z={key:1,class:"domain"},tt=y({__name:"index",setup(_){return m(this,null,function*(){let v,l;k({ipv4:"",ipv6:""});const n=k({ddnstoDomain:"",ipv4Domain:"",ipv6Domain:""}),r=k({install:!0,error:null}),F=()=>m(this,null,function*(){yield Promise.all([h()])}),h=()=>m(this,null,function*(){try{const t=yield w.Guide.Ddns.GET(),{result:s,error:p}=t.data;if(p)throw p;s&&(n.ddnstoDomain=s.ddnstoDomain,n.ipv4Domain=s.ipv4Domain,n.ipv6Domain=s.ipv6Domain)}catch(t){console.log(t)}});[v,l]=E(()=>F()),yield v,l();const c=x(()=>n.ddnstoDomain),i=x(()=>{const t=n.ipv4Domain;return t!=null&&t!=""&&t!="Stopped"?{url:`http://${t}`,title:t,ok:!0}:{url:`http://${t}`,title:"\u672A\u914D\u7F6E",ok:!1}}),u=x(()=>{const t=n.ipv6Domain;return t!=null&&t!=""&&t!="Stopped"?{url:`http://${t}`,title:t,ok:!0}:{url:`http://${t}`,title:"\u672A\u914D\u7F6E",ok:!1}}),C=()=>{S({domain:c.value,callback:t=>{}})},f=t=>{B({setup:t,callback:s=>{switch(t){case"ipv4":n.ipv4Domain=s.domain;break;case"ipv6":n.ipv6Domain=s.domain;break}}})};return(t,s)=>(o(),a("div",$,[I,e("div",P,[e("div",T,[O,e("div",q,[e("div",G,[r.install?(o(),a("a",{key:0,href:c.value,target:"_blank",class:"domain"},d(c.value),9,j)):(o(),a(A,{key:1},[r.error?(o(),a("a",K,d(r.error),1)):(o(),a("a",L,"\u672A\u5B89\u88C5"))],64)),e("a",{class:"setting",onClick:s[0]||(s[0]=p=>C())},"\u5FEB\u901F\u914D\u7F6E")])])]),e("div",V,[z,e("div",H,[e("div",J,[i.value.ok?(o(),a("a",{key:0,href:i.value.url,target:"_blank",class:"domain"},d(i.value.title),9,M)):(o(),a("a",Q,d(i.value.title),1)),e("a",{class:"setting",onClick:s[1]||(s[1]=p=>f("ipv4"))},"\u5FEB\u901F\u914D\u7F6E")])])]),e("div",R,[U,e("div",W,[e("div",X,[u.value.ok?(o(),a("a",{key:0,href:u.value.url,target:"_blank",class:"domain"},d(u.value.title),9,Y)):(o(),a("a",Z,d(u.value.title),1)),e("a",{class:"setting",onClick:s[2]||(s[2]=p=>f("ipv6"))},"\u5FEB\u901F\u914D\u7F6E")])])])])]))})}});var it=g(tt,[["__scopeId","data-v-613b66e3"]]);export{it as default};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -515,4 +515,11 @@ o = s:option(Value, option_name("xudp_concurrency"), translate("XUDP Mux concurr
|
||||
o.default = 8
|
||||
o:depends({ [option_name("xmux")] = true })
|
||||
|
||||
--[[tcpMptcp]]
|
||||
o = s:option(Flag, option_name("tcpMptcp"), "tcpMptcp", translate("Enable Multipath TCP, need to be enabled in both server and client configuration."))
|
||||
o.default = 0
|
||||
|
||||
o = s:option(Flag, option_name("tcpNoDelay"), "tcpNoDelay")
|
||||
o.default = 0
|
||||
|
||||
api.luci_types(arg[1], m, s, type_name, option_prefix)
|
||||
|
@ -127,7 +127,9 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
-- 底层传输配置
|
||||
streamSettings = (node.streamSettings or node.protocol == "vmess" or node.protocol == "vless" or node.protocol == "socks" or node.protocol == "shadowsocks" or node.protocol == "trojan") and {
|
||||
sockopt = {
|
||||
mark = 255
|
||||
mark = 255,
|
||||
tcpMptcp = (node.tcpMptcp == "1") and true or nil,
|
||||
tcpNoDelay = (node.tcpNoDelay == "1") and true or nil,
|
||||
},
|
||||
network = node.transport,
|
||||
security = node.stream_security,
|
||||
|
@ -95,7 +95,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pure-u-1-4 check" onclick="check_connect('baidu', 'http://www.baidu.com')">
|
||||
<div class="pure-u-1-4 check" onclick="check_connect('baidu', 'https://www.baidu.com')">
|
||||
<div class="block pure-g">
|
||||
<div class="pure-u-1-3">
|
||||
<div class="img-con">
|
||||
@ -107,7 +107,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pure-u-1-4 check" onclick="check_connect('google', 'http://www.google.com/generate_204')">
|
||||
<div class="pure-u-1-4 check" onclick="check_connect('google', 'https://www.google.com/generate_204')">
|
||||
<div class="block pure-g">
|
||||
<div class="pure-u-1-3">
|
||||
<div class="img-con">
|
||||
@ -119,7 +119,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pure-u-1-4 check" onclick="check_connect('github', 'http://github.com')">
|
||||
<div class="pure-u-1-4 check" onclick="check_connect('github', 'https://github.com')">
|
||||
<div class="block pure-g">
|
||||
<div class="pure-u-1-3">
|
||||
<div class="img-con">
|
||||
|
@ -1446,3 +1446,6 @@ msgstr "后量子对等证书签名方案"
|
||||
|
||||
msgid "Disable adaptive sizing of TLS records"
|
||||
msgstr "禁用 TLS 记录的自适应大小调整"
|
||||
|
||||
msgid "Enable Multipath TCP, need to be enabled in both server and client configuration."
|
||||
msgstr "启用 Multipath TCP,需在服务端和客户端配置中同时启用。"
|
||||
|
Loading…
Reference in New Issue
Block a user