🐶 Sync 2025-11-02 14:26:26
This commit is contained in:
62
airconnect/Makefile
Normal file
62
airconnect/Makefile
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2015-2016 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v3.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=airconnect
|
||||||
|
PKG_VERSION:=1.9.2
|
||||||
|
PKG_RELEASE=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=AirConnect-$(PKG_VERSION).zip
|
||||||
|
PKG_SOURCE_URL:=https://github.com/philippe44/AirConnect/releases/download/$(PKG_VERSION)/
|
||||||
|
PKG_HASH:=9f59e980333e2971111a3a2dadb1672ae92d9e9ef910bb3151aea5c315b0305a
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/airconnect-$(PKG_VERSION)
|
||||||
|
|
||||||
|
PKG_LICENSE:=MIT
|
||||||
|
PKG_LICENSE_FILE:=LICENSE
|
||||||
|
PKG_MAINTAINER:=sbwml <admin@cooluc.com>
|
||||||
|
|
||||||
|
ifeq ($(ARCH),arm)
|
||||||
|
ARM_CPU_FEATURES:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE))))
|
||||||
|
ifeq ($(ARM_CPU_FEATURES),)
|
||||||
|
ARCH:=armv6
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=multimedia
|
||||||
|
CATEGORY:=Multimedia
|
||||||
|
TITLE:=AirConnect
|
||||||
|
URL:=https://github.com/philippe44/AirConnect
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
Use AirPlay to stream to UPnP/Sonos & Chromecast devices
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/conffiles
|
||||||
|
/etc/config/airconnect
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Prepare
|
||||||
|
unzip -q -d $(PKG_BUILD_DIR) $(DL_DIR)/AirConnect-$(PKG_VERSION).zip
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin $(1)/etc/config $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./files/airconnect.init $(1)/etc/init.d/airconnect
|
||||||
|
$(INSTALL_CONF) ./files/airconnect.config $(1)/etc/config/airconnect
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/aircast-linux-$(ARCH)-static $(1)/usr/bin/aircast
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/airupnp-linux-$(ARCH)-static $(1)/usr/bin/airupnp
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
7
airconnect/files/airconnect.config
Normal file
7
airconnect/files/airconnect.config
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
config airconnect 'config'
|
||||||
|
option 'enabled' '0'
|
||||||
|
option 'interface' 'br-lan'
|
||||||
|
option 'aircast' '1'
|
||||||
|
option 'airupnp' '1'
|
||||||
|
|
||||||
55
airconnect/files/airconnect.init
Normal file
55
airconnect/files/airconnect.init
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=99
|
||||||
|
USE_PROCD=1
|
||||||
|
PROG_AIRCAST=/usr/bin/aircast
|
||||||
|
PROG_AIRUPNP=/usr/bin/airupnp
|
||||||
|
|
||||||
|
get_config() {
|
||||||
|
config_get enabled $1 enabled "0"
|
||||||
|
config_get interface $1 interface "br-lan"
|
||||||
|
config_get aircast $1 aircast "1"
|
||||||
|
config_get airupnp $1 airupnp "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load "airconnect"
|
||||||
|
config_foreach get_config "airconnect"
|
||||||
|
[ $enabled -eq 0 ] && return 0
|
||||||
|
|
||||||
|
# UPnP/Sonos
|
||||||
|
if [ "$airupnp" -eq 1 ]; then
|
||||||
|
procd_open_instance airupnp
|
||||||
|
procd_set_param command $PROG_AIRUPNP
|
||||||
|
procd_append_param command -l 1000:2000
|
||||||
|
procd_append_param command -Z
|
||||||
|
procd_append_param command -b $interface
|
||||||
|
procd_set_param stdout 0
|
||||||
|
procd_set_param stderr 0
|
||||||
|
procd_set_param respawn
|
||||||
|
procd_close_instance airupnp
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Chromecast
|
||||||
|
if [ "$aircast" -eq 1 ]; then
|
||||||
|
procd_open_instance aircast
|
||||||
|
procd_set_param command $PROG_AIRCAST
|
||||||
|
procd_append_param command -l 1000:2000
|
||||||
|
procd_append_param command -Z
|
||||||
|
procd_append_param command -b $interface
|
||||||
|
procd_set_param stdout 0
|
||||||
|
procd_set_param stderr 0
|
||||||
|
procd_set_param respawn
|
||||||
|
procd_close_instance aircast
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "airconnect"
|
||||||
|
}
|
||||||
|
|
||||||
|
reload_service() {
|
||||||
|
stop
|
||||||
|
sleep 1
|
||||||
|
start
|
||||||
|
}
|
||||||
129
airplay2/Makefile
Normal file
129
airplay2/Makefile
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
# updated to work with latest source from abrasive
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=airplay2
|
||||||
|
PKG_VERSION:=4.3.7
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=shairport-sync-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/mikebrady/shairport-sync/tar.gz/$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=a1242d100b61fe1fffbbf706e919ed51d6a341c9fb8293fb42046e32ae2b3338
|
||||||
|
|
||||||
|
PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>, \
|
||||||
|
Mike Brady <mikebrady@eircom.net>
|
||||||
|
PKG_LICENSE:=MIT
|
||||||
|
PKG_LICENSE_FILES:=COPYING LICENSES shairport.c
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/shairport-sync-$(PKG_VERSION)
|
||||||
|
|
||||||
|
PKG_FIXUP:=autoreconf
|
||||||
|
PKG_INSTALL:=1
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/airplay2/default
|
||||||
|
SECTION:=sound
|
||||||
|
CATEGORY:=Sound
|
||||||
|
TITLE:=AirPlay compatible audio player
|
||||||
|
DEPENDS:=@AUDIO_SUPPORT +libpthread +alsa-lib +libconfig +libdaemon +libpopt +libplist +libsodium +libgcrypt +libffmpeg-full +libuuid +nqptp +libmosquitto
|
||||||
|
PROVIDES:=airplay2
|
||||||
|
URL:=https://github.com/mikebrady/shairport-sync
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/airplay2-openssl
|
||||||
|
$(Package/airplay2/default)
|
||||||
|
TITLE+= (openssl)
|
||||||
|
DEPENDS+= +libopenssl +libavahi-client +libsoxr
|
||||||
|
VARIANT:=openssl
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/airplay2-mbedtls
|
||||||
|
$(Package/airplay2/default)
|
||||||
|
TITLE+= (mbed TLS)
|
||||||
|
DEPENDS+= +libmbedtls +libavahi-client +libsoxr
|
||||||
|
VARIANT:=mbedtls
|
||||||
|
DEFAULT_VARIANT:=1
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/airplay2-mini
|
||||||
|
$(Package/airplay2/default)
|
||||||
|
TITLE+= (minimal)
|
||||||
|
DEPENDS+= +libmbedtls
|
||||||
|
VARIANT:=mini
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/airplay2/default/description
|
||||||
|
Shairport Sync plays audio from iTunes and AirPlay sources, including
|
||||||
|
iOS devices, Quicktime Player and third party sources such as forkedDaapd.
|
||||||
|
Audio played by a Shairport Sync-powered device stays synchronised with the source
|
||||||
|
and hence with similar devices playing the same source.
|
||||||
|
|
||||||
|
Shairport Sync does not support AirPlay video or photo streaming.
|
||||||
|
Ensure Kernel Modules > Sound Support > kmod-sound-core is selected.
|
||||||
|
Also select kmod-usb-audio if you want to use USB-connected sound cards.
|
||||||
|
endef
|
||||||
|
Package/airplay2-openssl/description = $(Package/airplay2/default/description)
|
||||||
|
Package/airplay2-mbedtls/description = $(Package/airplay2/default/description)
|
||||||
|
|
||||||
|
define Package/airplay2-mini/description
|
||||||
|
$(Package/airplay2/default/description)
|
||||||
|
|
||||||
|
Minimal version uses mbed TLS and does not include libsoxr and avahi support.
|
||||||
|
endef
|
||||||
|
|
||||||
|
TARGET_CFLAGS += -std=gnu17
|
||||||
|
|
||||||
|
CONFIGURE_ARGS += \
|
||||||
|
--with-alsa \
|
||||||
|
--with-libdaemon \
|
||||||
|
--with-airplay-2 \
|
||||||
|
--with-pipe \
|
||||||
|
--with-mqtt-client \
|
||||||
|
--with-metadata
|
||||||
|
|
||||||
|
ifeq ($(BUILD_VARIANT),openssl)
|
||||||
|
CONFIGURE_ARGS+= --with-ssl=openssl
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BUILD_VARIANT),mbedtls)
|
||||||
|
CONFIGURE_ARGS+= --with-ssl=mbedtls
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BUILD_VARIANT),mini)
|
||||||
|
CONFIGURE_ARGS+= --with-ssl=mbedtls --with-tinysvcmdns
|
||||||
|
else
|
||||||
|
CONFIGURE_ARGS+= --with-avahi --with-soxr
|
||||||
|
endif
|
||||||
|
|
||||||
|
TARGET_LDFLAGS += -Wl,--as-needed
|
||||||
|
|
||||||
|
define Package/airplay2/default/conffiles
|
||||||
|
/etc/config/airplay2
|
||||||
|
endef
|
||||||
|
|
||||||
|
Package/airplay2-openssl/conffiles = $(Package/airplay2/default/conffiles)
|
||||||
|
Package/airplay2-mbedtls/conffiles = $(Package/airplay2/default/conffiles)
|
||||||
|
Package/airplay2-mini/conffiles = $(Package/airplay2/default/conffiles)
|
||||||
|
|
||||||
|
define Package/airplay2/default/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/shairport-sync $(1)/usr/bin/airplay2
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./files/airplay2.init $(1)/etc/init.d/airplay2
|
||||||
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
|
$(INSTALL_CONF) ./files/airplay2.config $(1)/etc/config/airplay2
|
||||||
|
endef
|
||||||
|
|
||||||
|
Package/airplay2-openssl/install = $(Package/airplay2/default/install)
|
||||||
|
Package/airplay2-mbedtls/install = $(Package/airplay2/default/install)
|
||||||
|
Package/airplay2-mini/install = $(Package/airplay2/default/install)
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,airplay2-openssl))
|
||||||
|
$(eval $(call BuildPackage,airplay2-mbedtls))
|
||||||
|
$(eval $(call BuildPackage,airplay2-mini))
|
||||||
73
airplay2/files/airplay2.config
Normal file
73
airplay2/files/airplay2.config
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
config airplay2
|
||||||
|
option enabled '0'
|
||||||
|
option respawn '1'
|
||||||
|
# General
|
||||||
|
option name 'AirPlay2-%v-%h'
|
||||||
|
option password ''
|
||||||
|
option interpolation 'basic' # basic/soxr
|
||||||
|
option output_backend '' # alsa/pipe/stdout/ao/dummy/pulse/sndio
|
||||||
|
option mdns_backend '' # avahi/external-avahi/dns-sd/external-dns-sd/tinysvcmdns
|
||||||
|
option port '5050' # 5000
|
||||||
|
option udp_port_base '6001' # 6001
|
||||||
|
option udp_port_range '100' # 100
|
||||||
|
option statistics '' # no/yes - DEPRECATED: This option will be removed in a future release. Use 'diagnostics_statistics' instead
|
||||||
|
option drift '' # 88
|
||||||
|
option resync_threshold '' # 2205
|
||||||
|
option log_verbosity '' # 0/1/2/3 - DEPRECATED: This option will be removed in a future release. Use 'diagnostics_log_verbosity' instead
|
||||||
|
option ignore_volume_control '' # no/yes
|
||||||
|
option volume_range_db '' # 30 to 150
|
||||||
|
option regtype '' # _raop._tcp
|
||||||
|
option playback_mode '' # stereo/mono
|
||||||
|
# Metadata
|
||||||
|
option metadata_enabled '' # no/yes
|
||||||
|
option metadata_cover_art '' # no/yes
|
||||||
|
option metadata_pipe_name '' # /tmp/shairport-sync-metadata
|
||||||
|
option metadata_pipe_timeout '' # 5000
|
||||||
|
option metadata_socket_address '' # 226.0.0.1
|
||||||
|
option metadata_socket_port '' # 5555
|
||||||
|
option metadata_socket_msglength # 65000
|
||||||
|
# Session Control
|
||||||
|
option sesctl_run_before_play_begins '' # /etc/shairport-sync-start.sh
|
||||||
|
option sesctl_run_after_play_ends '' # /etc/shairport-sync-stop.sh
|
||||||
|
option sesctl_run_before_entering_active_state '' # /path/to/script.sh
|
||||||
|
option sesctl_run_after_exiting_active_state '' # /path/to/script.sh
|
||||||
|
option sesctl_run_if_an_unfixable_error_is_detected '' # /path/to/script.sh
|
||||||
|
option sesctl_run_when_volume_is_set '' # /path/to/script.sh
|
||||||
|
option sesctl_wait_for_completion '' # no/yes
|
||||||
|
option sesctl_session_interruption 'no' # no/yes
|
||||||
|
option sesctl_session_timeout '120' # 120
|
||||||
|
# ALSA
|
||||||
|
option alsa_output_device '' # default
|
||||||
|
option alsa_mixer_control_name 'PCM' # PCM
|
||||||
|
option alsa_mixer_device '' # default
|
||||||
|
option alsa_latency_offset '' # 0
|
||||||
|
option alsa_output_rate 'auto'
|
||||||
|
option alsa_buffer_length '6615' # 6615
|
||||||
|
option alsa_disable_synchronization '' # no/yes
|
||||||
|
option alsa_period_size '' # number
|
||||||
|
option alsa_buffer_size '' # number
|
||||||
|
# Pipe
|
||||||
|
option pipe_name '' # /tmp/shairport-sync-audio
|
||||||
|
option pipe_latency_offset '' # 0
|
||||||
|
option pipe_buffer_length '' # 44100
|
||||||
|
# Stdout
|
||||||
|
option stdout_latency_offset '' # 0
|
||||||
|
option stdout_buffer_length '' # 44100
|
||||||
|
# MQTT: https://github.com/mikebrady/shairport-sync/blob/master/MQTT.md
|
||||||
|
option mqtt_enabled 'no'
|
||||||
|
option mqtt_hostname '127.0.0.1'
|
||||||
|
option mqtt_port '1883'
|
||||||
|
option mqtt_username '' # empty = no authentication
|
||||||
|
option mqtt_password '' # empty = no authentication
|
||||||
|
option mqtt_topic 'shairport'
|
||||||
|
option mqtt_publish_raw 'no'
|
||||||
|
option mqtt_publish_parsed 'no'
|
||||||
|
option mqtt_publish_cover 'no'
|
||||||
|
option mqtt_enable_remote 'no'
|
||||||
|
# AO
|
||||||
|
option ao_latency_offset '' # 0
|
||||||
|
option ao_buffer_length '' # 44100
|
||||||
|
# Diagnostics
|
||||||
|
option diagnostics_statistics '' # no/yes
|
||||||
|
option diagnostics_log_output_to '' # syslog/stderr/stdout
|
||||||
|
option diagnostics_log_verbosity '' # 0/1/2/3
|
||||||
182
airplay2/files/airplay2.init
Executable file
182
airplay2/files/airplay2.init
Executable file
@@ -0,0 +1,182 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2015-2016 OpenWrt.org
|
||||||
|
|
||||||
|
START=99
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
append_num() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
|
config_get val "$cfg" "$var"
|
||||||
|
if [ -n "$val" ] || [ -n "$def" ]; then
|
||||||
|
printf "\t%s = ${val:-$def};\n" "$opt"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
append_str() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
|
config_get val "$cfg" "$var"
|
||||||
|
if [ -n "$val" ] || [ -n "$def" ]; then
|
||||||
|
printf "\t%s = \"%s\";\n" "$opt" "${val:-$def}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_instance() {
|
||||||
|
local cfg=$1
|
||||||
|
local conf_custom conf_file aux
|
||||||
|
|
||||||
|
config_get_bool aux "$cfg" 'enabled' '0'
|
||||||
|
[ "$aux" = 0 ] && return 1
|
||||||
|
|
||||||
|
config_get_bool conf_custom "$cfg" 'conf_custom' '0'
|
||||||
|
config_get conf_file "$cfg" "conf_file"
|
||||||
|
[ "$conf_custom" -ne 1 ] && [ -z "$conf_file" ] && {
|
||||||
|
mkdir -p /var/etc
|
||||||
|
conf_file="/var/etc/airplay2-${cfg}.conf"
|
||||||
|
} && {
|
||||||
|
printf "// Automatically generated from UCI config\n\n"
|
||||||
|
|
||||||
|
# General
|
||||||
|
printf "general =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_str "$cfg" name "name"
|
||||||
|
append_str "$cfg" password "password"
|
||||||
|
append_str "$cfg" interpolation "interpolation"
|
||||||
|
append_str "$cfg" output_backend "output_backend"
|
||||||
|
append_str "$cfg" mdns_backend "mdns_backend"
|
||||||
|
append_num "$cfg" port "port"
|
||||||
|
append_num "$cfg" udp_port_base "udp_port_base"
|
||||||
|
append_num "$cfg" udp_port_range "udp_port_range"
|
||||||
|
append_num "$cfg" drift "drift"
|
||||||
|
append_num "$cfg" resync_threshold "resync_threshold"
|
||||||
|
append_str "$cfg" ignore_volume_control "ignore_volume_control"
|
||||||
|
append_num "$cfg" volume_range_db "volume_range_db"
|
||||||
|
append_str "$cfg" regtype "regtype"
|
||||||
|
append_str "$cfg" playback_mode "playback_mode"
|
||||||
|
printf "};\n\n"
|
||||||
|
|
||||||
|
# Metadata
|
||||||
|
printf "metadata =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_str "$cfg" metadata_enabled "enabled"
|
||||||
|
append_str "$cfg" metadata_cover_art "include_cover_art"
|
||||||
|
append_str "$cfg" metadata_pipe_name "pipe_name"
|
||||||
|
append_num "$cfg" metadata_pipe_timeout "pipe_timeout"
|
||||||
|
append_str "$cfg" metadata_socket_address "socket_address"
|
||||||
|
append_num "$cfg" metadata_socket_port "socket_port"
|
||||||
|
append_num "$cfg" metadata_socket_msglength "socket_msglength"
|
||||||
|
printf "};\n\n"
|
||||||
|
|
||||||
|
# Session control
|
||||||
|
printf "sessioncontrol =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_str "$cfg" sesctl_run_before_play_begins "run_this_before_play_begins"
|
||||||
|
append_str "$cfg" sesctl_run_after_play_ends "run_this_after_play_ends"
|
||||||
|
append_str "$cfg" sesctl_run_before_entering_active_state "run_this_before_entering_active_state"
|
||||||
|
append_str "$cfg" sesctl_run_after_exiting_active_state "run_this_after_exiting_active_state"
|
||||||
|
append_str "$cfg" sesctl_run_if_an_unfixable_error_is_detected "run_this_if_an_unfixable_error_is_detected"
|
||||||
|
append_str "$cfg" sesctl_run_when_volume_is_set "run_this_when_volume_is_set"
|
||||||
|
append_str "$cfg" sesctl_wait_for_completion "wait_for_completion"
|
||||||
|
append_str "$cfg" sesctl_session_interruption "allow_session_interruption"
|
||||||
|
append_num "$cfg" sesctl_session_timeout "session_timeout"
|
||||||
|
printf "};\n\n"
|
||||||
|
|
||||||
|
# Alsa audio back end
|
||||||
|
printf "alsa =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_str "$cfg" alsa_output_device "output_device"
|
||||||
|
append_str "$cfg" alsa_mixer_control_name "mixer_control_name"
|
||||||
|
append_str "$cfg" alsa_mixer_device "mixer_device"
|
||||||
|
append_num "$cfg" alsa_latency_offset "audio_backend_latency_offset"
|
||||||
|
local alsa_output_rate_val
|
||||||
|
config_get alsa_output_rate_val "$cfg" "alsa_output_rate"
|
||||||
|
[ $alsa_output_rate_val != "auto" ] && append_num "$cfg" alsa_output_rate "output_rate" "44100"
|
||||||
|
append_num "$cfg" alsa_buffer_length "audio_backend_buffer_desired_length"
|
||||||
|
append_str "$cfg" alsa_disable_synchronization "disable_synchronization"
|
||||||
|
append_num "$cfg" alsa_period_size "period_size"
|
||||||
|
append_num "$cfg" alsa_buffer_size "buffer_size"
|
||||||
|
printf "};\n\n"
|
||||||
|
|
||||||
|
# Pipe audio back end
|
||||||
|
printf "pipe =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_str "$cfg" pipe_name "name"
|
||||||
|
append_num "$cfg" pipe_latency_offset "audio_backend_latency_offset"
|
||||||
|
append_num "$cfg" pipe_buffer_length "audio_backend_buffer_desired_length"
|
||||||
|
printf "};\n\n"
|
||||||
|
|
||||||
|
# Stdout audio back end
|
||||||
|
printf "stdout =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_num "$cfg" stdout_latency_offset "audio_backend_latency_offset"
|
||||||
|
append_num "$cfg" stdout_buffer_length "audio_backend_buffer_desired_length"
|
||||||
|
printf "};\n\n"
|
||||||
|
|
||||||
|
# MQTT
|
||||||
|
printf "mqtt =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_str "$cfg" mqtt_enabled "enabled"
|
||||||
|
append_str "$cfg" mqtt_hostname "hostname"
|
||||||
|
append_num "$cfg" mqtt_port "port"
|
||||||
|
append_str "$cfg" mqtt_username "username"
|
||||||
|
append_str "$cfg" mqtt_password "password"
|
||||||
|
append_str "$cfg" mqtt_topic "topic"
|
||||||
|
append_str "$cfg" mqtt_publish_raw "publish_raw"
|
||||||
|
append_str "$cfg" mqtt_publish_parsed "publish_parsed"
|
||||||
|
append_str "$cfg" mqtt_publish_cover "publish_cover"
|
||||||
|
append_str "$cfg" mqtt_enable_remote "enable_remote"
|
||||||
|
printf "};\n\n"
|
||||||
|
|
||||||
|
# AO audio back end
|
||||||
|
printf "ao =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_num "$cfg" ao_latency_offset "audio_backend_latency_offset"
|
||||||
|
append_num "$cfg" ao_buffer_length "audio_backend_buffer_desired_length"
|
||||||
|
printf "};\n\n"
|
||||||
|
|
||||||
|
# Diagnostics
|
||||||
|
config_get log_verbosity "$cfg" log_verbosity
|
||||||
|
config_get statistics "$cfg" statistics
|
||||||
|
|
||||||
|
printf "diagnostics =\n"
|
||||||
|
printf "{\n"
|
||||||
|
append_str "$cfg" diagnostics_statistics "statistics" "${statistics}"
|
||||||
|
append_str "$cfg" diagnostics_log_output_to "log_output_to"
|
||||||
|
append_num "$cfg" diagnostics_log_verbosity "log_verbosity" "${log_verbosity}"
|
||||||
|
printf "};\n\n"
|
||||||
|
} > "$conf_file"
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
|
||||||
|
procd_set_param command /usr/bin/airplay2
|
||||||
|
procd_append_param command -c "$conf_file"
|
||||||
|
|
||||||
|
config_get_bool aux "$cfg" 'respawn' '0'
|
||||||
|
[ "$aux" = 1 ] && procd_set_param respawn
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "airplay2"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load airplay2
|
||||||
|
config_foreach start_instance airplay2
|
||||||
|
}
|
||||||
|
|
||||||
|
reload_service() {
|
||||||
|
stop
|
||||||
|
sleep 1
|
||||||
|
start
|
||||||
|
}
|
||||||
73
autocore-arm/Makefile
Normal file
73
autocore-arm/Makefile
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2020 Lean <coolsnowwolf@gmail.com>
|
||||||
|
# Copyright (C) 2021 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=autocore
|
||||||
|
PKG_FLAGS:=nonshared
|
||||||
|
PKG_VERSION:=1.0.0
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_CONFIG_DEPENDS:= \
|
||||||
|
CONFIG_TARGET_bcm27xx \
|
||||||
|
CONFIG_TARGET_bcm53xx
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(INCLUDE_DIR)/target.mk
|
||||||
|
|
||||||
|
define Package/autocore-arm
|
||||||
|
TITLE:=ARM auto core script.
|
||||||
|
MAINTAINER:=CN_SZTL
|
||||||
|
DEPENDS:=@(arm||aarch64) \
|
||||||
|
+TARGET_bcm27xx:bcm27xx-userland \
|
||||||
|
+TARGET_bcm53xx:nvram
|
||||||
|
VARIANT:=arm
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/autocore-x86
|
||||||
|
TITLE:=x86/x64 auto core loadbalance script.
|
||||||
|
MAINTAINER:=Lean / CN_SZTL
|
||||||
|
DEPENDS:=@TARGET_x86 +lm-sensors +ethtool
|
||||||
|
VARIANT:=x86
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/autocore/install/Default
|
||||||
|
$(INSTALL_DIR) $(1)/etc
|
||||||
|
$(CP) ./files/generic/10_system.js $(1)/etc/rpcd_10_system.js
|
||||||
|
$(CP) ./files/generic/29_ports.js $(1)/etc/rpcd_29_ports.js
|
||||||
|
$(CP) ./files/generic/luci $(1)/etc/rpcd_luci
|
||||||
|
$(CP) ./files/generic/sys.uc $(1)/etc/ucode_sys
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||||
|
$(INSTALL_BIN) ./files/generic/090-cover-index_files $(1)/etc/uci-defaults/
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/sbin
|
||||||
|
$(INSTALL_BIN) ./files/generic/cpuinfo $(1)/sbin/
|
||||||
|
$(INSTALL_BIN) ./files/generic/ethinfo $(1)/sbin/
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
|
||||||
|
$(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/autocore-arm/install
|
||||||
|
$(call Package/autocore/install/Default,$(1))
|
||||||
|
|
||||||
|
ifneq ($(filter ipq% %mt7622, $(TARGETID)),)
|
||||||
|
$(INSTALL_BIN) ./files/arm/tempinfo $(1)/sbin/
|
||||||
|
endif
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/autocore-x86/install
|
||||||
|
$(call Package/autocore/install/Default,$(1))
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./files/x86/autocore $(1)/etc/init.d/
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,autocore-arm))
|
||||||
|
$(eval $(call BuildPackage,autocore-x86))
|
||||||
21
autocore-arm/files/arm/tempinfo
Executable file
21
autocore-arm/files/arm/tempinfo
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
IEEE_PATH="/sys/class/ieee80211"
|
||||||
|
THERMAL_PATH="/sys/class/thermal"
|
||||||
|
|
||||||
|
if grep -Eq "ipq40xx|ipq806x" "/etc/openwrt_release"; then
|
||||||
|
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input | awk '$1=$1')"
|
||||||
|
else
|
||||||
|
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input | awk '$1=$1')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q "ipq40xx" "/etc/openwrt_release"; then
|
||||||
|
if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then
|
||||||
|
mt76_temp=" $(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input")°C"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "WiFi:${mt76_temp} ${wifi_temp}"
|
||||||
|
else
|
||||||
|
cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp")"
|
||||||
|
echo -n "CPU: ${cpu_temp}, WiFi: ${wifi_temp}"
|
||||||
|
fi
|
||||||
10
autocore-arm/files/generic/090-cover-index_files
Executable file
10
autocore-arm/files/generic/090-cover-index_files
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
[ -f '/etc/rpcd_10_system.js' ] && mv -f '/etc/rpcd_10_system.js' '/www/luci-static/resources/view/status/include/10_system.js'
|
||||||
|
[ -f '/etc/rpcd_29_ports.js' ] && mv -f '/etc/rpcd_29_ports.js' '/www/luci-static/resources/view/status/include/29_ports.js'
|
||||||
|
[ -f '/etc/rpcd_luci' ] && mv -f '/etc/rpcd_luci' '/usr/share/rpcd/ucode/luci'
|
||||||
|
[ -f '/etc/ucode_sys' ] && mv -f '/etc/ucode_sys' '/usr/share/ucode/luci/sys.uc'
|
||||||
|
|
||||||
|
/etc/init.d/rpcd restart
|
||||||
|
|
||||||
|
exit 0
|
||||||
115
autocore-arm/files/generic/10_system.js
Normal file
115
autocore-arm/files/generic/10_system.js
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
'use strict';
|
||||||
|
'require baseclass';
|
||||||
|
'require fs';
|
||||||
|
'require rpc';
|
||||||
|
|
||||||
|
var callLuciVersion = rpc.declare({
|
||||||
|
object: 'luci',
|
||||||
|
method: 'getVersion'
|
||||||
|
});
|
||||||
|
|
||||||
|
var callSystemBoard = rpc.declare({
|
||||||
|
object: 'system',
|
||||||
|
method: 'board'
|
||||||
|
});
|
||||||
|
|
||||||
|
var callSystemInfo = rpc.declare({
|
||||||
|
object: 'system',
|
||||||
|
method: 'info'
|
||||||
|
});
|
||||||
|
|
||||||
|
var callCPUBench = rpc.declare({
|
||||||
|
object: 'luci',
|
||||||
|
method: 'getCPUBench'
|
||||||
|
});
|
||||||
|
|
||||||
|
var callCPUInfo = rpc.declare({
|
||||||
|
object: 'luci',
|
||||||
|
method: 'getCPUInfo'
|
||||||
|
});
|
||||||
|
|
||||||
|
var callCPUUsage = rpc.declare({
|
||||||
|
object: 'luci',
|
||||||
|
method: 'getCPUUsage'
|
||||||
|
});
|
||||||
|
|
||||||
|
var callTempInfo = rpc.declare({
|
||||||
|
object: 'luci',
|
||||||
|
method: 'getTempInfo'
|
||||||
|
});
|
||||||
|
|
||||||
|
return baseclass.extend({
|
||||||
|
title: _('System'),
|
||||||
|
|
||||||
|
load: function() {
|
||||||
|
return Promise.all([
|
||||||
|
L.resolveDefault(callSystemBoard(), {}),
|
||||||
|
L.resolveDefault(callSystemInfo(), {}),
|
||||||
|
L.resolveDefault(callCPUBench(), {}),
|
||||||
|
L.resolveDefault(callCPUInfo(), {}),
|
||||||
|
L.resolveDefault(callCPUUsage(), {}),
|
||||||
|
L.resolveDefault(callTempInfo(), {}),
|
||||||
|
L.resolveDefault(callLuciVersion(), { revision: _('unknown version'), branch: 'LuCI' })
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function(data) {
|
||||||
|
var boardinfo = data[0],
|
||||||
|
systeminfo = data[1],
|
||||||
|
cpubench = data[2],
|
||||||
|
cpuinfo = data[3],
|
||||||
|
cpuusage = data[4],
|
||||||
|
tempinfo = data[5],
|
||||||
|
luciversion = data[6];
|
||||||
|
|
||||||
|
luciversion = luciversion.branch + ' ' + luciversion.revision;
|
||||||
|
|
||||||
|
var datestr = null;
|
||||||
|
|
||||||
|
if (systeminfo.localtime) {
|
||||||
|
var date = new Date(systeminfo.localtime * 1000);
|
||||||
|
|
||||||
|
datestr = '%04d-%02d-%02d %02d:%02d:%02d'.format(
|
||||||
|
date.getUTCFullYear(),
|
||||||
|
date.getUTCMonth() + 1,
|
||||||
|
date.getUTCDate(),
|
||||||
|
date.getUTCHours(),
|
||||||
|
date.getUTCMinutes(),
|
||||||
|
date.getUTCSeconds()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var fields = [
|
||||||
|
_('Hostname'), boardinfo.hostname,
|
||||||
|
_('Model'), boardinfo.model + cpubench.cpubench,
|
||||||
|
_('Architecture'), cpuinfo.cpuinfo,
|
||||||
|
_('Target Platform'), (L.isObject(boardinfo.release) ? boardinfo.release.target : ''),
|
||||||
|
_('Firmware Version'), (L.isObject(boardinfo.release) ? boardinfo.release.description + ' / ' : '') + (luciversion || ''),
|
||||||
|
_('Kernel Version'), boardinfo.kernel,
|
||||||
|
_('Local Time'), datestr,
|
||||||
|
_('Uptime'), systeminfo.uptime ? '%t'.format(systeminfo.uptime) : null,
|
||||||
|
_('Load Average'), Array.isArray(systeminfo.load) ? '%.2f, %.2f, %.2f'.format(
|
||||||
|
systeminfo.load[0] / 65535.0,
|
||||||
|
systeminfo.load[1] / 65535.0,
|
||||||
|
systeminfo.load[2] / 65535.0
|
||||||
|
) : null,
|
||||||
|
_('CPU usage'), cpuusage.cpuusage
|
||||||
|
];
|
||||||
|
|
||||||
|
if (tempinfo.tempinfo) {
|
||||||
|
fields.splice(6, 0, _('Temperature'));
|
||||||
|
fields.splice(7, 0, tempinfo.tempinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
var table = E('table', { 'class': 'table' });
|
||||||
|
|
||||||
|
for (var i = 0; i < fields.length; i += 2) {
|
||||||
|
table.appendChild(E('tr', { 'class': 'tr' }, [
|
||||||
|
E('td', { 'class': 'td left', 'width': '33%' }, [ fields[i] ]),
|
||||||
|
E('td', { 'class': 'td left' }, [ (fields[i + 1] != null) ? fields[i + 1] : '?' ])
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
});
|
||||||
386
autocore-arm/files/generic/29_ports.js
Normal file
386
autocore-arm/files/generic/29_ports.js
Normal file
@@ -0,0 +1,386 @@
|
|||||||
|
'use strict';
|
||||||
|
'require baseclass';
|
||||||
|
'require fs';
|
||||||
|
'require ui';
|
||||||
|
'require uci';
|
||||||
|
'require rpc';
|
||||||
|
'require network';
|
||||||
|
'require firewall';
|
||||||
|
|
||||||
|
var callLuciETHInfo = rpc.declare({
|
||||||
|
object: 'luci',
|
||||||
|
method: 'getETHInfo',
|
||||||
|
expect: { result: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
function isString(v)
|
||||||
|
{
|
||||||
|
return typeof(v) === 'string' && v !== '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveVLANChain(ifname, bridges, mapping)
|
||||||
|
{
|
||||||
|
while (!mapping[ifname]) {
|
||||||
|
var m = ifname.match(/^(.+)\.([^.]+)$/);
|
||||||
|
|
||||||
|
if (!m)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (bridges[m[1]]) {
|
||||||
|
if (bridges[m[1]].vlan_filtering)
|
||||||
|
mapping[ifname] = bridges[m[1]].vlans[m[2]];
|
||||||
|
else
|
||||||
|
mapping[ifname] = bridges[m[1]].ports;
|
||||||
|
}
|
||||||
|
else if (/^[0-9]{1,4}$/.test(m[2]) && m[2] <= 4095) {
|
||||||
|
mapping[ifname] = [ m[1] ];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ifname = m[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildVLANMappings(mapping)
|
||||||
|
{
|
||||||
|
var bridge_vlans = uci.sections('network', 'bridge-vlan'),
|
||||||
|
vlan_devices = uci.sections('network', 'device'),
|
||||||
|
interfaces = uci.sections('network', 'interface'),
|
||||||
|
bridges = {};
|
||||||
|
|
||||||
|
/* find bridge VLANs */
|
||||||
|
for (var i = 0, s; (s = bridge_vlans[i]) != null; i++) {
|
||||||
|
if (!isString(s.device) || !/^[0-9]{1,4}$/.test(s.vlan) || +s.vlan > 4095)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var aliases = L.toArray(s.alias),
|
||||||
|
ports = L.toArray(s.ports),
|
||||||
|
br = bridges[s.device] = (bridges[s.device] || { ports: [], vlans: {}, vlan_filtering: true });
|
||||||
|
|
||||||
|
br.vlans[s.vlan] = [];
|
||||||
|
|
||||||
|
for (var j = 0; j < ports.length; j++) {
|
||||||
|
var port = ports[j].replace(/:[ut*]+$/, '');
|
||||||
|
|
||||||
|
if (br.ports.indexOf(port) === -1)
|
||||||
|
br.ports.push(port);
|
||||||
|
|
||||||
|
br.vlans[s.vlan].push(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var j = 0; j < aliases.length; j++)
|
||||||
|
if (aliases[j] != s.vlan)
|
||||||
|
br.vlans[aliases[j]] = br.vlans[s.vlan];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* find bridges, VLAN devices */
|
||||||
|
for (var i = 0, s; (s = vlan_devices[i]) != null; i++) {
|
||||||
|
if (s.type == 'bridge') {
|
||||||
|
if (!isString(s.name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var ports = L.toArray(s.ports),
|
||||||
|
br = bridges[s.name] || (bridges[s.name] = { ports: [], vlans: {}, vlan_filtering: false });
|
||||||
|
|
||||||
|
if (s.vlan_filtering == '0')
|
||||||
|
br.vlan_filtering = false;
|
||||||
|
else if (s.vlan_filtering == '1')
|
||||||
|
br.vlan_filtering = true;
|
||||||
|
|
||||||
|
for (var j = 0; j < ports.length; j++)
|
||||||
|
if (br.ports.indexOf(ports[j]) === -1)
|
||||||
|
br.ports.push(ports[j]);
|
||||||
|
|
||||||
|
mapping[s.name] = br.ports;
|
||||||
|
}
|
||||||
|
else if (s.type == '8021q' || s.type == '8021ad') {
|
||||||
|
if (!isString(s.name) || !isString(s.vid) || !isString(s.ifname))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* parent device is a bridge */
|
||||||
|
if (bridges[s.ifname]) {
|
||||||
|
/* parent bridge is VLAN enabled, device refers to VLAN ports */
|
||||||
|
if (bridges[s.ifname].vlan_filtering)
|
||||||
|
mapping[s.name] = bridges[s.ifname].vlans[s.vid];
|
||||||
|
|
||||||
|
/* parent bridge is not VLAN enabled, device refers to all bridge ports */
|
||||||
|
else
|
||||||
|
mapping[s.name] = bridges[s.ifname].ports;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* parent is a simple netdev */
|
||||||
|
else {
|
||||||
|
mapping[s.name] = [ s.ifname ];
|
||||||
|
}
|
||||||
|
|
||||||
|
resolveVLANChain(s.ifname, bridges, mapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* resolve VLAN tagged interfaces in bridge ports */
|
||||||
|
for (var brname in bridges) {
|
||||||
|
for (var i = 0; i < bridges[brname].ports.length; i++)
|
||||||
|
resolveVLANChain(bridges[brname].ports[i], bridges, mapping);
|
||||||
|
|
||||||
|
for (var vid in bridges[brname].vlans)
|
||||||
|
for (var i = 0; i < bridges[brname].vlans[vid].length; i++)
|
||||||
|
resolveVLANChain(bridges[brname].vlans[vid][i], bridges, mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* find implicit VLAN devices */
|
||||||
|
for (var i = 0, s; (s = interfaces[i]) != null; i++) {
|
||||||
|
if (!isString(s.device))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
resolveVLANChain(s.device, bridges, mapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveVLANPorts(ifname, mapping, seen)
|
||||||
|
{
|
||||||
|
var ports = [];
|
||||||
|
|
||||||
|
if (!seen)
|
||||||
|
seen = {};
|
||||||
|
|
||||||
|
if (mapping[ifname]) {
|
||||||
|
for (var i = 0; i < mapping[ifname].length; i++) {
|
||||||
|
if (!seen[mapping[ifname][i]]) {
|
||||||
|
seen[mapping[ifname][i]] = true;
|
||||||
|
ports.push.apply(ports, resolveVLANPorts(mapping[ifname][i], mapping, seen));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ports.push(ifname);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ports.sort(L.naturalCompare);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildInterfaceMapping(zones, networks) {
|
||||||
|
var vlanmap = {},
|
||||||
|
portmap = {},
|
||||||
|
netmap = {};
|
||||||
|
|
||||||
|
buildVLANMappings(vlanmap);
|
||||||
|
|
||||||
|
for (var i = 0; i < networks.length; i++) {
|
||||||
|
var l3dev = networks[i].getDevice();
|
||||||
|
|
||||||
|
if (!l3dev)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var ports = resolveVLANPorts(l3dev.getName(), vlanmap);
|
||||||
|
|
||||||
|
for (var j = 0; j < ports.length; j++) {
|
||||||
|
portmap[ports[j]] = portmap[ports[j]] || { networks: [], zones: [] };
|
||||||
|
portmap[ports[j]].networks.push(networks[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
netmap[networks[i].getName()] = networks[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < zones.length; i++) {
|
||||||
|
var networknames = zones[i].getNetworks();
|
||||||
|
|
||||||
|
for (var j = 0; j < networknames.length; j++) {
|
||||||
|
if (!netmap[networknames[j]])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var l3dev = netmap[networknames[j]].getDevice();
|
||||||
|
|
||||||
|
if (!l3dev)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var ports = resolveVLANPorts(l3dev.getName(), vlanmap);
|
||||||
|
|
||||||
|
for (var k = 0; k < ports.length; k++) {
|
||||||
|
portmap[ports[k]] = portmap[ports[k]] || { networks: [], zones: [] };
|
||||||
|
|
||||||
|
if (portmap[ports[k]].zones.indexOf(zones[i]) === -1)
|
||||||
|
portmap[ports[k]].zones.push(zones[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return portmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatSpeed(carrier, speed, duplex) {
|
||||||
|
if ((speed > 0) && duplex) {
|
||||||
|
var d = (duplex == 'half') ? '\u202f(H)' : '',
|
||||||
|
e = E('span', { 'title': _('Speed: %d Mibit/s, Duplex: %s').format(speed, duplex) });
|
||||||
|
|
||||||
|
switch (speed) {
|
||||||
|
case 10: e.innerText = '10\u202fM' + d; break;
|
||||||
|
case 100: e.innerText = '100\u202fM' + d; break;
|
||||||
|
case 1000: e.innerText = '1\u202fGbE' + d; break;
|
||||||
|
case 2500: e.innerText = '2.5\u202fGbE'; break;
|
||||||
|
case 5000: e.innerText = '5\u202fGbE'; break;
|
||||||
|
case 10000: e.innerText = '10\u202fGbE'; break;
|
||||||
|
case 25000: e.innerText = '25\u202fGbE'; break;
|
||||||
|
case 40000: e.innerText = '40\u202fGbE'; break;
|
||||||
|
default: e.innerText = '%d\u202fMbE%s'.format(speed, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return carrier ? _('Connected') : _('no link');
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatStats(portdev) {
|
||||||
|
var stats = portdev._devstate('stats') || {};
|
||||||
|
|
||||||
|
return ui.itemlist(E('span'), [
|
||||||
|
_('Received bytes'), '%1024mB'.format(stats.rx_bytes),
|
||||||
|
_('Received packets'), '%1000mPkts.'.format(stats.rx_packets),
|
||||||
|
_('Received multicast'), '%1000mPkts.'.format(stats.multicast),
|
||||||
|
_('Receive errors'), '%1000mPkts.'.format(stats.rx_errors),
|
||||||
|
_('Receive dropped'), '%1000mPkts.'.format(stats.rx_dropped),
|
||||||
|
|
||||||
|
_('Transmitted bytes'), '%1024mB'.format(stats.tx_bytes),
|
||||||
|
_('Transmitted packets'), '%1000mPkts.'.format(stats.tx_packets),
|
||||||
|
_('Transmit errors'), '%1000mPkts.'.format(stats.tx_errors),
|
||||||
|
_('Transmit dropped'), '%1000mPkts.'.format(stats.tx_dropped),
|
||||||
|
|
||||||
|
_('Collisions seen'), stats.collisions
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderNetworkBadge(network, zonename) {
|
||||||
|
var l3dev = network.getDevice();
|
||||||
|
var span = E('span', { 'class': 'ifacebadge', 'style': 'margin:.125em 0' }, [
|
||||||
|
E('span', {
|
||||||
|
'class': 'zonebadge',
|
||||||
|
'title': zonename ? _('Part of zone %q').format(zonename) : _('No zone assigned'),
|
||||||
|
'style': firewall.getZoneColorStyle(zonename)
|
||||||
|
}, '\u202f'),
|
||||||
|
'\u202f', network.getName(), ': '
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (l3dev)
|
||||||
|
span.appendChild(E('img', {
|
||||||
|
'title': l3dev.getI18n(),
|
||||||
|
'src': L.resource('icons/%s%s.svg'.format(l3dev.getType(), l3dev.isUp() ? '' : '_disabled'))
|
||||||
|
}));
|
||||||
|
else
|
||||||
|
span.appendChild(E('em', _('(no interfaces attached)')));
|
||||||
|
|
||||||
|
return span;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderNetworksTooltip(pmap) {
|
||||||
|
var res = [ null ],
|
||||||
|
zmap = {};
|
||||||
|
|
||||||
|
for (var i = 0; pmap && i < pmap.zones.length; i++) {
|
||||||
|
var networknames = pmap.zones[i].getNetworks();
|
||||||
|
|
||||||
|
for (var k = 0; k < networknames.length; k++)
|
||||||
|
zmap[networknames[k]] = pmap.zones[i].getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; pmap && i < pmap.networks.length; i++)
|
||||||
|
res.push(E('br'), renderNetworkBadge(pmap.networks[i], zmap[pmap.networks[i].getName()]));
|
||||||
|
|
||||||
|
if (res.length > 1)
|
||||||
|
res[0] = N_((res.length - 1) / 2, 'Part of network:', 'Part of networks:');
|
||||||
|
else
|
||||||
|
res[0] = _('Port is not part of any network');
|
||||||
|
|
||||||
|
return E([], res);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseclass.extend({
|
||||||
|
title: _('Port status'),
|
||||||
|
|
||||||
|
load: function() {
|
||||||
|
return Promise.all([
|
||||||
|
L.resolveDefault(callLuciETHInfo(), {}),
|
||||||
|
L.resolveDefault(fs.read('/etc/board.json'), '{}'),
|
||||||
|
firewall.getZones(),
|
||||||
|
network.getNetworks(),
|
||||||
|
uci.load('network')
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function(data) {
|
||||||
|
if (L.hasSystemFeature('swconfig'))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var board = JSON.parse(data[1]),
|
||||||
|
known_ports = [],
|
||||||
|
port_map = buildInterfaceMapping(data[2], data[3]);
|
||||||
|
|
||||||
|
if (Array.isArray(data[0]) && data[0].length > 0) {
|
||||||
|
known_ports = data[0].map(port => ({
|
||||||
|
...port,
|
||||||
|
netdev: network.instantiateDevice(port.device)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (L.isObject(board) && L.isObject(board.network)) {
|
||||||
|
for (var k = 'lan'; k != null; k = (k == 'lan') ? 'wan' : null) {
|
||||||
|
if (!L.isObject(board.network[k]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Array.isArray(board.network[k].ports))
|
||||||
|
for (let i = 0; i < board.network[k].ports.length; i++)
|
||||||
|
known_ports.push({
|
||||||
|
role: k,
|
||||||
|
device: board.network[k].ports[i],
|
||||||
|
netdev: network.instantiateDevice(board.network[k].ports[i])
|
||||||
|
});
|
||||||
|
else if (typeof(board.network[k].device) == 'string')
|
||||||
|
known_ports.push({
|
||||||
|
role: k,
|
||||||
|
device: board.network[k].device,
|
||||||
|
netdev: network.instantiateDevice(board.network[k].device)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
known_ports.sort(function(a, b) {
|
||||||
|
return L.naturalCompare(a.device, b.device);
|
||||||
|
});
|
||||||
|
|
||||||
|
return E('div', { 'style': 'display:grid;grid-template-columns:repeat(auto-fit, minmax(70px, 1fr));margin-bottom:1em' }, known_ports.map(function(port) {
|
||||||
|
var speed = port.netdev.getSpeed(),
|
||||||
|
duplex = port.netdev.getDuplex(),
|
||||||
|
carrier = port.netdev.getCarrier(),
|
||||||
|
pmap = port_map[port.netdev.getName()],
|
||||||
|
pzones = (pmap && pmap.zones.length) ? pmap.zones.sort(function(a, b) { return L.naturalCompare(a.getName(), b.getName()) }) : [ null ];
|
||||||
|
|
||||||
|
return E('div', { 'class': 'ifacebox', 'style': 'margin:.25em;min-width:70px;max-width:100px' }, [
|
||||||
|
E('div', { 'class': 'ifacebox-head', 'style': 'font-weight:bold' }, [ port.netdev.getName() ]),
|
||||||
|
E('div', { 'class': 'ifacebox-body' }, [
|
||||||
|
E('img', { 'src': L.resource('icons/port_%s.svg').format(carrier ? 'up' : 'down') }),
|
||||||
|
E('br'),
|
||||||
|
formatSpeed(carrier, speed, duplex)
|
||||||
|
]),
|
||||||
|
E('div', { 'class': 'ifacebox-head cbi-tooltip-container', 'style': 'display:flex' }, [
|
||||||
|
E([], pzones.map(function(zone) {
|
||||||
|
return E('div', {
|
||||||
|
'class': 'zonebadge',
|
||||||
|
'style': 'cursor:help;flex:1;height:3px;opacity:' + (carrier ? 1 : 0.25) + ';' + firewall.getZoneColorStyle(zone)
|
||||||
|
});
|
||||||
|
})),
|
||||||
|
E('span', { 'class': 'cbi-tooltip left' }, [ renderNetworksTooltip(pmap) ])
|
||||||
|
]),
|
||||||
|
E('div', { 'class': 'ifacebox-body' }, [
|
||||||
|
E('div', { 'class': 'cbi-tooltip-container', 'style': 'text-align:left;font-size:80%' }, [
|
||||||
|
'\u25b2\u202f%1024.1mB'.format(port.netdev.getTXBytes()),
|
||||||
|
E('br'),
|
||||||
|
'\u25bc\u202f%1024.1mB'.format(port.netdev.getRXBytes()),
|
||||||
|
E('span', { 'class': 'cbi-tooltip' }, formatStats(port.netdev))
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
61
autocore-arm/files/generic/cpuinfo
Executable file
61
autocore-arm/files/generic/cpuinfo
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /etc/openwrt_release
|
||||||
|
|
||||||
|
CPUINFO_PATH="/proc/cpuinfo"
|
||||||
|
CPUFREQ_PATH="/sys/devices/system/cpu/cpufreq"
|
||||||
|
THERMAL_PATH="/sys/class/thermal"
|
||||||
|
|
||||||
|
cpu_arch="$(awk -F ': ' '/model name/ {print $2}' "$CPUINFO_PATH" | head -n1)"
|
||||||
|
[ -n "${cpu_arch}" ] || cpu_arch="$(uname -m)"
|
||||||
|
|
||||||
|
case "$DISTRIB_TARGET" in
|
||||||
|
"x86"/*)
|
||||||
|
cpu_cores="$(grep "core id" "$CPUINFO_PATH" | sort -u | wc -l)C $(grep -c "processor" "$CPUINFO_PATH")T" ;;
|
||||||
|
*)
|
||||||
|
cpu_cores="$(grep -c "processor" "$CPUINFO_PATH")" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$DISTRIB_TARGET" in
|
||||||
|
"bcm27xx"/*)
|
||||||
|
cpu_freq="$(( $(vcgencmd measure_clock arm | awk -F '=' '{print $2}') / 1000000 ))Mhz" ;;
|
||||||
|
"bcm53xx"/*)
|
||||||
|
cpu_freq="$(nvram get clkfreq | awk -F ',' '{print $1}')MHz" ;;
|
||||||
|
"mvebu"/*)
|
||||||
|
cpu_freq="$(awk -F ': ' '/BogoMIPS/ {print $2}' "$CPUINFO_PATH" | head -n1)MHz" ;;
|
||||||
|
"x86"/*)
|
||||||
|
cpu_freq="$(awk -F ': ' '/MHz/ {print $2}' "$CPUINFO_PATH" | head -n1)MHz"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
[ ! -e "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq" ] || \
|
||||||
|
cpu_freq="$(awk '{printf("%.fMHz", $0 / 1000)}' "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq")"
|
||||||
|
[ ! -e "$CPUFREQ_PATH/policy4/cpuinfo_cur_freq" ] || \
|
||||||
|
big_cpu_freq="$(awk '{printf("%.fMHz ", $0 / 1000)}' "$CPUFREQ_PATH/policy4/cpuinfo_cur_freq")"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$DISTRIB_TARGET" in
|
||||||
|
"bcm27xx"/*)
|
||||||
|
cpu_temp="$(vcgencmd measure_temp | awk -F '=' '{print $2}' | awk -F "'" '{print $1}')°C" ;;
|
||||||
|
"x86"/*)
|
||||||
|
# Intel
|
||||||
|
cpu_temp="$(sensors "coretemp-*" 2>"/dev/null" | grep -E "(Package id |Core )" | grep -Eo "\+[0-9.]*°C" | head -n1 | tr -d "+")"
|
||||||
|
# AMD
|
||||||
|
[ -n "${cpu_temp}" ] || cpu_temp="$(sensors "k10temp-*" 2>"/dev/null" | awk '/Tctl|Tdie/ {print $2}' | head -n1 | tr -d "+")"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
[ ! -e "$THERMAL_PATH/thermal_zone0/temp" ] || \
|
||||||
|
cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp")"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$big_cpu_freq$cpu_freq" ] && [ -n "$cpu_temp" ]; then
|
||||||
|
echo -n "$cpu_arch x $cpu_cores ($cpu_temp)"
|
||||||
|
elif [ -z "$cpu_temp" ] && [ -n "$big_cpu_freq$cpu_freq" ] || \
|
||||||
|
grep -Eq "ipq|mt7622" "/etc/openwrt_release"; then
|
||||||
|
echo -n "$cpu_arch x $cpu_cores ($big_cpu_freq$cpu_freq)"
|
||||||
|
elif [ -n "$cpu_temp" ] && [ -n "$big_cpu_freq$cpu_freq" ]; then
|
||||||
|
echo -n "$cpu_arch x $cpu_cores ($big_cpu_freq$cpu_freq, ${cpu_temp})"
|
||||||
|
else
|
||||||
|
echo -n "$cpu_arch x $cpu_cores"
|
||||||
|
fi
|
||||||
23
autocore-arm/files/generic/ethinfo
Executable file
23
autocore-arm/files/generic/ethinfo
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local util = require "luci.util"
|
||||||
|
local jsonc = require "luci.jsonc"
|
||||||
|
|
||||||
|
local eth_info = {}
|
||||||
|
local ifname, stat
|
||||||
|
for ifname, stat in pairs(util.ubus("network.device", "status")) do
|
||||||
|
if ifname:match("^(eth%d+)$") == ifname or ifname:match("^(usb%d+)$") or ifname:match("^(lan%d+)$") or ifname:match("wan") == ifname then
|
||||||
|
eth_info[#eth_info + 1] = {
|
||||||
|
device = ifname
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(
|
||||||
|
eth_info,
|
||||||
|
function(a, b)
|
||||||
|
return a.device < b.device
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
print(jsonc.stringify(eth_info))
|
||||||
695
autocore-arm/files/generic/luci
Executable file
695
autocore-arm/files/generic/luci
Executable file
@@ -0,0 +1,695 @@
|
|||||||
|
// Copyright 2022 Jo-Philipp Wich <jo@mein.io>
|
||||||
|
// Licensed to the public under the Apache License 2.0.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import { stdin, access, dirname, basename, open, popen, glob, lsdir, readfile, readlink, error } from 'fs';
|
||||||
|
import { cursor } from 'uci';
|
||||||
|
|
||||||
|
import { init_list, init_index, init_enabled, init_action, conntrack_list, process_list } from 'luci.sys';
|
||||||
|
import { revision, branch } from 'luci.version';
|
||||||
|
import { statvfs, uname } from 'luci.core';
|
||||||
|
|
||||||
|
import timezones from 'luci.zoneinfo';
|
||||||
|
|
||||||
|
|
||||||
|
function shellquote(s) {
|
||||||
|
return `'${replace(s, "'", "'\\''")}'`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const methods = {
|
||||||
|
getVersion: {
|
||||||
|
call: function(request) {
|
||||||
|
return { revision, branch };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitList: {
|
||||||
|
args: { name: 'name' },
|
||||||
|
call: function(request) {
|
||||||
|
let scripts = {};
|
||||||
|
|
||||||
|
for (let name in filter(init_list(), i => !request.args.name || i == request.args.name)) {
|
||||||
|
let idx = init_index(name);
|
||||||
|
|
||||||
|
scripts[name] = {
|
||||||
|
index: idx?.[0],
|
||||||
|
stop: idx?.[1],
|
||||||
|
enabled: init_enabled(name)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return length(scripts) ? scripts : { error: 'No such init script' };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setInitAction: {
|
||||||
|
args: { name: 'name', action: 'action' },
|
||||||
|
call: function(request) {
|
||||||
|
switch (request.args.action) {
|
||||||
|
case 'enable':
|
||||||
|
case 'disable':
|
||||||
|
case 'start':
|
||||||
|
case 'stop':
|
||||||
|
case 'restart':
|
||||||
|
case 'reload':
|
||||||
|
const rc = init_action(request.args.name, request.args.action);
|
||||||
|
|
||||||
|
if (rc === false)
|
||||||
|
return { error: 'No such init script' };
|
||||||
|
|
||||||
|
return { result: rc == 0 };
|
||||||
|
|
||||||
|
default:
|
||||||
|
return { error: 'Invalid action' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getLocaltime: {
|
||||||
|
call: function(request) {
|
||||||
|
return { result: time() };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setLocaltime: {
|
||||||
|
args: { localtime: 0 },
|
||||||
|
call: function(request) {
|
||||||
|
let t = localtime(request.args.localtime);
|
||||||
|
|
||||||
|
if (t) {
|
||||||
|
system(sprintf('date -s "%04d-%02d-%02d %02d:%02d:%02d" >/dev/null', t.year, t.mon, t.mday, t.hour, t.min, t.sec));
|
||||||
|
system('/etc/init.d/sysfixtime restart >/dev/null');
|
||||||
|
}
|
||||||
|
|
||||||
|
return { result: request.args.localtime };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getTimezones: {
|
||||||
|
call: function(request) {
|
||||||
|
let tz = trim(readfile('/etc/TZ'));
|
||||||
|
let zn = cursor()?.get?.('system', '@system[0]', 'zonename');
|
||||||
|
let result = {};
|
||||||
|
|
||||||
|
for (let zone, tzstring in timezones) {
|
||||||
|
result[zone] = { tzstring };
|
||||||
|
|
||||||
|
if (zn == zone)
|
||||||
|
result[zone].active = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getLEDs: {
|
||||||
|
call: function() {
|
||||||
|
let result = {};
|
||||||
|
|
||||||
|
for (let led in lsdir('/sys/class/leds')) {
|
||||||
|
let s;
|
||||||
|
|
||||||
|
result[led] = { triggers: [] };
|
||||||
|
|
||||||
|
s = trim(readfile(`/sys/class/leds/${led}/trigger`));
|
||||||
|
for (let trigger in split(s, ' ')) {
|
||||||
|
push(result[led].triggers, trim(trigger, '[]'));
|
||||||
|
|
||||||
|
if (trigger != result[led].triggers[-1])
|
||||||
|
result[led].active_trigger = result[led].triggers[-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
s = readfile(`/sys/class/leds/${led}/brightness`);
|
||||||
|
result[led].brightness = +s;
|
||||||
|
|
||||||
|
s = readfile(`/sys/class/leds/${led}/max_brightness`);
|
||||||
|
result[led].max_brightness = +s;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getUSBDevices: {
|
||||||
|
call: function() {
|
||||||
|
let result = { devices: [], ports: [] };
|
||||||
|
|
||||||
|
for (let path in glob('/sys/bus/usb/devices/[0-9]*/manufacturer')) {
|
||||||
|
let id = basename(dirname(path));
|
||||||
|
|
||||||
|
push(result.devices, {
|
||||||
|
id,
|
||||||
|
vid: trim(readfile(`/sys/bus/usb/devices/${id}/idVendor`)),
|
||||||
|
pid: trim(readfile(`/sys/bus/usb/devices/${id}/idProduct`)),
|
||||||
|
vendor: trim(readfile(path)),
|
||||||
|
product: trim(readfile(`/sys/bus/usb/devices/${id}/product`)),
|
||||||
|
speed: +readfile(`/sys/bus/usb/devices/${id}/speed`)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let path in glob('/sys/bus/usb/devices/*/*-port[0-9]*')) {
|
||||||
|
let port = basename(path);
|
||||||
|
let link = readlink(`${path}/device`);
|
||||||
|
|
||||||
|
push(result.ports, {
|
||||||
|
port,
|
||||||
|
device: basename(link)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getConntrackHelpers: {
|
||||||
|
call: function() {
|
||||||
|
const uci = cursor();
|
||||||
|
let helpers = [];
|
||||||
|
let package;
|
||||||
|
|
||||||
|
if (uci.load('/usr/share/firewall4/helpers'))
|
||||||
|
package = 'helpers';
|
||||||
|
else if (uci.load('/usr/share/fw3/helpers.conf'))
|
||||||
|
package = 'helpers.conf';
|
||||||
|
|
||||||
|
if (package) {
|
||||||
|
uci.foreach(package, 'helper', (s) => {
|
||||||
|
push(helpers, {
|
||||||
|
name: s.name,
|
||||||
|
description: s.description,
|
||||||
|
module: s.module,
|
||||||
|
family: s.family,
|
||||||
|
proto: s.proto,
|
||||||
|
port: s.port
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return { result: helpers };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getFeatures: {
|
||||||
|
call: function() {
|
||||||
|
let result = {
|
||||||
|
firewall: access('/sbin/fw3') == true,
|
||||||
|
firewall4: access('/sbin/fw4') == true,
|
||||||
|
opkg: access('/bin/opkg') == true,
|
||||||
|
bonding: access('/sys/module/bonding'),
|
||||||
|
mii_tool: access('/usr/sbin/mii-tool'),
|
||||||
|
offloading: access('/sys/module/xt_FLOWOFFLOAD/refcnt') == true || access('/sys/module/nft_flow_offload/refcnt') == true,
|
||||||
|
fullcone: access('/sys/module/xt_FULLCONENAT/refcnt') == true || access('/sys/module/nft_fullcone/refcnt') == true,
|
||||||
|
shortcutfe: access('/sys/module/shortcut_fe/refcnt') == true,
|
||||||
|
natflow: access('/dev/natflow_ctl') == true,
|
||||||
|
br2684ctl: access('/usr/sbin/br2684ctl') == true,
|
||||||
|
swconfig: access('/sbin/swconfig') == true,
|
||||||
|
odhcpd: access('/usr/sbin/odhcpd') == true,
|
||||||
|
zram: access('/sys/class/zram-control') == true,
|
||||||
|
sysntpd: readlink('/usr/sbin/ntpd') != null,
|
||||||
|
ipv6: access('/proc/net/ipv6_route') == true,
|
||||||
|
dropbear: access('/usr/sbin/dropbear') == true,
|
||||||
|
cabundle: access('/etc/ssl/certs/ca-certificates.crt') == true,
|
||||||
|
relayd: access('/usr/sbin/relayd') == true,
|
||||||
|
apk: access('/usr/bin/apk') == true,
|
||||||
|
wifi: access('/sbin/wifi') == true,
|
||||||
|
iptables: access('/usr/sbin/iptables') == true,
|
||||||
|
offload_hw: system((`[[ $(. /etc/openwrt_release ; echo $DISTRIB_TARGET) == "mediatek"* || $(. /etc/openwrt_release ; echo $DISTRIB_TARGET) == *"bcm"* ]]`)) == 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const wifi_features = [ 'eap', '11ac', '11ax', '11be', '11r', 'acs', 'sae', 'owe', 'suiteb192', 'wep', 'wps', 'ocv' ];
|
||||||
|
|
||||||
|
if (access('/usr/sbin/hostapd')) {
|
||||||
|
result.hostapd = { cli: access('/usr/sbin/hostapd_cli') == true };
|
||||||
|
|
||||||
|
for (let feature in wifi_features)
|
||||||
|
result.hostapd[feature] = system(`/usr/sbin/hostapd -v${feature} >/dev/null 2>/dev/null`) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access('/usr/sbin/wpa_supplicant')) {
|
||||||
|
result.wpasupplicant = { cli: access('/usr/sbin/wpa_cli') == true };
|
||||||
|
|
||||||
|
for (let feature in wifi_features)
|
||||||
|
result.wpasupplicant[feature] = system(`/usr/sbin/wpa_supplicant -v${feature} >/dev/null 2>/dev/null`) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let fd = popen('dnsmasq --version 2>/dev/null');
|
||||||
|
|
||||||
|
if (fd) {
|
||||||
|
const m = match(fd.read('all'), /^Compile time options: (.+)$/s);
|
||||||
|
|
||||||
|
for (let opt in split(m?.[1], ' ')) {
|
||||||
|
let f = replace(opt, 'no-', '', 1);
|
||||||
|
|
||||||
|
result.dnsmasq ??= {};
|
||||||
|
result.dnsmasq[lc(f)] = (f == opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
fd.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = popen('ipset --help 2>/dev/null');
|
||||||
|
|
||||||
|
if (fd) {
|
||||||
|
for (let line = fd.read('line'), flag = false; length(line); line = fd.read('line')) {
|
||||||
|
if (line == 'Supported set types:\n') {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
else if (flag) {
|
||||||
|
const m = match(line, /^ +([\w:,]+)\t+([0-9]+)\t/);
|
||||||
|
|
||||||
|
if (m) {
|
||||||
|
result.ipset ??= {};
|
||||||
|
result.ipset[m[1]] ??= +m[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fd.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getSwconfigFeatures: {
|
||||||
|
args: { switch: 'switch0' },
|
||||||
|
call: function(request) {
|
||||||
|
// Parse some common switch properties from swconfig help output.
|
||||||
|
const swc = popen(`swconfig dev ${shellquote(request.args.switch)} help 2>/dev/null`);
|
||||||
|
|
||||||
|
if (swc) {
|
||||||
|
let is_port_attr = false;
|
||||||
|
let is_vlan_attr = false;
|
||||||
|
let result = {};
|
||||||
|
|
||||||
|
for (let line = swc.read('line'); length(line); line = swc.read('line')) {
|
||||||
|
if (match(line, /^\s+--vlan/)) {
|
||||||
|
is_vlan_attr = true;
|
||||||
|
}
|
||||||
|
else if (match(line, /^\s+--port/)) {
|
||||||
|
is_vlan_attr = false;
|
||||||
|
is_port_attr = true;
|
||||||
|
}
|
||||||
|
else if (match(line, /cpu @/)) {
|
||||||
|
result.switch_title = match(line, /^switch[0-9]+: \w+\((.+)\)/)?.[1];
|
||||||
|
result.num_vlans = match(line, /vlans: ([0-9]+)/)?.[1] ?? 16;
|
||||||
|
result.min_vid = 1;
|
||||||
|
}
|
||||||
|
else if (match(line, /: (pvid|tag|vid)/)) {
|
||||||
|
if (is_vlan_attr)
|
||||||
|
result.vid_option = match(line, /: (\w+)/)?.[1];
|
||||||
|
}
|
||||||
|
else if (match(line, /: enable_vlan4k/)) {
|
||||||
|
result.vlan4k_option = 'enable_vlan4k';
|
||||||
|
}
|
||||||
|
else if (match(line, /: enable_vlan/)) {
|
||||||
|
result.vlan_option = 'enable_vlan';
|
||||||
|
}
|
||||||
|
else if (match(line, /: enable_learning/)) {
|
||||||
|
result.learning_option = 'enable_learning';
|
||||||
|
}
|
||||||
|
else if (match(line, /: enable_mirror_rx/)) {
|
||||||
|
result.mirror_option = 'enable_mirror_rx';
|
||||||
|
}
|
||||||
|
else if (match(line, /: max_length/)) {
|
||||||
|
result.jumbo_option = 'max_length';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
swc.close();
|
||||||
|
|
||||||
|
if (!length(result))
|
||||||
|
return { error: 'No such switch' };
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return { error: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getSwconfigPortState: {
|
||||||
|
args: { switch: 'switch0' },
|
||||||
|
call: function(request) {
|
||||||
|
const swc = popen(`swconfig dev ${shellquote(request.args.switch)} show 2>/dev/null`);
|
||||||
|
|
||||||
|
if (swc) {
|
||||||
|
let ports = [], port;
|
||||||
|
|
||||||
|
for (let line = swc.read('line'); length(line); line = swc.read('line')) {
|
||||||
|
if (match(line, /^VLAN [0-9]+:/) && length(ports))
|
||||||
|
break;
|
||||||
|
|
||||||
|
let pnum = match(line, /^Port ([0-9]+):/)?.[1];
|
||||||
|
|
||||||
|
if (pnum) {
|
||||||
|
port = {
|
||||||
|
port: +pnum,
|
||||||
|
duplex: false,
|
||||||
|
speed: 0,
|
||||||
|
link: false,
|
||||||
|
auto: false,
|
||||||
|
rxflow: false,
|
||||||
|
txflow: false
|
||||||
|
};
|
||||||
|
|
||||||
|
push(ports, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port) {
|
||||||
|
let m;
|
||||||
|
|
||||||
|
if (match(line, /full[ -]duplex/))
|
||||||
|
port.duplex = true;
|
||||||
|
|
||||||
|
if ((m = match(line, / speed:([0-9]+)/)) != null)
|
||||||
|
port.speed = +m[1];
|
||||||
|
|
||||||
|
if ((m = match(line, /([0-9]+) Mbps/)) != null && !port.speed)
|
||||||
|
port.speed = +m[1];
|
||||||
|
|
||||||
|
if ((m = match(line, /link: ([0-9]+)/)) != null && !port.speed)
|
||||||
|
port.speed = +m[1];
|
||||||
|
|
||||||
|
if (match(line, /(link|status): ?up/))
|
||||||
|
port.link = true;
|
||||||
|
|
||||||
|
if (match(line, /auto-negotiate|link:.*auto/))
|
||||||
|
port.auto = true;
|
||||||
|
|
||||||
|
if (match(line, /link:.*rxflow/))
|
||||||
|
port.rxflow = true;
|
||||||
|
|
||||||
|
if (match(line, /link:.*txflow/))
|
||||||
|
port.txflow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
swc.close();
|
||||||
|
|
||||||
|
if (!length(ports))
|
||||||
|
return { error: 'No such switch' };
|
||||||
|
|
||||||
|
return { result: ports };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return { error: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setPassword: {
|
||||||
|
args: { username: 'root', password: 'password' },
|
||||||
|
call: function(request) {
|
||||||
|
const u = shellquote(request.args.username);
|
||||||
|
const p = shellquote(request.args.password);
|
||||||
|
|
||||||
|
return {
|
||||||
|
result: system(`(echo ${p}; sleep 1; echo ${p}) | /bin/busybox passwd ${u} >/dev/null 2>&1`) == 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getBlockDevices: {
|
||||||
|
call: function() {
|
||||||
|
const block = popen('/sbin/block info 2>/dev/null');
|
||||||
|
|
||||||
|
if (block) {
|
||||||
|
let result = {};
|
||||||
|
|
||||||
|
for (let line = block.read('line'); length(line); line = block.read('line')) {
|
||||||
|
let dev = match(line, /^\/dev\/([^:]+):/)?.[1];
|
||||||
|
|
||||||
|
if (dev) {
|
||||||
|
let e = result[dev] = {
|
||||||
|
dev: `/dev/${dev}`,
|
||||||
|
size: +readfile(`/sys/class/block/${dev}/size`) * 512
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let m in match(line, / (\w+)="([^"]+)"/g))
|
||||||
|
e[lc(m[1])] = m[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
block.close();
|
||||||
|
|
||||||
|
const swaps = open('/proc/swaps', 'r');
|
||||||
|
|
||||||
|
if (swaps) {
|
||||||
|
for (let line = swaps.read('line'); length(line); line = swaps.read('line')) {
|
||||||
|
let m = match(line, /^(\/\S+)\s+\S+\s+(\d+)/);
|
||||||
|
|
||||||
|
if (m) {
|
||||||
|
let dev = replace(m[1], /\\(\d\d\d)/g, (_, n) => chr(int(n, 8)));
|
||||||
|
|
||||||
|
result[`swap:${m[1]}`] = {
|
||||||
|
dev,
|
||||||
|
type: 'swap',
|
||||||
|
size: +m[2] * 1024
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
swaps.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return { error: 'Unable to execute block utility' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setBlockDetect: {
|
||||||
|
call: function() {
|
||||||
|
return { result: system('/sbin/block detect > /etc/config/fstab') == 0 };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getMountPoints: {
|
||||||
|
call: function() {
|
||||||
|
const fd = open('/proc/mounts', 'r');
|
||||||
|
|
||||||
|
if (fd) {
|
||||||
|
let result = [];
|
||||||
|
|
||||||
|
for (let line = fd.read('line'); length(line); line = fd.read('line')) {
|
||||||
|
const m = split(line, ' ');
|
||||||
|
const device = replace(m[0], /\\([0-9][0-9][0-9])/g, (m, n) => char(int(n, 8)));
|
||||||
|
const mount = replace(m[1], /\\([0-9][0-9][0-9])/g, (m, n) => char(int(n, 8)));
|
||||||
|
const stat = statvfs(mount);
|
||||||
|
|
||||||
|
if (stat?.blocks > 0) {
|
||||||
|
push(result, {
|
||||||
|
device, mount,
|
||||||
|
size: stat.bsize * stat.blocks,
|
||||||
|
avail: stat.bsize * stat.bavail,
|
||||||
|
free: stat.bsize * stat.bfree
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fd.close();
|
||||||
|
|
||||||
|
return { result };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return { error: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getRealtimeStats: {
|
||||||
|
args: { mode: 'interface', device: 'eth0' },
|
||||||
|
call: function(request) {
|
||||||
|
let flags;
|
||||||
|
|
||||||
|
if (request.args.mode == 'interface')
|
||||||
|
flags = `-i ${shellquote(request.args.device)}`;
|
||||||
|
else if (request.args.mode == 'wireless')
|
||||||
|
flags = `-r ${shellquote(request.args.device)}`;
|
||||||
|
else if (request.args.mode == 'conntrack')
|
||||||
|
flags = '-c';
|
||||||
|
else if (request.args.mode == 'load')
|
||||||
|
flags = '-l';
|
||||||
|
else
|
||||||
|
return { error: 'Invalid mode' };
|
||||||
|
|
||||||
|
const fd = popen(`luci-bwc ${flags}`, 'r');
|
||||||
|
|
||||||
|
if (fd) {
|
||||||
|
let result;
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = { result: json(`[${fd.read('all')}]`) };
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
result = { error: err };
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return { error: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getConntrackList: {
|
||||||
|
call: function() {
|
||||||
|
return { result: conntrack_list() };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getProcessList: {
|
||||||
|
call: function() {
|
||||||
|
return { result: process_list() };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getBuiltinEthernetPorts: {
|
||||||
|
call: function() {
|
||||||
|
let fd = open('/etc/board.json', 'r');
|
||||||
|
let board = fd ? json(fd) : {};
|
||||||
|
let ports = [];
|
||||||
|
|
||||||
|
for (let k in [ 'lan', 'wan' ]) {
|
||||||
|
if (!board?.network?.[k])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (type(board.network[k].ports) == 'array') {
|
||||||
|
for (let ifname in board.network[k].ports) {
|
||||||
|
push(ports, { role: k, device: ifname });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type(board.network[k].device) == 'string') {
|
||||||
|
push(ports, { role: k, device: board.network[k].device });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for targets that do not enumerate all netdevs in board.json */
|
||||||
|
if (uname().machine in [ 'x86_64' ] &&
|
||||||
|
match(ports[0]?.device, /^eth\d+$/)) {
|
||||||
|
let bus = readlink(`/sys/class/net/${ports[0].device}/device/subsystem`);
|
||||||
|
|
||||||
|
for (let netdev in lsdir('/sys/class/net')) {
|
||||||
|
if (!match(netdev, /^eth\d+$/))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (length(filter(ports, port => port.device == netdev)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (readlink(`/sys/class/net/${netdev}/device/subsystem`) != bus)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
push(ports, { role: 'unknown', device: netdev });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { result: ports };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getCPUBench: {
|
||||||
|
call: function() {
|
||||||
|
return { cpubench: readfile('/etc/bench.log') || '' };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getCPUInfo: {
|
||||||
|
call: function() {
|
||||||
|
if (!access('/sbin/cpuinfo'))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const fd = popen('/sbin/cpuinfo');
|
||||||
|
if (fd) {
|
||||||
|
let cpuinfo = fd.read('all');
|
||||||
|
if (!cpuinfo)
|
||||||
|
cpuinfo = '?';
|
||||||
|
fd.close();
|
||||||
|
|
||||||
|
return { cpuinfo: cpuinfo };
|
||||||
|
} else {
|
||||||
|
return { cpuinfo: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getCPUUsage: {
|
||||||
|
call: function() {
|
||||||
|
const fd = popen('/bin/busybox top -n1 | awk \'/^CPU/ {printf("%d%", 100 - $8)}\'');
|
||||||
|
if (fd) {
|
||||||
|
let cpuusage = fd.read('all');
|
||||||
|
if (!cpuusage)
|
||||||
|
cpuusage = '?';
|
||||||
|
fd.close();
|
||||||
|
|
||||||
|
return { cpuusage: cpuusage };
|
||||||
|
} else {
|
||||||
|
return { cpuusage: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getTempInfo: {
|
||||||
|
call: function() {
|
||||||
|
if (!access('/sbin/tempinfo'))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const fd = popen('/sbin/tempinfo');
|
||||||
|
if (fd) {
|
||||||
|
let tempinfo = fd.read('all');
|
||||||
|
if (!tempinfo)
|
||||||
|
tempinfo = '?';
|
||||||
|
fd.close();
|
||||||
|
|
||||||
|
return { tempinfo: tempinfo };
|
||||||
|
} else {
|
||||||
|
return { tempinfo: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getOnlineUsers: {
|
||||||
|
call: function() {
|
||||||
|
const fd = open('/proc/net/arp', 'r');
|
||||||
|
if (fd) {
|
||||||
|
let onlineusers = 0;
|
||||||
|
|
||||||
|
for (let line = fd.read('line'); length(line); line = fd.read('line'))
|
||||||
|
if (match(trim(line), /^.*(0x2).*(br-lan)$/))
|
||||||
|
onlineusers++;
|
||||||
|
|
||||||
|
fd.close();
|
||||||
|
|
||||||
|
return { onlineusers: onlineusers };
|
||||||
|
} else {
|
||||||
|
return { onlineusers: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getETHInfo: {
|
||||||
|
call: function() {
|
||||||
|
if (!access('/sbin/ethinfo'))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const fd = popen('/sbin/ethinfo');
|
||||||
|
if (fd) {
|
||||||
|
let ethinfo = fd.read('all');
|
||||||
|
if (!ethinfo)
|
||||||
|
ethinfo = '{}';
|
||||||
|
ethinfo = json(ethinfo);
|
||||||
|
fd.close();
|
||||||
|
|
||||||
|
return { result: ethinfo };
|
||||||
|
} else {
|
||||||
|
return { result: error() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { luci: methods };
|
||||||
10
autocore-arm/files/generic/luci-mod-status-autocore.json
Normal file
10
autocore-arm/files/generic/luci-mod-status-autocore.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"luci-mod-status-autocore": {
|
||||||
|
"description": "Grant access to autocore",
|
||||||
|
"read": {
|
||||||
|
"ubus": {
|
||||||
|
"luci": [ "getCPUInfo", "getTempInfo", "getCPUBench", "getCPUUsage", "getOnlineUsers", "getETHInfo" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
159
autocore-arm/files/generic/sys.uc
Normal file
159
autocore-arm/files/generic/sys.uc
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
// Copyright 2022 Jo-Philipp Wich <jo@mein.io>
|
||||||
|
// Licensed to the public under the Apache License 2.0.
|
||||||
|
|
||||||
|
import { basename, readlink, readfile, open, popen, stat, glob } from 'fs';
|
||||||
|
|
||||||
|
export function process_list() {
|
||||||
|
const top = popen('/bin/busybox top -bn1');
|
||||||
|
let line, list = [];
|
||||||
|
|
||||||
|
for (let line = top.read('line'); length(line); line = top.read('line')) {
|
||||||
|
let m = match(trim(line), /^([0-9]+) +([0-9]+) +(.+) +([RSDZTWI][<NW ][<N ]) +([0-9]+m?) +([0-9]+%) +([0-9]+%) +(.+)$/);
|
||||||
|
|
||||||
|
if (m && m[8] != '/bin/busybox top -bn1') {
|
||||||
|
push(list, {
|
||||||
|
PID: m[1],
|
||||||
|
PPID: m[2],
|
||||||
|
USER: trim(m[3]),
|
||||||
|
STAT: m[4],
|
||||||
|
VSZ: m[5],
|
||||||
|
'%MEM': m[6],
|
||||||
|
'%CPU': m[7],
|
||||||
|
COMMAND: m[8]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
top.close();
|
||||||
|
|
||||||
|
return list;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function conntrack_list(callback) {
|
||||||
|
const etcpr = open('/etc/protocols');
|
||||||
|
const protos = {};
|
||||||
|
|
||||||
|
if (etcpr) {
|
||||||
|
for (let line = etcpr.read('line'); length(line); line = etcpr.read('line')) {
|
||||||
|
const m = match(line, /^([^# \t\n]+)\s+([0-9]+)\s+/);
|
||||||
|
|
||||||
|
if (m)
|
||||||
|
protos[m[2]] = m[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
etcpr.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
const nfct = open('/proc/net/nf_conntrack', 'r');
|
||||||
|
let connt;
|
||||||
|
|
||||||
|
if (nfct) {
|
||||||
|
let lineCount = 0;
|
||||||
|
for (let line = nfct.read('line'); length(line) && lineCount < 1200; line = nfct.read('line')) {
|
||||||
|
lineCount++;
|
||||||
|
let m = match(line, /^(ipv[46]) +([0-9]+) +\S+ +([0-9]+)( +.+)\n$/);
|
||||||
|
|
||||||
|
if (!m)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
let fam = m[1];
|
||||||
|
let l3 = m[2];
|
||||||
|
let l4 = m[3];
|
||||||
|
let tuples = m[4];
|
||||||
|
let timeout = null;
|
||||||
|
|
||||||
|
m = match(tuples, /^ +([0-9]+)( .+)$/);
|
||||||
|
|
||||||
|
if (m) {
|
||||||
|
timeout = m[1];
|
||||||
|
tuples = m[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index(tuples, 'TIME_WAIT') !== -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
let e = {
|
||||||
|
bytes: 0,
|
||||||
|
packets: 0,
|
||||||
|
layer3: fam,
|
||||||
|
layer4: protos[l4] ?? 'unknown',
|
||||||
|
timeout: +timeout
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let kv in match(tuples, / (\w+)=(\S+)/g)) {
|
||||||
|
switch (kv[1]) {
|
||||||
|
case 'bytes':
|
||||||
|
case 'packets':
|
||||||
|
e[kv[1]] += +kv[2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'src':
|
||||||
|
case 'dst':
|
||||||
|
e[kv[1]] ??= arrtoip(iptoarr(kv[2]));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'sport':
|
||||||
|
case 'dport':
|
||||||
|
e[kv[1]] ??= +kv[2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
e[kv[1]] = kv[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
callback(e);
|
||||||
|
else
|
||||||
|
push(connt ??= [], e);
|
||||||
|
}
|
||||||
|
|
||||||
|
nfct.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return callback ? true : (connt ?? []);
|
||||||
|
};
|
||||||
|
|
||||||
|
export function init_list() {
|
||||||
|
return map(filter(glob('/etc/init.d/*'), path => {
|
||||||
|
const s = stat(path);
|
||||||
|
|
||||||
|
return s?.type == 'file' && s?.perm?.user_exec;
|
||||||
|
}), basename);
|
||||||
|
};
|
||||||
|
|
||||||
|
export function init_index(name) {
|
||||||
|
const src = readfile(`/etc/init.d/${basename(name)}`, 2048);
|
||||||
|
const idx = [];
|
||||||
|
|
||||||
|
for (let m in match(src, /^[[:space:]]*(START|STOP)=('[0-9][0-9]'|"[0-9][0-9]"|[0-9][0-9])[[:space:]]*$/gs)) {
|
||||||
|
switch (m[1]) {
|
||||||
|
case 'START': idx[0] = +trim(m[2], '"\''); break;
|
||||||
|
case 'STOP': idx[1] = +trim(m[2], '"\''); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return length(idx) ? idx : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function init_enabled(name) {
|
||||||
|
for (let path in glob(`/etc/rc.d/[SK][0-9][0-9]${basename(name)}`)) {
|
||||||
|
const ln = readlink(path);
|
||||||
|
const s1 = stat(index(ln, '/') == 0 ? ln : `/etc/rc.d/${ln}`);
|
||||||
|
const s2 = stat(`/etc/init.d/${basename(name)}`);
|
||||||
|
|
||||||
|
if (s1?.inode == s2?.inode && s1?.type == 'file' && s1?.perm?.user_exec)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function init_action(name, action) {
|
||||||
|
const s = stat(`/etc/init.d/${basename(name)}`);
|
||||||
|
|
||||||
|
if (s?.type != 'file' || s?.user_exec == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return system(`env -i /etc/init.d/${basename(name)} ${action} >/dev/null`);
|
||||||
|
};
|
||||||
39
autocore-arm/files/x86/autocore
Executable file
39
autocore-arm/files/x86/autocore
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2017 lean <coolsnowwolf@gmail.com>
|
||||||
|
|
||||||
|
START=99
|
||||||
|
|
||||||
|
start() {
|
||||||
|
rfc=4096
|
||||||
|
threads="$(grep -c "processor" "/proc/cpuinfo")"
|
||||||
|
|
||||||
|
sysctl -w net.core.rps_sock_flow_entries="$(( rfc * threads ))"
|
||||||
|
|
||||||
|
for fileRps in /sys/class/net/eth*/queues/rx-*/rps_cpus
|
||||||
|
do
|
||||||
|
echo "$threads" > "$fileRps"
|
||||||
|
done
|
||||||
|
|
||||||
|
for fileRfc in /sys/class/net/eth*/queues/rx-*/rps_flow_cnt
|
||||||
|
do
|
||||||
|
echo "$rfc" > "$fileRfc"
|
||||||
|
done
|
||||||
|
|
||||||
|
uci set network.@globals[0].packet_steering="1"
|
||||||
|
uci commit network
|
||||||
|
|
||||||
|
for i in $(ip address | awk -F ': ' '/eth[0-9]+/ {print $2}' | xargs)
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ethtool -K "$i" rx-checksum on
|
||||||
|
ethtool -K "$i" tx-checksum-ip-generic on || {
|
||||||
|
ethtool -K "$i" tx-checksum-ipv4 on
|
||||||
|
ethtool -K "$i" tx-checksum-ipv6 on
|
||||||
|
}
|
||||||
|
ethtool -K "$i" tx-scatter-gather on
|
||||||
|
ethtool -K "$i" gso on
|
||||||
|
ethtool -K "$i" tso on
|
||||||
|
ethtool -K "$i" ufo on
|
||||||
|
}
|
||||||
|
done
|
||||||
|
} >"/dev/null" 2>&1
|
||||||
43
bash-completion/Makefile
Normal file
43
bash-completion/Makefile
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=bash-completion
|
||||||
|
PKG_VERSION:=2.14.0
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||||
|
PKG_SOURCE_URL:=https://github.com/scop/bash-completion/releases/download/$(PKG_VERSION)
|
||||||
|
PKG_HASH:=5c7494f968280832d6adb5aa19f745a56f1a79df311e59338c5efa6f7285e168
|
||||||
|
|
||||||
|
PKG_MAINTAINER:=sbwml <admin@cooluc.com>
|
||||||
|
PKG_LICENSE:=GPL-2.0
|
||||||
|
PKG_LICENSE_FILES:=COPYING
|
||||||
|
|
||||||
|
PKG_INSTALL:=1
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/bash-completion
|
||||||
|
SECTION:=utils
|
||||||
|
CATEGORY:=Utilities
|
||||||
|
SUBMENU:=Shells
|
||||||
|
TITLE:=Programmable completion functions for bash
|
||||||
|
URL:=https://github.com/scop/bash-completion
|
||||||
|
DEPENDS:=+bash
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/bash-completion/description
|
||||||
|
bash-completion is a collection of command line command completions for the Bash shell,
|
||||||
|
collection of helper functions to assist in creating new completions,
|
||||||
|
and set of facilities for loading completions automatically on demand, as well as installing them.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/bash-completion/install
|
||||||
|
$(INSTALL_DIR) $(1)/etc/profile.d
|
||||||
|
$(CP) $(PKG_INSTALL_DIR)/etc/profile.d/* $(1)/etc/profile.d/
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/bash-completion
|
||||||
|
$(CP) $(PKG_INSTALL_DIR)/usr/share/bash-completion/* $(1)/usr/share/bash-completion/
|
||||||
|
$(INSTALL_DIR) $(1)/etc/bash_completion.d
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,bash-completion))
|
||||||
93
chinadns-ng/Makefile
Normal file
93
chinadns-ng/Makefile
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=chinadns-ng
|
||||||
|
PKG_VERSION:=2025.08.09
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
ifeq ($(ARCH),aarch64)
|
||||||
|
ifeq ($(BOARD),rockchip)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@aarch64-linux-musl@generic+v8a@fast+lto
|
||||||
|
PKG_HASH:=3fe0217615dd7060b7287d2b6b31d2a0b364137398bfb335a03bead322eac716
|
||||||
|
else
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl_noasm@aarch64-linux-musl@generic+v8a@fast+lto
|
||||||
|
PKG_HASH:=42ddd494200ec6d88b35902927688d316bc23e06e6c08d9e01eb2412196ab845
|
||||||
|
endif
|
||||||
|
else ifeq ($(ARCH),arm)
|
||||||
|
ifeq ($(CONFIG_arm_v6),y)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@arm-linux-musleabi@generic+v6+soft_float@fast+lto
|
||||||
|
PKG_HASH:=0a401d1dc11129481b2baf86f847d55d66bd7e725cba4bf57875fdad27ef0052
|
||||||
|
else ifeq ($(CONFIG_arm_v7),y)
|
||||||
|
ifeq ($(CONFIG_HAS_FPU),y)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@arm-linux-musleabihf@generic+v7a@fast+lto
|
||||||
|
PKG_HASH:=dfa1f6ba80fb0925613822f4c4e00df8da68e7b8b772048d26a0d1a9d07d346b
|
||||||
|
else
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@arm-linux-musleabi@generic+v6+soft_float@fast+lto
|
||||||
|
PKG_HASH:=0a401d1dc11129481b2baf86f847d55d66bd7e725cba4bf57875fdad27ef0052
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@arm-linux-musleabi@generic+v5te+soft_float@fast+lto
|
||||||
|
PKG_HASH:=dc104953fcd95c1c98b7b2b54b0b6731565e0650f81230e6de127a486803f42f
|
||||||
|
endif
|
||||||
|
else ifeq ($(ARCH),mips)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@mips-linux-musl@mips32+soft_float@fast+lto
|
||||||
|
PKG_HASH:=b610821a8f61b0ed3c8c7e82e10d401348a9de17f900988589024a37c4099c8e
|
||||||
|
else ifeq ($(ARCH),mipsel)
|
||||||
|
ifeq ($(CONFIG_HAS_FPU),)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@mipsel-linux-musl@mips32+soft_float@fast+lto
|
||||||
|
PKG_HASH:=760544a88724e3b1b9eac79c9400231e81aa8786f8f00a979229e175811ffe6d
|
||||||
|
else
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@mipsel-linux-musl@mips32@fast+lto
|
||||||
|
PKG_HASH:=ec547c31a884e0967437ceb90a5c270864efe81b0e40939e0ec2810c7bfd6653
|
||||||
|
endif
|
||||||
|
else ifeq ($(ARCH),mips64)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@mips64-linux-musl@mips64+soft_float@fast+lto
|
||||||
|
PKG_HASH:=2d0fce18a7ef1d74fdc12738767e66998a52c2b30d8790da760933853fe8726e
|
||||||
|
else ifeq ($(ARCH),mips64el)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@mips64el-linux-musl@mips64+soft_float@fast+lto
|
||||||
|
PKG_HASH:=a301d8d200d06582c60bbe0e487a28f5b41e6f0997a548cf882a7b078dab089c
|
||||||
|
else ifeq ($(ARCH),i386)
|
||||||
|
ifneq ($(CONFIG_TARGET_x86_geode)$(CONFIG_TARGET_x86_legacy),)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@i386-linux-musl@i686@fast+lto
|
||||||
|
PKG_HASH:=85e057dd0a0e8913b30471737436ab8b71834c494ed9f9e53544261b1ffdc8d6
|
||||||
|
else
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@i386-linux-musl@pentium4@fast+lto
|
||||||
|
PKG_HASH:=2d0f1a05c82f2e21e71a6618c7f1d2e7f46aa6a21535d774d517e87ec00c989b
|
||||||
|
endif
|
||||||
|
else ifeq ($(ARCH),x86_64)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@x86_64-linux-musl@x86_64@fast+lto
|
||||||
|
PKG_HASH:=842ea4e9816efd91d39bc76ead5c4a42e79011757e37c521b4270b675cfcb30c
|
||||||
|
else ifeq ($(ARCH),riscv64)
|
||||||
|
PKG_ARCH:=chinadns-ng+wolfssl@riscv64-linux-musl@baseline_rv64@fast+lto
|
||||||
|
PKG_HASH:=7056f47f4d6b20109e007792694dc83e5eac44c9265d7be20f6dc10375b35a9b
|
||||||
|
else
|
||||||
|
PKG_HASH:=dummy
|
||||||
|
endif
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(ARCH_PACKAGES)
|
||||||
|
PKG_SOURCE_URL:=https://github.com/zfl9/chinadns-ng/releases/download/$(PKG_VERSION)/$(PKG_ARCH)?
|
||||||
|
UNPACK_CMD=$(CP) $(DL_DIR)/$(PKG_SOURCE) $(PKG_BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
PKG_LICENSE:=AGPL-3.0-only
|
||||||
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
PKG_MAINTAINER:=sbwml <admin@cooluc.com>
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/chinadns-ng
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=IP Addresses and Names
|
||||||
|
TITLE:=ChinaDNS next generation, refactoring with epoll and ipset.
|
||||||
|
URL:=https://github.com/zfl9/chinadns-ng
|
||||||
|
DEPENDS:=@(aarch64||arm||i386||mips||mipsel||mips64||mips64el||x86_64||riscv64) +ipset
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/chinadns-ng/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/chinadns-ng $(1)/usr/bin
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,chinadns-ng))
|
||||||
160
daed/Makefile
Normal file
160
daed/Makefile
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2023 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=daed
|
||||||
|
PKG_VERSION:=2025.09.23
|
||||||
|
DAED_VERSION:=daed-c3588a9
|
||||||
|
WING_VERSION:=wing-6df3da2
|
||||||
|
CORE_VERSION:=core-5abd651
|
||||||
|
WING_HASH_SHORT:=$(shell echo $(WING_VERSION) | cut -d- -f2)
|
||||||
|
CORE_HASH_SHORT:=$(shell echo $(CORE_VERSION) | cut -d- -f2)
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_PROTO:=git
|
||||||
|
PKG_SOURCE_VERSION:=c3588a904c932d1fc83ee51096761776003fc25c
|
||||||
|
PKG_SOURCE_URL:=https://github.com/daeuniverse/daed.git
|
||||||
|
PKG_MIRROR_HASH:=skip
|
||||||
|
|
||||||
|
PKG_LICENSE:=AGPL-3.0-only MIT
|
||||||
|
PKG_LICENSE_FILES:=LICENSE wing/LICENSE
|
||||||
|
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
|
||||||
|
PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/wing
|
||||||
|
PKG_BUILD_DEPENDS:=golang/host bpf-headers node/host
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_BUILD_FLAGS:=no-mips16
|
||||||
|
|
||||||
|
GO_PKG:=github.com/daeuniverse/dae-wing
|
||||||
|
GO_PKG_LDFLAGS:= \
|
||||||
|
-s -w -X '$(GO_PKG)/db.AppDescription=$(PKG_NAME) is a integration solution of dae, API and UI.'
|
||||||
|
GO_PKG_LDFLAGS_X= \
|
||||||
|
$(GO_PKG)/db.AppName=$(PKG_NAME) \
|
||||||
|
$(GO_PKG)/db.AppVersion=$(DAED_VERSION)_$(WING_VERSION)_$(CORE_VERSION)
|
||||||
|
GO_PKG_TAGS:=embedallowed
|
||||||
|
GO_PKG_TARGET_VARS:=$(filter-out CGO_ENABLED=%,$(GO_PKG_TARGET_VARS)) \
|
||||||
|
CGO_ENABLED=1 \
|
||||||
|
GOEXPERIMENT=greenteagc
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(INCLUDE_DIR)/bpf.mk
|
||||||
|
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||||
|
|
||||||
|
GO_PKG_DEFAULT_LDFLAGS:=-w -s -extldflags "-static"
|
||||||
|
TAR_CMD=$(HOST_TAR) -C $(BUILD_DIR)/ $(TAR_OPTIONS)
|
||||||
|
|
||||||
|
define Package/daed/Default
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Web Servers/Proxies
|
||||||
|
URL:=https://github.com/daeuniverse/daed
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/daed
|
||||||
|
$(call Package/daed/Default)
|
||||||
|
TITLE:=A Modern Dashboard For dae
|
||||||
|
# You need enable KERNEL_DEBUG_INFO_BTF and KERNEL_BPF_EVENTS
|
||||||
|
DEPENDS:=$(GO_ARCH_DEPENDS) $(BPF_DEPENDS) \
|
||||||
|
+ca-bundle +kmod-sched-core +kmod-sched-bpf +kmod-xdp-sockets-diag \
|
||||||
|
+kmod-veth +v2ray-geoip +v2ray-geosite
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/daed/description
|
||||||
|
daed is a backend of dae, provides a method to bundle arbitrary
|
||||||
|
frontend, dae and geodata into one binary.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/daed/conffiles
|
||||||
|
/etc/daed/wing.db
|
||||||
|
/etc/config/daed
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Prepare
|
||||||
|
( \
|
||||||
|
$(TAR) --strip-components=1 -C $(PKG_BUILD_DIR)/../ -xzf $(DL_DIR)/$(PKG_NAME)-$(PKG_VERSION).tar.gz ; \
|
||||||
|
rm -rf $(PKG_BUILD_DIR) && git clone https://github.com/daeuniverse/dae-wing $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/wing && git -C $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/wing checkout $(WING_HASH_SHORT) ; \
|
||||||
|
rm -rf $(PKG_BUILD_DIR)/dae-core && git clone https://github.com/daeuniverse/dae $(PKG_BUILD_DIR)/dae-core && git -C $(PKG_BUILD_DIR)/dae-core checkout $(CORE_HASH_SHORT) ; \
|
||||||
|
pushd $(PKG_BUILD_DIR)/dae-core ; \
|
||||||
|
git submodule update --init ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae/pull/763.patch | patch -p1 ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae/pull/839.patch | patch -p1 ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae/commit/56fb759.patch | patch -p1 ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae/commit/af2e2c6.patch | patch -p1 ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae/commit/d96dc26.patch | patch -p1 ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae/commit/6ff101c.patch | patch -p1 ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae/commit/5740b94.patch | patch -p1 ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae/commit/cec1642.patch | patch -p1 ; \
|
||||||
|
sed -i 's/Warn("failed to write cached DNS resp")/Debug("failed to write cached DNS resp")/g' control/dns_control.go ; \
|
||||||
|
sed -i 's/Warn("failed to send DNS response")/Debug("failed to send DNS response")/g' control/dns_control.go ; \
|
||||||
|
sed -i 's/Warn("failed to send DNS reject response")/Debug("failed to send DNS reject response")/g' control/dns_control.go ; \
|
||||||
|
go mod tidy ; \
|
||||||
|
popd ; \
|
||||||
|
pushd $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/wing ; \
|
||||||
|
wget -qO - https://github.com/daeuniverse/dae-wing/commit/ca02961.patch | patch -p1 ; \
|
||||||
|
go mod tidy ; \
|
||||||
|
popd ; \
|
||||||
|
pushd $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) ; \
|
||||||
|
npm install -g pnpm ; \
|
||||||
|
pnpm install ; \
|
||||||
|
pnpm build ; \
|
||||||
|
popd ; \
|
||||||
|
mkdir -p $(PKG_BUILD_DIR)/webrender/web ; \
|
||||||
|
cp -rf $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/dist/* $(PKG_BUILD_DIR)/webrender/web ; \
|
||||||
|
find $(PKG_BUILD_DIR)/webrender/web -type f -size +4k ! -name "*.gz" ! -name "*.woff" ! -name "*.woff2" -exec sh -c '\
|
||||||
|
gzip -9 -k "{}"; \
|
||||||
|
if [ "$$$$(stat -c %s {})" -lt "$$$$(stat -c %s {}.gz)" ]; then \
|
||||||
|
rm {}.gz; \
|
||||||
|
else \
|
||||||
|
rm {}; \
|
||||||
|
fi' \
|
||||||
|
";" ; \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
|
DAE_CFLAGS:= \
|
||||||
|
-O2 -Wall -Werror \
|
||||||
|
-DMAX_MATCH_SET_LEN=1024 \
|
||||||
|
-D__UNROLL_ROUTE_LOOP \
|
||||||
|
-I$(BPF_HEADERS_DIR)/tools/lib \
|
||||||
|
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/asm/mach-generic
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_USE_MUSL),)
|
||||||
|
TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
|
||||||
|
endif
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
( \
|
||||||
|
pushd $(PKG_BUILD_DIR) ; \
|
||||||
|
$(MAKE) deps ; \
|
||||||
|
$(GO_GENERAL_BUILD_CONFIG_VARS) \
|
||||||
|
$(GO_PKG_BUILD_CONFIG_VARS) \
|
||||||
|
$(GO_PKG_BUILD_VARS); \
|
||||||
|
go generate ./... ; \
|
||||||
|
cd dae-core ; \
|
||||||
|
BPF_CLANG="$(CLANG)" \
|
||||||
|
BPF_STRIP_FLAG="-strip=$(LLVM_STRIP)" \
|
||||||
|
BPF_CFLAGS="$(DAE_CFLAGS)" \
|
||||||
|
BPF_TARGET="bpfel,bpfeb" \
|
||||||
|
go generate control/control.go ; \
|
||||||
|
popd ; \
|
||||||
|
$(call GoPackage/Build/Compile) ; \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/daed/install
|
||||||
|
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dae-wing $(1)/usr/bin/daed
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
|
$(INSTALL_CONF) $(CURDIR)/files/daed.config $(1)/etc/config/daed
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) $(CURDIR)/files/daed.init $(1)/etc/init.d/daed
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call GoBinPackage,daed))
|
||||||
|
$(eval $(call BuildPackage,daed))
|
||||||
7
daed/files/daed.config
Normal file
7
daed/files/daed.config
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
config daed 'config'
|
||||||
|
option enabled '0'
|
||||||
|
option listen_addr '0.0.0.0:2023'
|
||||||
|
option log_maxbackups '1'
|
||||||
|
option log_maxsize '5'
|
||||||
|
|
||||||
46
daed/files/daed.init
Executable file
46
daed/files/daed.init
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2023 Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
|
START=99
|
||||||
|
|
||||||
|
CONF="daed"
|
||||||
|
PROG="/usr/bin/daed"
|
||||||
|
LOG="/var/log/daed/daed.log"
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load "$CONF"
|
||||||
|
|
||||||
|
local enabled
|
||||||
|
config_get_bool enabled "config" "enabled" "0"
|
||||||
|
[ "$enabled" -eq "1" ] || return 1
|
||||||
|
|
||||||
|
local listen_addr log_maxbackups log_maxsize
|
||||||
|
config_get listen_addr "config" "listen_addr" "0.0.0.0:2023"
|
||||||
|
config_get log_maxbackups "config" "log_maxbackups" "1"
|
||||||
|
config_get log_maxsize "config" "log_maxsize" "5"
|
||||||
|
|
||||||
|
procd_open_instance "$CONF"
|
||||||
|
procd_set_param command "$PROG" run
|
||||||
|
procd_append_param command --config "/etc/daed/"
|
||||||
|
procd_append_param command --listen "$listen_addr"
|
||||||
|
procd_append_param command --logfile "$LOG"
|
||||||
|
procd_append_param command --logfile-maxbackups "$log_maxbackups"
|
||||||
|
procd_append_param command --logfile-maxsize "$log_maxsize"
|
||||||
|
|
||||||
|
procd_set_param limits core="unlimited"
|
||||||
|
procd_set_param limits nofile="1000000 1000000"
|
||||||
|
procd_set_param respawn
|
||||||
|
# procd_set_param stdout 1
|
||||||
|
procd_set_param stderr 1
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
rm -f "$LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "$CONF"
|
||||||
|
}
|
||||||
56
ddns-scripts-aliyun/Makefile
Normal file
56
ddns-scripts-aliyun/Makefile
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=ddns-scripts-aliyun
|
||||||
|
PKG_VERSION:=1.0.3
|
||||||
|
PKG_RELEASE:=6
|
||||||
|
|
||||||
|
PKG_LICENSE:=GPLv2
|
||||||
|
PKG_MAINTAINER:=Sense <sensec@gmail.com>
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=IP Addresses and Names
|
||||||
|
TITLE:=DDNS extension for AliYun.com
|
||||||
|
PKGARCH:=all
|
||||||
|
DEPENDS:=+ddns-scripts +curl +jsonfilter +openssl-util
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
Dynamic DNS Client scripts extension for AliYun.com
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(CP) ./*.sh $(PKG_BUILD_DIR)
|
||||||
|
# remove comments, white spaces and empty lines
|
||||||
|
for FILE in `find $(PKG_BUILD_DIR) -type f`; do \
|
||||||
|
$(SED) 's/^[[:space:]]*//' \
|
||||||
|
-e '/^#[[:space:]]\|^#$$$$/d' \
|
||||||
|
-e 's/[[:space:]]#[[:space:]].*$$$$//' \
|
||||||
|
-e 's/[[:space:]]*$$$$//' \
|
||||||
|
-e '/^\/\/[[:space:]]/d' \
|
||||||
|
-e '/^[[:space:]]*$$$$/d' $$$$FILE; \
|
||||||
|
done
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/lib/ddns
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/update_aliyun_com.sh $(1)/usr/lib/ddns
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/ddns/default
|
||||||
|
$(INSTALL_DATA) ./aliyun.com.json $(1)/usr/share/ddns/default
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/prerm
|
||||||
|
#!/bin/sh
|
||||||
|
[ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop >/dev/null 2>&1
|
||||||
|
exit 0 # suppress errors
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
2
ddns-scripts-aliyun/README.md
Normal file
2
ddns-scripts-aliyun/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# ddns-scripts-aliyun
|
||||||
|
基于https://github.com/sensec/ddns-scripts_aliyun 改进,将wget替换为curl,并且完善了逻辑判断,日志可以显示更新失败时的原因
|
||||||
9
ddns-scripts-aliyun/aliyun.com.json
Normal file
9
ddns-scripts-aliyun/aliyun.com.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "aliyun.com",
|
||||||
|
"ipv4": {
|
||||||
|
"url": "update_aliyun_com.sh"
|
||||||
|
},
|
||||||
|
"ipv6": {
|
||||||
|
"url": "update_aliyun_com.sh"
|
||||||
|
}
|
||||||
|
}
|
||||||
205
ddns-scripts-aliyun/update_aliyun_com.sh
Normal file
205
ddns-scripts-aliyun/update_aliyun_com.sh
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 用于阿里云解析的DNS更新脚本
|
||||||
|
# 阿里云解析API文档 https://help.aliyun.com/document_detail/29739.html
|
||||||
|
#
|
||||||
|
# 本脚本由 dynamic_dns_functions.sh 内的函数 send_update() 调用
|
||||||
|
#
|
||||||
|
# 需要在 /etc/config/ddns 中设置的选项
|
||||||
|
# option username - 阿里云API访问账号 Access Key ID。可通过 aliyun.com 帐号管理的 accesskeys 获取, 或者访问 https://ak-console.aliyun.com
|
||||||
|
# option password - 阿里云API访问密钥 Access Key Secret
|
||||||
|
# option domain - 完整的域名。建议主机与域名之间使用 @符号 分隔,否则将以第一个 .符号 之前的内容作为主机名
|
||||||
|
#
|
||||||
|
|
||||||
|
# 检查传入参数
|
||||||
|
[ -z "$username" ] && write_log 14 "Configuration error! The 'username' that holds the Alibaba Cloud API access account cannot be empty"
|
||||||
|
[ -z "$password" ] && write_log 14 "Configuration error! The 'password' that holds the Alibaba Cloud API access account cannot be empty"
|
||||||
|
|
||||||
|
# 检查外部调用工具
|
||||||
|
[ -n "$CURL_SSL" ] || write_log 13 "Alibaba Cloud API communication require cURL with SSL support. Please install"
|
||||||
|
[ -n "$CURL_PROXY" ] || write_log 13 "cURL: libcurl compiled without Proxy support"
|
||||||
|
command -v sed >/dev/null 2>&1 || write_log 13 "Sed support is required to use Alibaba Cloud API, please install first"
|
||||||
|
command -v openssl >/dev/null 2>&1 || write_log 13 "Openssl-util support is required to use Alibaba Cloud API, please install first"
|
||||||
|
|
||||||
|
# 变量声明
|
||||||
|
local __HOST __DOMAIN __TYPE __CMDBASE __RECID __TTL
|
||||||
|
|
||||||
|
# 从 $domain 分离主机和域名
|
||||||
|
[ "${domain:0:2}" = "@." ] && domain="${domain/./}" # 主域名处理
|
||||||
|
[ "$domain" = "${domain/@/}" ] && domain="${domain/./@}" # 未找到分隔符,兼容常用域名格式
|
||||||
|
__HOST="${domain%%@*}"
|
||||||
|
__DOMAIN="${domain#*@}"
|
||||||
|
[ -z "$__HOST" -o "$__HOST" = "$__DOMAIN" ] && __HOST=@
|
||||||
|
|
||||||
|
# 设置记录类型
|
||||||
|
[ $use_ipv6 = 0 ] && __TYPE=A || __TYPE=AAAA
|
||||||
|
|
||||||
|
# 构造基本通信命令
|
||||||
|
build_command(){
|
||||||
|
__CMDBASE="$CURL -Ss"
|
||||||
|
# 绑定用于通信的主机/IP
|
||||||
|
if [ -n "$bind_network" ];then
|
||||||
|
local __DEVICE
|
||||||
|
network_get_physdev __DEVICE $bind_network || write_log 13 "Can not detect local device using 'network_get_physdev $bind_network' - Error: '$?'"
|
||||||
|
write_log 7 "Force communication via device '$__DEVICE'"
|
||||||
|
__CMDBASE="$__CMDBASE --interface $__DEVICE"
|
||||||
|
fi
|
||||||
|
# 强制设定IP版本
|
||||||
|
if [ $force_ipversion = 1 ];then
|
||||||
|
[ $use_ipv6 = 0 ] && __CMDBASE="$__CMDBASE -4" || __CMDBASE="$__CMDBASE -6"
|
||||||
|
fi
|
||||||
|
# 设置CA证书参数
|
||||||
|
if [ $use_https = 1 ];then
|
||||||
|
if [ "$cacert" = IGNORE ];then
|
||||||
|
__CMDBASE="$__CMDBASE --insecure"
|
||||||
|
elif [ -f "$cacert" ];then
|
||||||
|
__CMDBASE="$__CMDBASE --cacert $cacert"
|
||||||
|
elif [ -d "$cacert" ];then
|
||||||
|
__CMDBASE="$__CMDBASE --capath $cacert"
|
||||||
|
elif [ -n "$cacert" ];then
|
||||||
|
write_log 14 "No valid certificate(s) found at '$cacert' for HTTPS communication"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# 如果没有设置,禁用代理 (这可能是 .wgetrc 或环境设置错误)
|
||||||
|
[ -z "$proxy" ] && __CMDBASE="$__CMDBASE --noproxy '*'"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 百分号编码
|
||||||
|
percentEncode(){
|
||||||
|
if [ -z "${1//[A-Za-z0-9_.~-]/}" ];then
|
||||||
|
echo -n "$1"
|
||||||
|
else
|
||||||
|
local string=$1;local i=0;local ret chr
|
||||||
|
while [ $i -lt ${#string} ];do
|
||||||
|
chr=${string:$i:1}
|
||||||
|
[ -z "${chr#[^A-Za-z0-9_.~-]}" ] && chr=$(printf '%%%02X' "'$chr")
|
||||||
|
ret="$ret$chr"
|
||||||
|
i=$(( $i + 1 ))
|
||||||
|
done
|
||||||
|
echo -n "$ret"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 用于阿里云API的通信函数
|
||||||
|
aliyun_transfer(){
|
||||||
|
__CNT=0;__URLARGS=
|
||||||
|
[ $# = 0 ] && write_log 12 "'aliyun_transfer()' Error - wrong number of parameters"
|
||||||
|
# 添加请求参数
|
||||||
|
for string in $*;do
|
||||||
|
case "${string%%=*}" in
|
||||||
|
Format|Version|AccessKeyId|SignatureMethod|Timestamp|SignatureVersion|SignatureNonce|Signature);; # 过滤公共参数
|
||||||
|
*)__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}");;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
__URLARGS="${__URLARGS:1}"
|
||||||
|
# 附加公共参数
|
||||||
|
string="Format=JSON";__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
string="Version=2015-01-09";__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
string="AccessKeyId=$username";__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
string="SignatureMethod=HMAC-SHA1";__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
string="Timestamp="$(date -u '+%Y-%m-%dT%H:%M:%SZ');__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
string="SignatureVersion=1.0";__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
string="SignatureNonce="$(cat '/proc/sys/kernel/random/uuid');__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
string="Line=default";__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
# 对请求参数进行排序,用于生成签名
|
||||||
|
string=$(echo -n "$__URLARGS" | sed 's/\'"&"'/\n/g' | sort | sed ':label; N; s/\n/\'"&"'/g; b label')
|
||||||
|
# 构造用于计算签名的字符串
|
||||||
|
string="GET&"$(percentEncode "/")"&"$(percentEncode "$string")
|
||||||
|
# 字符串计算签名值
|
||||||
|
local signature=$(echo -n "$string" | openssl dgst -sha1 -hmac "$password&" -binary | openssl base64)
|
||||||
|
# 附加签名参数
|
||||||
|
string="Signature=$signature";__URLARGS="$__URLARGS&"$(percentEncode "${string%%=*}")"="$(percentEncode "${string#*=}")
|
||||||
|
__A="$__CMDBASE 'https://alidns.aliyuncs.com/?$__URLARGS'"
|
||||||
|
write_log 7 "#> $__A"
|
||||||
|
while ! __TMP=`eval $__A 2>&1`;do
|
||||||
|
write_log 3 "[$__TMP]"
|
||||||
|
if [ $VERBOSE -gt 1 ];then
|
||||||
|
write_log 4 "Transfer failed - detailed mode: $VERBOSE - Do not try again after an error"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
__CNT=$(( $__CNT + 1 ))
|
||||||
|
[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && write_log 14 "Transfer failed after $retry_count retries"
|
||||||
|
write_log 4 "Transfer failed - $__CNT Try again in $RETRY_SECONDS seconds"
|
||||||
|
sleep $RETRY_SECONDS &
|
||||||
|
PID_SLEEP=$!
|
||||||
|
wait $PID_SLEEP
|
||||||
|
PID_SLEEP=0
|
||||||
|
done
|
||||||
|
__ERR=`jsonfilter -s "$__TMP" -e "@.Code"`
|
||||||
|
[ -z "$__ERR" ] && return 0
|
||||||
|
case $__ERR in
|
||||||
|
LastOperationNotFinished)printf "%s\n" " $(date +%H%M%S) : 最后一次操作未完成,2秒后重试" >> $LOGFILE;return 1;;
|
||||||
|
InvalidTimeStamp.Expired)printf "%s\n" " $(date +%H%M%S) : 时间戳错误,2秒后重试" >> $LOGFILE;return 1;;
|
||||||
|
InvalidAccessKeyId.NotFound)__ERR="无效AccessKey ID";;
|
||||||
|
SignatureDoesNotMatch)__ERR="无效AccessKey Secret";;
|
||||||
|
InvalidDomainName.NoExist)__ERR="无效域名";;
|
||||||
|
esac
|
||||||
|
local A="$(date +%H%M%S) ERROR : [$__ERR] - 终止进程"
|
||||||
|
logger -p user.err -t ddns-scripts[$$] $SECTION_ID: ${A:15}
|
||||||
|
printf "%s\n" " $A" >> $LOGFILE
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# 添加解析记录
|
||||||
|
add_domain(){
|
||||||
|
while ! aliyun_transfer "Action=AddDomainRecord" "DomainName=$__DOMAIN" "RR=$__HOST" "Type=$__TYPE" "Value=$__IP";do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
printf "%s\n" " $(date +%H%M%S) : 添加解析记录成功: [$([ "$__HOST" = @ ] || echo $__HOST.)$__DOMAIN],[IP:$__IP]" >> $LOGFILE
|
||||||
|
}
|
||||||
|
|
||||||
|
# 启用解析记录
|
||||||
|
enable_domain(){
|
||||||
|
while ! aliyun_transfer "Action=SetDomainRecordStatus" "RecordId=$__RECID" "Status=Enable";do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
printf "%s\n" " $(date +%H%M%S) : 启用解析记录成功" >> $LOGFILE
|
||||||
|
}
|
||||||
|
|
||||||
|
# 修改解析记录
|
||||||
|
update_domain(){
|
||||||
|
while ! aliyun_transfer "Action=UpdateDomainRecord" "RecordId=$__RECID" "RR=$__HOST" "Type=$__TYPE" "Value=$__IP" "TTL=$__TTL";do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
printf "%s\n" " $(date +%H%M%S) : 修改解析记录成功: [$([ "$__HOST" = @ ] || echo $__HOST.)$__DOMAIN],[IP:$__IP],[TTL:$__TTL]" >> $LOGFILE
|
||||||
|
}
|
||||||
|
|
||||||
|
# 获取子域名解析记录列表
|
||||||
|
describe_domain(){
|
||||||
|
ret=0
|
||||||
|
while ! aliyun_transfer "Action=DescribeSubDomainRecords" "SubDomain=$__HOST.$__DOMAIN" "Type=$__TYPE";do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
__TMP=`jsonfilter -s "$__TMP" -e "@.DomainRecords.Record[@]"`
|
||||||
|
if [ -z "$__TMP" ];then
|
||||||
|
printf "%s\n" " $(date +%H%M%S) : 解析记录不存在: [$([ "$__HOST" = @ ] || echo $__HOST.)$__DOMAIN]" >> $LOGFILE
|
||||||
|
ret=1
|
||||||
|
else
|
||||||
|
__STATUS=`jsonfilter -s "$__TMP" -e "@.Status"`
|
||||||
|
__RECIP=`jsonfilter -s "$__TMP" -e "@.Value"`
|
||||||
|
if [ "$__STATUS" != ENABLE ];then
|
||||||
|
printf "%s\n" " $(date +%H%M%S) : 解析记录被禁用" >> $LOGFILE
|
||||||
|
ret=$(( $ret | 2 ))
|
||||||
|
fi
|
||||||
|
if [ "$__RECIP" != "$__IP" ];then
|
||||||
|
__TTL=`jsonfilter -s "$__TMP" -e "@.TTL"`
|
||||||
|
printf "%s\n" " $(date +%H%M%S) : 解析记录需要更新: [解析记录IP:$__RECIP] [本地IP:$__IP]" >> $LOGFILE
|
||||||
|
ret=$(( $ret | 4 ))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_command
|
||||||
|
describe_domain
|
||||||
|
if [ $ret = 0 ];then
|
||||||
|
printf "%s\n" " $(date +%H%M%S) : 解析记录不需要更新: [解析记录IP:$__RECIP] [本地IP:$__IP]" >> $LOGFILE
|
||||||
|
elif [ $ret = 1 ];then
|
||||||
|
sleep 3
|
||||||
|
add_domain
|
||||||
|
else
|
||||||
|
__RECID=`jsonfilter -s "$__TMP" -e "@.RecordId"`
|
||||||
|
[ $(( $ret & 2 )) -ne 0 ] && sleep 3 && enable_domain
|
||||||
|
[ $(( $ret & 4 )) -ne 0 ] && sleep 3 && update_domain
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
80
ddnsto/Makefile
Normal file
80
ddnsto/Makefile
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2015-2016 OpenWrt.org
|
||||||
|
# Copyright (C) 2020 jjm2473@gmail.com
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v3.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_ARCH_DDNSTO:=$(ARCH)
|
||||||
|
|
||||||
|
PKG_NAME:=ddnsto
|
||||||
|
# use PKG_SOURCE_DATE instead of PKG_VERSION for compitable
|
||||||
|
PKG_SOURCE_DATE:=3.0.4
|
||||||
|
PKG_RELEASE:=8
|
||||||
|
ARCH_HEXCODE:=
|
||||||
|
ifeq ($(ARCH),x86_64)
|
||||||
|
ARCH_HEXCODE=8664
|
||||||
|
else ifeq ($(ARCH),aarch64)
|
||||||
|
ARCH_HEXCODE=aa64
|
||||||
|
else ifeq ($(ARCH),arm)
|
||||||
|
ARCH_HEXCODE=aa32
|
||||||
|
else ifeq ($(ARCH),mipsel)
|
||||||
|
ARCH_HEXCODE=1b0c
|
||||||
|
endif
|
||||||
|
PKG_SOURCE_VERSION:=$(ARCH_HEXCODE)
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_SOURCE_DATE).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://dl.istoreos.com/binary/ddnsto/
|
||||||
|
PKG_HASH:=486aa15a5e026b5a3aca72f1850746e127a7e86ef11db8a7c498dad29545eaf6
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-binary-$(PKG_SOURCE_DATE)
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Web Servers/Proxies
|
||||||
|
TITLE:=DDNS.to - the reverse proxy
|
||||||
|
DEPENDS:=
|
||||||
|
PKGARCH:=all
|
||||||
|
URL:=https://www.ddnsto.com/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
DDNS.to is a reverse proxy
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/conffiles
|
||||||
|
/etc/config/ddnsto
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/postinst
|
||||||
|
#!/bin/sh
|
||||||
|
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||||
|
[ -f /etc/uci-defaults/ddnsto ] && /etc/uci-defaults/ddnsto && rm -f /etc/uci-defaults/ddnsto
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d $(1)/etc/uci-defaults
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ddnsto.$(PKG_ARCH_DDNSTO) $(1)/usr/sbin/ddnstod
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ddwebdav.$(PKG_ARCH_DDNSTO) $(1)/usr/sbin/ddwebdav
|
||||||
|
$(INSTALL_CONF) ./files/ddnsto.config $(1)/etc/config/ddnsto
|
||||||
|
$(INSTALL_BIN) ./files/ddnsto.init $(1)/etc/init.d/ddnsto
|
||||||
|
$(INSTALL_BIN) ./files/ddnsto.uci-default $(1)/etc/uci-defaults/ddnsto
|
||||||
|
$(LN) /usr/sbin/ddnstod $(1)/usr/sbin/ddnsto
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
49
ddnsto/files/ddnsto-monitor.sh
Normal file
49
ddnsto/files/ddnsto-monitor.sh
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
DEVICE_IDX=0
|
||||||
|
LOG_LEVEL=2
|
||||||
|
while getopts u:x:l: flag
|
||||||
|
do
|
||||||
|
case "${flag}" in
|
||||||
|
u) TOKEN=${OPTARG};;
|
||||||
|
x) DEVICE_IDX=${OPTARG};;
|
||||||
|
l) LOG_LEVEL=${OPTARG};;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "${TOKEN}" ]; then
|
||||||
|
logger "ddnsto: the token is empty, get token from https://www.ddnsto.com/ "
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ddnsto version device_id is is:"
|
||||||
|
/usr/sbin/ddnsto -u ${TOKEN} -w
|
||||||
|
|
||||||
|
_term() {
|
||||||
|
logger "ddnsto: SIGTERM"
|
||||||
|
killall ddnsto 2>/dev/null
|
||||||
|
killall ddwebdav 2>/dev/null
|
||||||
|
|
||||||
|
rm -f /tmp/.ddnsto.pid
|
||||||
|
rm -f /tmp/.ddnsto.status
|
||||||
|
rm -f /tmp/.ddnsto.up
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
trap "_term;" SIGTERM
|
||||||
|
|
||||||
|
while true ; do
|
||||||
|
if ! pidof "ddnsto" > /dev/null ; then
|
||||||
|
logger "ddnsto try running"
|
||||||
|
/usr/sbin/ddnsto -u ${TOKEN} -x ${DEVICE_IDX} &
|
||||||
|
PID=$!
|
||||||
|
wait $PID
|
||||||
|
RET=$?
|
||||||
|
logger "ddnsto EXIT CODE: ${RET}"
|
||||||
|
if [ "${RET}" == "100" ]; then
|
||||||
|
logger "ddnsto token error, please set a correct token from https://www.ddnsto.com/ "
|
||||||
|
exit 100
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sleep 20
|
||||||
|
done
|
||||||
5
ddnsto/files/ddnsto.config
Normal file
5
ddnsto/files/ddnsto.config
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
config ddnsto
|
||||||
|
option enabled '0'
|
||||||
|
option feat_port '3033'
|
||||||
|
option feat_enabled '0'
|
||||||
|
option index '0'
|
||||||
45
ddnsto/files/ddnsto.init
Executable file
45
ddnsto/files/ddnsto.init
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=99
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
get_config() {
|
||||||
|
config_get_bool enabled $1 enabled 1
|
||||||
|
config_get_bool logger $1 logger 0
|
||||||
|
config_get token $1 token
|
||||||
|
config_get index $1 index 0
|
||||||
|
config_get_bool feat_enabled $1 feat_enabled 1
|
||||||
|
}
|
||||||
|
|
||||||
|
ddnsto_prepare() {
|
||||||
|
killall ddnstod 2>/dev/null
|
||||||
|
killall ddwebdav 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
ddnsto_prepare
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
ddnsto_prepare
|
||||||
|
config_load ddnsto
|
||||||
|
config_foreach get_config ddnsto
|
||||||
|
if [ $enabled != 1 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$token" ]; then
|
||||||
|
logger -t ddnsto -p warn "token not set"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command /usr/sbin/ddnstod -u "$token" -x $index -F
|
||||||
|
[ "$logger" == 1 ] && procd_set_param stderr 1
|
||||||
|
procd_set_param respawn
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "ddnsto"
|
||||||
|
}
|
||||||
12
ddnsto/files/ddnsto.uci-default
Executable file
12
ddnsto/files/ddnsto.uci-default
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
delete ucitrack.@ddnsto[-1]
|
||||||
|
add ucitrack ddnsto
|
||||||
|
set ucitrack.@ddnsto[-1].init=ddnsto
|
||||||
|
commit ucitrack
|
||||||
|
EOF
|
||||||
|
|
||||||
|
/etc/init.d/ddnsto enable
|
||||||
|
|
||||||
|
exit 0
|
||||||
55
default-settings/Makefile
Normal file
55
default-settings/Makefile
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2016-2017 GitHub
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v3.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=default-settings
|
||||||
|
PKG_VERSION:=1.2
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
PKG_LICENSE:=GPLv3
|
||||||
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
|
||||||
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/default-settings
|
||||||
|
SECTION:=luci
|
||||||
|
CATEGORY:=LuCI
|
||||||
|
TITLE:=LuCI support for Default Settings
|
||||||
|
PKGARCH:=all
|
||||||
|
DEPENDS:= \
|
||||||
|
+luci-base \
|
||||||
|
+luci-lib-ip \
|
||||||
|
+luci-lib-ipkg \
|
||||||
|
+luci-lib-ipkg \
|
||||||
|
+luci-lib-jsonc \
|
||||||
|
+luci-lib-nixio \
|
||||||
|
+luci-proto-ipv6 \
|
||||||
|
+bash \
|
||||||
|
+kmod-nft-fullcone \
|
||||||
|
+zoneinfo-asia \
|
||||||
|
+@LUCI_LANG_zh_Hans
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/default-settings/description
|
||||||
|
Default Settings & Language Support Packages.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/default-settings/install
|
||||||
|
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||||
|
$(INSTALL_BIN) ./default/zzz-default-settings $(1)/etc/uci-defaults/zzz-default-settings
|
||||||
|
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
||||||
|
po2lmo ./i18n/default.zh_Hans.po $(1)/usr/lib/lua/luci/i18n/default.zh-cn.lmo
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,default-settings))
|
||||||
516
default-settings/default/zzz-default-settings
Normal file
516
default-settings/default/zzz-default-settings
Normal file
@@ -0,0 +1,516 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /etc/os-release
|
||||||
|
. /lib/functions/uci-defaults.sh
|
||||||
|
|
||||||
|
[ $(uname -m) = "x86_64" ] && alias board_name="echo x86_64"
|
||||||
|
|
||||||
|
# theme
|
||||||
|
if [ -d "/www/luci-static/argon" ] && [ -z "$(uci -q get luci.main.pollinterval)" ]; then
|
||||||
|
uci set luci.main.mediaurlbase='/luci-static/argon'
|
||||||
|
uci set luci.main.pollinterval='3'
|
||||||
|
uci commit luci
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ttyd
|
||||||
|
uci set ttyd.@ttyd[0].command='/bin/login -f root'
|
||||||
|
uci commit ttyd
|
||||||
|
/etc/init.d/ttyd restart
|
||||||
|
|
||||||
|
# Set lucky
|
||||||
|
uci set lucky.@lucky[0].enabled='0'
|
||||||
|
uci commit lucky
|
||||||
|
/etc/init.d/lucky restart
|
||||||
|
|
||||||
|
# Set up hostname mapping
|
||||||
|
uci add dhcp domain
|
||||||
|
uci set "dhcp.@domain[-1].name=time.android.com"
|
||||||
|
uci set "dhcp.@domain[-1].ip=203.107.6.88"
|
||||||
|
uci commit dhcp
|
||||||
|
|
||||||
|
# Set SSH
|
||||||
|
uci delete ttyd.@ttyd[0].interface
|
||||||
|
uci set dropbear.@dropbear[0].Interface=''
|
||||||
|
uci commit
|
||||||
|
|
||||||
|
# timezone
|
||||||
|
uci set system.@system[0].timezone=CST-8
|
||||||
|
uci set system.@system[0].zonename=Asia/Shanghai
|
||||||
|
uci commit system
|
||||||
|
|
||||||
|
# log level
|
||||||
|
uci set system.@system[0].conloglevel='1'
|
||||||
|
uci set system.@system[0].cronloglevel='9'
|
||||||
|
uci commit system
|
||||||
|
|
||||||
|
# zram
|
||||||
|
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||||
|
zram_size=$(echo | awk "{print int($mem_total*0.25/1024)}")
|
||||||
|
uci set system.@system[0].zram_size_mb="$zram_size"
|
||||||
|
uci set system.@system[0].zram_comp_algo='lz4'
|
||||||
|
uci commit system
|
||||||
|
|
||||||
|
# opkg mirror
|
||||||
|
if [ $(grep -c SNAPSHOT /etc/opkg/distfeeds.conf) -eq '0' ]; then
|
||||||
|
sed -i 's,downloads.openwrt.org,mirrors.aliyun.com/openwrt,g' /etc/opkg/distfeeds.conf
|
||||||
|
else
|
||||||
|
sed -i 's,downloads.openwrt.org,mirrors.pku.edu.cn/openwrt,g' /etc/opkg/distfeeds.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set password
|
||||||
|
sed -i 's/root::0:0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.:0:0:99999:7:::/g' /etc/shadow
|
||||||
|
sed -i 's/root:::0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.:0:0:99999:7:::/g' /etc/shadow
|
||||||
|
|
||||||
|
devices_setup()
|
||||||
|
{
|
||||||
|
case "$(board_name)" in
|
||||||
|
armsom,sige3|\
|
||||||
|
armsom,sige7|\
|
||||||
|
sinovoip,bpi-r2-pro|\
|
||||||
|
friendlyarm,nanopc-t4|\
|
||||||
|
friendlyarm,nanopc-t6|\
|
||||||
|
friendlyarm,nanopi-r2c|\
|
||||||
|
friendlyarm,nanopi-r2c-plus|\
|
||||||
|
friendlyarm,nanopi-r2s|\
|
||||||
|
friendlyarm,nanopi-r3s|\
|
||||||
|
friendlyarm,nanopi-r4s|\
|
||||||
|
friendlyarm,nanopi-r4se|\
|
||||||
|
friendlyarm,nanopi-r5c|\
|
||||||
|
friendlyarm,nanopi-r5s|\
|
||||||
|
friendlyarm,nanopi-r6c|\
|
||||||
|
friendlyarm,nanopi-r6s|\
|
||||||
|
huake,guangmiao-g4c|\
|
||||||
|
fastrhino,r6xs|\
|
||||||
|
hinlink,opc-h6xk|\
|
||||||
|
radxa,rock-5a|\
|
||||||
|
radxa,rock-5b|\
|
||||||
|
xunlong,orangepi-5|\
|
||||||
|
xunlong,orangepi-5-plus)
|
||||||
|
uci set irqbalance.irqbalance.enabled='0'
|
||||||
|
uci commit irqbalance
|
||||||
|
service irqbalance stop
|
||||||
|
[ ! -d "/usr/share/openwrt_core" ] && {
|
||||||
|
sed -i '/openwrt_core/d' /etc/opkg/distfeeds.conf
|
||||||
|
openwrt_core="openwrt_core/aarch64_generic"
|
||||||
|
sed -i "\$a\src/gz openwrt_core https://raw.githubusercontent.com/QuickWrt/${openwrt_core}/$(grep Version /usr/lib/opkg/info/kernel.control | awk '{print $2}')" /etc/opkg/distfeeds.conf
|
||||||
|
}
|
||||||
|
uci set ota.config.api_url="https://api.kejizero.xyz/openwrt/rockchip.json"
|
||||||
|
uci commit ota
|
||||||
|
;;
|
||||||
|
x86_64)
|
||||||
|
[ $(uname -r | awk -F. '{print $1}') = 6 ] && {
|
||||||
|
[ -f /sys/kernel/btf/vmlinux ] && [ ! -d "/usr/share/openwrt_core" ] && {
|
||||||
|
openwrt_core="openwrt_core/x86_64"
|
||||||
|
sed -i '/openwrt_core/d' /etc/opkg/distfeeds.conf
|
||||||
|
sed -i "\$a\src/gz openwrt_core https://raw.githubusercontent.com/QuickWrt/${openwrt_core}/$(grep Version /usr/lib/opkg/info/kernel.control | awk '{print $2}')" /etc/opkg/distfeeds.conf
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uci set ota.config.api_url="https://api.kejizero.xyz/openwrt/x86_64.json"
|
||||||
|
uci commit ota
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# opkg mirror
|
||||||
|
sed -i 's,downloads.openwrt.org,mirrors.aliyun.com/openwrt,g' /etc/opkg/distfeeds.conf
|
||||||
|
|
||||||
|
# extra packages
|
||||||
|
echo "src/gz openwrt_extras https://opkg.kejizero.xyz/openwrt-24.10/$(. /etc/openwrt_release ; echo $DISTRIB_ARCH)" >> /etc/opkg/distfeeds.conf
|
||||||
|
|
||||||
|
# nginx
|
||||||
|
uci set nginx.global.uci_enable='true'
|
||||||
|
uci del nginx._lan
|
||||||
|
uci del nginx._redirect2ssl
|
||||||
|
uci add nginx server
|
||||||
|
uci rename nginx.@server[0]='_lan'
|
||||||
|
uci set nginx._lan.server_name='_lan'
|
||||||
|
uci add_list nginx._lan.listen='80 default_server'
|
||||||
|
uci add_list nginx._lan.listen='[::]:80 default_server'
|
||||||
|
#uci add_list nginx._lan.include='restrict_locally'
|
||||||
|
uci add_list nginx._lan.include='conf.d/*.locations'
|
||||||
|
uci set nginx._lan.access_log='off; # logd openwrt'
|
||||||
|
uci commit nginx
|
||||||
|
service nginx restart
|
||||||
|
|
||||||
|
# docker mirror
|
||||||
|
if [ -f /etc/config/dockerd ] && [ $(grep -c daocloud.io /etc/config/dockerd) -eq '0' ]; then
|
||||||
|
uci add_list dockerd.globals.registry_mirrors="https://docker.m.daocloud.io"
|
||||||
|
uci commit dockerd
|
||||||
|
fi
|
||||||
|
|
||||||
|
# firewall
|
||||||
|
[ $(grep -c shortcut_fe /etc/config/firewall) -eq '0' ] && uci set firewall.@defaults[0].flow_offloading='1'
|
||||||
|
if [ $(ifconfig -a | grep -o '^eth[^ ]*' | wc -l) -le 1 ] || [ "$OPENWRT_BOARD" = "armsr/armv8" ]; then
|
||||||
|
uci set firewall.@zone[1].input='ACCEPT'
|
||||||
|
fi
|
||||||
|
uci set firewall.@defaults[0].input='ACCEPT'
|
||||||
|
uci commit firewall
|
||||||
|
|
||||||
|
# diagnostics
|
||||||
|
if [ $(uci -q get luci.diag.ping) = "openwrt.org" ]; then
|
||||||
|
uci set luci.diag.dns='www.qq.com'
|
||||||
|
uci set luci.diag.ping='www.qq.com'
|
||||||
|
uci set luci.diag.route='www.qq.com'
|
||||||
|
uci commit luci
|
||||||
|
fi
|
||||||
|
|
||||||
|
# packet steering
|
||||||
|
uci -q get network.globals.packet_steering > /dev/null || {
|
||||||
|
uci set network.globals='globals'
|
||||||
|
uci set network.globals.packet_steering=2
|
||||||
|
uci set network.globals.steering_flows='128'
|
||||||
|
uci commit network
|
||||||
|
}
|
||||||
|
|
||||||
|
# disable coremark
|
||||||
|
sed -i '/coremark/d' /etc/crontabs/root
|
||||||
|
crontab /etc/crontabs/root
|
||||||
|
|
||||||
|
# Smartdns相关设置
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[0].enabled='1'
|
||||||
|
uci set smartdns.@server[0].type='udp'
|
||||||
|
uci set smartdns.@server[0].name='清华大学TUNA协会'
|
||||||
|
uci set smartdns.@server[0].ip='101.6.6.6'
|
||||||
|
uci set smartdns.@server[0].server_group='smartdns-China'
|
||||||
|
uci set smartdns.@server[0].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[1].enabled='1'
|
||||||
|
uci set smartdns.@server[1].type='udp'
|
||||||
|
uci set smartdns.@server[1].name='114'
|
||||||
|
uci set smartdns.@server[1].ip='114.114.114.114'
|
||||||
|
uci set smartdns.@server[1].server_group='smartdns-China'
|
||||||
|
uci set smartdns.@server[1].blacklist_ip='0'
|
||||||
|
uci set smartdns.@server[1].port='53'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[2].enabled='1'
|
||||||
|
uci set smartdns.@server[2].type='udp'
|
||||||
|
uci set smartdns.@server[2].name='ail dns ipv4'
|
||||||
|
uci set smartdns.@server[2].ip='223.5.5.5'
|
||||||
|
uci set smartdns.@server[2].port='53'
|
||||||
|
uci set smartdns.@server[2].server_group='smartdns-China'
|
||||||
|
uci set smartdns.@server[2].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[3].enabled='1'
|
||||||
|
uci set smartdns.@server[3].name='Ali DNS'
|
||||||
|
uci set smartdns.@server[3].ip='https://dns.alidns.com/dns-query'
|
||||||
|
uci set smartdns.@server[3].type='https'
|
||||||
|
uci set smartdns.@server[3].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[3].server_group='smartdns-China'
|
||||||
|
uci set smartdns.@server[3].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[4].enabled='1'
|
||||||
|
uci set smartdns.@server[4].name='360 Secure DNS'
|
||||||
|
uci set smartdns.@server[4].type='https'
|
||||||
|
uci set smartdns.@server[4].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[4].server_group='smartdns-China'
|
||||||
|
uci set smartdns.@server[4].blacklist_ip='0'
|
||||||
|
uci set smartdns.@server[4].ip='https://doh.360.cn/dns-query'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[5].enabled='1'
|
||||||
|
uci set smartdns.@server[5].name='DNSPod Public DNS+'
|
||||||
|
uci set smartdns.@server[5].ip='https://doh.pub/dns-query'
|
||||||
|
uci set smartdns.@server[5].type='https'
|
||||||
|
uci set smartdns.@server[5].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[5].server_group='smartdns-China'
|
||||||
|
uci set smartdns.@server[5].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[6].enabled='1'
|
||||||
|
uci set smartdns.@server[6].type='udp'
|
||||||
|
uci set smartdns.@server[6].name='baidu dns'
|
||||||
|
uci set smartdns.@server[6].ip='180.76.76.76'
|
||||||
|
uci set smartdns.@server[6].port='53'
|
||||||
|
uci set smartdns.@server[6].server_group='smartdns-China'
|
||||||
|
uci set smartdns.@server[6].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[7].enabled='1'
|
||||||
|
uci set smartdns.@server[7].type='udp'
|
||||||
|
uci set smartdns.@server[7].name='360dns'
|
||||||
|
uci set smartdns.@server[7].ip='101.226.4.6'
|
||||||
|
uci set smartdns.@server[7].port='53'
|
||||||
|
uci set smartdns.@server[7].server_group='smartdns-China'
|
||||||
|
uci set smartdns.@server[7].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[8].enabled='1'
|
||||||
|
uci set smartdns.@server[8].type='udp'
|
||||||
|
uci set smartdns.@server[8].name='dnspod'
|
||||||
|
uci set smartdns.@server[8].ip='119.29.29.29'
|
||||||
|
uci set smartdns.@server[8].port='53'
|
||||||
|
uci set smartdns.@server[8].blacklist_ip='0'
|
||||||
|
uci set smartdns.@server[8].server_group='smartdns-China'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[9].enabled='1'
|
||||||
|
uci set smartdns.@server[9].name='Cloudflare-tls'
|
||||||
|
uci set smartdns.@server[9].ip='1.1.1.1'
|
||||||
|
uci set smartdns.@server[9].type='tls'
|
||||||
|
uci set smartdns.@server[9].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[9].exclude_default_group='0'
|
||||||
|
uci set smartdns.@server[9].blacklist_ip='0'
|
||||||
|
uci set smartdns.@server[9].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[9].port='853'
|
||||||
|
uci set smartdns.@server[9].spki_pin='GP8Knf7qBae+aIfythytMbYnL+yowaWVeD6MoLHkVRg='
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[10].enabled='1'
|
||||||
|
uci set smartdns.@server[10].name='Google_DNS-tls'
|
||||||
|
uci set smartdns.@server[10].type='tls'
|
||||||
|
uci set smartdns.@server[10].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[10].exclude_default_group='0'
|
||||||
|
uci set smartdns.@server[10].blacklist_ip='0'
|
||||||
|
uci set smartdns.@server[10].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[10].port='853'
|
||||||
|
uci set smartdns.@server[10].ip='8.8.4.4'
|
||||||
|
uci set smartdns.@server[10].spki_pin='r/fTokourI3+um9Rws4XrHG6fWEmHpZ8iWnOUjzwwjQ='
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[11].enabled='1'
|
||||||
|
uci set smartdns.@server[11].name='Quad9-tls'
|
||||||
|
uci set smartdns.@server[11].ip='9.9.9.9'
|
||||||
|
uci set smartdns.@server[11].type='tls'
|
||||||
|
uci set smartdns.@server[11].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[11].exclude_default_group='0'
|
||||||
|
uci set smartdns.@server[11].blacklist_ip='0'
|
||||||
|
uci set smartdns.@server[11].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[11].port='853'
|
||||||
|
uci set smartdns.@server[11].spki_pin='/SlsviBkb05Y/8XiKF9+CZsgCtrqPQk5bh47o0R3/Cg='
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[12].enabled='1'
|
||||||
|
uci set smartdns.@server[12].name='quad9-ipv6'
|
||||||
|
uci set smartdns.@server[12].ip='2620:fe::fe'
|
||||||
|
uci set smartdns.@server[12].port='9953'
|
||||||
|
uci set smartdns.@server[12].type='udp'
|
||||||
|
uci set smartdns.@server[12].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[12].exclude_default_group='0'
|
||||||
|
uci set smartdns.@server[12].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[13].enabled='1'
|
||||||
|
uci set smartdns.@server[13].name='谷歌DNS'
|
||||||
|
uci set smartdns.@server[13].ip='https://dns.google/dns-query'
|
||||||
|
uci set smartdns.@server[13].type='https'
|
||||||
|
uci set smartdns.@server[13].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[13].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[13].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[14].enabled='1'
|
||||||
|
uci set smartdns.@server[14].name='Cloudflare DNS '
|
||||||
|
uci set smartdns.@server[14].ip='https://dns.cloudflare.com/dns-query'
|
||||||
|
uci set smartdns.@server[14].type='https'
|
||||||
|
uci set smartdns.@server[14].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[14].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[14].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[15].enabled='1'
|
||||||
|
uci set smartdns.@server[15].name='CIRA Canadian Shield DNS'
|
||||||
|
uci set smartdns.@server[15].ip='https://private.canadianshield.cira.ca/dns-query'
|
||||||
|
uci set smartdns.@server[15].type='https'
|
||||||
|
uci set smartdns.@server[15].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[15].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[15].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[16].enabled='1'
|
||||||
|
uci set smartdns.@server[16].name='Restena DNS'
|
||||||
|
uci set smartdns.@server[16].ip='https://kaitain.restena.lu/dns-query'
|
||||||
|
uci set smartdns.@server[16].type='https'
|
||||||
|
uci set smartdns.@server[16].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[16].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[16].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[17].enabled='1'
|
||||||
|
uci set smartdns.@server[17].name='Quad9 DNS'
|
||||||
|
uci set smartdns.@server[17].ip='https://dns.quad9.net/dns-query'
|
||||||
|
uci set smartdns.@server[17].type='https'
|
||||||
|
uci set smartdns.@server[17].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[17].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[17].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[18].enabled='1'
|
||||||
|
uci set smartdns.@server[18].name='CZ.NIC ODVR'
|
||||||
|
uci set smartdns.@server[18].ip='https://odvr.nic.cz/doh'
|
||||||
|
uci set smartdns.@server[18].type='https'
|
||||||
|
uci set smartdns.@server[18].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[18].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[18].blacklist_ip='0'
|
||||||
|
uci add smartdns server
|
||||||
|
uci set smartdns.@server[19].enabled='1'
|
||||||
|
uci set smartdns.@server[19].name='AhaDNS-Spain'
|
||||||
|
uci set smartdns.@server[19].ip='https://doh.es.ahadns.net/dns-query '
|
||||||
|
uci set smartdns.@server[19].type='https'
|
||||||
|
uci set smartdns.@server[19].no_check_certificate='0'
|
||||||
|
uci set smartdns.@server[19].server_group='smartdns-Overseas'
|
||||||
|
uci set smartdns.@server[19].blacklist_ip='0'
|
||||||
|
uci commit smartdns
|
||||||
|
/etc/init.d/smartdns restart
|
||||||
|
|
||||||
|
### nikki
|
||||||
|
# 设置基础状态
|
||||||
|
uci set nikki.status='status'
|
||||||
|
|
||||||
|
# 主配置
|
||||||
|
uci set nikki.config=config
|
||||||
|
uci set nikki.config.init='1'
|
||||||
|
uci set nikki.config.enabled='0' # 关闭
|
||||||
|
uci set nikki.config.profile='subscription:subscription'
|
||||||
|
uci set nikki.config.start_delay='0'
|
||||||
|
uci set nikki.config.scheduled_restart='0'
|
||||||
|
uci set nikki.config.cron_expression='0 3 * * *'
|
||||||
|
uci set nikki.config.test_profile='1'
|
||||||
|
uci set nikki.config.fast_reload='1'
|
||||||
|
|
||||||
|
# 代理设置
|
||||||
|
uci set nikki.proxy=proxy
|
||||||
|
uci set nikki.proxy.enabled='1'
|
||||||
|
uci set nikki.proxy.tcp_mode='redirect'
|
||||||
|
uci set nikki.proxy.udp_mode='tun'
|
||||||
|
uci set nikki.proxy.ipv4_dns_hijack='1'
|
||||||
|
uci set nikki.proxy.ipv6_dns_hijack='1'
|
||||||
|
uci set nikki.proxy.ipv4_proxy='1'
|
||||||
|
uci set nikki.proxy.ipv6_proxy='1'
|
||||||
|
uci set nikki.proxy.fake_ip_ping_hijack='1'
|
||||||
|
uci set nikki.proxy.router_proxy='1'
|
||||||
|
uci set nikki.proxy.lan_proxy='1'
|
||||||
|
uci add_list nikki.proxy.lan_inbound_interface='lan'
|
||||||
|
uci add_list nikki.proxy.bypass_dscp='4'
|
||||||
|
uci set nikki.proxy.bypass_china_mainland_ip='0'
|
||||||
|
uci set nikki.proxy.proxy_tcp_dport='0-65535'
|
||||||
|
uci set nikki.proxy.proxy_udp_dport='0-65535'
|
||||||
|
|
||||||
|
# 订阅配置(需替换真实URL)
|
||||||
|
uci set nikki.subscription=subscription
|
||||||
|
uci set nikki.subscription.name='订阅配置'
|
||||||
|
uci set nikki.subscription.url='http://your_real_subscription_url.yaml' # 请修改
|
||||||
|
uci set nikki.subscription.user_agent='clash.meta'
|
||||||
|
uci set nikki.subscription.prefer='remote'
|
||||||
|
|
||||||
|
# 混合配置
|
||||||
|
uci set nikki.mixin=mixin
|
||||||
|
uci set nikki.mixin.log_level='warning'
|
||||||
|
uci set nikki.mixin.mode='rule'
|
||||||
|
uci set nikki.mixin.match_process='off'
|
||||||
|
uci set nikki.mixin.ipv6='1'
|
||||||
|
uci set nikki.mixin.ui_path='ui'
|
||||||
|
uci set nikki.mixin.ui_url='https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip'
|
||||||
|
uci set nikki.mixin.api_listen='[::]:9090'
|
||||||
|
uci set nikki.mixin.selection_cache='1'
|
||||||
|
uci set nikki.mixin.allow_lan='1'
|
||||||
|
uci set nikki.mixin.http_port='8080'
|
||||||
|
uci set nikki.mixin.socks_port='1080'
|
||||||
|
uci set nikki.mixin.mixed_port='7890'
|
||||||
|
uci set nikki.mixin.redir_port='7891'
|
||||||
|
uci set nikki.mixin.tproxy_port='7892'
|
||||||
|
uci set nikki.mixin.authentication='1'
|
||||||
|
uci set nikki.mixin.tun_device='ZeroWrt'
|
||||||
|
uci set nikki.mixin.tun_stack='gvisor'
|
||||||
|
uci set nikki.mixin.tun_dns_hijack='0'
|
||||||
|
uci add_list nikki.mixin.tun_dns_hijacks='tcp://any:53'
|
||||||
|
uci add_list nikki.mixin.tun_dns_hijacks='udp://any:53'
|
||||||
|
uci set nikki.mixin.dns_listen='[::]:1053'
|
||||||
|
uci set nikki.mixin.dns_ipv6='1'
|
||||||
|
uci set nikki.mixin.dns_mode='fake-ip'
|
||||||
|
uci set nikki.mixin.fake_ip_range='198.18.0.1/16'
|
||||||
|
uci set nikki.mixin.fake_ip_filter='1'
|
||||||
|
uci set nikki.mixin.fake_ip_cache='1'
|
||||||
|
uci set nikki.mixin.hosts='1'
|
||||||
|
uci set nikki.mixin.dns_nameserver='1'
|
||||||
|
uci set nikki.mixin.dns_nameserver_policy='0'
|
||||||
|
uci set nikki.mixin.sniffer_force_domain_name='0'
|
||||||
|
uci set nikki.mixin.sniffer_ignore_domain_name='0'
|
||||||
|
uci set nikki.mixin.sniffer_sniff='1'
|
||||||
|
uci set nikki.mixin.rule='0'
|
||||||
|
uci set nikki.mixin.rule_provider='0'
|
||||||
|
uci set nikki.mixin.mixin_file_content='0'
|
||||||
|
uci set nikki.mixin.unify_delay='1'
|
||||||
|
uci set nikki.mixin.tcp_concurrent='1'
|
||||||
|
uci set nikki.mixin.tcp_keep_alive_idle='600'
|
||||||
|
uci set nikki.mixin.tcp_keep_alive_interval='15'
|
||||||
|
uci set nikki.mixin.ui_name='Zashboard'
|
||||||
|
uci set nikki.mixin.api_secret='123456' # 请修改
|
||||||
|
uci set nikki.mixin.tun_mtu='9000'
|
||||||
|
uci set nikki.mixin.tun_gso='1'
|
||||||
|
uci set nikki.mixin.tun_gso_max_size='65536'
|
||||||
|
uci set nikki.mixin.tun_endpoint_independent_nat='1'
|
||||||
|
uci add_list nikki.mixin.fake_ip_filters='+.lan'
|
||||||
|
uci add_list nikki.mixin.fake_ip_filters='+.local'
|
||||||
|
uci add_list nikki.mixin.fake_ip_filters='geosite:cn'
|
||||||
|
uci set nikki.mixin.fake_ip_filter_mode='blacklist'
|
||||||
|
uci set nikki.mixin.dns_respect_rules='0'
|
||||||
|
uci set nikki.mixin.dns_doh_prefer_http3='0'
|
||||||
|
uci set nikki.mixin.dns_system_hosts='1'
|
||||||
|
uci set nikki.mixin.dns_hosts='1'
|
||||||
|
uci set nikki.mixin.sniffer='1'
|
||||||
|
uci set nikki.mixin.sniffer_sniff_dns_mapping='1'
|
||||||
|
uci set nikki.mixin.sniffer_sniff_pure_ip='1'
|
||||||
|
uci set nikki.mixin.geoip_format='dat'
|
||||||
|
uci set nikki.mixin.geodata_loader='standard'
|
||||||
|
uci set nikki.mixin.geosite_url='https://testingcf.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat'
|
||||||
|
uci set nikki.mixin.geoip_dat_url='https://testingcf.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat'
|
||||||
|
uci set nikki.mixin.geox_auto_update='1'
|
||||||
|
uci set nikki.mixin.geox_update_interval='24'
|
||||||
|
|
||||||
|
# 环境配置
|
||||||
|
uci set nikki.env=env
|
||||||
|
uci set nikki.env.disable_safe_path_check='0'
|
||||||
|
uci set nikki.env.disable_loopback_detector='0'
|
||||||
|
uci set nikki.env.disable_quic_go_gso='0'
|
||||||
|
uci set nikki.env.disable_quic_go_ecn='0'
|
||||||
|
|
||||||
|
# 路由访问控制(第一组)
|
||||||
|
uci set nikki.@router_access_control[0]=router_access_control
|
||||||
|
uci set nikki.@router_access_control[0].enabled='1'
|
||||||
|
uci add_list nikki.@router_access_control[0].user='dnsmasq'
|
||||||
|
uci add_list nikki.@router_access_control[0].user='ftp'
|
||||||
|
uci add_list nikki.@router_access_control[0].user='logd'
|
||||||
|
uci add_list nikki.@router_access_control[0].user='nobody'
|
||||||
|
uci add_list nikki.@router_access_control[0].user='ntp'
|
||||||
|
uci add_list nikki.@router_access_control[0].user='ubus'
|
||||||
|
uci add_list nikki.@router_access_control[0].group='dnsmasq'
|
||||||
|
uci add_list nikki.@router_access_control[0].group='ftp'
|
||||||
|
uci add_list nikki.@router_access_control[0].group='logd'
|
||||||
|
uci add_list nikki.@router_access_control[0].group='nogroup'
|
||||||
|
uci add_list nikki.@router_access_control[0].group='ntp'
|
||||||
|
uci add_list nikki.@router_access_control[0].group='ubus'
|
||||||
|
uci add_list nikki.@router_access_control[0].cgroup='adguardhome'
|
||||||
|
uci add_list nikki.@router_access_control[0].cgroup='aria2'
|
||||||
|
uci add_list nikki.@router_access_control[0].cgroup='dnsmasq'
|
||||||
|
uci add_list nikki.@router_access_control[0].cgroup='netbird'
|
||||||
|
uci add_list nikki.@router_access_control[0].cgroup='qbittorrent'
|
||||||
|
uci add_list nikki.@router_access_control[0].cgroup='sysntpd'
|
||||||
|
uci add_list nikki.@router_access_control[0].cgroup='tailscale'
|
||||||
|
uci add_list nikki.@router_access_control[0].cgroup='zerotier'
|
||||||
|
uci set nikki.@router_access_control[0].proxy='0'
|
||||||
|
|
||||||
|
# 路由访问控制(第二组)
|
||||||
|
uci set nikki.@router_access_control[1]=router_access_control
|
||||||
|
uci set nikki.@router_access_control[1].enabled='1'
|
||||||
|
uci set nikki.@router_access_control[1].proxy='1'
|
||||||
|
|
||||||
|
# LAN访问控制
|
||||||
|
uci set nikki.lan_access_control=lan_access_control
|
||||||
|
uci set nikki.lan_access_control.enabled='1'
|
||||||
|
uci set nikki.lan_access_control.proxy='1'
|
||||||
|
|
||||||
|
# 认证配置
|
||||||
|
uci set nikki.authentication=authentication
|
||||||
|
uci set nikki.authentication.enabled='1'
|
||||||
|
uci set nikki.authentication.username='admin' # 建议修改
|
||||||
|
uci set nikki.authentication.password='your_strong_password' # 必须修改
|
||||||
|
|
||||||
|
# 域名配置
|
||||||
|
uci set nikki.hosts=hosts
|
||||||
|
uci set nikki.hosts.enabled='1'
|
||||||
|
uci set nikki.hosts.domain_name='*.yourdomain.com' # 替换为实际域名
|
||||||
|
|
||||||
|
# DNS服务器配置(示例配置第一个)
|
||||||
|
uci set nikki.@nameserver[0]=nameserver
|
||||||
|
uci set nikki.@nameserver[0].enabled='1'
|
||||||
|
uci set nikki.@nameserver[0].type='nameserver'
|
||||||
|
uci add_list nikki.@nameserver[0].nameserver='223.5.5.5'
|
||||||
|
uci add_list nikki.@nameserver[0].nameserver='119.29.29.29'
|
||||||
|
|
||||||
|
# 提交所有更改
|
||||||
|
uci commit nikki
|
||||||
|
|
||||||
|
# 重启服务
|
||||||
|
/etc/init.d/nikki restart
|
||||||
|
|
||||||
|
# init
|
||||||
|
devices_setup
|
||||||
|
|
||||||
|
exit 0
|
||||||
123
default-settings/i18n/default.zh_Hans.po
Normal file
123
default-settings/i18n/default.zh_Hans.po
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
msgid "CPU usage"
|
||||||
|
msgstr "CPU 使用率"
|
||||||
|
|
||||||
|
msgid "Confirm Reboot"
|
||||||
|
msgstr "确认重启"
|
||||||
|
|
||||||
|
msgid "Are you sure you want to reboot the system?"
|
||||||
|
msgstr "你确认要重启系统?"
|
||||||
|
|
||||||
|
msgid "Confirm"
|
||||||
|
msgstr "确认"
|
||||||
|
|
||||||
|
msgid "Login"
|
||||||
|
msgstr "登录"
|
||||||
|
|
||||||
|
msgid "Logout"
|
||||||
|
msgstr "退出"
|
||||||
|
|
||||||
|
msgid "Base Setting"
|
||||||
|
msgstr "基本设置"
|
||||||
|
|
||||||
|
msgid "Log"
|
||||||
|
msgstr "日志"
|
||||||
|
|
||||||
|
msgid "NAS"
|
||||||
|
msgstr "网络存储"
|
||||||
|
|
||||||
|
msgid "NFtables Firewall"
|
||||||
|
msgstr "NFtables 防火墙"
|
||||||
|
|
||||||
|
msgid "IPtables Firewall"
|
||||||
|
msgstr "IPtables 防火墙"
|
||||||
|
|
||||||
|
msgid "Refresh interval"
|
||||||
|
msgstr "刷新间隔"
|
||||||
|
|
||||||
|
msgid "Refresh interval in seconds"
|
||||||
|
msgstr "刷新间隔(以秒为单位)"
|
||||||
|
|
||||||
|
msgid "Use as docker root directory (/opt)"
|
||||||
|
msgstr "作为 docker 根目录使用(/opt)"
|
||||||
|
|
||||||
|
msgid "Full Cone NAT"
|
||||||
|
msgstr "全锥形 NAT"
|
||||||
|
|
||||||
|
msgid "Full Cone NAT6"
|
||||||
|
msgstr "全锥形 NAT6"
|
||||||
|
|
||||||
|
msgid "Disable"
|
||||||
|
msgstr "禁用"
|
||||||
|
|
||||||
|
msgid "Nftables Fullcone nat"
|
||||||
|
msgstr "Nftables 全锥形 NAT"
|
||||||
|
|
||||||
|
msgid "Nftables based fullcone nat scheme."
|
||||||
|
msgstr "基于 Nftables 的全锥形 NAT 方案。"
|
||||||
|
|
||||||
|
msgid "Broadcom Fullcone nat"
|
||||||
|
msgstr "Broadcom 全锥形 NAT"
|
||||||
|
|
||||||
|
msgid "Broadcom based fullcone nat scheme."
|
||||||
|
msgstr "基于博通的全锥型 NAT 方案。"
|
||||||
|
|
||||||
|
msgid "IPv6 NAT"
|
||||||
|
msgstr "IPv6 网络地址转换(NAT6)"
|
||||||
|
|
||||||
|
msgid "Applicable to internet environments where the router is not assigned an IPv6 prefix, such as when using an upstream optical modem for dial-up."
|
||||||
|
msgstr "适用于没有给路由分配 IPv6 前缀的上网环境,例如:上级光猫拨号"
|
||||||
|
|
||||||
|
msgid "Shortcut-FE flow offloading"
|
||||||
|
msgstr "Shortcut-FE 流量卸载"
|
||||||
|
|
||||||
|
msgid "Shortcut-FE based offloading for routing/NAT"
|
||||||
|
msgstr "基于 Shortcut-FE 的 路由/NAT 卸载"
|
||||||
|
|
||||||
|
msgid "Connection Manager"
|
||||||
|
msgstr "连接管理器"
|
||||||
|
|
||||||
|
msgid "Set up the Shortcut-FE engine connection manager"
|
||||||
|
msgstr "设置 Shortcut-FE 引擎连接管理器"
|
||||||
|
|
||||||
|
msgid "Natflow offloading"
|
||||||
|
msgstr "Natflow 流量卸载"
|
||||||
|
|
||||||
|
msgid "Natflow based offloading for routing/NAT"
|
||||||
|
msgstr "基于 Natflow 的 路由/NAT 卸载"
|
||||||
|
|
||||||
|
msgid "Natflow delay packet"
|
||||||
|
msgstr "Natflow 延迟数据包"
|
||||||
|
|
||||||
|
msgid "Set up the natflow delay packet"
|
||||||
|
msgstr "设置 Natflow 延迟数据包"
|
||||||
|
|
||||||
|
msgid "Custom rules allow you to execute arbitrary nft commands which are not otherwise covered by the firewall framework. The rules are executed after each firewall restart, right after the default ruleset has been loaded."
|
||||||
|
msgstr "自定义规则允许您执行不属于防火墙框架的任意 nft 命令。每次重启防火墙时,这些命令在默认的规则运行后立即执行。"
|
||||||
|
|
||||||
|
msgid "Units: milliseconds. 0 means unspecified."
|
||||||
|
msgstr "单位:毫秒。0 表示未指定。"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Dictates how long a node assumes a neighbor is reachable after a "
|
||||||
|
"reachability confirmation; published in <abbr title=\"Router "
|
||||||
|
"Advertisement\">RA</abbr> messages."
|
||||||
|
msgstr ""
|
||||||
|
"规定节点在确认邻居可达后,假定其保持可达状态的持续时间;通过 <abbr title="
|
||||||
|
"\"Router Advertisement\">RA</abbr> 消息发布。"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Dictates how long a node assumes a neighbor is reachable after a "
|
||||||
|
"reachability confirmation; published in <abbr title=\"Router "
|
||||||
|
"Advertisement\">RA</abbr> messages."
|
||||||
|
msgstr ""
|
||||||
|
"规定节点在确认邻居可达后,假定其保持可达状态的持续时间;通过 <abbr title="
|
||||||
|
"\"Router Advertisement\">RA</abbr> 消息发布。"
|
||||||
|
|
||||||
|
msgid "<abbr title=\"Router Advertisement\">RA</abbr> Retransmission Timer"
|
||||||
|
msgstr "<abbr title=\"Router Advertisement\">RA</abbr> 重传定时器"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Controls retransmitted Neighbor Solicitation messages; published in <abbr "
|
||||||
|
"title=\"Router Advertisement\">RA</abbr> messages."
|
||||||
|
msgstr "控制重传的邻居请求消息;在 <abbr title=\"Router Advertisement\">路由通告</abb"
|
||||||
|
"r>消息中发布。"
|
||||||
53
dns2socks-rust/Makefile
Normal file
53
dns2socks-rust/Makefile
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2017-2024 Zxlhhyccc <zxlhhyccc@gmail.com>
|
||||||
|
# Copyright (C) 2021-2024 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=dns2socks-rust
|
||||||
|
PKG_VERSION:=0.2.3
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/tun2proxy/dns2socks/tar.gz/v$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=4bb4a238aace1ad2b2e8b8f7414a5d28838e380299da57379bae6254f642be42
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/dns2socks-$(PKG_VERSION)
|
||||||
|
|
||||||
|
PKG_MAINTAINER:=Zxlhhyccc <zxlhhyccc@gmail.com>
|
||||||
|
PKG_LICENSE:=MIT
|
||||||
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
|
||||||
|
PKG_BUILD_DEPENDS:=rust/host
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
|
||||||
|
#RUST_PKG:=dns2socks
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(TOPDIR)/feeds/packages/lang/rust/rust-package.mk
|
||||||
|
|
||||||
|
define Package/dns2socks-rust
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=IP Addresses and Names
|
||||||
|
TITLE:=DNS forwards to SOCKS5 server
|
||||||
|
URL:=https://github.com/tun2proxy/dns2socks.git
|
||||||
|
DEPENDS:=$$(RUST_ARCH_DEPENDS)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dns2socks-rust/description
|
||||||
|
This is a DNS server that forwards DNS requests to a SOCKS5 server.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(call Build/Compile/Cargo,,--all-features)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dns2socks-rust/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/target/$(RUSTC_TARGET_ARCH)/release/dns2socks $(1)/usr/bin/dns2socks-rust
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,dns2socks-rust))
|
||||||
53
dns2socks/Makefile
Normal file
53
dns2socks/Makefile
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=dns2socks
|
||||||
|
PKG_VERSION:=2.1
|
||||||
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
|
PKG_SOURCE:=SourceCode.zip
|
||||||
|
PKG_SOURCE_URL:=@SF/dns2socks
|
||||||
|
PKG_SOURCE_DATE:=2020-02-18
|
||||||
|
PKG_HASH:=406b5003523577d39da66767adfe54f7af9b701374363729386f32f6a3a995f4
|
||||||
|
|
||||||
|
PKG_MAINTAINER:=ghostmaker
|
||||||
|
PKG_LICENSE:=BSD-3-Clause
|
||||||
|
PKG_LICENSE_FILE:=LICENSE
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
UNZIP_CMD:=unzip -q -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
|
||||||
|
|
||||||
|
define Package/dns2socks
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=IP Addresses and Names
|
||||||
|
TITLE:=DNS to SOCKS or HTTP proxy
|
||||||
|
URL:=http://dns2socks.sourceforge.net/
|
||||||
|
DEPENDS:=+libpthread
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dns2socks/description
|
||||||
|
This is a command line utility to resolve DNS requests via
|
||||||
|
a SOCKS tunnel like Tor or a HTTP proxy.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(TARGET_CC) \
|
||||||
|
$(TARGET_CFLAGS) \
|
||||||
|
$(TARGET_CPPFLAGS) \
|
||||||
|
$(FPIC) \
|
||||||
|
-o $(PKG_BUILD_DIR)/DNS2SOCKS/dns2socks \
|
||||||
|
$(PKG_BUILD_DIR)/DNS2SOCKS/DNS2SOCKS.c \
|
||||||
|
$(TARGET_LDFLAGS) -pthread
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dns2socks/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/DNS2SOCKS/dns2socks $(1)/usr/bin/dns2socks
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,dns2socks))
|
||||||
43
dns2tcp/Makefile
Normal file
43
dns2tcp/Makefile
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=dns2tcp
|
||||||
|
PKG_VERSION:=1.1.2
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/zfl9/dns2tcp/tar.gz/v$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=5e8c6302a1d32c16ae7d4b8e39cd9aad1f2d7e68fe18813e76cb1e48ec5940d2
|
||||||
|
|
||||||
|
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
PKG_LICENSE:=AGPL-3.0-only
|
||||||
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
PKG_BUILD_FLAGS:=no-mips16
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/dns2tcp
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=IP Addresses and Names
|
||||||
|
TITLE:=utility to convert dns query from udp to tcp
|
||||||
|
URL:=https://github.com/zfl9/dns2tcp
|
||||||
|
endef
|
||||||
|
|
||||||
|
TARGET_CFLAGS+= $(FPIC) -Wl,--gc-sections -flto
|
||||||
|
MAKE_FLAGS+= \
|
||||||
|
CFLAGS="-std=c99 $(TARGET_CFLAGS)" \
|
||||||
|
EVCFLAGS="$(TARGET_CFLAGS)"
|
||||||
|
|
||||||
|
define Package/dns2tcp/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/dns2tcp $(1)/usr/bin/
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,dns2tcp))
|
||||||
223
ffmpeg-remux/Makefile
Normal file
223
ffmpeg-remux/Makefile
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2017-2020 Ian Leonard <antonlacon@gmail.com>
|
||||||
|
# Copyright (C) 2018 Ted Hess <thess@kitschensync.net>
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=ffmpeg-remux
|
||||||
|
PKG_VERSION:=4.3.3
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=ffmpeg-$(PKG_VERSION).tar.xz
|
||||||
|
PKG_SOURCE_URL:=https://ffmpeg.org/releases/
|
||||||
|
PKG_HASH:=9f0a68fbd74feb4e50dc220bddd59d84626774a53687fb737806ae00e5c6e9e6
|
||||||
|
PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>, \
|
||||||
|
Ian Leonard <antonlacon@gmail.com>
|
||||||
|
|
||||||
|
PKG_LICENSE:=LGPL-2.1-or-later GPL-2.0-or-later LGPL-3.0-or-later
|
||||||
|
PKG_LICENSE_FILES:=COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv2.1 COPYING.LGPLv3
|
||||||
|
PKG_CPE_ID:=cpe:/a:ffmpeg:ffmpeg
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-x/ffmpeg-$(PKG_VERSION)
|
||||||
|
|
||||||
|
FFMPEG_REMUX_DECODERS:= \
|
||||||
|
mpeg1video \
|
||||||
|
mpeg2video \
|
||||||
|
mpeg4 \
|
||||||
|
mpegvideo \
|
||||||
|
h264 \
|
||||||
|
hevc \
|
||||||
|
vc1 \
|
||||||
|
|
||||||
|
FFMPEG_REMUX_MUXERS:= \
|
||||||
|
matroska \
|
||||||
|
h264 \
|
||||||
|
hevc \
|
||||||
|
mp4 \
|
||||||
|
mpeg1video \
|
||||||
|
mpeg2video \
|
||||||
|
mpegts \
|
||||||
|
ogg \
|
||||||
|
|
||||||
|
FFMPEG_REMUX_DEMUXERS:= \
|
||||||
|
avi \
|
||||||
|
h264 \
|
||||||
|
hevc \
|
||||||
|
matroska \
|
||||||
|
mov \
|
||||||
|
mpegps \
|
||||||
|
mpegts \
|
||||||
|
mpegvideo \
|
||||||
|
ogg \
|
||||||
|
rm \
|
||||||
|
vc1 \
|
||||||
|
wv \
|
||||||
|
|
||||||
|
FFMPEG_REMUX_PARSERS:= \
|
||||||
|
aac \
|
||||||
|
flac \
|
||||||
|
ac3 \
|
||||||
|
h264 \
|
||||||
|
hevc \
|
||||||
|
mpegaudio \
|
||||||
|
mpeg4video \
|
||||||
|
mpegvideo \
|
||||||
|
vc1 \
|
||||||
|
|
||||||
|
FFMPEG_REMUX_PROTOCOLS:= \
|
||||||
|
file pipe
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/ffmpeg-remux
|
||||||
|
TITLE:=FFmpeg remux
|
||||||
|
SECTION:=multimedia
|
||||||
|
CATEGORY:=Multimedia
|
||||||
|
URL:=https://ffmpeg.org/
|
||||||
|
DEPENDS+= +libpthread +zlib +libbz2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/ffmpeg-remux/description
|
||||||
|
FFmpeg remux only program
|
||||||
|
endef
|
||||||
|
|
||||||
|
# Strip off FPU notation
|
||||||
|
REAL_CPU_TYPE:=$(firstword $(subst +, ,$(CONFIG_CPU_TYPE)))
|
||||||
|
# Fixup cpu types recogized by ffmpeg configure
|
||||||
|
REAL_CPU_TYPE:=$(subst octeonplus,octeon+,$(REAL_CPU_TYPE))
|
||||||
|
|
||||||
|
FFMPEG_CONFIGURE:= \
|
||||||
|
CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(FPIC)" \
|
||||||
|
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||||
|
./configure \
|
||||||
|
--enable-cross-compile \
|
||||||
|
--cross-prefix="$(TARGET_CROSS)" \
|
||||||
|
--arch="$(ARCH)" \
|
||||||
|
$(if $(REAL_CPU_TYPE),--cpu=$(call qstrip,$(REAL_CPU_TYPE)),) \
|
||||||
|
--target-os=linux \
|
||||||
|
--prefix="/usr" \
|
||||||
|
--pkg-config="pkg-config" \
|
||||||
|
--enable-shared \
|
||||||
|
--enable-pthreads \
|
||||||
|
--enable-zlib \
|
||||||
|
--disable-doc \
|
||||||
|
--disable-debug \
|
||||||
|
\
|
||||||
|
--disable-lzma \
|
||||||
|
--disable-vaapi \
|
||||||
|
--disable-vdpau \
|
||||||
|
--disable-outdevs
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SOFT_FLOAT),y)
|
||||||
|
FFMPEG_CONFIGURE+= \
|
||||||
|
--disable-altivec \
|
||||||
|
--disable-vsx \
|
||||||
|
--disable-power8 \
|
||||||
|
--disable-armv5te \
|
||||||
|
--disable-armv6 \
|
||||||
|
--disable-armv6t2 \
|
||||||
|
--disable-fast-unaligned \
|
||||||
|
--disable-runtime-cpudetect
|
||||||
|
|
||||||
|
else ifneq ($(findstring arm,$(CONFIG_ARCH))$(findstring aarch64,$(CONFIG_ARCH)),)
|
||||||
|
FFMPEG_CONFIGURE+= \
|
||||||
|
--disable-runtime-cpudetect
|
||||||
|
# XXX: GitHub issue 3320 ppc cpu with fpu but no altivec (WNDR4700)
|
||||||
|
else ifneq ($(findstring powerpc,$(CONFIG_ARCH)),)
|
||||||
|
FFMPEG_CONFIGURE+= \
|
||||||
|
--disable-altivec
|
||||||
|
endif
|
||||||
|
|
||||||
|
# selectively disable optimizations according to arch/cpu type
|
||||||
|
ifneq ($(findstring arm,$(CONFIG_ARCH)),)
|
||||||
|
FFMPEG_CONFIGURE+= --enable-lto
|
||||||
|
|
||||||
|
ifneq ($(findstring vfp,$(CONFIG_CPU_TYPE)),)
|
||||||
|
FFMPEG_CONFIGURE+= --enable-vfp
|
||||||
|
else
|
||||||
|
FFMPEG_CONFIGURE+= --disable-vfp
|
||||||
|
endif
|
||||||
|
ifneq ($(findstring neon,$(CONFIG_CPU_TYPE)),)
|
||||||
|
FFMPEG_CONFIGURE+= \
|
||||||
|
--enable-neon \
|
||||||
|
--enable-vfp
|
||||||
|
else
|
||||||
|
FFMPEG_CONFIGURE+= --disable-neon
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(findstring aarch64,$(CONFIG_ARCH)),)
|
||||||
|
FFMPEG_CONFIGURE+= \
|
||||||
|
--enable-lto \
|
||||||
|
--enable-neon \
|
||||||
|
--enable-vfp
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(ARCH),x86_64)
|
||||||
|
FFMPEG_CONFIGURE+= --enable-lto
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_FFMPEG_X86ASM),y)
|
||||||
|
FFMPEG_CONFIGURE += --enable-x86asm
|
||||||
|
else
|
||||||
|
FFMPEG_CONFIGURE += --disable-x86asm
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
FFMPEG_ENABLE= \
|
||||||
|
$(foreach c, $(2), \
|
||||||
|
--enable-$(1)="$(c)" \
|
||||||
|
)
|
||||||
|
|
||||||
|
FFMPEG_CONFIGURE+= \
|
||||||
|
--enable-hardcoded-tables \
|
||||||
|
--disable-static \
|
||||||
|
--libdir="/usr/lib/remux" \
|
||||||
|
--enable-rpath \
|
||||||
|
\
|
||||||
|
--disable-ffplay \
|
||||||
|
--disable-alsa \
|
||||||
|
--disable-iconv \
|
||||||
|
--disable-sndio \
|
||||||
|
--disable-schannel \
|
||||||
|
--disable-sdl2 \
|
||||||
|
--disable-securetransport \
|
||||||
|
--disable-xlib \
|
||||||
|
--disable-v4l2-m2m \
|
||||||
|
--disable-avdevice \
|
||||||
|
--disable-postproc \
|
||||||
|
--disable-swresample \
|
||||||
|
--disable-swscale \
|
||||||
|
--disable-everything \
|
||||||
|
$(call FFMPEG_ENABLE,decoder,$(FFMPEG_REMUX_DECODERS)) \
|
||||||
|
$(call FFMPEG_ENABLE,parser,$(FFMPEG_REMUX_PARSERS)) \
|
||||||
|
$(call FFMPEG_ENABLE,demuxer,$(FFMPEG_REMUX_DEMUXERS)) \
|
||||||
|
$(call FFMPEG_ENABLE,muxer,$(FFMPEG_REMUX_MUXERS)) \
|
||||||
|
$(call FFMPEG_ENABLE,protocol,$(FFMPEG_REMUX_PROTOCOLS))
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_TARGET_x86),)
|
||||||
|
TARGET_CFLAGS+= -fomit-frame-pointer
|
||||||
|
endif
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
( cd $(PKG_BUILD_DIR); $(FFMPEG_CONFIGURE) )
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||||
|
DESTDIR="$(PKG_INSTALL_DIR)" \
|
||||||
|
all install
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/ffmpeg-remux/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/lib/remux
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(CP) $(PKG_INSTALL_DIR)/usr/lib/remux/lib{avcodec,avfilter,avformat,avutil}.so.* $(1)/usr/lib/remux/
|
||||||
|
$(CP) $(PKG_INSTALL_DIR)/usr/bin/ffmpeg $(1)/usr/bin/remux
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,ffmpeg-remux))
|
||||||
47
floatip/Makefile
Normal file
47
floatip/Makefile
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2024 jjm2473 <jjm2473@gmail.com>
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the MIT License.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=floatip
|
||||||
|
PKG_VERSION:=1.0.9
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=IP Addresses and Names
|
||||||
|
TITLE:=Float IP
|
||||||
|
DEPENDS:=+curl
|
||||||
|
PKGARCH:=all
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
Auto setup an IP if some host down
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/conffiles
|
||||||
|
/etc/config/floatip
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/libexec $(1)/etc/init.d $(1)/etc/config $(1)/etc/uci-defaults
|
||||||
|
$(INSTALL_BIN) ./files/floatip.sh $(1)/usr/libexec/floatip.sh
|
||||||
|
$(INSTALL_BIN) ./files/floatip.init $(1)/etc/init.d/floatip
|
||||||
|
$(INSTALL_CONF) ./files/floatip.config $(1)/etc/config/floatip
|
||||||
|
$(INSTALL_BIN) ./files/floatip.uci-default $(1)/etc/uci-defaults/floatip
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
17
floatip/files/floatip.config
Normal file
17
floatip/files/floatip.config
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
config floatip 'main'
|
||||||
|
# 启动时,enabled != 1 ,或者原 lan 口配置网段不包括 set_ip,清除自身的 set_ip,然后退出进程。
|
||||||
|
option enabled '0'
|
||||||
|
# fallback 表示后备
|
||||||
|
option role 'fallback'
|
||||||
|
# option role 'main'
|
||||||
|
# 对于 fallback 节点,检查到 check_ip 都不在线超过一定时间(例如30秒),就设置自身的 set_ip,然后检查 check_ip 中任一 IP 在线就清除自身的 set_ip,重复上述流程。
|
||||||
|
# 对于 main 节点,启动后不断检查 set_ip 和 check_url,直到 set_ip 不在线且 check_url 没有失败,就设置自身的 set_ip 并允许 LAN 口 ping,否则清除自身的 set_ip 并禁止 LAN 口 ping,重复上述流程。
|
||||||
|
# set_ip 可以不提供前缀长度,将会按 lan 口配置的网段的长度
|
||||||
|
option set_ip '192.168.100.3/24'
|
||||||
|
# option set_ip '192.168.100.3'
|
||||||
|
# check_ip 仅 fallback 有效,并且检查时只检查跟 set_ip 同一网段的
|
||||||
|
list check_ip '192.168.100.2'
|
||||||
|
# list check_ip '192.168.100.4'
|
||||||
|
# check_url 仅 main 有效
|
||||||
|
# list check_url 'https://www.google.com/generate_204'
|
||||||
|
# option check_url_timeout '5'
|
||||||
73
floatip/files/floatip.init
Executable file
73
floatip/files/floatip.init
Executable file
@@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=98
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
enable_lan_ping() {
|
||||||
|
uci -q set firewall.floatip_lan_offline.enabled=0 || return 0
|
||||||
|
uci changes | grep -Fq 'firewall.floatip_lan_offline.enabled' || return 0
|
||||||
|
uci commit firewall
|
||||||
|
/etc/init.d/firewall reload
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load floatip
|
||||||
|
config_get_bool enabled "main" enabled 0
|
||||||
|
ifdown floatip
|
||||||
|
[[ "$enabled" = 1 ]] || {
|
||||||
|
enable_lan_ping
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
[[ "`uci -q get network.lan.proto`" = "static" ]] || {
|
||||||
|
logger -s -t floatip "LAN proto is not static"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
local set_ip set_prefix
|
||||||
|
config_get set_ip "main" set_ip
|
||||||
|
[[ -n "$set_ip" ]] || return 0
|
||||||
|
if [[ "$set_ip" = "*/*" ]]; then
|
||||||
|
eval "$(ipcalc.sh "$set_ip" )";set_prefix=$PREFIX;set_ip=$IP
|
||||||
|
else
|
||||||
|
set_prefix=32
|
||||||
|
fi
|
||||||
|
local lan_ip="`uci -q get network.lan.ipaddr`"
|
||||||
|
[[ -n "$lan_ip" ]] || return 0
|
||||||
|
local lan_net lan_prefix set_net ip
|
||||||
|
local in_range=0
|
||||||
|
local lan_netmask="`uci -q get network.lan.netmask`"
|
||||||
|
for ip in $lan_ip; do
|
||||||
|
if [[ "$ip" = "*/*" ]]; then
|
||||||
|
eval "$(ipcalc.sh $ip )";lan_net=$NETWORK;lan_prefix=$PREFIX
|
||||||
|
else
|
||||||
|
# prefix=32 if not present
|
||||||
|
[[ -n "$lan_netmask" ]] || continue
|
||||||
|
eval "$(ipcalc.sh $ip $lan_netmask )";lan_net=$NETWORK;lan_prefix=$PREFIX
|
||||||
|
fi
|
||||||
|
[[ "$set_prefix" -ge "$lan_prefix" ]] || continue
|
||||||
|
eval "$(ipcalc.sh $set_ip/$lan_prefix )";set_net=$NETWORK
|
||||||
|
[[ "$set_net" = "$lan_net" ]] && {
|
||||||
|
[[ "$set_prefix" = 32 ]] && set_prefix=$lan_prefix
|
||||||
|
in_range=1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ $in_range = 1 ]] || {
|
||||||
|
logger -s -t floatip "float ip is not belong to any LAN subnets"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command /usr/libexec/floatip.sh "$set_prefix"
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_set_param file /etc/config/floatip
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
enable_lan_ping
|
||||||
|
ifdown floatip
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "network" "floatip"
|
||||||
|
}
|
||||||
238
floatip/files/floatip.sh
Executable file
238
floatip/files/floatip.sh
Executable file
@@ -0,0 +1,238 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
LOCK_FILE="/var/lock/floatip_loop.lock"
|
||||||
|
|
||||||
|
DEFAULT_PREFIX=24
|
||||||
|
|
||||||
|
# random number 0-255
|
||||||
|
random() {
|
||||||
|
local num=$(dd if=/dev/urandom bs=1 count=1 2>/dev/null | hexdump -ve '1/1 "%u"')
|
||||||
|
if [[ -z "$num" ]]; then
|
||||||
|
num=$(($(grep -om1 '[0-9][0-9]$' /proc/uptime) * 255 / 100))
|
||||||
|
fi
|
||||||
|
echo ${num:-1}
|
||||||
|
}
|
||||||
|
|
||||||
|
# check host alive, timeout in 2 seconds
|
||||||
|
host_alive() {
|
||||||
|
ping -4 -c 2 -A -t 1 -W 1 -q "$1" >/dev/null
|
||||||
|
# arping -f -q -b -c 2 -w 2 -i 1 -I br-lan "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_up() {
|
||||||
|
local ipaddr="$1"
|
||||||
|
echo "set my floatip to $ipaddr" >&2
|
||||||
|
if ! uci -q get network.floatip.ipaddr | grep -Fwq $ipaddr; then
|
||||||
|
if [[ "x$(uci -q get network.floatip)" = xinterface ]]; then
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
delete network.floatip.ipaddr
|
||||||
|
add_list network.floatip.ipaddr=$ipaddr
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
set network.floatip=interface
|
||||||
|
set network.floatip.proto=static
|
||||||
|
add_list network.floatip.ipaddr=$ipaddr
|
||||||
|
set network.floatip.device=br-lan
|
||||||
|
set network.floatip.auto=0
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
uci commit network
|
||||||
|
fi
|
||||||
|
ifup floatip
|
||||||
|
}
|
||||||
|
|
||||||
|
set_lan_ping() {
|
||||||
|
if [[ "$1" = 0 ]]; then
|
||||||
|
if [[ "x$(uci -q get firewall.floatip_lan_offline)" = xrule ]]; then
|
||||||
|
uci -q delete firewall.floatip_lan_offline.enabled
|
||||||
|
uci changes | grep -Fq 'firewall.floatip_lan_offline.enabled' || return 0
|
||||||
|
else
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
set firewall.floatip_lan_offline=rule
|
||||||
|
set firewall.floatip_lan_offline.name=FloatIP-LAN-Offline
|
||||||
|
set firewall.floatip_lan_offline.src=lan
|
||||||
|
set firewall.floatip_lan_offline.proto=icmp
|
||||||
|
set firewall.floatip_lan_offline.icmp_type=echo-request
|
||||||
|
set firewall.floatip_lan_offline.family=ipv4
|
||||||
|
set firewall.floatip_lan_offline.target=DROP
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
uci -q set firewall.floatip_lan_offline.enabled=0 || return 0
|
||||||
|
uci changes | grep -Fq 'firewall.floatip_lan_offline.enabled' || return 0
|
||||||
|
fi
|
||||||
|
uci commit firewall
|
||||||
|
/etc/init.d/firewall reload 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
safe_sleep() {
|
||||||
|
local sec="$1"
|
||||||
|
[[ "$sec" -lt 1 ]] && sec=1
|
||||||
|
sleep $sec
|
||||||
|
}
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
fallback_loop() {
|
||||||
|
local set_ip check_ip set_net set_prefix
|
||||||
|
config_get set_ip "main" set_ip
|
||||||
|
[[ -n "$set_ip" ]] || return 1
|
||||||
|
[[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/$DEFAULT_PREFIX"
|
||||||
|
eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP
|
||||||
|
local ipaddr="$set_ip/$set_prefix"
|
||||||
|
echo "ipaddr=$ipaddr"
|
||||||
|
|
||||||
|
local valid_check_ip cip
|
||||||
|
config_get check_ip "main" check_ip
|
||||||
|
for cip in $check_ip; do
|
||||||
|
eval "$(ipcalc.sh $cip/$set_prefix )"
|
||||||
|
[[ "$NETWORK" = "$set_net" ]] && valid_check_ip="$valid_check_ip $cip"
|
||||||
|
done
|
||||||
|
valid_check_ip="$valid_check_ip "
|
||||||
|
|
||||||
|
local order_check_ip="$valid_check_ip"
|
||||||
|
local found_alive consume_time
|
||||||
|
local dead_counter=0 floatip_up=0
|
||||||
|
while :; do
|
||||||
|
found_alive=0
|
||||||
|
consume_time=0
|
||||||
|
echo "checking host(s) $order_check_ip alive"
|
||||||
|
for cip in $order_check_ip; do
|
||||||
|
if host_alive $cip; then
|
||||||
|
echo "host $cip alive"
|
||||||
|
found_alive=1
|
||||||
|
# reorder to reduce check time
|
||||||
|
order_check_ip=" ${cip}${valid_check_ip// $cip / }"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
consume_time=$(($consume_time + 2))
|
||||||
|
done
|
||||||
|
if [[ $found_alive = 1 ]]; then
|
||||||
|
if [[ $floatip_up = 1 ]]; then
|
||||||
|
echo "set down floatip" >&2
|
||||||
|
ifdown floatip
|
||||||
|
floatip_up=0
|
||||||
|
else
|
||||||
|
dead_counter=0
|
||||||
|
fi
|
||||||
|
safe_sleep $((10 - $consume_time))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [[ $floatip_up = 1 ]]; then
|
||||||
|
safe_sleep $((5 - $consume_time))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
dead_counter=$(($dead_counter + 1))
|
||||||
|
if [[ $dead_counter -lt 3 ]]; then
|
||||||
|
safe_sleep $((10 - $consume_time))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "no host alive, set up floatip $ipaddr" >&2
|
||||||
|
set_up "$ipaddr"
|
||||||
|
floatip_up=1
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main_loop() {
|
||||||
|
local set_ip set_prefix
|
||||||
|
config_get set_ip "main" set_ip
|
||||||
|
[[ -n "$set_ip" ]] || return 1
|
||||||
|
[[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/$DEFAULT_PREFIX"
|
||||||
|
eval "$(ipcalc.sh "$set_ip" )";set_prefix=$PREFIX;set_ip=$IP
|
||||||
|
local ipaddr="$set_ip/$set_prefix"
|
||||||
|
echo "ipaddr=$ipaddr"
|
||||||
|
|
||||||
|
local check_urls check_url_timeout
|
||||||
|
config_get check_urls "main" check_url
|
||||||
|
config_get check_url_timeout "main" check_url_timeout '5'
|
||||||
|
local dead_counter=0 floatip_up=0 url_pass check_url curl_code consume_time found_alive
|
||||||
|
# sleep 2-6s
|
||||||
|
sleep $(( $(random) / 60 + 2))
|
||||||
|
while :; do
|
||||||
|
consume_time=0
|
||||||
|
if [[ $floatip_up = 0 ]]; then
|
||||||
|
found_alive=0
|
||||||
|
echo "checking host $set_ip alive"
|
||||||
|
if host_alive $set_ip; then
|
||||||
|
echo "host $set_ip alive"
|
||||||
|
found_alive=1
|
||||||
|
else
|
||||||
|
consume_time=$(($consume_time + 2))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
url_pass=1
|
||||||
|
for check_url in $check_urls ; do
|
||||||
|
curl -L --fail --show-error --no-progress-meter -o /dev/null \
|
||||||
|
--connect-timeout "$check_url_timeout" --max-time "$check_url_timeout" \
|
||||||
|
-I "$check_url" 2>&1
|
||||||
|
curl_code=$?
|
||||||
|
[[ $curl_code = 0 ]] && continue
|
||||||
|
[[ $curl_code = 6 || $curl_code = 7 || $curl_code = 28 ]] && \
|
||||||
|
consume_time=$(($consume_time + $check_url_timeout))
|
||||||
|
echo "check_url $check_url fail, code $curl_code"
|
||||||
|
url_pass=0
|
||||||
|
break
|
||||||
|
done
|
||||||
|
if [[ $floatip_up = 0 ]]; then
|
||||||
|
if [[ $url_pass = 1 ]]; then
|
||||||
|
# notify fallback node to offline
|
||||||
|
set_lan_ping
|
||||||
|
if [[ $found_alive = 0 ]]; then
|
||||||
|
echo "no host alive, and url passed, set up floatip $ipaddr" >&2
|
||||||
|
set_up "$ipaddr"
|
||||||
|
floatip_up=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
set_lan_ping 0
|
||||||
|
fi
|
||||||
|
safe_sleep $((5 - $consume_time))
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
if [[ $url_pass = 0 ]]; then
|
||||||
|
dead_counter=$(($dead_counter + 1))
|
||||||
|
if [[ $dead_counter -lt 3 ]]; then
|
||||||
|
safe_sleep $((5 - $consume_time))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "set down floatip, and disable ping" >&2
|
||||||
|
ifdown floatip
|
||||||
|
set_lan_ping 0
|
||||||
|
floatip_up=0
|
||||||
|
fi
|
||||||
|
dead_counter=0
|
||||||
|
fi
|
||||||
|
sleep 20
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local role
|
||||||
|
config_load floatip
|
||||||
|
config_get role "main" role
|
||||||
|
if [[ "$role" = "main" ]]; then
|
||||||
|
main_loop
|
||||||
|
elif [[ "$role" = "fallback" ]]; then
|
||||||
|
fallback_loop
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
try_lock() {
|
||||||
|
exec 200>"$LOCK_FILE"
|
||||||
|
flock -x 200 && return 0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "locking $LOCK_FILE" >&2
|
||||||
|
try_lock || {
|
||||||
|
echo "lock $LOCK_FILE failed, already running?" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
echo "lock $LOCK_FILE success" >&2
|
||||||
|
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
[[ "$1" -ge 0 && "$1" -lt 32 ]] && DEFAULT_PREFIX=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
main
|
||||||
14
floatip/files/floatip.uci-default
Normal file
14
floatip/files/floatip.uci-default
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
delete ucitrack.@floatip[-1]
|
||||||
|
add ucitrack floatip
|
||||||
|
set ucitrack.@floatip[-1].init=floatip
|
||||||
|
commit ucitrack
|
||||||
|
EOF
|
||||||
|
|
||||||
|
[[ "`uci -q get network.lan.proto`" = "static" && -n "`uci -q get network.lan.gateway`" ]] || exit 0
|
||||||
|
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
set floatip.main.role=main
|
||||||
|
commit floatip
|
||||||
|
EOF
|
||||||
30
fw_download_tool/Makefile
Normal file
30
fw_download_tool/Makefile
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2015-2016 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v3.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=fw_download_tool
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_LICENSE:=GPL-3.0
|
||||||
|
PKG_LICENSE_FILE:=COPYING
|
||||||
|
PKG_MAINTAINER:=sbwml <admin@cooluc.com>
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
TITLE:=Firmware downloader
|
||||||
|
DEPENDS:=+libcurl
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/fw_download_tool $(1)/usr/bin/fw_download_tool
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
674
fw_download_tool/src/COPYING
Normal file
674
fw_download_tool/src/COPYING
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
8
fw_download_tool/src/Makefile
Normal file
8
fw_download_tool/src/Makefile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
CC = gcc
|
||||||
|
CFLAGS += -lcurl
|
||||||
|
|
||||||
|
program: fw_download_tool.c
|
||||||
|
$(CC) $(CFLAGS) -o fw_download_tool fw_download_tool.c
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f fw_download_tool
|
||||||
240
fw_download_tool/src/fw_download_tool.c
Normal file
240
fw_download_tool/src/fw_download_tool.c
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* OpenWrt OTA lightweight downloader - by sbwml
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
static int progressCallback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||||
|
{
|
||||||
|
double progress = 0.0;
|
||||||
|
if (dltotal > 0.0)
|
||||||
|
{
|
||||||
|
progress = (dlnow / dltotal) * 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%.2f%%\r", progress);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long parseTimeout(const char *timeoutStr)
|
||||||
|
{
|
||||||
|
long timeout = 0;
|
||||||
|
int len = strlen(timeoutStr);
|
||||||
|
if (len > 1)
|
||||||
|
{
|
||||||
|
char unit = timeoutStr[len - 1];
|
||||||
|
char *endptr;
|
||||||
|
long value = strtol(timeoutStr, &endptr, 10);
|
||||||
|
if (endptr == timeoutStr)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Invalid timeout value: %s\n", timeoutStr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (unit)
|
||||||
|
{
|
||||||
|
case 's':
|
||||||
|
timeout = value;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
timeout = value * 60;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
timeout = value * 60 * 60;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
timeout = value * 60 * 60 * 24;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Invalid timeout unit: %c\n", unit);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeout = strtol(timeoutStr, NULL, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
int downloadFile(const char *url, const char *outputPath, const char *userAgent, long timeout, int skipSSL, int followRedirects, int useIPv4, int useIPv6)
|
||||||
|
{
|
||||||
|
CURL *curl;
|
||||||
|
CURLcode res;
|
||||||
|
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
curl = curl_easy_init();
|
||||||
|
if (curl)
|
||||||
|
{
|
||||||
|
fp = fopen(outputPath, "wb");
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to open file for writing\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||||
|
|
||||||
|
if (timeout > 0)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skipSSL)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (followRedirects)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useIPv4)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||||
|
}
|
||||||
|
else if (useIPv6)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
|
||||||
|
}
|
||||||
|
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
if (res != CURLE_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
||||||
|
fclose(fp);
|
||||||
|
remove(outputPath);
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const char *url;
|
||||||
|
const char *outputPath = NULL;
|
||||||
|
const char *userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
|
||||||
|
long timeout = 0;
|
||||||
|
int skipSSL = 0;
|
||||||
|
int followRedirects = 0;
|
||||||
|
int useIPv4 = 0;
|
||||||
|
int useIPv6 = 0;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage: %s <url> [-o <output_path>] [-u <user_agent>] [-t <timeout>] [-k] [-L] [-4] [-6]\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
url = argv[1];
|
||||||
|
|
||||||
|
for (i = 2; i < argc; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[i], "-o") == 0)
|
||||||
|
{
|
||||||
|
if (i + 1 < argc)
|
||||||
|
{
|
||||||
|
outputPath = argv[i + 1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Invalid arguments. Use -o to specify the output path.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "-u") == 0)
|
||||||
|
{
|
||||||
|
if (i + 1 < argc)
|
||||||
|
{
|
||||||
|
userAgent = argv[i + 1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Invalid arguments. Use -u to specify the User-Agent.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "-t") == 0)
|
||||||
|
{
|
||||||
|
if (i + 1 < argc)
|
||||||
|
{
|
||||||
|
const char *timeoutStr = argv[i + 1];
|
||||||
|
i++;
|
||||||
|
timeout = parseTimeout(timeoutStr);
|
||||||
|
if (timeout < 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Invalid arguments. Use -t to specify the timeout.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "-k") == 0)
|
||||||
|
{
|
||||||
|
skipSSL = 1;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "-L") == 0)
|
||||||
|
{
|
||||||
|
followRedirects = 1;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "-4") == 0)
|
||||||
|
{
|
||||||
|
useIPv4 = 1;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "-6") == 0)
|
||||||
|
{
|
||||||
|
useIPv6 = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Invalid arguments.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outputPath == NULL)
|
||||||
|
{
|
||||||
|
outputPath = "/tmp/firmware.img.part";
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = downloadFile(url, outputPath, userAgent, timeout, skipSSL, followRedirects, useIPv4, useIPv6);
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Download failed.\n");
|
||||||
|
remove(outputPath);
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
48
geoview/Makefile
Normal file
48
geoview/Makefile
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=geoview
|
||||||
|
PKG_VERSION:=0.1.11
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/snowie2000/geoview/tar.gz/$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=a3ad07d3926c329f6990d67e17119f0c9a4ee26e89b0e2f541b27230c2806e94
|
||||||
|
|
||||||
|
PKG_LICENSE:=Apache-2.0
|
||||||
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
PKG_MAINTAINER:=snowie2000
|
||||||
|
|
||||||
|
PKG_BUILD_DEPENDS:=golang/host
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
PKG_BUILD_FLAGS:=no-mips16
|
||||||
|
|
||||||
|
GO_PKG:=github.com/snowie2000/geoview
|
||||||
|
GO_PKG_BUILD_PKG:=$(GO_PKG)
|
||||||
|
|
||||||
|
GO_PKG_LDFLAGS:=-s -w
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||||
|
|
||||||
|
define Package/geoview
|
||||||
|
TITLE:=A geofile toolkit
|
||||||
|
URL:=https://github.com/snowie2000/geoview
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=IP Addresses and Names
|
||||||
|
DEPENDS+= $(GO_ARCH_DEPENDS)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/geoview/description
|
||||||
|
geoview is a handy tool to extract useful information from geo* files.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/geoview/install
|
||||||
|
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/geoview $(1)/usr/bin/
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call GoBinPackage,geoview))
|
||||||
|
$(eval $(call BuildPackage,geoview))
|
||||||
59
hysteria/Makefile
Normal file
59
hysteria/Makefile
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=hysteria
|
||||||
|
PKG_VERSION:=2.6.5
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/apernet/hysteria/tar.gz/app/v$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=21a04ef8ce640d7c60c3b8678500b6e6481862d9af62f9ce2663b772211718d0
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-app-v$(PKG_VERSION)
|
||||||
|
|
||||||
|
PKG_LICENSE:=MIT
|
||||||
|
PKG_LICENSE_FILE:=LICENSE
|
||||||
|
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
|
||||||
|
PKG_BUILD_DEPENDS:=golang/host
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
PKG_BUILD_FLAGS:=no-mips16
|
||||||
|
|
||||||
|
GO_PKG:=github.com/apernet/hysteria
|
||||||
|
GO_PKG_BUILD_PKG:=$(GO_PKG)/app/v2
|
||||||
|
GO_PKG_LDFLAGS_X = \
|
||||||
|
$(GO_PKG)/app/v2/cmd.appVersion=v$(PKG_VERSION) \
|
||||||
|
$(GO_PKG)/app/v2/cmd.appType=release \
|
||||||
|
$(GO_PKG)/app/v2/cmd.appPlatform=$(GO_OS) \
|
||||||
|
$(GO_PKG)/app/v2/cmd.appArch=$(GO_ARCH)
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||||
|
|
||||||
|
define Package/hysteria
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
TITLE:=A feature-packed network utility optimized for networks of poor quality
|
||||||
|
URL:=https://github.com/apernet/hysteria
|
||||||
|
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/hysteria/description
|
||||||
|
Hysteria is a feature-packed network utility optimized for networks
|
||||||
|
of poor quality (e.g. satellite connections, congested public Wi-Fi,
|
||||||
|
connecting from China to servers abroad) powered by a custom version
|
||||||
|
of QUIC protocol.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/hysteria/install
|
||||||
|
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/app $(1)/usr/bin/hysteria
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call GoBinPackage,hysteria))
|
||||||
|
$(eval $(call BuildPackage,hysteria))
|
||||||
46
ipt2socks/Makefile
Normal file
46
ipt2socks/Makefile
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=ipt2socks
|
||||||
|
PKG_VERSION:=1.1.4
|
||||||
|
PKG_RELEASE:=3
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/zfl9/ipt2socks/tar.gz/v$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=68dc76e63951d655c2fd9b420e175b5a75a50014d6db6e729398b41f2c988356
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
PKG_BUILD_FLAGS:=no-mips16
|
||||||
|
|
||||||
|
PKG_LICENSE:=AGPL-3.0
|
||||||
|
PKG_LICENSE_FILE:=LICENSE
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/ipt2socks
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
TITLE:=Convert iptables to socks5
|
||||||
|
URL:=https://github.com/zfl9/ipt2socks
|
||||||
|
DEPENDS:=+libpthread
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/ipt2socks/description
|
||||||
|
Utility for converting iptables (redirect/tproxy) to socks5.
|
||||||
|
endef
|
||||||
|
|
||||||
|
TARGET_CFLAGS+= $(FPIC) -flto
|
||||||
|
MAKE_FLAGS+= \
|
||||||
|
CFLAGS="-std=c99 -pthread $(TARGET_CFLAGS)" \
|
||||||
|
EVCFLAGS="$(TARGET_CFLAGS)"
|
||||||
|
|
||||||
|
define Package/ipt2socks/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ipt2socks $(1)/usr/bin
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,ipt2socks))
|
||||||
78
istoreenhance/Makefile
Normal file
78
istoreenhance/Makefile
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2015-2016 OpenWrt.org
|
||||||
|
# Copyright (C) 2020 jjm2473@gmail.com
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v3.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_ARCH_ISTOREENHANCE:=$(ARCH)
|
||||||
|
|
||||||
|
PKG_NAME:=istoreenhance
|
||||||
|
# use PKG_SOURCE_DATE instead of PKG_VERSION for compitable
|
||||||
|
PKG_SOURCE_DATE:=0.3.7
|
||||||
|
PKG_RELEASE:=5
|
||||||
|
ARCH_HEXCODE:=
|
||||||
|
ifeq ($(ARCH),x86_64)
|
||||||
|
ARCH_HEXCODE=8664
|
||||||
|
else ifeq ($(ARCH),aarch64)
|
||||||
|
ARCH_HEXCODE=aa64
|
||||||
|
else ifeq ($(ARCH),arm)
|
||||||
|
ARCH_HEXCODE=aa32
|
||||||
|
else ifeq ($(ARCH),mipsel)
|
||||||
|
ARCH_HEXCODE=1b0c
|
||||||
|
endif
|
||||||
|
PKG_SOURCE_VERSION:=$(ARCH_HEXCODE)
|
||||||
|
PKG_SOURCE:=iStoreEnhance-binary-$(PKG_SOURCE_DATE).tar.gz
|
||||||
|
PKG_SOURCE_URL:=http://dl.istoreos.com/binary/iStoreEnhance/
|
||||||
|
PKG_HASH:=b6ddbe864b28e5912378d3fdf3ad8bc5f74e5ddd33dd0f8990d47749d03def26
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/iStoreEnhance-binary-$(PKG_SOURCE_DATE)
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Web Servers/Proxies
|
||||||
|
TITLE:=iStoreEnhance - Fix some net issues for istore
|
||||||
|
DEPENDS:=@(arm||x86_64||aarch64)
|
||||||
|
PKGARCH:=all
|
||||||
|
URL:=https://www.kspeeder.com/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
Fix some net issues for istore
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/conffiles
|
||||||
|
/etc/config/istoreenhance
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/postinst
|
||||||
|
#!/bin/sh
|
||||||
|
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||||
|
[ -f /etc/uci-defaults/istoreenhance ] && /etc/uci-defaults/istoreenhance && rm -f /etc/uci-defaults/istoreenhance
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d $(1)/etc/uci-defaults
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/iStoreEnhance.$(PKG_ARCH_ISTOREENHANCE) $(1)/usr/sbin/iStoreEnhance
|
||||||
|
$(INSTALL_CONF) ./files/istoreenhance.config $(1)/etc/config/istoreenhance
|
||||||
|
$(INSTALL_BIN) ./files/istoreenhance.init $(1)/etc/init.d/istoreenhance
|
||||||
|
$(INSTALL_BIN) ./files/istoreenhance.uci-default $(1)/etc/uci-defaults/istoreenhance
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
4
istoreenhance/files/istoreenhance.config
Normal file
4
istoreenhance/files/istoreenhance.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
config istoreenhance
|
||||||
|
option enabled '0'
|
||||||
|
option port '5443'
|
||||||
|
option adminport '5003'
|
||||||
72
istoreenhance/files/istoreenhance.init
Executable file
72
istoreenhance/files/istoreenhance.init
Executable file
@@ -0,0 +1,72 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=99
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
write_mirrors_config() {
|
||||||
|
local filename="$1"
|
||||||
|
cat > "$filename" << 'EOF'
|
||||||
|
mirrors:
|
||||||
|
- url: "https://docker.1ms.run"
|
||||||
|
- url: "https://docker.m.daocloud.io"
|
||||||
|
- url: "https://docker.m.ixdev.cn"
|
||||||
|
- url: "https://dockerproxy.net"
|
||||||
|
- url: "https://image.cloudlayer.icu"
|
||||||
|
- url: "https://docker.13140521.xyz"
|
||||||
|
- url: "https://docker.1panel.live"
|
||||||
|
- url: "https://docker.anye.in"
|
||||||
|
- url: "https://docker.amingg.com"
|
||||||
|
- url: "https://hub.rat.dev"
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
get_config() {
|
||||||
|
config_get_bool enabled $1 enabled 0
|
||||||
|
config_get port $1 port 5443
|
||||||
|
config_get adminport $1 adminport 5003
|
||||||
|
config_get cache $1 cache
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load istoreenhance
|
||||||
|
config_foreach get_config istoreenhance
|
||||||
|
if [ $enabled != 1 ]; then
|
||||||
|
disabled_mirrors
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $cache ]; then
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $cache/kspeeder.yml ]; then
|
||||||
|
parent_dir=$(dirname "$cache")
|
||||||
|
[ -d "$parent_dir" ] || mkdir "$parent_dir"
|
||||||
|
[ -d "$cache" ] || mkdir "$cache"
|
||||||
|
write_mirrors_config $cache/kspeeder.yml
|
||||||
|
fi
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param env KS_USER_MIRROR_CONFIG=$cache/kspeeder.yml
|
||||||
|
procd_set_param limits nofile="65535 65535"
|
||||||
|
procd_set_param command /usr/sbin/iStoreEnhance
|
||||||
|
[ -n "$port" ] && procd_append_param command --localAddr ":$port" --adminAddr ":$adminport" --cachePath $cache
|
||||||
|
procd_set_param respawn
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "istoreenhance"
|
||||||
|
}
|
||||||
|
|
||||||
|
disabled_mirrors() {
|
||||||
|
local mirror=$(uci get dockerd.globals.registry_mirrors | grep -oE 'https://registry\.linkease\.net:[0-9]+')
|
||||||
|
[ -n "$mirror" ] || return 0
|
||||||
|
uci del_list "dockerd.globals.registry_mirrors=$mirror"
|
||||||
|
uci commit dockerd
|
||||||
|
/etc/init.d/dockerd reload
|
||||||
|
}
|
||||||
|
|
||||||
|
service_stopped() {
|
||||||
|
disabled_mirrors
|
||||||
|
}
|
||||||
15
istoreenhance/files/istoreenhance.uci-default
Executable file
15
istoreenhance/files/istoreenhance.uci-default
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
delete ucitrack.@istoreenhance[-1]
|
||||||
|
add ucitrack istoreenhance
|
||||||
|
set ucitrack.@istoreenhance[-1].init=istoreenhance
|
||||||
|
commit ucitrack
|
||||||
|
|
||||||
|
delete firewall.istoreenhance
|
||||||
|
EOF
|
||||||
|
|
||||||
|
/etc/init.d/istoreenhance enable
|
||||||
|
#/etc/init.d/istoreenhance start
|
||||||
|
|
||||||
|
exit 0
|
||||||
46
libcron/Makefile
Normal file
46
libcron/Makefile
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=libcron
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE_PROTO:=git
|
||||||
|
PKG_SOURCE_URL:=https://github.com/PerMalmberg/libcron.git
|
||||||
|
PKG_SOURCE_DATE:=2023-11-14
|
||||||
|
PKG_SOURCE_VERSION:=41f238ceb09d4179e7346d78584a0c978e5d0059
|
||||||
|
PKG_MIRROR_HASH:=1d5ed3dd15abd1df765904b80153943c12cf1b2b212432c8f116a5eff30e953d
|
||||||
|
|
||||||
|
PKG_LICENSE:=MIT
|
||||||
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
CMAKE_INSTALL:=1
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(INCLUDE_DIR)/cmake.mk
|
||||||
|
|
||||||
|
define Package/libcron
|
||||||
|
SECTION:=lib
|
||||||
|
CATEGORY:=Libraries
|
||||||
|
URL:=https://github.com/PerMalmberg/libcron
|
||||||
|
TITLE:=A C++ scheduling library using cron formatting
|
||||||
|
DEPENDS:=+libstdcpp
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/libcron/description
|
||||||
|
Libcron offers an easy to use API to add callbacks with corresponding
|
||||||
|
cron-formatted strings.
|
||||||
|
endef
|
||||||
|
|
||||||
|
CMAKE_OPTIONS+= -DBUILD_SHARED_LIBS=ON
|
||||||
|
|
||||||
|
define Package/libcron/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/lib/
|
||||||
|
$(CP) $(PKG_INSTALL_DIR)/usr/lib/liblibcron.so $(1)/usr/lib/
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,libcron))
|
||||||
81
linkease/Makefile
Normal file
81
linkease/Makefile
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2015-2016 OpenWrt.org
|
||||||
|
# Copyright (C) 2020 jjm2473@gmail.com
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v3.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_ARCH_LINKEASE:=$(ARCH)
|
||||||
|
|
||||||
|
PKG_NAME:=linkease
|
||||||
|
# use PKG_SOURCE_DATE instead of PKG_VERSION for compitable
|
||||||
|
PKG_SOURCE_DATE:=1.7.5
|
||||||
|
PKG_RELEASE:=4
|
||||||
|
ARCH_HEXCODE:=
|
||||||
|
ifeq ($(ARCH),x86_64)
|
||||||
|
ARCH_HEXCODE=8664
|
||||||
|
else ifeq ($(ARCH),aarch64)
|
||||||
|
ARCH_HEXCODE=aa64
|
||||||
|
else ifeq ($(ARCH),arm)
|
||||||
|
ARCH_HEXCODE=aa32
|
||||||
|
else ifeq ($(ARCH),mipsel)
|
||||||
|
ARCH_HEXCODE=1b0c
|
||||||
|
endif
|
||||||
|
PKG_SOURCE_VERSION:=$(ARCH_HEXCODE)
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_SOURCE_DATE).tar.gz
|
||||||
|
PKG_SOURCE_URL:=http://dl.istoreos.com/binary/LinkEase/LinuxStorage/
|
||||||
|
PKG_HASH:=f3ae319974d940f5741cd9fbd295a3a378164e7df82665defa99935608fe733a
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-binary-$(PKG_SOURCE_DATE)
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Web Servers/Proxies
|
||||||
|
TITLE:=LinkEase - the file cloud
|
||||||
|
DEPENDS:=@(arm||x86_64||aarch64) +linkmount
|
||||||
|
PKGARCH:=all
|
||||||
|
URL:=https://www.linkease.com/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
LinkEase is a file cloud
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/conffiles
|
||||||
|
/etc/config/linkease
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/postinst
|
||||||
|
#!/bin/sh
|
||||||
|
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||||
|
[ -f /etc/uci-defaults/linkease ] && /etc/uci-defaults/linkease && rm -f /etc/uci-defaults/linkease
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/sbin/linkease-plugins $(1)/etc/config $(1)/etc/init.d $(1)/etc/uci-defaults
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/linkease.$(PKG_ARCH_LINKEASE) $(1)/usr/sbin/linkease
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/heif-converter.$(PKG_ARCH_LINKEASE) $(1)/usr/sbin/heif-converter
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/linkease-media.$(PKG_ARCH_LINKEASE) $(1)/usr/sbin/linkease-media
|
||||||
|
$(INSTALL_BIN) ./files/linkease-config.sh $(1)/usr/sbin/linkease-config.sh
|
||||||
|
$(INSTALL_CONF) ./files/linkease.config $(1)/etc/config/linkease
|
||||||
|
$(INSTALL_BIN) ./files/linkease.init $(1)/etc/init.d/linkease
|
||||||
|
$(INSTALL_BIN) ./files/linkease.uci-default $(1)/etc/uci-defaults/linkease
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
134
linkease/files/aria2.sh
Executable file
134
linkease/files/aria2.sh
Executable file
@@ -0,0 +1,134 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sh_ver="1.0.0"
|
||||||
|
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/sbin:/bin
|
||||||
|
aria2_conf_dir=/var/etc/aria2/
|
||||||
|
#替换成你设备aria2.conf路径
|
||||||
|
aria2_conf=${aria2_conf_dir}/aria2.conf.main
|
||||||
|
#替换成你设备的aria2c路径
|
||||||
|
aria2c=/usr/bin/aria2c
|
||||||
|
Green_font_prefix="\033[32m"
|
||||||
|
Red_font_prefix="\033[31m"
|
||||||
|
Green_background_prefix="\033[42;37m"
|
||||||
|
Red_background_prefix="\033[41;37m"
|
||||||
|
Font_color_suffix="\033[0m"
|
||||||
|
Info="[${Green_font_prefix}信息${Font_color_suffix}]"
|
||||||
|
Error="[${Red_font_prefix}错误${Font_color_suffix}]"
|
||||||
|
Tip="[${Green_font_prefix}注意${Font_color_suffix}]"
|
||||||
|
error_code=11
|
||||||
|
success_code=0
|
||||||
|
|
||||||
|
return_error(){
|
||||||
|
echo 'Content-Type:application/json;charset=utf-8'
|
||||||
|
echo
|
||||||
|
echo "{
|
||||||
|
"\"success\"":$error_code,
|
||||||
|
"\"error\"":"\"$1\"",
|
||||||
|
"\"result"\":null
|
||||||
|
}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
return_ok(){
|
||||||
|
echo 'Content-Type:application/json;charset=utf-8'
|
||||||
|
echo
|
||||||
|
echo "{
|
||||||
|
"\"success\"":$success_code,
|
||||||
|
"\"error\"":"\"$1\"",
|
||||||
|
"\"result"\":null
|
||||||
|
}"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
return_result(){
|
||||||
|
echo 'Content-Type:application/json;charset=utf-8'
|
||||||
|
echo
|
||||||
|
echo "{
|
||||||
|
"\"success\"":$success_code,
|
||||||
|
"\"error\"":"\"\"",
|
||||||
|
"\"result"\":$1
|
||||||
|
}"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#进程中是否运行aria2
|
||||||
|
check_pid() {
|
||||||
|
PID=$(ps -ef | grep "aria2c" | grep -v grep | grep -v "aria2.sh" | grep -v "init.d" | grep -v "service" | awk '{print $2}')
|
||||||
|
}
|
||||||
|
|
||||||
|
#aria2是否正在运行
|
||||||
|
aria2_work_status(){
|
||||||
|
check_pid
|
||||||
|
# [[ ! -z ${PID} ]] && echo -e "${Error} Aria2 正在运行,请检查 !" && exit 1
|
||||||
|
[[ ! -z ${PID} ]] && return_ok "Aria2正在运行"
|
||||||
|
return_error "Aria2未运行"
|
||||||
|
}
|
||||||
|
|
||||||
|
#检测设备是否安装aria2
|
||||||
|
check_installed_status() {
|
||||||
|
[[ ! -e ${aria2c} ]] && return_error "Aria2 没有安装,请检查 !"
|
||||||
|
[[ ! -e ${aria2_conf} ]] && return_error "Aria2 配置文件不存在,请检查 !"
|
||||||
|
# return_ok "Aria2已安装"
|
||||||
|
}
|
||||||
|
#读取aria2配置信息
|
||||||
|
read_config() {
|
||||||
|
check_installed_status
|
||||||
|
if [[ ! -e ${aria2_conf} ]]; then
|
||||||
|
return_error "Aria2 配置文件不存在,请检查 !"
|
||||||
|
else
|
||||||
|
conf_text=$(cat ${aria2_conf} | grep -v '#')
|
||||||
|
aria2_dir=$(echo -e "${conf_text}" | grep "^dir=" | awk -F "=" '{print $NF}')
|
||||||
|
aria2_port=$(echo -e "${conf_text}" | grep "^rpc-listen-port=" | awk -F "=" '{print $NF}')
|
||||||
|
aria2_passwd=$(echo -e "${conf_text}" | grep "^rpc-secret=" | awk -F "=" '{print $NF}')
|
||||||
|
aria2_bt_port=$(echo -e "${conf_text}" | grep "^listen-port=" | awk -F "=" '{print $NF}')
|
||||||
|
aria2_dht_port=$(echo -e "${conf_text}" | grep "^dht-listen-port=" | awk -F "=" '{print $NF}')
|
||||||
|
|
||||||
|
return_result "{
|
||||||
|
"\"dir"\":"\"$aria2_dir"\",
|
||||||
|
"\"rpc-listen-port"\":"\"$aria2_port"\",
|
||||||
|
"\"rpc-secret"\":"\"$aria2_passwd"\",
|
||||||
|
"\"listen-port"\":"\"$aria2_bt_port"\",
|
||||||
|
"\"dht-listen-port"\":"\"$aria2_dht_port"\"}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#"Content-Type:text/html;charset=utf-8"
|
||||||
|
#echo
|
||||||
|
|
||||||
|
#SERVER_SOFTWARE = $SERVER_SOFTWARE #服务器软件
|
||||||
|
#SERVER_NAME = $SERVER_NAME #服务器主机名
|
||||||
|
#GATEWAY_INTERFACE = $GATEWAY_INTERFACE #CGI版本
|
||||||
|
#SERVER_PROTOCOL = $SERVER_PROTOCOL #通信使用的协议
|
||||||
|
#SERVER_PORT = $SERVER_PORT #服务器的端口号
|
||||||
|
#REQUEST_METHOD = $REQUEST_METHOD #请求方法(GET/POST/PUT/DELETE..)
|
||||||
|
#HTTP_ACCEPT = $HTTP_ACCEPT #HTTP定义的浏览器能够接受的数据类型
|
||||||
|
#SCRIPT_NAME = $SCRIPT_NAME #当前运行的脚本名称(包含路径)
|
||||||
|
#QUERY_STRING = $QUERY_STRING #地址栏中传的数据(get方式)
|
||||||
|
#REMOTE_ADDR = $REMOTE_ADDR #客户端的ip
|
||||||
|
|
||||||
|
#根据url QUERY调不同方法
|
||||||
|
query(){
|
||||||
|
aria2Query=${QUERY_STRING}
|
||||||
|
parse(){
|
||||||
|
echo $1 | sed 's/.*'$2'=\([[:alnum:]]*\).*/\1/'
|
||||||
|
}
|
||||||
|
value=$(parse $aria2Query "action")
|
||||||
|
|
||||||
|
if [ ! -z = "$value" ]
|
||||||
|
then
|
||||||
|
if [ "$value" = "status" ]
|
||||||
|
then
|
||||||
|
check_installed_status
|
||||||
|
elif [ "$value" = "readConfig" ]
|
||||||
|
then
|
||||||
|
read_config
|
||||||
|
elif [ "$value" = "workStatus" ]
|
||||||
|
then
|
||||||
|
aria2_work_status
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
return_error "action不能为空"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
query
|
||||||
89
linkease/files/linkease-config.sh
Executable file
89
linkease/files/linkease-config.sh
Executable file
@@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
source /lib/functions.sh
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
save)
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
uci set "linkease.@linkease[0].preconfig=$2"
|
||||||
|
uci commit
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
load)
|
||||||
|
if [ -f "/usr/sbin/preconfig.data" ]; then
|
||||||
|
data="`cat /usr/sbin/preconfig.data`"
|
||||||
|
uci set "linkease.@linkease[0].preconfig=${data}"
|
||||||
|
uci commit
|
||||||
|
rm /usr/sbin/preconfig.data
|
||||||
|
else
|
||||||
|
data="`uci -q get linkease.@linkease[0].preconfig`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${data}" ]; then
|
||||||
|
echo "nil"
|
||||||
|
else
|
||||||
|
echo "${data}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
local_save)
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
uci set "linkease.@linkease[0].local_home=$2"
|
||||||
|
uci commit
|
||||||
|
ROOT_DIR="$2"
|
||||||
|
if [ -f "/etc/config/quickstart" ]; then
|
||||||
|
config_load quickstart
|
||||||
|
config_get MAIN_DIR main main_dir ""
|
||||||
|
config_get CONF_DIR main conf_dir ""
|
||||||
|
config_get PUB_DIR main pub_dir ""
|
||||||
|
config_get DL_DIR main dl_dir ""
|
||||||
|
config_get TMP_DIR main tmp_dir ""
|
||||||
|
# echo "$MAIN_DIR $CONF_DIR $PUB_DIR $DL_DIR $TMP_DIR"
|
||||||
|
if [ "$ROOT_DIR" = "$MAIN_DIR" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
uci set "quickstart.main.main_dir=$ROOT_DIR"
|
||||||
|
if [ -z "$CONF_DIR" -o "$CONF_DIR" = "$MAIN_DIR/Configs" ]; then
|
||||||
|
uci set "quickstart.main.conf_dir=$ROOT_DIR/Configs"
|
||||||
|
fi
|
||||||
|
if [ -z "$PUB_DIR" -o "$PUB_DIR" = "$MAIN_DIR/Public" ]; then
|
||||||
|
uci set "quickstart.main.pub_dir=$ROOT_DIR/Public"
|
||||||
|
fi
|
||||||
|
if [ -z "$DL_DIR" -o "$DL_DIR" = "$MAIN_DIR/Public/Downloads" ]; then
|
||||||
|
uci set "quickstart.main.dl_dir=$ROOT_DIR/Public/Downloads"
|
||||||
|
fi
|
||||||
|
if [ -z "$TMP_DIR" -o "$TMP_DIR" = "$MAIN_DIR/Caches" ]; then
|
||||||
|
uci set "quickstart.main.tmp_dir=$ROOT_DIR/Caches"
|
||||||
|
fi
|
||||||
|
uci commit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
local_load)
|
||||||
|
if [ -f "/etc/config/quickstart" ]; then
|
||||||
|
data="`uci -q get quickstart.main.main_dir`"
|
||||||
|
fi
|
||||||
|
if [ -z "$data" ]; then
|
||||||
|
data="`uci -q get linkease.@linkease[0].local_home`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${data}" ]; then
|
||||||
|
echo "nil"
|
||||||
|
else
|
||||||
|
echo "${data}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
status)
|
||||||
|
echo "TODO"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {save|load|status}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
3
linkease/files/linkease.config
Normal file
3
linkease/files/linkease.config
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
config linkease
|
||||||
|
option port '8897'
|
||||||
|
option enabled '1'
|
||||||
30
linkease/files/linkease.init
Executable file
30
linkease/files/linkease.init
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=99
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
get_config() {
|
||||||
|
config_get_bool enabled $1 enabled 1
|
||||||
|
config_get_bool logger $1 logger
|
||||||
|
config_get_bool allowPublic $1 allowPublic
|
||||||
|
config_get port $1 port 8897
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load linkease
|
||||||
|
config_foreach get_config linkease
|
||||||
|
[ $enabled != 1 ] && return 1
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param limits nofile="65535 65535"
|
||||||
|
procd_set_param command /usr/sbin/linkease
|
||||||
|
[ -n "$port" ] && procd_append_param command --deviceAddr ":$port" --localApi /var/run/linkease.sock
|
||||||
|
[ "$allowPublic" == 1 ] && procd_append_param command --allowPublic
|
||||||
|
[ "$logger" == 1 ] && procd_set_param stderr 1
|
||||||
|
procd_set_param respawn
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "linkease"
|
||||||
|
}
|
||||||
22
linkease/files/linkease.uci-default
Executable file
22
linkease/files/linkease.uci-default
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
delete ucitrack.@linkease[-1]
|
||||||
|
add ucitrack linkease
|
||||||
|
set ucitrack.@linkease[-1].init=linkease
|
||||||
|
commit ucitrack
|
||||||
|
|
||||||
|
delete firewall.linkease
|
||||||
|
set firewall.linkease=rule
|
||||||
|
set firewall.linkease.name="linkease"
|
||||||
|
set firewall.linkease.target="ACCEPT"
|
||||||
|
set firewall.linkease.src="wan"
|
||||||
|
set firewall.linkease.proto="tcp"
|
||||||
|
set firewall.linkease.dest_port="8897"
|
||||||
|
commit firewall
|
||||||
|
EOF
|
||||||
|
|
||||||
|
/etc/init.d/linkease enable
|
||||||
|
/etc/init.d/linkease start
|
||||||
|
|
||||||
|
exit 0
|
||||||
63
linkmount/Makefile
Normal file
63
linkmount/Makefile
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_ARCH_LINKEASE:=$(ARCH)
|
||||||
|
|
||||||
|
PKG_NAME:=linkmount
|
||||||
|
# use PKG_SOURCE_DATE instead of PKG_VERSION for compitable
|
||||||
|
PKG_SOURCE_DATE:=1.0.3
|
||||||
|
PKG_RELEASE:=3
|
||||||
|
ARCH_HEXCODE:=
|
||||||
|
ifeq ($(ARCH),x86_64)
|
||||||
|
ARCH_HEXCODE=8664
|
||||||
|
else ifeq ($(ARCH),aarch64)
|
||||||
|
ARCH_HEXCODE=aa64
|
||||||
|
else ifeq ($(ARCH),arm)
|
||||||
|
ARCH_HEXCODE=aa32
|
||||||
|
else ifeq ($(ARCH),mipsel)
|
||||||
|
ARCH_HEXCODE=1b0c
|
||||||
|
endif
|
||||||
|
PKG_SOURCE_VERSION:=$(ARCH_HEXCODE)
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_SOURCE_DATE).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://dl.istoreos.com/binary/LinkEase/AutoUpgrade/linkmount/
|
||||||
|
PKG_HASH:=b8a5b99751cdd3dd84ac75c94e3cff5b898f910c86f12b4c7ec74dc8b3c510cb
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-binary-$(PKG_SOURCE_DATE)
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Web Servers/Proxies
|
||||||
|
TITLE:=LinkMount - the file cloud
|
||||||
|
DEPENDS:=@(arm||x86_64||aarch64)
|
||||||
|
PKGARCH:=all
|
||||||
|
URL:=https://www.linkease.com/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
LinkMount is used by LinkEase
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/sbin/linkmount
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_ARCH_LINKEASE)/bin/linkmount_bin $(1)/usr/sbin/linkmount/linkmount_bin
|
||||||
|
$(CP) $(PKG_BUILD_DIR)/$(PKG_ARCH_LINKEASE)/bin/lib $(1)/usr/sbin/linkmount/lib
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
|
|
||||||
44
lua-neturl/Makefile
Normal file
44
lua-neturl/Makefile
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022-2023 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=neturl
|
||||||
|
PKG_VERSION:=1.1-1
|
||||||
|
PKG_RELEASE:=3
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/golgote/neturl/tar.gz/v$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=25f3a94ba9f435ef1395555de2bf17d6f934d789fa515ed965405919e42be27b
|
||||||
|
|
||||||
|
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
PKG_LICENSE:=MIT
|
||||||
|
PKG_LICNESE_FILES:=LICENSE.txt
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/lua-neturl
|
||||||
|
SUBMENU:=Lua
|
||||||
|
SECTION:=lang
|
||||||
|
CATEGORY:=Languages
|
||||||
|
TITLE:=URL and Query string parser, builder, normalizer for Lua
|
||||||
|
URL:=https://github.com/golgote/neturl
|
||||||
|
DEPENDS:=+lua
|
||||||
|
PKGARCH:=all
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/lua-neturl/description
|
||||||
|
This small Lua library provides a few functions to parse URL with
|
||||||
|
querystring and build new URL easily.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/lua-neturl/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/lib/lua
|
||||||
|
$(CP) $(PKG_BUILD_DIR)/lib/net/url.lua $(1)/usr/lib/lua/
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,lua-neturl))
|
||||||
20
lua-neturl/patches/010-userinfo-regex.patch
Normal file
20
lua-neturl/patches/010-userinfo-regex.patch
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
--- a/lib/net/url.lua
|
||||||
|
+++ b/lib/net/url.lua
|
||||||
|
@@ -340,7 +340,7 @@ function M:setAuthority(authority)
|
||||||
|
self.password = v
|
||||||
|
return ''
|
||||||
|
end)
|
||||||
|
- if string.find(userinfo, "^[%w%+%.]+$") then
|
||||||
|
+ if string.find(userinfo, "^[%p%w%+%.]+$") then
|
||||||
|
self.user = userinfo
|
||||||
|
else
|
||||||
|
-- incorrect userinfo
|
||||||
|
@@ -369,7 +369,7 @@ function M.parse(url)
|
||||||
|
comp.fragment = v
|
||||||
|
return ''
|
||||||
|
end)
|
||||||
|
- url =url:gsub('^([%w][%w%+%-%.]*)%:', function(v)
|
||||||
|
+ url =url:gsub('^([%w][%w%+%-%_%.]*)%:', function(v)
|
||||||
|
comp.scheme = v:lower()
|
||||||
|
return ''
|
||||||
|
end)
|
||||||
68
luci-app-adguardhome/Makefile
Normal file
68
luci-app-adguardhome/Makefile
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=luci-app-adguardhome
|
||||||
|
PKG_VERSION:=1.1.1
|
||||||
|
PKG_MAINTAINER:=<https://github.com/sirpdboy/luci-app-adguardhome>
|
||||||
|
|
||||||
|
LUCI_TITLE:=LuCI app for AdGuardHome
|
||||||
|
LUCI_PKGARCH:=all
|
||||||
|
LUCI_DEPENDS:=+ca-certs +!wget&&!curl&&!wget-ssl:curl
|
||||||
|
LUCI_DESCRIPTION:=LuCI support for AdGuardHome
|
||||||
|
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/conffiles
|
||||||
|
/etc/config/AdGuardHome
|
||||||
|
/etc/AdGuardHome.yaml
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/preinst
|
||||||
|
#!/bin/sh
|
||||||
|
uci -q batch <<-EOF >/dev/null 2>&1
|
||||||
|
delete ucitrack.@AdGuardHome[-1]
|
||||||
|
add ucitrack AdGuardHome
|
||||||
|
set ucitrack.@AdGuardHome[-1].init=AdGuardHome
|
||||||
|
commit ucitrack
|
||||||
|
EOF
|
||||||
|
rm -f /tmp/luci-indexcache
|
||||||
|
exit 0
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/postinst
|
||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
chmod +x /usr/share/AdGuardHome/*
|
||||||
|
chmod +x /etc/init.d/AdGuardHome
|
||||||
|
/etc/init.d/AdGuardHome enable >/dev/null 2>&1
|
||||||
|
enable=$(uci get AdGuardHome.AdGuardHome.enabled 2>/dev/null)
|
||||||
|
if [ "$enable" == "1" ]; then
|
||||||
|
/etc/init.d/AdGuardHome reload >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
rm -f /tmp/luci-indexcache
|
||||||
|
rm -f /tmp/luci-modulecache/*
|
||||||
|
exit 0
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/prerm
|
||||||
|
#!/bin/sh
|
||||||
|
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||||
|
/etc/init.d/AdGuardHome disable
|
||||||
|
/etc/init.d/AdGuardHome stop
|
||||||
|
uci -q batch <<-EOF >/dev/null 2>&1
|
||||||
|
delete ucitrack.@AdGuardHome[-1]
|
||||||
|
commit ucitrack
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/postrm
|
||||||
|
#!/bin/sh
|
||||||
|
rm -rf /etc/AdGuardHome/
|
||||||
|
exit 0
|
||||||
|
endef
|
||||||
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
|
# call BuildPackage - OpenWrt buildroot signature
|
||||||
126
luci-app-adguardhome/luasrc/controller/AdGuardHome.lua
Normal file
126
luci-app-adguardhome/luasrc/controller/AdGuardHome.lua
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
module("luci.controller.AdGuardHome", package.seeall)
|
||||||
|
local fs = require "nixio.fs"
|
||||||
|
local http = require "luci.http"
|
||||||
|
local uci = require"luci.model.uci".cursor()
|
||||||
|
function index()
|
||||||
|
local page = entry({"admin", "services", "AdGuardHome"},alias("admin", "services", "AdGuardHome", "base"),_("AdGuard Home"))
|
||||||
|
page.order = 11
|
||||||
|
page.dependent = true
|
||||||
|
page.acl_depends = { "luci-app-adguardhome" }
|
||||||
|
entry({"admin", "services", "AdGuardHome", "base"}, cbi("AdGuardHome/base"), _("Base Setting"), 1).leaf = true
|
||||||
|
entry({"admin", "services", "AdGuardHome", "log"}, form("AdGuardHome/log"), _("Log"), 2).leaf = true
|
||||||
|
entry({"admin", "services", "AdGuardHome", "manual"}, cbi("AdGuardHome/manual"), _("Manual Config"), 3).leaf = true
|
||||||
|
entry({"admin", "services", "AdGuardHome", "status"}, call("act_status")).leaf = true
|
||||||
|
entry({"admin", "services", "AdGuardHome", "check"}, call("check_update"))
|
||||||
|
entry({"admin", "services", "AdGuardHome", "doupdate"}, call("do_update"))
|
||||||
|
entry({"admin", "services", "AdGuardHome", "getlog"}, call("get_log"))
|
||||||
|
entry({"admin", "services", "AdGuardHome", "dodellog"}, call("do_dellog"))
|
||||||
|
entry({"admin", "services", "AdGuardHome", "reloadconfig"}, call("reload_config"))
|
||||||
|
entry({"admin", "services", "AdGuardHome", "gettemplateconfig"}, call("get_template_config"))
|
||||||
|
end
|
||||||
|
function get_template_config()
|
||||||
|
local b
|
||||||
|
local d=""
|
||||||
|
local file = "/tmp/resolv.conf.d/resolv.conf.auto"
|
||||||
|
if not fs.access(file) then
|
||||||
|
file = "/tmp/resolv.conf.auto"
|
||||||
|
end
|
||||||
|
for cnt in io.lines(file) do
|
||||||
|
b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$")
|
||||||
|
if (b ~= nil) then d = d .. " - " .. b .. "\n" end
|
||||||
|
end
|
||||||
|
local f=io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+")
|
||||||
|
local tbl = {}
|
||||||
|
local a=""
|
||||||
|
while (1) do
|
||||||
|
a=f:read("*l")
|
||||||
|
if (a=="#bootstrap_dns") then
|
||||||
|
a=d
|
||||||
|
elseif (a=="#upstream_dns") then
|
||||||
|
a=d
|
||||||
|
elseif (a==nil) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
table.insert(tbl, a)
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
|
http.prepare_content("text/plain; charset=utf-8")
|
||||||
|
http.write(table.concat(tbl, "\n"))
|
||||||
|
end
|
||||||
|
function reload_config()
|
||||||
|
fs.remove("/tmp/AdGuardHometmpconfig.yaml")
|
||||||
|
http.prepare_content("application/json")
|
||||||
|
http.write('')
|
||||||
|
end
|
||||||
|
function act_status()
|
||||||
|
local e={}
|
||||||
|
local binpath=uci:get("AdGuardHome","AdGuardHome","binpath")
|
||||||
|
e.running=luci.sys.call("pgrep "..binpath.." >/dev/null")==0
|
||||||
|
e.redirect=(fs.readfile("/var/run/AdGredir")=="1")
|
||||||
|
http.prepare_content("application/json")
|
||||||
|
http.write_json(e)
|
||||||
|
end
|
||||||
|
function do_update()
|
||||||
|
fs.writefile("/var/run/lucilogpos","0")
|
||||||
|
http.prepare_content("application/json")
|
||||||
|
http.write('')
|
||||||
|
local arg
|
||||||
|
if luci.http.formvalue("force") == "1" then
|
||||||
|
arg="force"
|
||||||
|
else
|
||||||
|
arg=""
|
||||||
|
end
|
||||||
|
if arg=="force" then
|
||||||
|
luci.sys.exec("kill $(pgrep /usr/share/AdGuardHome/update_core.sh) ; sh /usr/share/AdGuardHome/update_core.sh "..arg.." >/tmp/AdGuardHome_update.log 2>&1 &")
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
luci.sys.exec("sh /usr/share/AdGuardHome/update_core.sh "..arg.." >/tmp/AdGuardHome_update.log 2>&1 &")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function get_log()
|
||||||
|
local logfile=uci:get("AdGuardHome","AdGuardHome","logfile")
|
||||||
|
if (logfile==nil) then
|
||||||
|
http.write("no log available\n")
|
||||||
|
return
|
||||||
|
elseif (logfile=="syslog") then
|
||||||
|
if not fs.access("/var/run/AdGuardHomesyslog") then
|
||||||
|
luci.sys.exec("(/usr/share/AdGuardHome/getsyslog.sh &); sleep 1;")
|
||||||
|
end
|
||||||
|
logfile="/tmp/AdGuardHometmp.log"
|
||||||
|
fs.writefile("/var/run/AdGuardHomesyslog","1")
|
||||||
|
elseif not fs.access(logfile) then
|
||||||
|
http.write("")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
http.prepare_content("text/plain; charset=utf-8")
|
||||||
|
local fdp = tonumber(fs.readfile("/var/run/lucilogpos")) or 0
|
||||||
|
local f=io.open(logfile, "r+")
|
||||||
|
f:seek("set",fdp)
|
||||||
|
local a=f:read(2048000) or ""
|
||||||
|
fdp=f:seek()
|
||||||
|
fs.writefile("/var/run/lucilogpos",tostring(fdp))
|
||||||
|
f:close()
|
||||||
|
http.write(a)
|
||||||
|
end
|
||||||
|
function do_dellog()
|
||||||
|
local logfile=uci:get("AdGuardHome","AdGuardHome","logfile")
|
||||||
|
fs.writefile(logfile,"")
|
||||||
|
http.prepare_content("application/json")
|
||||||
|
http.write('')
|
||||||
|
end
|
||||||
|
function check_update()
|
||||||
|
http.prepare_content("text/plain; charset=utf-8")
|
||||||
|
local fdp=tonumber(fs.readfile("/var/run/lucilogpos")) or 0
|
||||||
|
local f=io.open("/tmp/AdGuardHome_update.log", "r+")
|
||||||
|
f:seek("set",fdp)
|
||||||
|
local a=f:read(2048000) or ""
|
||||||
|
fdp=f:seek()
|
||||||
|
fs.writefile("/var/run/lucilogpos",tostring(fdp))
|
||||||
|
f:close()
|
||||||
|
if fs.access("/var/run/update_core") then
|
||||||
|
http.write(a)
|
||||||
|
else
|
||||||
|
http.write(a.."\0")
|
||||||
|
end
|
||||||
|
end
|
||||||
345
luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua
Normal file
345
luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua
Normal file
@@ -0,0 +1,345 @@
|
|||||||
|
require("luci.sys")
|
||||||
|
require("luci.util")
|
||||||
|
require("io")
|
||||||
|
local m,s,o,o1
|
||||||
|
local fs=require"nixio.fs"
|
||||||
|
local uci=require"luci.model.uci".cursor()
|
||||||
|
local configpath=uci:get("AdGuardHome","AdGuardHome","configpath") or "/etc/AdGuardHome.yaml"
|
||||||
|
local binpath=uci:get("AdGuardHome","AdGuardHome","binpath") or "/usr/bin/AdGuardHome"
|
||||||
|
httpport=uci:get("AdGuardHome","AdGuardHome","httpport") or "3000"
|
||||||
|
m = Map("AdGuardHome", "AdGuard Home")
|
||||||
|
m.description = translate("Free and open source, powerful network-wide ads & trackers blocking DNS server.")
|
||||||
|
m:section(SimpleSection).template = "AdGuardHome/AdGuardHome_status"
|
||||||
|
|
||||||
|
s = m:section(TypedSection, "AdGuardHome")
|
||||||
|
s.anonymous=true
|
||||||
|
s.addremove=false
|
||||||
|
|
||||||
|
---- Basic Settings ----
|
||||||
|
s:tab("basic", translate("Main Config"))
|
||||||
|
|
||||||
|
o = s:taboption("basic", Flag, "enabled", translate("Enable"))
|
||||||
|
o.default = 0
|
||||||
|
o.optional = false
|
||||||
|
|
||||||
|
o = s:taboption("basic", Value,"httpport",translate("Browser management port"))
|
||||||
|
o.placeholder=3000
|
||||||
|
o.default=3000
|
||||||
|
o.datatype="port"
|
||||||
|
o.optional = false
|
||||||
|
|
||||||
|
local binmtime=uci:get("AdGuardHome","AdGuardHome","binmtime") or "0"
|
||||||
|
|
||||||
|
local e=""
|
||||||
|
if not fs.access(configpath) then e = e .. " " .. translate("no config") end
|
||||||
|
if not fs.access(binpath) then
|
||||||
|
e=e.." "..translate("no core")
|
||||||
|
else
|
||||||
|
local version=uci:get("AdGuardHome","AdGuardHome","version")
|
||||||
|
local testtime=fs.stat(binpath,"mtime")
|
||||||
|
if testtime~=tonumber(binmtime) or version==nil then
|
||||||
|
|
||||||
|
version = luci.sys.exec(string.format("echo -n $(%s --version 2>&1 | awk -F 'version ' '{print $2}' | awk -F ',' '{print $1}')", binpath))
|
||||||
|
if version == "" then version = "core error" end
|
||||||
|
uci:set("AdGuardHome", "AdGuardHome", "version", version)
|
||||||
|
uci:set("AdGuardHome", "AdGuardHome", "binmtime", testtime)
|
||||||
|
uci:commit("AdGuardHome")
|
||||||
|
end
|
||||||
|
e=version..e
|
||||||
|
end
|
||||||
|
|
||||||
|
o = s:taboption("basic", ListValue, "core_version", translate("Core Version"))
|
||||||
|
o:value("latest", translate("Latest Version"))
|
||||||
|
o:value("beta", translate("Beta Version"))
|
||||||
|
o.default = "latest"
|
||||||
|
o = s:taboption("basic", Button, "restart", translate("Upgrade Core"))
|
||||||
|
o.inputtitle=translate("Update core version")
|
||||||
|
o.template = "AdGuardHome/AdGuardHome_check"
|
||||||
|
o.showfastconfig=(not fs.access(configpath))
|
||||||
|
o.description = string.format(translate("Current core version:") .. "<strong><font id='updateversion' color='green'>%s </font></strong>", e)
|
||||||
|
|
||||||
|
local port=luci.sys.exec("grep -A 5 '^dns:' "..configpath.." | grep 'port:' | awk '{print $2}' 2>nul")
|
||||||
|
if (port=="") then port="?" end
|
||||||
|
|
||||||
|
o = s:taboption("basic", ListValue, "redirect", port..translate("Redirect"), translate("AdGuardHome redirect mode"))
|
||||||
|
o:value("none", translate("none"))
|
||||||
|
o:value("dnsmasq-upstream", translate("Run as dnsmasq upstream server"))
|
||||||
|
o:value("redirect", translate("Redirect 53 port to AdGuardHome"))
|
||||||
|
o:value("exchange", translate("Use port 53 replace dnsmasq"))
|
||||||
|
o.default = "none"
|
||||||
|
o.optional = true
|
||||||
|
---- chpass
|
||||||
|
o = s:taboption("basic",Value, "hashpass", translate("Change management password"), translate("Press load culculate model and culculate finally save/apply"))
|
||||||
|
o.default = ""
|
||||||
|
o.datatype = "string"
|
||||||
|
o.template = "AdGuardHome/AdGuardHome_chpass"
|
||||||
|
o.optional = true
|
||||||
|
|
||||||
|
-- wait net on boot
|
||||||
|
o = s:taboption("basic", Flag, "waitonboot", translate("Start up only when the network is normal"))
|
||||||
|
o.default = 1
|
||||||
|
o.optional = false
|
||||||
|
|
||||||
|
---- Core Settings ----
|
||||||
|
s:tab("core", translate("Core Config"))
|
||||||
|
|
||||||
|
o = s:taboption("core",Value, "binpath", translate("Bin Path"), translate("AdGuardHome Bin path if no bin will auto download"))
|
||||||
|
o.default = "/usr/bin/AdGuardHome"
|
||||||
|
o.datatype = "string"
|
||||||
|
o.optional = false
|
||||||
|
o.rmempty=false
|
||||||
|
o.validate=function(self, value)
|
||||||
|
if value=="" then return nil end
|
||||||
|
if fs.stat(value,"type")=="dir" then
|
||||||
|
fs.rmdir(value)
|
||||||
|
end
|
||||||
|
if fs.stat(value,"type")=="dir" then
|
||||||
|
if (m.message) then
|
||||||
|
m.message =m.message.."\nerror!bin path is a dir"
|
||||||
|
else
|
||||||
|
m.message ="error!bin path is a dir"
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
--- upx
|
||||||
|
o = s:taboption("core",ListValue, "upxflag", translate("use upx to compress bin after download"))
|
||||||
|
o:value("", translate("none"))
|
||||||
|
o:value("-1", translate("compress faster"))
|
||||||
|
o:value("-9", translate("compress better"))
|
||||||
|
o:value("--best", translate("compress best(can be slow for big files)"))
|
||||||
|
o:value("--brute", translate("try all available compression methods & filters [slow]"))
|
||||||
|
o:value("--ultra-brute", translate("try even more compression variants [very slow]"))
|
||||||
|
o.default = ""
|
||||||
|
o.description=translate("bin use less space,but may have compatibility issues")
|
||||||
|
o.rmempty = true
|
||||||
|
---- config path
|
||||||
|
o = s:taboption("core",Value, "configpath", translate("Config Path"), translate("AdGuardHome config path"))
|
||||||
|
o.default = "/etc/AdGuardHome.yaml"
|
||||||
|
o.datatype = "string"
|
||||||
|
o.optional = false
|
||||||
|
o.rmempty=false
|
||||||
|
o.validate=function(self, value)
|
||||||
|
if value==nil then return nil end
|
||||||
|
if fs.stat(value,"type")=="dir" then
|
||||||
|
fs.rmdir(value)
|
||||||
|
end
|
||||||
|
if fs.stat(value,"type")=="dir" then
|
||||||
|
if m.message then
|
||||||
|
m.message =m.message.."\nerror!config path is a dir"
|
||||||
|
else
|
||||||
|
m.message ="error!config path is a dir"
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
---- work dir
|
||||||
|
o = s:taboption("core",Value, "workdir", translate("Work dir"), translate("AdGuardHome work dir include rules,audit log and database"))
|
||||||
|
o.default = "/etc/AdGuardHome"
|
||||||
|
o.datatype = "string"
|
||||||
|
o.optional = false
|
||||||
|
o.rmempty=false
|
||||||
|
o.validate=function(self, value)
|
||||||
|
if value=="" then return nil end
|
||||||
|
if fs.stat(value,"type")=="reg" then
|
||||||
|
if m.message then
|
||||||
|
m.message =m.message.."\nerror!work dir is a file"
|
||||||
|
else
|
||||||
|
m.message ="error!work dir is a file"
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
if string.sub(value, -1)=="/" then
|
||||||
|
return string.sub(value, 1, -2)
|
||||||
|
else
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
---- log file
|
||||||
|
o = s:taboption("core",Value, "logfile", translate("Runtime log file"), translate("AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log"))
|
||||||
|
o.datatype = "string"
|
||||||
|
o.rmempty = true
|
||||||
|
o.validate=function(self, value)
|
||||||
|
if fs.stat(value,"type")=="dir" then
|
||||||
|
fs.rmdir(value)
|
||||||
|
end
|
||||||
|
if fs.stat(value,"type")=="dir" then
|
||||||
|
if m.message then
|
||||||
|
m.message =m.message.."\nerror!log file is a dir"
|
||||||
|
else
|
||||||
|
m.message ="error!log file is a dir"
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
---- debug
|
||||||
|
o = s:taboption("core",Flag, "verbose", translate("Verbose log"))
|
||||||
|
o.default = 0
|
||||||
|
o.optional = true
|
||||||
|
---- gfwlist
|
||||||
|
local a=luci.sys.call("grep -m 1 -q programadd "..configpath)
|
||||||
|
if (a==0) then
|
||||||
|
a="Added"
|
||||||
|
else
|
||||||
|
a="Not added"
|
||||||
|
end
|
||||||
|
|
||||||
|
---- Backup Settings ----
|
||||||
|
s:tab("other", translate("Other Config"))
|
||||||
|
|
||||||
|
---- upgrade protect
|
||||||
|
o = s:taboption("other", DynamicList, "upprotect", translate("Keep files when system upgrade"))
|
||||||
|
o:value("$binpath",translate("core bin"))
|
||||||
|
o:value("$configpath",translate("config file"))
|
||||||
|
o:value("$logfile",translate("log file"))
|
||||||
|
o:value("$workdir/data/sessions.db",translate("sessions.db"))
|
||||||
|
o:value("$workdir/data/stats.db",translate("stats.db"))
|
||||||
|
o:value("$workdir/data/querylog.json",translate("querylog.json"))
|
||||||
|
o:value("$workdir/data/filters",translate("filters"))
|
||||||
|
o.widget = "checkbox"
|
||||||
|
o.default = nil
|
||||||
|
o.optional=true
|
||||||
|
|
||||||
|
---- backup workdir on shutdown
|
||||||
|
local workdir=uci:get("AdGuardHome","AdGuardHome","workdir") or "/etc/AdGuardHome"
|
||||||
|
o = s:taboption("other",MultiValue, "backupfile", translate("Backup workdir files when shutdown"))
|
||||||
|
o1 = s:taboption("other",Value, "backupwdpath", translate("Backup workdir path"))
|
||||||
|
local name
|
||||||
|
o:value("filters","filters")
|
||||||
|
o:value("stats.db","stats.db")
|
||||||
|
o:value("querylog.json","querylog.json")
|
||||||
|
o:value("sessions.db","sessions.db")
|
||||||
|
o1:depends ("backupfile", "filters")
|
||||||
|
o1:depends ("backupfile", "stats.db")
|
||||||
|
o1:depends ("backupfile", "querylog.json")
|
||||||
|
o1:depends ("backupfile", "sessions.db")
|
||||||
|
for name in fs.glob(workdir.."/data/*")
|
||||||
|
do
|
||||||
|
name=fs.basename (name)
|
||||||
|
if name~="filters" and name~="stats.db" and name~="querylog.json" and name~="sessions.db" then
|
||||||
|
o:value(name,name)
|
||||||
|
o1:depends ("backupfile", name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
o.widget = "checkbox"
|
||||||
|
o.default = nil
|
||||||
|
o.optional=false
|
||||||
|
o.description=translate("Will be restore when workdir/data is empty")
|
||||||
|
----backup workdir path
|
||||||
|
|
||||||
|
o1.default = "/etc/AdGuardHome"
|
||||||
|
o1.datatype = "string"
|
||||||
|
o1.optional = false
|
||||||
|
o1.validate=function(self, value)
|
||||||
|
if fs.stat(value,"type")=="reg" then
|
||||||
|
if m.message then
|
||||||
|
m.message =m.message.."\nerror!backup dir is a file"
|
||||||
|
else
|
||||||
|
m.message ="error!backup dir is a file"
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
if string.sub(value,-1)=="/" then
|
||||||
|
return string.sub(value, 1, -2)
|
||||||
|
else
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---- Crontab Settings ----
|
||||||
|
|
||||||
|
o = s:taboption("other",MultiValue, "crontab", translate("Crontab task"),translate("Please change time and args in crontab"))
|
||||||
|
o:value("autohost",translate("Auto update ipv6 hosts and restart AdGuardHome"))
|
||||||
|
o:value("autogfw",translate("Auto update gfwlist and restart AdGuardHome"))
|
||||||
|
o:value("autogfwipset",translate("Auto update ipset list and restart AdGuardHome"))
|
||||||
|
o.widget = "checkbox"
|
||||||
|
o.default = nil
|
||||||
|
o.optional = false
|
||||||
|
|
||||||
|
---- GFWList Settings ----
|
||||||
|
local a
|
||||||
|
if fs.access(configpath) then
|
||||||
|
a=luci.sys.call("grep -m 1 -q programadd "..configpath)
|
||||||
|
else
|
||||||
|
a=1
|
||||||
|
end
|
||||||
|
if (a==0) then
|
||||||
|
a="Added"
|
||||||
|
else
|
||||||
|
a="Not added"
|
||||||
|
end
|
||||||
|
|
||||||
|
o=s:taboption("other", Button,"gfwdel",translate("Del gfwlist"),translate(a))
|
||||||
|
o.optional = false
|
||||||
|
o.inputtitle=translate("Del")
|
||||||
|
o.write=function()
|
||||||
|
luci.sys.exec("sh /usr/share/AdGuardHome/gfw2adg.sh del 2>&1")
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin","services","AdGuardHome"))
|
||||||
|
end
|
||||||
|
o=s:taboption("other", Button,"gfwadd",translate("Add gfwlist"),translate(a))
|
||||||
|
o.optional = false
|
||||||
|
o.inputtitle=translate("Add")
|
||||||
|
o.write=function()
|
||||||
|
luci.sys.exec("sh /usr/share/AdGuardHome/gfw2adg.sh 2>&1")
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin","services","AdGuardHome"))
|
||||||
|
end
|
||||||
|
if fs.access(configpath) then
|
||||||
|
a=luci.sys.call("grep -m 1 -q ipset.txt "..configpath)
|
||||||
|
else
|
||||||
|
a=1
|
||||||
|
end
|
||||||
|
if (a==0) then
|
||||||
|
a="Added"
|
||||||
|
else
|
||||||
|
a="Not added"
|
||||||
|
end
|
||||||
|
o=s:taboption("other", Button,"gfwipsetdel",translate("Del gfwlist").." "..translate("(ipset only)"),translate(a))
|
||||||
|
o.optional = false
|
||||||
|
o.inputtitle=translate("Del")
|
||||||
|
o.write=function()
|
||||||
|
luci.sys.exec("sh /usr/share/AdGuardHome/gfwipset2adg.sh del 2>&1")
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin","services","AdGuardHome"))
|
||||||
|
end
|
||||||
|
o=s:taboption("other", Button," ",translate("Add gfwlist").." "..translate("(ipset only)"),translate(a).." "..translate("will set to name gfwlist"))
|
||||||
|
o.optional = false
|
||||||
|
o.inputtitle=translate("Add")
|
||||||
|
o.write=function()
|
||||||
|
luci.sys.exec("sh /usr/share/AdGuardHome/gfwipset2adg.sh 2>&1")
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin","services","AdGuardHome"))
|
||||||
|
end
|
||||||
|
o = s:taboption("other", Value, "gfwupstream", translate("Gfwlist upstream dns server"), translate("Gfwlist domain upstream dns service")..translate(a))
|
||||||
|
o.default = "tcp://208.67.220.220:5353"
|
||||||
|
o.datatype = "string"
|
||||||
|
o.optional = false
|
||||||
|
|
||||||
|
fs.writefile("/var/run/AdG_log_pos","0")
|
||||||
|
|
||||||
|
function m.on_commit(map)
|
||||||
|
if (fs.access("/var/run/AdGserverdis")) then
|
||||||
|
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local ucitracktest=uci:get("AdGuardHome","AdGuardHome","ucitracktest")
|
||||||
|
if ucitracktest=="1" then
|
||||||
|
return
|
||||||
|
elseif ucitracktest=="0" then
|
||||||
|
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||||
|
else
|
||||||
|
if (fs.access("/var/run/AdGlucitest")) then
|
||||||
|
uci:set("AdGuardHome","AdGuardHome","ucitracktest","0")
|
||||||
|
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||||
|
else
|
||||||
|
fs.writefile("/var/run/AdGlucitest","")
|
||||||
|
if (ucitracktest=="2") then
|
||||||
|
uci:set("AdGuardHome","AdGuardHome","ucitracktest","1")
|
||||||
|
else
|
||||||
|
uci:set("AdGuardHome","AdGuardHome","ucitracktest","2")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
uci:commit("AdGuardHome")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return m
|
||||||
16
luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/log.lua
Normal file
16
luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/log.lua
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
local fs = require "nixio.fs"
|
||||||
|
local uci = require"luci.model.uci".cursor()
|
||||||
|
local f, t
|
||||||
|
f = SimpleForm("logview")
|
||||||
|
f.reset = false
|
||||||
|
f.submit = false
|
||||||
|
t=f:field(TextValue,"conf")
|
||||||
|
t.rmempty=true
|
||||||
|
t.rows=20
|
||||||
|
t.template="AdGuardHome/log"
|
||||||
|
t.readonly="readonly"
|
||||||
|
local logfile=uci:get("AdGuardHome","AdGuardHome","logfile") or ""
|
||||||
|
t.timereplace=(logfile~="syslog" and logfile~="" )
|
||||||
|
t.pollcheck=logfile~=""
|
||||||
|
fs.writefile("/var/run/lucilogpos", "0")
|
||||||
|
return f
|
||||||
96
luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/manual.lua
Normal file
96
luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/manual.lua
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
local m, s, o
|
||||||
|
local fs = require "nixio.fs"
|
||||||
|
local uci=require"luci.model.uci".cursor()
|
||||||
|
local sys=require"luci.sys"
|
||||||
|
require("string")
|
||||||
|
require("io")
|
||||||
|
require("table")
|
||||||
|
function gen_template_config()
|
||||||
|
local b
|
||||||
|
local d=""
|
||||||
|
local file = "/tmp/resolv.conf.d/resolv.conf.auto"
|
||||||
|
if not fs.access(file) then
|
||||||
|
file = "/tmp/resolv.conf.auto"
|
||||||
|
end
|
||||||
|
for cnt in io.lines(file) do
|
||||||
|
b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$")
|
||||||
|
if (b ~= nil) then d = d .. " - " .. b .. "\n" end
|
||||||
|
end
|
||||||
|
local f=io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+")
|
||||||
|
local tbl = {}
|
||||||
|
local a=""
|
||||||
|
while (1) do
|
||||||
|
a=f:read("*l")
|
||||||
|
if (a=="#bootstrap_dns") then
|
||||||
|
a=d
|
||||||
|
elseif (a=="#upstream_dns") then
|
||||||
|
a=d
|
||||||
|
elseif (a==nil) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
table.insert(tbl, a)
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
|
return table.concat(tbl, "\n")
|
||||||
|
end
|
||||||
|
m = Map("AdGuardHome")
|
||||||
|
local configpath = uci:get("AdGuardHome","AdGuardHome","configpath")
|
||||||
|
local binpath = uci:get("AdGuardHome","AdGuardHome","binpath")
|
||||||
|
s = m:section(TypedSection, "AdGuardHome")
|
||||||
|
s.anonymous=true
|
||||||
|
s.addremove=false
|
||||||
|
--- config
|
||||||
|
o = s:option(TextValue, "escconf")
|
||||||
|
o.rows = 66
|
||||||
|
o.wrap = "off"
|
||||||
|
o.rmempty = true
|
||||||
|
o.cfgvalue = function(self, section)
|
||||||
|
return fs.readfile("/tmp/AdGuardHometmpconfig.yaml") or fs.readfile(configpath) or gen_template_config() or ""
|
||||||
|
end
|
||||||
|
o.validate=function(self, value)
|
||||||
|
fs.writefile("/tmp/AdGuardHometmpconfig.yaml", value:gsub("\r\n", "\n"))
|
||||||
|
if fs.access(binpath) then
|
||||||
|
if (sys.call(binpath .. " -c /tmp/AdGuardHometmpconfig.yaml --check-config 2> /tmp/AdGuardHometest.log") == 0) then return value end
|
||||||
|
else
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin","services","AdGuardHome","manual"))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
o.write = function(self, section, value)
|
||||||
|
fs.move("/tmp/AdGuardHometmpconfig.yaml",configpath)
|
||||||
|
end
|
||||||
|
o.remove = function(self, section, value) fs.writefile(configpath, "") end
|
||||||
|
|
||||||
|
--- js and reload button
|
||||||
|
o = s:option(DummyValue, "")
|
||||||
|
o.anonymous=true
|
||||||
|
o.template = "AdGuardHome/yamleditor"
|
||||||
|
if not fs.access(binpath) then
|
||||||
|
o.description=translate("WARNING!!! no bin found apply config will not be test")
|
||||||
|
end
|
||||||
|
--- log
|
||||||
|
if (fs.access("/tmp/AdGuardHometmpconfig.yaml")) then
|
||||||
|
local c=fs.readfile("/tmp/AdGuardHometest.log")
|
||||||
|
if (c~="") then
|
||||||
|
o = s:option(TextValue, "")
|
||||||
|
o.readonly=true
|
||||||
|
o.rows = 5
|
||||||
|
o.rmempty = true
|
||||||
|
o.name=""
|
||||||
|
o.cfgvalue = function(self, section)
|
||||||
|
return fs.readfile("/tmp/AdGuardHometest.log")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function m.on_commit(map)
|
||||||
|
local ucitracktest=uci:get("AdGuardHome","AdGuardHome","ucitracktest")
|
||||||
|
if ucitracktest=="1" then
|
||||||
|
return
|
||||||
|
elseif ucitracktest=="0" then
|
||||||
|
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||||
|
else
|
||||||
|
fs.writefile("/var/run/AdGlucitest","")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return m
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<%+cbi/valueheader%>
|
||||||
|
<%local fs=require"nixio.fs"%>
|
||||||
|
<input type="button" class="btn cbi-button cbi-button-apply" id="apply_update_button" value="<%:Update core version%>" onclick=" return apply_update() "/>
|
||||||
|
<input type="button" class="btn cbi-button cbi-button-apply" id="apply_forceupdate_button" value="<%:Force update%>" onclick=" return apply_forceupdate()" style="display:none"/>
|
||||||
|
<% if self.showfastconfig then %>
|
||||||
|
<input type="button" class="btn cbi-button cbi-button-apply" id="to_configpage" value="<%:Fast config%>" onclick="location.href='<%=url([[admin]], [[services]], [[AdGuardHome]], [[manual]])%>'"/>
|
||||||
|
<%end%>
|
||||||
|
<div id="logview" style="display:none">
|
||||||
|
<input type="checkbox" id="reversetag" value="reverse" onclick=" return reverselog()" style="vertical-align:middle;height: auto;"><%:reverse%></input>
|
||||||
|
<textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:block;" data-update="change" rows="5" cols="60" readonly="readonly" > </textarea>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
var updatebtn = document.getElementById('apply_update_button');
|
||||||
|
var forceupdatebtn = document.getElementById('apply_forceupdate_button');
|
||||||
|
var islogreverse = false;
|
||||||
|
function apply_forceupdate(){
|
||||||
|
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[doupdate]])%>',{ force: 1 },function(x, data){}
|
||||||
|
);
|
||||||
|
updatebtn.disabled = true;
|
||||||
|
poll_check();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
function reverselog(){
|
||||||
|
var lv = document.getElementById('cbid.logview.1.conf');
|
||||||
|
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
|
||||||
|
if (islogreverse){
|
||||||
|
islogreverse=false;
|
||||||
|
}else{
|
||||||
|
islogreverse=true;
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
function apply_update(){
|
||||||
|
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[doupdate]])%>',null,function(x, data){}
|
||||||
|
);
|
||||||
|
updatebtn.disabled = true;
|
||||||
|
updatebtn.value = '<%:Check...%>';
|
||||||
|
forceupdatebtn.style.display="inline"
|
||||||
|
poll_check();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
function poll_check(){
|
||||||
|
var tag = document.getElementById('logview');
|
||||||
|
tag.style.display="block"
|
||||||
|
XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[check]])%>', null,
|
||||||
|
function(x, data) {
|
||||||
|
var lv = document.getElementById('cbid.logview.1.conf');
|
||||||
|
if (x.responseText && lv) {
|
||||||
|
if (x.responseText=="\u0000"){
|
||||||
|
for(j = 0,len=this.XHR._q.length; j < len; j++) {
|
||||||
|
if (this.XHR._q[j].url == '<%=url([[admin]], [[services]], [[AdGuardHome]], [[check]])%>'){
|
||||||
|
this.XHR._q.splice(j,1);
|
||||||
|
updatebtn.disabled = false;
|
||||||
|
updatebtn.value = '<%:Updated%>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (islogreverse){
|
||||||
|
lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
|
||||||
|
}else{
|
||||||
|
lv.innerHTML += x.responseText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);}
|
||||||
|
<% if fs.access("/var/run/update_core") then %>
|
||||||
|
updatebtn.disabled = true;
|
||||||
|
updatebtn.value = '<%:Check...%>';
|
||||||
|
forceupdatebtn.style.display="inline"
|
||||||
|
poll_check();
|
||||||
|
<%elseif fs.access("/var/run/update_core_error") then %>
|
||||||
|
poll_check();
|
||||||
|
<%end%>
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<%+cbi/valuefooter%>
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<%+cbi/valueheader%>
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
function chpass(btn)
|
||||||
|
{
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.value = '<%:loading...%>';
|
||||||
|
if (typeof bcryptloaded == 'undefined' ){
|
||||||
|
var theHead = document.getElementsByTagName('head').item(0);
|
||||||
|
//创建脚本的dom对象实例
|
||||||
|
var myScript = document.createElement('script');
|
||||||
|
myScript.src = '<%=resource%>/twin-bcrypt.min.js'; //指定脚本路径
|
||||||
|
myScript.type = 'text/javascript'; //指定脚本类型
|
||||||
|
myScript.defer = true; //程序下载完后再解析和执行
|
||||||
|
theHead.appendChild(myScript);
|
||||||
|
bcryptloaded=1;
|
||||||
|
btn.value = '<%:Culculate%>';
|
||||||
|
btn.disabled = false;
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var lv = document.getElementById('cbid.AdGuardHome.AdGuardHome.hashpass');
|
||||||
|
if (lv.value != ""){
|
||||||
|
var hash = TwinBcrypt.hashSync(lv.value);
|
||||||
|
lv.value=hash;
|
||||||
|
btn.value = '<%:Please save/apply%>';
|
||||||
|
}else{
|
||||||
|
btn.value = '<%:is empty%>';
|
||||||
|
btn.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<input data-update="change"<%=
|
||||||
|
attr("id", cbid) ..
|
||||||
|
attr("name", cbid) ..
|
||||||
|
attr("type", self.password and "password" or "text") ..
|
||||||
|
attr("class", self.password and "cbi-input-password" or "cbi-input-text") ..
|
||||||
|
attr("value", self:cfgvalue(section) or self.default) ..
|
||||||
|
ifattr(self.size, "size") ..
|
||||||
|
ifattr(self.placeholder, "placeholder") ..
|
||||||
|
ifattr(self.readonly, "readonly") ..
|
||||||
|
ifattr(self.maxlength, "maxlength") ..
|
||||||
|
ifattr(self.datatype, "data-type", self.datatype) ..
|
||||||
|
ifattr(self.datatype, "data-optional", self.optional or self.rmempty) ..
|
||||||
|
ifattr(self.combobox_manual, "data-manual", self.combobox_manual) ..
|
||||||
|
ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist })
|
||||||
|
%> />
|
||||||
|
<% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
|
||||||
|
<input type="button" class="btn cbi-button cbi-button-apply" id="cbid.AdGuardHome.AdGuardHome.applychpass" value="<%:Load culculate model%>" onclick="return chpass(this)"/>
|
||||||
|
<%+cbi/valuefooter%>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[status]])%>', null,
|
||||||
|
function(x, data) {
|
||||||
|
var tb = document.getElementById('AdGuardHome_status');
|
||||||
|
if (data && tb) {
|
||||||
|
if (data.running) {
|
||||||
|
tb.innerHTML = '<em><b style=color:green>AdGuardHome <%:RUNNING%></b></em>';
|
||||||
|
} else {
|
||||||
|
tb.innerHTML = '<em><b style=color:red>AdGuardHome <%:NOT RUNNING%></b></em>';
|
||||||
|
}
|
||||||
|
if (data.redirect)
|
||||||
|
{
|
||||||
|
URL = window.location.protocol.toLowerCase() + "//" + window.location.hostname + ":<%=luci.model.uci.cursor():get("AdGuardHome", "AdGuardHome", "httpport") %>";
|
||||||
|
tb.innerHTML+='<em> <b style=color:green><%:Redirected%></b> </em> '
|
||||||
|
tb.innerHTML += "<input class=\"cbi-button cbi-button-reload \" type=\"button\" value=\" <%: Open Web Interface%>\" onclick=\"window.open('"+URL+"')\"/>";
|
||||||
|
} else {
|
||||||
|
tb.innerHTML+='<em><b style=color:red><%:Not redirect%></b></em>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||||
|
<fieldset class="cbi-section">
|
||||||
|
<p id="AdGuardHome_status">
|
||||||
|
<em><%:Collecting data...%></em>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
111
luci-app-adguardhome/luasrc/view/AdGuardHome/log.htm
Normal file
111
luci-app-adguardhome/luasrc/view/AdGuardHome/log.htm
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<%+cbi/valueheader%>
|
||||||
|
<input type="checkbox" name="NAME" value="reverse" onclick=" return reverselog()" style="vertical-align:middle;height: auto;" checked><%:reverse%></input>
|
||||||
|
<%if self.timereplace then%>
|
||||||
|
<input type="checkbox" name="NAME" value="localtime" onclick=" return chlogtime()" style="vertical-align:middle;height: auto;" checked><%:localtime%></input><br>
|
||||||
|
<%end%>
|
||||||
|
<textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="32" cols="60" readonly="readonly" > </textarea>
|
||||||
|
<input type="button" class="btn cbi-button cbi-button-apply" id="apply_update_button" value="<%:dellog%>" onclick=" return apply_del_log() "/>
|
||||||
|
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:download log%>" style=" display:inline;" onclick=" return download_log()" />
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
var islogreverse = true;
|
||||||
|
var isutc2local = <%=tostring(self.timereplace)%>;
|
||||||
|
function createAndDownloadFile(fileName, content) {
|
||||||
|
var aTag = document.createElement('a');
|
||||||
|
var blob = new Blob([content]);
|
||||||
|
aTag.download = fileName;
|
||||||
|
aTag.href = URL.createObjectURL(blob);
|
||||||
|
aTag.click();
|
||||||
|
URL.revokeObjectURL(blob);
|
||||||
|
}
|
||||||
|
function download_log(){
|
||||||
|
var lv = document.getElementById('cbid.logview.1.conf');
|
||||||
|
var dt = new Date();
|
||||||
|
var timestamp = (dt.getMonth()+1)+"-"+dt.getDate()+"-"+dt.getHours()+"_"+dt.getMinutes();
|
||||||
|
createAndDownloadFile("AdGuardHome"+timestamp+".log",lv.innerHTML)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
function apply_del_log(){
|
||||||
|
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[dodellog]])%>',null,function(x, data){
|
||||||
|
var lv = document.getElementById('cbid.logview.1.conf');
|
||||||
|
lv.innerHTML="";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
function chlogtime(){
|
||||||
|
var lv = document.getElementById('cbid.logview.1.conf');
|
||||||
|
if (isutc2local){
|
||||||
|
lv.innerHTML=line_toUTC(lv.innerHTML).join('\n');
|
||||||
|
isutc2local=false;
|
||||||
|
}else{
|
||||||
|
lv.innerHTML=line_tolocal(lv.innerHTML).join('\n');
|
||||||
|
isutc2local=true;
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
function reverselog(){
|
||||||
|
var lv = document.getElementById('cbid.logview.1.conf');
|
||||||
|
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
|
||||||
|
if (islogreverse){
|
||||||
|
islogreverse=false;
|
||||||
|
}else{
|
||||||
|
islogreverse=true;
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
function p(s) {
|
||||||
|
return s < 10 ? '0' + s: s;
|
||||||
|
}
|
||||||
|
function line_tolocal(str){
|
||||||
|
var strt=new Array();
|
||||||
|
str.trim().split('\n').forEach(function(v, i) {
|
||||||
|
var dt = new Date(v.substring(0,19)+" UTC");
|
||||||
|
if (dt != "Invalid Date"){
|
||||||
|
strt[i]=dt.getFullYear()+"/"+p(dt.getMonth()+1)+"/"+p(dt.getDate())+" "+p(dt.getHours())+":"+p(dt.getMinutes())+":"+p(dt.getSeconds())+v.substring(19);
|
||||||
|
}else{
|
||||||
|
strt[i]=v;}})
|
||||||
|
return strt
|
||||||
|
}
|
||||||
|
function line_toUTC(str){
|
||||||
|
var strt=new Array();
|
||||||
|
str.trim().split('\n').forEach(function(v, i) {
|
||||||
|
var dt = new Date(v.substring(0,19))
|
||||||
|
if (dt != "Invalid Date"){
|
||||||
|
strt[i]=dt.getUTCFullYear()+"/"+p(dt.getUTCMonth()+1)+"/"+p(dt.getUTCDate())+" "+p(dt.getUTCHours())+":"+p(dt.getUTCMinutes())+":"+p(dt.getUTCSeconds())+v.substring(19);
|
||||||
|
}else{
|
||||||
|
strt[i]=v;}})
|
||||||
|
return strt
|
||||||
|
}
|
||||||
|
function poll_check(){
|
||||||
|
XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[getlog]])%>', null,
|
||||||
|
function(x, data) {
|
||||||
|
var lv = document.getElementById('cbid.logview.1.conf');
|
||||||
|
if (x.responseText && lv) {
|
||||||
|
if (isutc2local)
|
||||||
|
{
|
||||||
|
var lines=line_toUTC(x.responseText);
|
||||||
|
if (islogreverse){
|
||||||
|
lv.innerHTML = lines.reverse().join('\n')+lv.innerHTML;
|
||||||
|
}else{
|
||||||
|
lv.innerHTML += lines.join('\n');
|
||||||
|
}
|
||||||
|
lv.innerHTML=line_tolocal(lv.innerHTML).join('\n');
|
||||||
|
}else{
|
||||||
|
if (islogreverse){
|
||||||
|
lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
|
||||||
|
}else{
|
||||||
|
lv.innerHTML += x.responseText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);}
|
||||||
|
<%if self.pollcheck then%>
|
||||||
|
poll_check();
|
||||||
|
<%else%>
|
||||||
|
var lv = document.getElementById('cbid.logview.1.conf');
|
||||||
|
lv.innerHTML="<%:Please add log path in config to enable log%>"
|
||||||
|
<%end%>
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<%+cbi/valuefooter%>
|
||||||
45
luci-app-adguardhome/luasrc/view/AdGuardHome/yamleditor.htm
Normal file
45
luci-app-adguardhome/luasrc/view/AdGuardHome/yamleditor.htm
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<%+cbi/valueheader%>
|
||||||
|
<script src="/luci-static/resources/codemirror/lib/codemirror.js"></script>
|
||||||
|
<link rel="stylesheet" href="/luci-static/resources/codemirror/lib/codemirror.css"/>
|
||||||
|
<script src="/luci-static/resources/codemirror/mode/yaml/yaml.js"></script>
|
||||||
|
<link rel="stylesheet" href="/luci-static/resources/codemirror/theme/dracula.css"/>
|
||||||
|
<link rel="stylesheet" href="/luci-static/resources/codemirror/addon/fold/foldgutter.css"/>
|
||||||
|
<script src="/luci-static/resources/codemirror/addon/fold/foldcode.js"></script>
|
||||||
|
<script src="/luci-static/resources/codemirror/addon/fold/foldgutter.js"></script>
|
||||||
|
<script src="/luci-static/resources/codemirror/addon/fold/indent-fold.js"></script>
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
var editor = CodeMirror.fromTextArea(document.getElementById("cbid.AdGuardHome.AdGuardHome.escconf"), {
|
||||||
|
mode: "text/yaml", //实现groovy代码高亮
|
||||||
|
styleActiveLine: true,
|
||||||
|
lineNumbers: true, //显示行号
|
||||||
|
theme: "dracula", //设置主题
|
||||||
|
lineWrapping: true, //代码折叠
|
||||||
|
foldGutter: true,
|
||||||
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||||
|
matchBrackets: true //括号匹配
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// 设置编辑器占满容器宽度
|
||||||
|
editor.setSize("100%", "70vh");
|
||||||
|
// 窗口大小改变时自动调整
|
||||||
|
window.addEventListener('resize', function() {
|
||||||
|
editor.refresh();
|
||||||
|
});
|
||||||
|
function reload_config(){
|
||||||
|
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[reloadconfig]])%>', null,
|
||||||
|
function(x, data) {
|
||||||
|
location.reload();
|
||||||
|
});}
|
||||||
|
function use_template(){
|
||||||
|
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[gettemplateconfig]])%>', null,
|
||||||
|
function(x, data) {
|
||||||
|
editor.setValue(x.responseText)
|
||||||
|
});}
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<%fs=require"nixio.fs"%>
|
||||||
|
<%if fs.access("/tmp/AdGuardHometmpconfig.yaml") then%>
|
||||||
|
<input type="button" id="apply_update_button" value="<%:Reload Config%>" onclick=" return reload_config() "/>
|
||||||
|
<%end%>
|
||||||
|
<input type="button" id="template_button" value="<%:Use template%>" onclick=" return use_template() "/>
|
||||||
|
<%+cbi/valuefooter%>
|
||||||
297
luci-app-adguardhome/po/zh-cn/AdGuardHome.po
Normal file
297
luci-app-adguardhome/po/zh-cn/AdGuardHome.po
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
|
||||||
|
msgid "Base Setting"
|
||||||
|
msgstr "基础设置"
|
||||||
|
|
||||||
|
msgid "Log"
|
||||||
|
msgstr "日志"
|
||||||
|
|
||||||
|
msgid "AdGuardHome's version"
|
||||||
|
msgstr "AdGuardHome 版本"
|
||||||
|
|
||||||
|
msgid "Needed to click 'save&apply' to generate the configuration file"
|
||||||
|
msgstr "需要点击“保存并应用”才能生成配置文件"
|
||||||
|
|
||||||
|
msgid "In case of the latest realease is a source code that can not download the binary file"
|
||||||
|
msgstr "防止最新release只有源码,导致下载不成功"
|
||||||
|
|
||||||
|
msgid "Manual Config"
|
||||||
|
msgstr "手动设置"
|
||||||
|
|
||||||
|
msgid "Free and open source, powerful network-wide ads & trackers blocking DNS server."
|
||||||
|
msgstr "全网络广告和跟踪程序拦截DNS服务器,默认账号和密码均为:admin"
|
||||||
|
|
||||||
|
msgid "RUNNING"
|
||||||
|
msgstr "运行中"
|
||||||
|
|
||||||
|
msgid "NOT RUNNING"
|
||||||
|
msgstr "未运行"
|
||||||
|
|
||||||
|
msgid "Redirected"
|
||||||
|
msgstr "已重定向"
|
||||||
|
|
||||||
|
msgid "Not redirect"
|
||||||
|
msgstr "未重定向"
|
||||||
|
|
||||||
|
msgid "Collecting data..."
|
||||||
|
msgstr "获取数据中..."
|
||||||
|
|
||||||
|
msgid "Enable"
|
||||||
|
msgstr "启用"
|
||||||
|
|
||||||
|
msgid "Browser management port"
|
||||||
|
msgstr "网页管理端口"
|
||||||
|
|
||||||
|
msgid "Upgrade Core"
|
||||||
|
msgstr "更新核心"
|
||||||
|
|
||||||
|
msgid "Update core version"
|
||||||
|
msgstr "更新核心版本"
|
||||||
|
|
||||||
|
msgid "Check..."
|
||||||
|
msgstr "检查中..."
|
||||||
|
|
||||||
|
msgid "Updated"
|
||||||
|
msgstr "已更新"
|
||||||
|
|
||||||
|
msgid "Force update"
|
||||||
|
msgstr "强制更新核心"
|
||||||
|
|
||||||
|
msgid "Fast config"
|
||||||
|
msgstr "快速配置"
|
||||||
|
|
||||||
|
msgid "Core Version"
|
||||||
|
msgstr "核心版本"
|
||||||
|
|
||||||
|
msgid "Latest Version"
|
||||||
|
msgstr "最新版"
|
||||||
|
|
||||||
|
msgid "Beta Version"
|
||||||
|
msgstr "测试版"
|
||||||
|
|
||||||
|
msgid "Current core version:"
|
||||||
|
msgstr "当前核心版本:"
|
||||||
|
|
||||||
|
msgid "core version:"
|
||||||
|
msgstr "核心版本:"
|
||||||
|
|
||||||
|
msgid "no config"
|
||||||
|
msgstr "没有配置文件"
|
||||||
|
|
||||||
|
msgid "no core"
|
||||||
|
msgstr "没有核心"
|
||||||
|
|
||||||
|
msgid "Redirect"
|
||||||
|
msgstr "重定向"
|
||||||
|
|
||||||
|
msgid "none"
|
||||||
|
msgstr "无"
|
||||||
|
|
||||||
|
msgid "Run as dnsmasq upstream server"
|
||||||
|
msgstr "作为dnsmasq的上游服务器"
|
||||||
|
|
||||||
|
msgid "Redirect 53 port to AdGuardHome"
|
||||||
|
msgstr "重定向53端口到AdGuardHome"
|
||||||
|
|
||||||
|
msgid "Use port 53 replace dnsmasq"
|
||||||
|
msgstr "使用53端口替换dnsmasq"
|
||||||
|
|
||||||
|
msgid "AdGuardHome redirect mode"
|
||||||
|
msgstr "AdGuardHome重定向模式"
|
||||||
|
|
||||||
|
msgid "Bin Path"
|
||||||
|
msgstr "执行文件路径"
|
||||||
|
|
||||||
|
msgid "AdGuardHome Bin path if no bin will auto download"
|
||||||
|
msgstr "AdGuardHome 执行文件路径 如果没有执行文件将自动下载"
|
||||||
|
|
||||||
|
msgid "use upx to compress bin after download"
|
||||||
|
msgstr "下载后使用upx压缩执行文件"
|
||||||
|
|
||||||
|
msgid "compress faster"
|
||||||
|
msgstr "快速压缩"
|
||||||
|
|
||||||
|
msgid "compress better"
|
||||||
|
msgstr "更好的压缩"
|
||||||
|
|
||||||
|
msgid "compress best(can be slow for big files)"
|
||||||
|
msgstr "最好的压缩(大文件可能慢)"
|
||||||
|
|
||||||
|
msgid "try all available compression methods & filters [slow]"
|
||||||
|
msgstr "尝试所有可能的压缩方法和过滤器[慢]"
|
||||||
|
|
||||||
|
msgid "try even more compression variants [very slow]"
|
||||||
|
msgstr "尝试更多变体压缩手段[很慢]"
|
||||||
|
|
||||||
|
msgid "bin use less space,but may have compatibility issues"
|
||||||
|
msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题"
|
||||||
|
|
||||||
|
msgid "Config Path"
|
||||||
|
msgstr "配置文件路径"
|
||||||
|
|
||||||
|
msgid "AdGuardHome config path"
|
||||||
|
msgstr "AdGuardHome 配置文件路径"
|
||||||
|
|
||||||
|
msgid "Work dir"
|
||||||
|
msgstr "工作目录"
|
||||||
|
|
||||||
|
msgid "AdGuardHome work dir include rules,audit log and database"
|
||||||
|
msgstr "AdGuardHome 工作目录包含规则,审计日志和数据库"
|
||||||
|
|
||||||
|
msgid "Runtime log file"
|
||||||
|
msgstr "运行日志路径"
|
||||||
|
|
||||||
|
msgid "AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log"
|
||||||
|
msgstr "AdGuardHome 运行日志, 如果填 syslog 将写入系统日志; 如果该项为空则不记录运行日志"
|
||||||
|
|
||||||
|
msgid "Verbose log"
|
||||||
|
msgstr "输出详细日志"
|
||||||
|
|
||||||
|
msgid "Add gfwlist"
|
||||||
|
msgstr "添加 GFW 列表"
|
||||||
|
|
||||||
|
msgid "Add"
|
||||||
|
msgstr "添加"
|
||||||
|
|
||||||
|
msgid "Added"
|
||||||
|
msgstr "已添加"
|
||||||
|
|
||||||
|
msgid "Not added"
|
||||||
|
msgstr "未添加"
|
||||||
|
|
||||||
|
msgid "Del gfwlist"
|
||||||
|
msgstr "删除gfw列表"
|
||||||
|
|
||||||
|
msgid "Del"
|
||||||
|
msgstr "删除"
|
||||||
|
|
||||||
|
msgid "Gfwlist upstream dns server"
|
||||||
|
msgstr "gfw列表上游服务器"
|
||||||
|
|
||||||
|
msgid "Gfwlist domain upstream dns service"
|
||||||
|
msgstr "gfw列表域名上游服务器"
|
||||||
|
|
||||||
|
msgid "Change management password"
|
||||||
|
msgstr "更改登录密码"
|
||||||
|
|
||||||
|
msgid "Culculate"
|
||||||
|
msgstr "计算"
|
||||||
|
|
||||||
|
msgid "Load culculate model"
|
||||||
|
msgstr "载入计算模块"
|
||||||
|
|
||||||
|
msgid "loading..."
|
||||||
|
msgstr "载入中"
|
||||||
|
|
||||||
|
msgid "Please save/apply"
|
||||||
|
msgstr "请点击[保存/应用]"
|
||||||
|
|
||||||
|
msgid "is empty"
|
||||||
|
msgstr "为空"
|
||||||
|
|
||||||
|
msgid "Press load culculate model and culculate finally save/apply"
|
||||||
|
msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]"
|
||||||
|
|
||||||
|
msgid "Keep files when system upgrade"
|
||||||
|
msgstr "系统升级时保留文件"
|
||||||
|
|
||||||
|
msgid "core bin"
|
||||||
|
msgstr "核心执行文件"
|
||||||
|
|
||||||
|
msgid "config file"
|
||||||
|
msgstr "配置文件"
|
||||||
|
|
||||||
|
msgid "log file"
|
||||||
|
msgstr "日志文件"
|
||||||
|
|
||||||
|
msgid "querylog.json"
|
||||||
|
msgstr "审计日志.json"
|
||||||
|
|
||||||
|
msgid "On boot when network ok restart"
|
||||||
|
msgstr "开机后网络准备好时重启"
|
||||||
|
|
||||||
|
msgid "Backup workdir files when shutdown"
|
||||||
|
msgstr "在关机时备份工作目录文件"
|
||||||
|
|
||||||
|
msgid "Will be restore when workdir/data is empty"
|
||||||
|
msgstr "在工作目录/data为空的时候恢复"
|
||||||
|
|
||||||
|
msgid "Backup workdir path"
|
||||||
|
msgstr "工作目录备份路径"
|
||||||
|
|
||||||
|
msgid "Crontab task"
|
||||||
|
msgstr "计划任务"
|
||||||
|
|
||||||
|
msgid "Auto update core"
|
||||||
|
msgstr "自动升级核心"
|
||||||
|
|
||||||
|
msgid "Auto tail querylog"
|
||||||
|
msgstr "自动截短查询日志"
|
||||||
|
|
||||||
|
msgid "Auto tail runtime log"
|
||||||
|
msgstr "自动截短运行日志"
|
||||||
|
|
||||||
|
msgid "Auto update ipv6 hosts and restart adh"
|
||||||
|
msgstr "自动更新ipv6主机并重启adh"
|
||||||
|
|
||||||
|
msgid "Auto update gfwlist and restart adh"
|
||||||
|
msgstr "自动更新gfw列表并重启adh"
|
||||||
|
|
||||||
|
msgid "Please change time and args in crontab"
|
||||||
|
msgstr "请在计划任务中修改时间和参数"
|
||||||
|
|
||||||
|
msgid "Core Update URL"
|
||||||
|
msgstr "核心更新地址"
|
||||||
|
|
||||||
|
msgid "reverse"
|
||||||
|
msgstr "逆序"
|
||||||
|
|
||||||
|
msgid "localtime"
|
||||||
|
msgstr "本地时间"
|
||||||
|
|
||||||
|
msgid "Please add log path in config to enable log"
|
||||||
|
msgstr "请在设置里填写日志路径以启用日志"
|
||||||
|
|
||||||
|
msgid "dellog"
|
||||||
|
msgstr "删除日志"
|
||||||
|
|
||||||
|
msgid "download log"
|
||||||
|
msgstr "下载日志"
|
||||||
|
|
||||||
|
msgid "Use template"
|
||||||
|
msgstr "使用模板"
|
||||||
|
|
||||||
|
msgid "Reload Config"
|
||||||
|
msgstr "重新载入配置"
|
||||||
|
|
||||||
|
msgid "WARNING!!! no bin found apply config will not be test"
|
||||||
|
msgstr "警告!!!未找到执行文件,提交配置将不会进行校验"
|
||||||
|
|
||||||
|
msgid "Change browser management username"
|
||||||
|
msgstr "改变网页登录用户名"
|
||||||
|
|
||||||
|
msgid "Username"
|
||||||
|
msgstr "用户名"
|
||||||
|
|
||||||
|
msgid "Check Config"
|
||||||
|
msgstr "检查配置"
|
||||||
|
|
||||||
|
msgid "unknown"
|
||||||
|
msgstr "未知"
|
||||||
|
|
||||||
|
msgid "Keep database when system upgrade"
|
||||||
|
msgstr "系统升级时保留数据"
|
||||||
|
|
||||||
|
msgid "Start up only when the network is normal"
|
||||||
|
msgstr "开机网络正常才启动"
|
||||||
|
|
||||||
|
msgid "Other Settings"
|
||||||
|
msgstr "其它设置"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
301
luci-app-adguardhome/po/zh_Hans/AdGuardHome.po
Normal file
301
luci-app-adguardhome/po/zh_Hans/AdGuardHome.po
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
|
||||||
|
|
||||||
|
msgid "Log"
|
||||||
|
msgstr "日志"
|
||||||
|
|
||||||
|
msgid "AdGuardHome's version"
|
||||||
|
msgstr "AdGuardHome 版本"
|
||||||
|
|
||||||
|
msgid "Needed to click 'save&apply' to generate the configuration file"
|
||||||
|
msgstr "需要点击“保存并应用”才能生成配置文件"
|
||||||
|
|
||||||
|
msgid "In case of the latest realease is a source code that can not download the binary file"
|
||||||
|
msgstr "防止最新release只有源码,导致下载不成功"
|
||||||
|
|
||||||
|
msgid "Manual Config"
|
||||||
|
msgstr "手动设置"
|
||||||
|
|
||||||
|
msgid "Free and open source, powerful network-wide ads & trackers blocking DNS server."
|
||||||
|
msgstr "全网络广告和跟踪程序拦截DNS服务器,默认账号和密码均为:admin"
|
||||||
|
|
||||||
|
msgid "RUNNING"
|
||||||
|
msgstr "运行中"
|
||||||
|
|
||||||
|
msgid "NOT RUNNING"
|
||||||
|
msgstr "未运行"
|
||||||
|
|
||||||
|
msgid "Redirected"
|
||||||
|
msgstr "已重定向"
|
||||||
|
|
||||||
|
msgid "Not redirect"
|
||||||
|
msgstr "未重定向"
|
||||||
|
|
||||||
|
msgid "Collecting data..."
|
||||||
|
msgstr "获取数据中..."
|
||||||
|
|
||||||
|
msgid "Enable"
|
||||||
|
msgstr "启用"
|
||||||
|
|
||||||
|
msgid "Browser management port"
|
||||||
|
msgstr "网页管理端口"
|
||||||
|
|
||||||
|
msgid "Upgrade Core"
|
||||||
|
msgstr "更新核心"
|
||||||
|
|
||||||
|
msgid "Update core version"
|
||||||
|
msgstr "更新核心版本"
|
||||||
|
|
||||||
|
msgid "Check..."
|
||||||
|
msgstr "检查中..."
|
||||||
|
|
||||||
|
msgid "Updated"
|
||||||
|
msgstr "已更新"
|
||||||
|
|
||||||
|
msgid "Force update"
|
||||||
|
msgstr "强制更新核心"
|
||||||
|
|
||||||
|
msgid "Fast config"
|
||||||
|
msgstr "快速配置"
|
||||||
|
|
||||||
|
msgid "Core Version"
|
||||||
|
msgstr "核心版本"
|
||||||
|
|
||||||
|
msgid "Latest Version"
|
||||||
|
msgstr "最新版"
|
||||||
|
|
||||||
|
msgid "Beta Version"
|
||||||
|
msgstr "测试版"
|
||||||
|
|
||||||
|
msgid "Current core version:"
|
||||||
|
msgstr "当前核心版本:"
|
||||||
|
|
||||||
|
msgid "core version:"
|
||||||
|
msgstr "核心版本:"
|
||||||
|
|
||||||
|
msgid "no config"
|
||||||
|
msgstr "没有配置文件"
|
||||||
|
|
||||||
|
msgid "no core"
|
||||||
|
msgstr "没有核心"
|
||||||
|
|
||||||
|
msgid "Redirect"
|
||||||
|
msgstr "重定向"
|
||||||
|
|
||||||
|
msgid "none"
|
||||||
|
msgstr "无"
|
||||||
|
|
||||||
|
msgid "Run as dnsmasq upstream server"
|
||||||
|
msgstr "作为dnsmasq的上游服务器"
|
||||||
|
|
||||||
|
msgid "Redirect 53 port to AdGuardHome"
|
||||||
|
msgstr "重定向53端口到AdGuardHome"
|
||||||
|
|
||||||
|
msgid "Use port 53 replace dnsmasq"
|
||||||
|
msgstr "使用53端口替换dnsmasq"
|
||||||
|
|
||||||
|
msgid "AdGuardHome redirect mode"
|
||||||
|
msgstr "AdGuardHome重定向模式"
|
||||||
|
|
||||||
|
msgid "Bin Path"
|
||||||
|
msgstr "执行文件路径"
|
||||||
|
|
||||||
|
msgid "AdGuardHome Bin path if no bin will auto download"
|
||||||
|
msgstr "AdGuardHome 执行文件路径 如果没有执行文件将自动下载"
|
||||||
|
|
||||||
|
msgid "use upx to compress bin after download"
|
||||||
|
msgstr "下载后使用upx压缩执行文件"
|
||||||
|
|
||||||
|
msgid "compress faster"
|
||||||
|
msgstr "快速压缩"
|
||||||
|
|
||||||
|
msgid "compress better"
|
||||||
|
msgstr "更好的压缩"
|
||||||
|
|
||||||
|
msgid "compress best(can be slow for big files)"
|
||||||
|
msgstr "最好的压缩(大文件可能慢)"
|
||||||
|
|
||||||
|
msgid "try all available compression methods & filters [slow]"
|
||||||
|
msgstr "尝试所有可能的压缩方法和过滤器[慢]"
|
||||||
|
|
||||||
|
msgid "try even more compression variants [very slow]"
|
||||||
|
msgstr "尝试更多变体压缩手段[很慢]"
|
||||||
|
|
||||||
|
msgid "bin use less space,but may have compatibility issues"
|
||||||
|
msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题"
|
||||||
|
|
||||||
|
msgid "Config Path"
|
||||||
|
msgstr "配置文件路径"
|
||||||
|
|
||||||
|
msgid "AdGuardHome config path"
|
||||||
|
msgstr "AdGuardHome 配置文件路径"
|
||||||
|
|
||||||
|
msgid "Work dir"
|
||||||
|
msgstr "工作目录"
|
||||||
|
|
||||||
|
msgid "AdGuardHome work dir include rules,audit log and database"
|
||||||
|
msgstr "AdGuardHome 工作目录包含规则,审计日志和数据库"
|
||||||
|
|
||||||
|
msgid "Runtime log file"
|
||||||
|
msgstr "运行日志路径"
|
||||||
|
|
||||||
|
msgid "AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log"
|
||||||
|
msgstr "AdGuardHome 运行日志, 如果填 syslog 将写入系统日志; 如果该项为空则不记录运行日志"
|
||||||
|
|
||||||
|
msgid "Verbose log"
|
||||||
|
msgstr "输出详细日志"
|
||||||
|
|
||||||
|
msgid "Add gfwlist"
|
||||||
|
msgstr "添加 GFW 列表"
|
||||||
|
|
||||||
|
msgid "Add"
|
||||||
|
msgstr "添加"
|
||||||
|
|
||||||
|
msgid "Added"
|
||||||
|
msgstr "已添加"
|
||||||
|
|
||||||
|
msgid "Not added"
|
||||||
|
msgstr "未添加"
|
||||||
|
|
||||||
|
msgid "Del gfwlist"
|
||||||
|
msgstr "删除gfw列表"
|
||||||
|
|
||||||
|
msgid "Del"
|
||||||
|
msgstr "删除"
|
||||||
|
|
||||||
|
msgid "Gfwlist upstream dns server"
|
||||||
|
msgstr "gfw列表上游服务器"
|
||||||
|
|
||||||
|
msgid "Gfwlist domain upstream dns service"
|
||||||
|
msgstr "gfw列表域名上游服务器"
|
||||||
|
|
||||||
|
msgid "Change management password"
|
||||||
|
msgstr "更改登录密码"
|
||||||
|
|
||||||
|
msgid "Culculate"
|
||||||
|
msgstr "计算"
|
||||||
|
|
||||||
|
msgid "Load culculate model"
|
||||||
|
msgstr "载入计算模块"
|
||||||
|
|
||||||
|
msgid "loading..."
|
||||||
|
msgstr "载入中"
|
||||||
|
|
||||||
|
msgid "Please save/apply"
|
||||||
|
msgstr "请点击[保存/应用]"
|
||||||
|
|
||||||
|
msgid "is empty"
|
||||||
|
msgstr "为空"
|
||||||
|
|
||||||
|
msgid "Press load culculate model and culculate finally save/apply"
|
||||||
|
msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]"
|
||||||
|
|
||||||
|
msgid "Keep files when system upgrade"
|
||||||
|
msgstr "系统升级时保留文件"
|
||||||
|
|
||||||
|
msgid "core bin"
|
||||||
|
msgstr "核心执行文件"
|
||||||
|
|
||||||
|
msgid "config file"
|
||||||
|
msgstr "配置文件"
|
||||||
|
|
||||||
|
msgid "log file"
|
||||||
|
msgstr "日志文件"
|
||||||
|
|
||||||
|
msgid "querylog.json"
|
||||||
|
msgstr "审计日志.json"
|
||||||
|
|
||||||
|
msgid "On boot when network ok restart"
|
||||||
|
msgstr "开机后网络准备好时重启"
|
||||||
|
|
||||||
|
msgid "Backup workdir files when shutdown"
|
||||||
|
msgstr "在关机时备份工作目录文件"
|
||||||
|
|
||||||
|
msgid "Will be restore when workdir/data is empty"
|
||||||
|
msgstr "在工作目录/data为空的时候恢复"
|
||||||
|
|
||||||
|
msgid "Backup workdir path"
|
||||||
|
msgstr "工作目录备份路径"
|
||||||
|
|
||||||
|
msgid "Crontab task"
|
||||||
|
msgstr "计划任务"
|
||||||
|
|
||||||
|
msgid "Auto update core"
|
||||||
|
msgstr "自动升级核心"
|
||||||
|
|
||||||
|
msgid "Auto tail querylog"
|
||||||
|
msgstr "自动截短查询日志"
|
||||||
|
|
||||||
|
msgid "Auto tail runtime log"
|
||||||
|
msgstr "自动截短运行日志"
|
||||||
|
|
||||||
|
msgid "Auto update ipv6 hosts and restart AdGuardHome"
|
||||||
|
msgstr "自动更新ipv6主机并重启AdGuardHome"
|
||||||
|
|
||||||
|
msgid "Auto update gfwlist and restart AdGuardHome"
|
||||||
|
msgstr "自动更新gfw列表并重启AdGuardHome"
|
||||||
|
|
||||||
|
msgid "Auto update ipset list and restart AdGuardHome"
|
||||||
|
msgstr "自动更新ipset列表并重启AdGuardHome"
|
||||||
|
|
||||||
|
msgid "Please change time and args in crontab"
|
||||||
|
msgstr "请在计划任务中修改时间和参数"
|
||||||
|
|
||||||
|
msgid "Core Update URL"
|
||||||
|
msgstr "核心更新地址"
|
||||||
|
|
||||||
|
msgid "reverse"
|
||||||
|
msgstr "逆序"
|
||||||
|
|
||||||
|
msgid "localtime"
|
||||||
|
msgstr "本地时间"
|
||||||
|
|
||||||
|
msgid "Please add log path in config to enable log"
|
||||||
|
msgstr "请在设置里填写日志路径以启用日志"
|
||||||
|
|
||||||
|
msgid "dellog"
|
||||||
|
msgstr "删除日志"
|
||||||
|
|
||||||
|
msgid "download log"
|
||||||
|
msgstr "下载日志"
|
||||||
|
|
||||||
|
msgid "Use template"
|
||||||
|
msgstr "使用模板"
|
||||||
|
|
||||||
|
msgid "Reload Config"
|
||||||
|
msgstr "重新载入配置"
|
||||||
|
|
||||||
|
msgid "WARNING!!! no bin found apply config will not be test"
|
||||||
|
msgstr "警告!!!未找到执行文件,提交配置将不会进行校验"
|
||||||
|
|
||||||
|
msgid "Change browser management username"
|
||||||
|
msgstr "改变网页登录用户名"
|
||||||
|
|
||||||
|
msgid "Username"
|
||||||
|
msgstr "用户名"
|
||||||
|
|
||||||
|
msgid "Check Config"
|
||||||
|
msgstr "检查配置"
|
||||||
|
|
||||||
|
msgid "unknown"
|
||||||
|
msgstr "未知"
|
||||||
|
|
||||||
|
msgid "Keep database when system upgrade"
|
||||||
|
msgstr "系统升级时保留数据"
|
||||||
|
|
||||||
|
msgid "Start up only when the network is normal"
|
||||||
|
msgstr "开机网络正常才启动"
|
||||||
|
|
||||||
|
msgid "Main Config"
|
||||||
|
msgstr "主要设置"
|
||||||
|
|
||||||
|
msgid "Other Config"
|
||||||
|
msgstr "其它设置"
|
||||||
|
|
||||||
|
msgid "Core Config"
|
||||||
|
msgstr "内核设置"
|
||||||
|
|
||||||
|
msgid "will set to name gfwlist"
|
||||||
|
msgstr "将设置为gfwlist名称"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
138
luci-app-adguardhome/root/etc/AdGuardHome.yaml
Normal file
138
luci-app-adguardhome/root/etc/AdGuardHome.yaml
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
http:
|
||||||
|
address: 0.0.0.0:3000
|
||||||
|
session_ttl: 720h
|
||||||
|
users:
|
||||||
|
- name: admin
|
||||||
|
password: $2y$10$vHRcARdPCieYG3RXWomV5evDYN.Nj/edtwEkQgQJZcK6z7qTLaIc6
|
||||||
|
auth_attempts: 5
|
||||||
|
block_auth_min: 15
|
||||||
|
http_proxy: ""
|
||||||
|
language: zh-cn
|
||||||
|
theme: auto
|
||||||
|
debug_pprof: false
|
||||||
|
dns:
|
||||||
|
bind_hosts:
|
||||||
|
- 0.0.0.0
|
||||||
|
port: 5553
|
||||||
|
anonymize_client_ip: false
|
||||||
|
protection_enabled: true
|
||||||
|
blocking_mode: default
|
||||||
|
blocking_ipv4: ""
|
||||||
|
blocking_ipv6: ""
|
||||||
|
blocked_response_ttl: 10
|
||||||
|
protection_disabled_until: null
|
||||||
|
parental_block_host: family-block.dns.adguard.com
|
||||||
|
safebrowsing_block_host: standard-block.dns.adguard.com
|
||||||
|
ratelimit: 0
|
||||||
|
ratelimit_whitelist: []
|
||||||
|
refuse_any: false
|
||||||
|
upstream_dns:
|
||||||
|
- 223.5.5.5
|
||||||
|
upstream_dns_file: ""
|
||||||
|
bootstrap_dns:
|
||||||
|
- 119.29.29.29
|
||||||
|
- 223.5.5.5
|
||||||
|
all_servers: false
|
||||||
|
fastest_addr: false
|
||||||
|
fastest_timeout: 1s
|
||||||
|
allowed_clients: []
|
||||||
|
disallowed_clients: []
|
||||||
|
blocked_hosts:
|
||||||
|
- version.bind
|
||||||
|
- id.server
|
||||||
|
- hostname.bind
|
||||||
|
trusted_proxies:
|
||||||
|
- 127.0.0.0/8
|
||||||
|
- ::1/128
|
||||||
|
cache_size: 4194304
|
||||||
|
cache_ttl_min: 0
|
||||||
|
cache_ttl_max: 0
|
||||||
|
cache_optimistic: true
|
||||||
|
bogus_nxdomain: []
|
||||||
|
aaaa_disabled: false
|
||||||
|
enable_dnssec: false
|
||||||
|
edns_client_subnet: false
|
||||||
|
max_goroutines: 300
|
||||||
|
ipset: []
|
||||||
|
filtering_enabled: true
|
||||||
|
filters_update_interval: 24
|
||||||
|
parental_enabled: false
|
||||||
|
safesearch_enabled: false
|
||||||
|
safebrowsing_enabled: false
|
||||||
|
safebrowsing_cache_size: 1048576
|
||||||
|
safesearch_cache_size: 1048576
|
||||||
|
parental_cache_size: 1048576
|
||||||
|
cache_time: 30
|
||||||
|
rewrites: []
|
||||||
|
blocked_services: []
|
||||||
|
upstream_timeout: 10s
|
||||||
|
private_networks: []
|
||||||
|
use_private_ptr_resolvers: true
|
||||||
|
local_ptr_upstreams: []
|
||||||
|
tls:
|
||||||
|
enabled: false
|
||||||
|
server_name: ""
|
||||||
|
force_https: false
|
||||||
|
port_https: 443
|
||||||
|
port_dns_over_tls: 853
|
||||||
|
port_dns_over_quic: 784
|
||||||
|
port_dnscrypt: 0
|
||||||
|
dnscrypt_config_file: ""
|
||||||
|
allow_unencrypted_doh: false
|
||||||
|
certificate_chain: ""
|
||||||
|
private_key: ""
|
||||||
|
certificate_path: ""
|
||||||
|
private_key_path: ""
|
||||||
|
filters:
|
||||||
|
- enabled: true
|
||||||
|
url: https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt
|
||||||
|
name: AdGuard DNS filter
|
||||||
|
id: 1228750870
|
||||||
|
- enabled: true
|
||||||
|
url: https://easylist-downloads.adblockplus.org/easylist.txt
|
||||||
|
name: EasyList-去除国际网页中大多数广告,包括不需要的框架、图像和对象
|
||||||
|
id: 139789112
|
||||||
|
- enabled: true
|
||||||
|
url: https://easylist-downloads.adblockplus.org/easylistchina.txt
|
||||||
|
name: EasyList China-EasyList针对国内的补充规则
|
||||||
|
id: 139789121
|
||||||
|
- enabled: true
|
||||||
|
url: https://anti-ad.net/easylist.txt
|
||||||
|
name: anti-AD命中率最高列表
|
||||||
|
id: 139789221
|
||||||
|
- enabled: true
|
||||||
|
url: https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt
|
||||||
|
name: AdGuard DNS filter
|
||||||
|
id: 139789332
|
||||||
|
- enabled: false
|
||||||
|
url: https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt
|
||||||
|
name: AdAway Default Blocklist
|
||||||
|
id: 149789121
|
||||||
|
whitelist_filters: []
|
||||||
|
user_rules:
|
||||||
|
|
||||||
|
dhcp:
|
||||||
|
enabled: false
|
||||||
|
interface_name: ""
|
||||||
|
dhcpv4:
|
||||||
|
gateway_ip: ""
|
||||||
|
subnet_mask: ""
|
||||||
|
range_start: ""
|
||||||
|
range_end: ""
|
||||||
|
lease_duration: 86400
|
||||||
|
icmp_timeout_msec: 1000
|
||||||
|
options: []
|
||||||
|
dhcpv6:
|
||||||
|
range_start: ""
|
||||||
|
lease_duration: 86400
|
||||||
|
ra_slaac_only: false
|
||||||
|
ra_allow_slaac: false
|
||||||
|
clients: []
|
||||||
|
log_compress: false
|
||||||
|
log_localtime: false
|
||||||
|
log_max_backups: 0
|
||||||
|
log_max_size: 100
|
||||||
|
log_max_age: 3
|
||||||
|
log_file: ""
|
||||||
|
verbose: false
|
||||||
|
schema_version: 10
|
||||||
13
luci-app-adguardhome/root/etc/config/AdGuardHome
Normal file
13
luci-app-adguardhome/root/etc/config/AdGuardHome
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
config AdGuardHome 'AdGuardHome'
|
||||||
|
option configpath '/etc/AdGuardHome.yaml'
|
||||||
|
option workdir '/etc/AdGuardHome'
|
||||||
|
option redirect 'dnsmasq-upstream'
|
||||||
|
option logfile '/tmp/AdGuardHome.log'
|
||||||
|
option verbose '0'
|
||||||
|
option binpath '/usr/bin/AdGuardHome'
|
||||||
|
option enabled '0'
|
||||||
|
option core_version 'latest'
|
||||||
|
option waitonboot '1'
|
||||||
|
option upxflag '-9'
|
||||||
|
option update_url 'https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz'
|
||||||
609
luci-app-adguardhome/root/etc/init.d/AdGuardHome
Normal file
609
luci-app-adguardhome/root/etc/init.d/AdGuardHome
Normal file
@@ -0,0 +1,609 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
START=95
|
||||||
|
STOP=01
|
||||||
|
|
||||||
|
ipt=$(command -v iptables-legacy || command -v iptables)
|
||||||
|
ip6t=$(command -v ip6tables-legacy || command -v ip6tables)
|
||||||
|
bin_nft=$(command -v nft || which nft)
|
||||||
|
CONFIGURATION=AdGuardHome
|
||||||
|
CRON_FILE=/etc/crontabs/root
|
||||||
|
GFWSET="gfwlist"
|
||||||
|
EXTRA_COMMANDS="do_redirect testbackup test_crontab force_reload isrunning"
|
||||||
|
EXTRA_HELP=" do_redirect 0 or 1\
|
||||||
|
testbackup backup or restore\
|
||||||
|
test_crontab
|
||||||
|
force_reload
|
||||||
|
isrunning"
|
||||||
|
|
||||||
|
set_forward_dnsmasq()
|
||||||
|
{
|
||||||
|
local PORT="$1"
|
||||||
|
addr="127.0.0.1#$PORT"
|
||||||
|
OLD_SERVER="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||||
|
echo $OLD_SERVER | grep "^$addr" >/dev/null 2>&1
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
uci delete dhcp.@dnsmasq[0].server 2>/dev/null
|
||||||
|
uci add_list dhcp.@dnsmasq[0].server=$addr
|
||||||
|
for server in $OLD_SERVER; do
|
||||||
|
if [ "$server" = "$addr" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# uci add_list dhcp.@dnsmasq[0].server=$server
|
||||||
|
done
|
||||||
|
uci delete dhcp.@dnsmasq[0].resolvfile 2>/dev/null
|
||||||
|
uci set dhcp.@dnsmasq[0].noresolv=1
|
||||||
|
uci commit dhcp
|
||||||
|
/etc/init.d/dnsmasq restart
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_forward_dnsmasq()
|
||||||
|
{
|
||||||
|
local OLD_PORT="$1"
|
||||||
|
addr="127.0.0.1#$OLD_PORT"
|
||||||
|
OLD_SERVER="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||||
|
echo $OLD_SERVER | grep "^$addr" >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
uci del_list dhcp.@dnsmasq[0].server=$addr 2>/dev/null
|
||||||
|
addrlist="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||||
|
if [ -z "$addrlist" ] ; then
|
||||||
|
resolvfile="/tmp/resolv.conf.d/resolv.conf.auto"
|
||||||
|
[ ! -f "$resolvfile" ] && resolvfile="/tmp/resolv.conf.auto"
|
||||||
|
uci set dhcp.@dnsmasq[0].resolvfile="$resolvfile" 2>/dev/null
|
||||||
|
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
|
||||||
|
fi
|
||||||
|
uci commit dhcp
|
||||||
|
/etc/init.d/dnsmasq restart
|
||||||
|
}
|
||||||
|
|
||||||
|
set_firewall()
|
||||||
|
{
|
||||||
|
uci set firewall.adguardhome_redirect="redirect"
|
||||||
|
uci set firewall.adguardhome_redirect.target="DNAT"
|
||||||
|
uci set firewall.adguardhome_redirect.name="AdGuard Home"
|
||||||
|
uci set firewall.adguardhome_redirect.src="lan"
|
||||||
|
uci set firewall.adguardhome_redirect.family="any"
|
||||||
|
uci set firewall.adguardhome_redirect.src_dport="53"
|
||||||
|
uci set firewall.adguardhome_redirect.dest_port="$AdGuardHome_PORT"
|
||||||
|
uci commit firewall
|
||||||
|
/etc/init.d/firewall reload
|
||||||
|
echo "firewall rules updated."
|
||||||
|
}
|
||||||
|
|
||||||
|
clear_firewall()
|
||||||
|
{
|
||||||
|
redirects=$(uci show firewall | grep "firewall.adguardhome_redirect")
|
||||||
|
if [ -z "$redirects" ]; then
|
||||||
|
echo "no redirect rules found."
|
||||||
|
else
|
||||||
|
uci delete firewall.adguardhome_redirect
|
||||||
|
uci commit firewall
|
||||||
|
/etc/init.d/firewall reload
|
||||||
|
echo "deleted redirect rule: firewall.adguardhome_redirect"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "$CONFIGURATION"
|
||||||
|
[ "$(uci get AdGuardHome.AdGuardHome.redirect)" == "redirect" ] && procd_add_reload_trigger firewall
|
||||||
|
}
|
||||||
|
|
||||||
|
isrunning(){
|
||||||
|
config_load "${CONFIGURATION}"
|
||||||
|
_isrunning
|
||||||
|
local r=$?
|
||||||
|
([ "$r" == "0" ] && echo "running") || ([ "$r" == "1" ] && echo "not run" ) || echo "no bin"
|
||||||
|
return $r
|
||||||
|
}
|
||||||
|
|
||||||
|
_isrunning(){
|
||||||
|
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
|
||||||
|
[ ! -f "$binpath" ] && return 2
|
||||||
|
pgrep $binpath 2>&1 >/dev/null && return 0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
force_reload(){
|
||||||
|
config_load "${CONFIGURATION}"
|
||||||
|
_isrunning && procd_send_signal "$CONFIGURATION" || start
|
||||||
|
}
|
||||||
|
|
||||||
|
rm_port53()
|
||||||
|
{
|
||||||
|
local AdGuardHome_PORT=$(config_editor "dns.port" "" "$configpath" "1")
|
||||||
|
dnsmasq_port=$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)
|
||||||
|
if [ -z "$dnsmasq_port" ]; then
|
||||||
|
dnsmasq_port="53"
|
||||||
|
fi
|
||||||
|
if [ "$dnsmasq_port" == "$AdGuardHome_PORT" ]; then
|
||||||
|
if [ "$dnsmasq_port" == "53" ]; then
|
||||||
|
dnsmasq_port="1745"
|
||||||
|
fi
|
||||||
|
elif [ "$dnsmasq_port" == "53" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
config_editor "dns.port" "$dnsmasq_port" "$configpath"
|
||||||
|
uci set dhcp.@dnsmasq[0].port="53"
|
||||||
|
uci commit dhcp
|
||||||
|
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
|
||||||
|
killall -9 $binpath
|
||||||
|
/etc/init.d/dnsmasq restart
|
||||||
|
}
|
||||||
|
|
||||||
|
use_port53()
|
||||||
|
{
|
||||||
|
local AdGuardHome_PORT=$(config_editor "dns.port" "" "$configpath" "1")
|
||||||
|
dnsmasq_port=$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)
|
||||||
|
if [ -z "$dnsmasq_port" ]; then
|
||||||
|
dnsmasq_port="53"
|
||||||
|
fi
|
||||||
|
if [ "$dnsmasq_port" == "$AdGuardHome_PORT" ]; then
|
||||||
|
if [ "$dnsmasq_port" == "53" ]; then
|
||||||
|
AdGuardHome_PORT="1745"
|
||||||
|
fi
|
||||||
|
elif [ "$AdGuardHome_PORT" == "53" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
config_editor "dns.port" "53" "$configpath"
|
||||||
|
uci set dhcp.@dnsmasq[0].port="$AdGuardHome_PORT"
|
||||||
|
uci commit dhcp
|
||||||
|
/etc/init.d/dnsmasq restart
|
||||||
|
}
|
||||||
|
|
||||||
|
do_redirect()
|
||||||
|
{
|
||||||
|
config_load "${CONFIGURATION}"
|
||||||
|
_do_redirect $1
|
||||||
|
}
|
||||||
|
|
||||||
|
_do_redirect()
|
||||||
|
{
|
||||||
|
local section="$CONFIGURATION"
|
||||||
|
enabled=$1
|
||||||
|
|
||||||
|
config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
|
||||||
|
AdGuardHome_PORT=$(config_editor "dns.port" "" "$configpath" "1")
|
||||||
|
if [ ! -s "$configpath" ]; then
|
||||||
|
cp -f /usr/share/AdGuardHome/AdGuardHome_template.yaml $configpath
|
||||||
|
fi
|
||||||
|
if [ -z "$AdGuardHome_PORT" ]; then
|
||||||
|
AdGuardHome_PORT="0"
|
||||||
|
fi
|
||||||
|
config_get "redirect" "$section" "redirect" "none"
|
||||||
|
config_get "old_redirect" "$section" "old_redirect" "none"
|
||||||
|
config_get "old_port" "$section" "old_port" "0"
|
||||||
|
config_get "old_enabled" "$section" "old_enabled" "0"
|
||||||
|
uci get dhcp.@dnsmasq[0].port >/dev/null 2>&1 || uci set dhcp.@dnsmasq[0].port="53" >/dev/null 2>&1
|
||||||
|
uci commit dhcp
|
||||||
|
if [ "$old_enabled" = "1" -a "$old_redirect" == "exchange" ]; then
|
||||||
|
AdGuardHome_PORT=$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$old_redirect" != "$redirect" ] || [ "$old_port" != "$AdGuardHome_PORT" ] || [ "$old_enabled" = "1" -a "$enabled" = "0" ]; then
|
||||||
|
if [ "$old_redirect" != "none" ]; then
|
||||||
|
if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
||||||
|
clear_firewall
|
||||||
|
elif [ "$old_redirect" == "dnsmasq-upstream" ]; then
|
||||||
|
stop_forward_dnsmasq "$old_port"
|
||||||
|
elif [ "$old_redirect" == "exchange" ]; then
|
||||||
|
rm_port53
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
elif [ "$old_enabled" = "1" -a "$enabled" = "1" ]; then
|
||||||
|
if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
||||||
|
clear_firewall
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
uci delete AdGuardHome.@AdGuardHome[0].old_redirect 2>/dev/null
|
||||||
|
uci delete AdGuardHome.@AdGuardHome[0].old_port 2>/dev/null
|
||||||
|
uci delete AdGuardHome.@AdGuardHome[0].old_enabled 2>/dev/null
|
||||||
|
uci add_list AdGuardHome.@AdGuardHome[0].old_redirect="$redirect" 2>/dev/null
|
||||||
|
uci add_list AdGuardHome.@AdGuardHome[0].old_port="$AdGuardHome_PORT" 2>/dev/null
|
||||||
|
uci add_list AdGuardHome.@AdGuardHome[0].old_enabled="$enabled" 2>/dev/null
|
||||||
|
uci commit AdGuardHome
|
||||||
|
|
||||||
|
if [ "$enabled" == "0" ] || [ "$AdGuardHome_PORT" == "0" ]; then
|
||||||
|
echo -n "0">/var/run/AdGredir
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
redirected=1
|
||||||
|
if [ "$redirect" = "redirect" ]; then
|
||||||
|
set_firewall
|
||||||
|
elif [ "$redirect" = "dnsmasq-upstream" ]; then
|
||||||
|
set_forward_dnsmasq
|
||||||
|
elif [ "$redirect" == "exchange" -a "$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)" == "53" ]; then
|
||||||
|
use_port53
|
||||||
|
else
|
||||||
|
redirected=0
|
||||||
|
fi
|
||||||
|
echo -n "$redirected">/var/run/AdGredir
|
||||||
|
}
|
||||||
|
|
||||||
|
get_filesystem()
|
||||||
|
{
|
||||||
|
# print out path filesystem
|
||||||
|
echo $1 | awk '
|
||||||
|
BEGIN{
|
||||||
|
while (("mount"| getline ret) > 0)
|
||||||
|
{
|
||||||
|
split(ret,d);
|
||||||
|
fs[d[3]]=d[5];
|
||||||
|
m=index(d[1],":")
|
||||||
|
if (m==0)
|
||||||
|
{
|
||||||
|
pt[d[3]]=d[1]
|
||||||
|
}else{
|
||||||
|
pt[d[3]]=substr(d[1],m+1)
|
||||||
|
}}}{
|
||||||
|
split($0,d,"/");
|
||||||
|
if ("/" in fs)
|
||||||
|
{
|
||||||
|
result1=fs["/"];
|
||||||
|
}
|
||||||
|
if ("/" in pt)
|
||||||
|
{
|
||||||
|
result2=pt["/"];
|
||||||
|
}
|
||||||
|
for (i=2;i<=length(d);i++)
|
||||||
|
{
|
||||||
|
p[i]=p[i-1]"/"d[i];
|
||||||
|
if (p[i] in fs)
|
||||||
|
{
|
||||||
|
result1=fs[p[i]];
|
||||||
|
result2=pt[p[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result2 in fs){
|
||||||
|
result=fs[result2]}
|
||||||
|
else{
|
||||||
|
result=result1}
|
||||||
|
print(result);}'
|
||||||
|
}
|
||||||
|
|
||||||
|
config_editor()
|
||||||
|
{
|
||||||
|
[ -n "$3" -a -f $3 ] || return
|
||||||
|
awk -v yaml="$1" -v value="$2" -v file="$3" -v ro="$4" '
|
||||||
|
BEGIN{split(yaml,part,"\.");s="";i=1;l=length(part);}
|
||||||
|
{
|
||||||
|
if (match($0,s""part[i]":"))
|
||||||
|
{
|
||||||
|
if (i==l)
|
||||||
|
{
|
||||||
|
split($0,t,": ");
|
||||||
|
if (ro==""){
|
||||||
|
system("sed -i '\''"FNR"c \\"t[1]": "value"'\'' "file);
|
||||||
|
}else{
|
||||||
|
print(t[2]);
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
s=s"[- ]{2}";
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}' $3
|
||||||
|
}
|
||||||
|
|
||||||
|
boot_service() {
|
||||||
|
rm /var/run/AdGserverdis >/dev/null 2>&1
|
||||||
|
config_load "${CONFIGURATION}"
|
||||||
|
config_get waitonboot $CONFIGURATION waitonboot "0"
|
||||||
|
config_get_bool enabled $CONFIGURATION enabled 0
|
||||||
|
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
|
||||||
|
[ -f "$binpath" ] && start_service
|
||||||
|
if [ "$enabled" == "1" ] && [ "$waitonboot" == "1" ]; then
|
||||||
|
procd_open_instance "waitnet"
|
||||||
|
procd_set_param command "/usr/share/AdGuardHome/waitnet.sh"
|
||||||
|
procd_close_instance
|
||||||
|
echo "no net start pinging"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testbackup(){
|
||||||
|
config_load "${CONFIGURATION}"
|
||||||
|
if [ "$1" == "backup" ]; then
|
||||||
|
backup
|
||||||
|
elif [ "$1" == "restore" ]; then
|
||||||
|
restore
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
restore()
|
||||||
|
{
|
||||||
|
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
|
||||||
|
config_get backupwdpath $CONFIGURATION backupwdpath "/etc/AdGuardHome"
|
||||||
|
cp -u -r -f $backupwdpath/data $workdir
|
||||||
|
}
|
||||||
|
|
||||||
|
backup() {
|
||||||
|
config_get backupwdpath $CONFIGURATION backupwdpath "/etc/AdGuardHome"
|
||||||
|
mkdir -p $backupwdpath/data
|
||||||
|
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
|
||||||
|
config_get backupfile $CONFIGURATION backupfile ""
|
||||||
|
for one in $backupfile;
|
||||||
|
do
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
if [ -d "$backupwdpath/data/$one" ]; then
|
||||||
|
cpret=$(cp -u -r -f $workdir/data/$one $backupwdpath/data 2>&1)
|
||||||
|
else
|
||||||
|
cpret=$(cp -u -r -f $workdir/data/$one $backupwdpath/data/$one 2>&1)
|
||||||
|
fi
|
||||||
|
echo "$cpret"
|
||||||
|
echo "$cpret" | grep "no space left on device"
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
echo "磁盘已满,删除log重试中"
|
||||||
|
del_querylog && continue
|
||||||
|
rm -f -r $backupwdpath/data/filters
|
||||||
|
rm -f -r $workdir/data/filters && continue
|
||||||
|
echo "backup failed"
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
_add_upprotect_file()
|
||||||
|
{
|
||||||
|
local file="$1"
|
||||||
|
# Expand variables in the file path
|
||||||
|
local expanded_file=$(eval echo "$file")
|
||||||
|
echo "$expanded_file" >> /lib/upgrade/keep.d/luci-app-adguardhome
|
||||||
|
}
|
||||||
|
start_service() {
|
||||||
|
# Reading config
|
||||||
|
rm /var/run/AdGserverdis >/dev/null 2>&1
|
||||||
|
config_load "${CONFIGURATION}"
|
||||||
|
# update password
|
||||||
|
config_get hashpass $CONFIGURATION hashpass ""
|
||||||
|
config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
|
||||||
|
if [ -n "$hashpass" ]; then
|
||||||
|
config_editor "users.password" "$hashpass" "$configpath"
|
||||||
|
uci set $CONFIGURATION.$CONFIGURATION.hashpass=""
|
||||||
|
fi
|
||||||
|
local ipst=0
|
||||||
|
config_get_bool enabled $CONFIGURATION enabled 0
|
||||||
|
# update crontab
|
||||||
|
do_crontab
|
||||||
|
echo "luci enable switch=$enabled"
|
||||||
|
if [ "$enabled" == "0" ]; then
|
||||||
|
_do_redirect 0
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
#what need to do before reload
|
||||||
|
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
|
||||||
|
grep -q "ipset.txt" $configpath 2>/dev/null && ipst=1
|
||||||
|
if [ $ipst -eq 1 ];then
|
||||||
|
ipset list $GFWSET >/dev/null 2>&1 || ipset create $GFWSET hash:ip 2>/dev/null
|
||||||
|
fi
|
||||||
|
config_get backupfile $CONFIGURATION backupfile ""
|
||||||
|
mkdir -p $workdir/data
|
||||||
|
if [ -n "$backupfile" ] && [ ! -d "$workdir/data" ]; then
|
||||||
|
restore
|
||||||
|
fi
|
||||||
|
# for overlay data-stk-oo not suppport
|
||||||
|
local cwdfs=$(get_filesystem $workdir)
|
||||||
|
echo "workdir is a $cwdfs filesystem"
|
||||||
|
if [ "$cwdfs" == "jffs2" ]; then
|
||||||
|
echo "fs error ln db to tmp $workdir $cwdfs"
|
||||||
|
logger "AdGuardHome" "warning db redirect to tmp"
|
||||||
|
touch $workdir/data/stats.db
|
||||||
|
if [ ! -L $workdir/data/stats.db ]; then
|
||||||
|
mv -f $workdir/data/stats.db /tmp/stats.db 2>/dev/null
|
||||||
|
ln -s /tmp/stats.db $workdir/data/stats.db 2>/dev/null
|
||||||
|
fi
|
||||||
|
touch $workdir/data/sessions.db
|
||||||
|
if [ ! -L $workdir/data/sessions.db ]; then
|
||||||
|
mv -f $workdir/data/sessions.db /tmp/sessions.db 2>/dev/null
|
||||||
|
ln -s /tmp/sessions.db $workdir/data/sessions.db 2>/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# hack to save config file when upgrade system
|
||||||
|
config_get upprotect $CONFIGURATION upprotect ""
|
||||||
|
if [ -n "$upprotect" ]; then
|
||||||
|
# Handle both old MultiValue format (space-separated) and new DynamicList format
|
||||||
|
if echo "$upprotect" | grep -q " "; then
|
||||||
|
# Old format: space-separated values
|
||||||
|
eval upprotect=${upprotect// /\\\\n}
|
||||||
|
echo -e "$upprotect">/lib/upgrade/keep.d/luci-app-adguardhome
|
||||||
|
else
|
||||||
|
echo -n > /lib/upgrade/keep.d/luci-app-adguardhome
|
||||||
|
# New format: UCI list, get all values
|
||||||
|
config_list_foreach $CONFIGURATION upprotect _add_upprotect_file
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
|
||||||
|
mkdir -p ${binpath%/*}
|
||||||
|
if [ ! -f "$binpath" ]; then
|
||||||
|
_do_redirect 0
|
||||||
|
/usr/share/AdGuardHome/update_core.sh 2>&1 >/tmp/AdGuardHome_update.log &
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
config_get httpport $CONFIGURATION httpport 3000
|
||||||
|
local ADDITIONAL_ARGS=" -c $configpath -w $workdir -p $httpport --no-check-update"
|
||||||
|
config_get logfile $CONFIGURATION logfile ""
|
||||||
|
if [ -n "$logfile" ]; then
|
||||||
|
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -l $logfile"
|
||||||
|
fi
|
||||||
|
config_get_bool verbose $CONFIGURATION verbose 0
|
||||||
|
if [ "$verbose" -eq 1 ]; then
|
||||||
|
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -v"
|
||||||
|
fi
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
SET_TZ="`uci get system.@system[0].timezone 2>/dev/null`"
|
||||||
|
if [ -n "$SET_TZ" ]; then
|
||||||
|
procd_set_param env TZ="$SET_TZ"
|
||||||
|
fi
|
||||||
|
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||||
|
procd_set_param limits core="unlimited" nofile="65535 65535"
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_set_param command $binpath $ADDITIONAL_ARGS
|
||||||
|
procd_set_param file "$configpath" "/etc/hosts" "/etc/config/AdGuardHome"
|
||||||
|
procd_close_instance
|
||||||
|
if [ -f "$configpath" ]; then
|
||||||
|
_do_redirect 1
|
||||||
|
else
|
||||||
|
_do_redirect 0
|
||||||
|
config_get "redirect" $CONFIGURATION "redirect" "none"
|
||||||
|
if [ "$redirect" != "none" ]; then
|
||||||
|
procd_open_instance "waitconfig"
|
||||||
|
procd_set_param command "/usr/share/AdGuardHome/watchconfig.sh"
|
||||||
|
procd_close_instance
|
||||||
|
echo "no config start watching"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "AdGuardHome service enabled"
|
||||||
|
# echo "luci enable switch=$enabled"
|
||||||
|
(sleep 10 && [ -z "$(pgrep $binpath)" ] && logger "AdGuardHome" "no process in 10s cancel redirect" && _do_redirect 0 )&
|
||||||
|
if [[ "`uci -q get bypass.@global[0].global_server`" && "`uci -q get bypass.@global[0].adguardhome 2>/dev/null`" == 1 && "$(uci -q get dhcp.@dnsmasq[0].port)" == "53" ]]; then
|
||||||
|
uci -q set AdGuardHome.AdGuardHome.redirect='exchange'
|
||||||
|
uci commit AdGuardHome
|
||||||
|
do_redirect 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
reload_service()
|
||||||
|
{
|
||||||
|
rm /var/run/AdGlucitest >/dev/null 2>&1
|
||||||
|
echo "AdGuardHome reloading"
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
del_querylog(){
|
||||||
|
local btarget=$(ls $backupwdpath/data | grep -F "querylog.json" | sort -r | head -n 1)
|
||||||
|
local wtarget=$(ls $workdir/data | grep -F "querylog.json" | sort -r | head -n 1)
|
||||||
|
if [ "$btarget"x == "$wtarget"x ]; then
|
||||||
|
[ -z "$btarget" ] && return 1
|
||||||
|
rm -f $workdir/data/$wtarget
|
||||||
|
rm -f $backupwdpath/data/$btarget
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ "$btarget" \> "$wtarget" ]; then
|
||||||
|
rm -f $backupwdpath/data/$btarget
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
rm -f $workdir/data/$wtarget
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service()
|
||||||
|
{
|
||||||
|
config_load "${CONFIGURATION}"
|
||||||
|
_do_redirect 0
|
||||||
|
do_crontab
|
||||||
|
if [ "$1" != "nobackup" ]; then
|
||||||
|
config_get backupfile $CONFIGURATION backupfile "0"
|
||||||
|
if [ -n "$backupfile" ]; then
|
||||||
|
backup
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "AdGuardHome service disabled"
|
||||||
|
touch /var/run/AdGserverdis
|
||||||
|
}
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
rc_procd boot_service "$@"
|
||||||
|
if eval "type service_started" 2>/dev/null >/dev/null; then
|
||||||
|
service_started
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
test_crontab(){
|
||||||
|
config_load "${CONFIGURATION}"
|
||||||
|
do_crontab
|
||||||
|
}
|
||||||
|
|
||||||
|
do_crontab(){
|
||||||
|
config_get_bool enabled $CONFIGURATION enabled 0
|
||||||
|
config_get crontab $CONFIGURATION crontab ""
|
||||||
|
local findstr default cronenable replace commit
|
||||||
|
local cronreload=0
|
||||||
|
local commit=0
|
||||||
|
findstr="/usr/share/AdGuardHome/update_core.sh"
|
||||||
|
default="30 3 * * * /usr/share/AdGuardHome/update_core.sh 2>&1"
|
||||||
|
[ "$enabled" == "0" ] || [ "${crontab//autoupdate/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
|
crontab_editor
|
||||||
|
|
||||||
|
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
|
||||||
|
config_get lastworkdir $CONFIGURATION lastworkdir "/etc/AdGuardHome"
|
||||||
|
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
|
||||||
|
#[ -n "$lastworkdir" ] && findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* $lastworkdir/data/querylog.json" && [ "$lastworkdir" != "$workdir" ] && replace="${lastworkdir//\//\\/}/${workdir//\//\\/}"
|
||||||
|
default="0 * * * * /usr/share/AdGuardHome/tailto.sh 2000 \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
|
||||||
|
[ "$enabled" == "0" ] || [ "${crontab//cutquerylog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
|
crontab_editor
|
||||||
|
#[ "$lastworkdir" != "$workdir" ] && uci set AdGuardHome.AdGuardHome.lastworkdir="$workdir" && commit=1
|
||||||
|
|
||||||
|
config_get logfile $CONFIGURATION logfile ""
|
||||||
|
config_get lastlogfile $CONFIGURATION lastlogfile ""
|
||||||
|
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.logfile)"
|
||||||
|
default="30 3 * * * /usr/share/AdGuardHome/tailto.sh 2000 \$(uci get AdGuardHome.AdGuardHome.logfile)"
|
||||||
|
#[ -n "$lastlogfile" ] && findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* $lastlogfile" && [ -n "$logfile" ] && [ "$lastlogfile" != "$logfile" ] && replace="${lastlogfile//\//\\/}/${logfile//\//\\/}"
|
||||||
|
[ "$logfile" == "syslog" ] || [ "$logfile" == "" ] || [ "$enabled" == "0" ] || [ "${crontab//cutruntimelog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
|
crontab_editor
|
||||||
|
#[ -n "$logfile" ] && [ "$lastlogfile" != "$logfile" ] && uci set AdGuardHome.AdGuardHome.lastlogfile="$logfile" && commit=1
|
||||||
|
|
||||||
|
findstr="/usr/share/AdGuardHome/addhost.sh"
|
||||||
|
default="0 * * * * /usr/share/AdGuardHome/addhost.sh"
|
||||||
|
[ "$enabled" == "0" ] || [ "${crontab//autohost/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
|
crontab_editor
|
||||||
|
[ "$cronenable" == "0" ] && /usr/share/AdGuardHome/addhost.sh "del" "noreload" || /usr/share/AdGuardHome/addhost.sh "" "noreload"
|
||||||
|
|
||||||
|
findstr="/usr/share/AdGuardHome/gfw2adg.sh"
|
||||||
|
default="30 3 * * * /usr/share/AdGuardHome/gfw2adg.sh"
|
||||||
|
[ "$enabled" == "0" ] || [ "${crontab//autogfw/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
|
crontab_editor
|
||||||
|
findstr="/usr/share/AdGuardHome/gfwipset2adg.sh"
|
||||||
|
default="31 3 * * * /usr/share/AdGuardHome/gfwipset2adg.sh"
|
||||||
|
[ "$enabled" == "0" ] || [ "${crontab//autogfwipset/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
|
crontab_editor
|
||||||
|
[ "$cronreload" -gt 0 ] && /etc/init.d/cron restart
|
||||||
|
#[ "$commit" -gt 0 ] && uci commit AdGuardHome
|
||||||
|
}
|
||||||
|
|
||||||
|
crontab_editor(){
|
||||||
|
#usage input:
|
||||||
|
#findstr=
|
||||||
|
#default=
|
||||||
|
#cronenable=
|
||||||
|
#replace="${last//\//\\/}/${now//\//\\/}"
|
||||||
|
#output:cronreload:if >1 please /etc/init.d/cron restart manual
|
||||||
|
local testline reload
|
||||||
|
local line="$(grep "$findstr" $CRON_FILE)"
|
||||||
|
[ -n "$replace" ] && [ -n "$line" ] && eval testline="\${line//$replace}" && [ "$testline" != "$line" ] && line="$testline" && reload="1" && replace=""
|
||||||
|
if [ "${line:0:1}" != "#" ]; then
|
||||||
|
if [ $cronenable -eq 1 ]; then
|
||||||
|
[ -z "$line" ] && line="$default" && reload="1"
|
||||||
|
if [ -n "$reload" ]; then
|
||||||
|
sed -i "\,$findstr,d" $CRON_FILE
|
||||||
|
echo "$line" >> $CRON_FILE
|
||||||
|
cronreload=$((cronreload+1))
|
||||||
|
fi
|
||||||
|
elif [ -n "$line" ]; then
|
||||||
|
sed -i "\,$findstr,d" $CRON_FILE
|
||||||
|
echo "#$line" >> $CRON_FILE
|
||||||
|
cronreload=$((cronreload+1))
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ $cronenable -eq 1 ]; then
|
||||||
|
sed -i "\,$findstr,d" $CRON_FILE
|
||||||
|
echo "${line:1}" >> $CRON_FILE
|
||||||
|
cronreload=$((cronreload+1))
|
||||||
|
elif [ -z "$reload" ]; then
|
||||||
|
sed -i "\,$findstr,d" $CRON_FILE
|
||||||
|
echo "$line" >> $CRON_FILE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
chmod +x /etc/init.d/AdGuardHome
|
||||||
|
uci -q batch <<-EOF >/dev/null 2>&1
|
||||||
|
delete ucitrack.@AdGuardHome[-1]
|
||||||
|
add ucitrack AdGuardHome
|
||||||
|
set ucitrack.@AdGuardHome[-1].init=AdGuardHome
|
||||||
|
commit ucitrack
|
||||||
|
delete AdGuardHome.AdGuardHome.ucitracktest
|
||||||
|
EOF
|
||||||
|
|
||||||
|
rm -f /tmp/luci-indexcache
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
#模板用户名为 admin 密码为 admin
|
||||||
|
#The username is admin and the password is admin.
|
||||||
|
#提交就可以直接用的配置模板文件
|
||||||
|
#a template config can be use with a apply
|
||||||
|
bind_host: 0.0.0.0
|
||||||
|
bind_port: 3000
|
||||||
|
beta_bind_port: 0
|
||||||
|
users:
|
||||||
|
- name: admin
|
||||||
|
password: $2y$10$vHRcARdPCieYG3RXWomV5evDYN.Nj/edtwEkQgQJZcK6z7qTLaIc6
|
||||||
|
auth_attempts: 5
|
||||||
|
block_auth_min: 15
|
||||||
|
http_proxy: ""
|
||||||
|
language: zh-cn
|
||||||
|
theme: auto
|
||||||
|
debug_pprof: false
|
||||||
|
dns:
|
||||||
|
bind_hosts:
|
||||||
|
- 0.0.0.0
|
||||||
|
port: 5333
|
||||||
|
anonymize_client_ip: false
|
||||||
|
protection_enabled: true
|
||||||
|
blocking_mode: default
|
||||||
|
blocking_ipv4: ""
|
||||||
|
blocking_ipv6: ""
|
||||||
|
blocked_response_ttl: 10
|
||||||
|
protection_disabled_until: null
|
||||||
|
parental_block_host: family-block.dns.adguard.com
|
||||||
|
safebrowsing_block_host: standard-block.dns.adguard.com
|
||||||
|
ratelimit: 0
|
||||||
|
ratelimit_whitelist: []
|
||||||
|
refuse_any: false
|
||||||
|
upstream_dns:
|
||||||
|
- 223.5.5.5
|
||||||
|
upstream_dns_file: ""
|
||||||
|
bootstrap_dns:
|
||||||
|
- 119.29.29.29
|
||||||
|
- 223.5.5.5
|
||||||
|
all_servers: false
|
||||||
|
fastest_addr: false
|
||||||
|
fastest_timeout: 1s
|
||||||
|
allowed_clients: []
|
||||||
|
disallowed_clients: []
|
||||||
|
blocked_hosts:
|
||||||
|
- version.bind
|
||||||
|
- id.server
|
||||||
|
- hostname.bind
|
||||||
|
trusted_proxies:
|
||||||
|
- 127.0.0.0/8
|
||||||
|
- ::1/128
|
||||||
|
cache_size: 4194304
|
||||||
|
cache_ttl_min: 0
|
||||||
|
cache_ttl_max: 0
|
||||||
|
cache_optimistic: true
|
||||||
|
bogus_nxdomain: []
|
||||||
|
aaaa_disabled: false
|
||||||
|
enable_dnssec: false
|
||||||
|
edns_client_subnet: false
|
||||||
|
max_goroutines: 300
|
||||||
|
ipset: []
|
||||||
|
filtering_enabled: true
|
||||||
|
filters_update_interval: 24
|
||||||
|
parental_enabled: false
|
||||||
|
safesearch_enabled: false
|
||||||
|
safebrowsing_enabled: false
|
||||||
|
safebrowsing_cache_size: 1048576
|
||||||
|
safesearch_cache_size: 1048576
|
||||||
|
parental_cache_size: 1048576
|
||||||
|
cache_time: 30
|
||||||
|
rewrites: []
|
||||||
|
blocked_services: []
|
||||||
|
upstream_timeout: 10s
|
||||||
|
private_networks: []
|
||||||
|
use_private_ptr_resolvers: true
|
||||||
|
local_ptr_upstreams: []
|
||||||
|
tls:
|
||||||
|
enabled: false
|
||||||
|
server_name: ""
|
||||||
|
force_https: false
|
||||||
|
port_https: 443
|
||||||
|
port_dns_over_tls: 853
|
||||||
|
port_dns_over_quic: 784
|
||||||
|
port_dnscrypt: 0
|
||||||
|
dnscrypt_config_file: ""
|
||||||
|
allow_unencrypted_doh: false
|
||||||
|
certificate_chain: ""
|
||||||
|
private_key: ""
|
||||||
|
certificate_path: ""
|
||||||
|
private_key_path: ""
|
||||||
|
filters:
|
||||||
|
- enabled: true
|
||||||
|
url: https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt
|
||||||
|
name: AdGuard DNS filter
|
||||||
|
id: 1128750870
|
||||||
|
- enabled: true
|
||||||
|
url: https://anti-ad.net/easylist.txt
|
||||||
|
name: 'CHN: anti-AD'
|
||||||
|
id: 1128750871
|
||||||
|
- enabled: true
|
||||||
|
url: https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt
|
||||||
|
name: AdGuard DNS filter
|
||||||
|
id: 1128751871
|
||||||
|
- enabled: false
|
||||||
|
url: https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt
|
||||||
|
name: AdAway Default Blocklist
|
||||||
|
id: 1128752871
|
||||||
|
whitelist_filters: []
|
||||||
|
user_rules:
|
||||||
|
- '@@||taobao.com^$important'
|
||||||
|
- '@@||jd.com^important'
|
||||||
|
- '@@||flyme.cn^$important'
|
||||||
|
- '@@||meizu.com^$important'
|
||||||
|
- '@@||wl.jd.com^$important'
|
||||||
|
- '@@||flydigi.com^'
|
||||||
|
- '@@||pv.sohu.com^$important'
|
||||||
|
dhcp:
|
||||||
|
enabled: false
|
||||||
|
interface_name: ""
|
||||||
|
dhcpv4:
|
||||||
|
gateway_ip: ""
|
||||||
|
subnet_mask: ""
|
||||||
|
range_start: ""
|
||||||
|
range_end: ""
|
||||||
|
lease_duration: 86400
|
||||||
|
icmp_timeout_msec: 1000
|
||||||
|
options: []
|
||||||
|
dhcpv6:
|
||||||
|
range_start: ""
|
||||||
|
lease_duration: 86400
|
||||||
|
ra_slaac_only: false
|
||||||
|
ra_allow_slaac: false
|
||||||
|
clients: []
|
||||||
|
log_compress: false
|
||||||
|
log_localtime: false
|
||||||
|
log_max_backups: 0
|
||||||
|
log_max_size: 100
|
||||||
|
log_max_age: 3
|
||||||
|
log_file: ""
|
||||||
|
verbose: false
|
||||||
|
schema_version: 10
|
||||||
35
luci-app-adguardhome/root/usr/share/AdGuardHome/addhost.sh
Normal file
35
luci-app-adguardhome/root/usr/share/AdGuardHome/addhost.sh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
checkmd5(){
|
||||||
|
local nowmd5=$(md5sum /etc/hosts)
|
||||||
|
nowmd5=${nowmd5%% *}
|
||||||
|
local lastmd5=$(uci get AdGuardHome.AdGuardHome.hostsmd5 2>/dev/null)
|
||||||
|
if [ "$nowmd5" != "$lastmd5" ]; then
|
||||||
|
uci set AdGuardHome.AdGuardHome.hostsmd5="$nowmd5"
|
||||||
|
uci commit AdGuardHome
|
||||||
|
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
[ "$1" == "del" ] && sed -i '/programaddstart/,/programaddend/d' /etc/hosts && checkmd5 "$2" && exit 0
|
||||||
|
/usr/bin/awk 'BEGIN{
|
||||||
|
while ((getline < "/tmp/dhcp.leases") > 0)
|
||||||
|
{
|
||||||
|
a[$2]=$4;
|
||||||
|
}
|
||||||
|
while (("ip -6 neighbor show | grep -v fe80" | getline) > 0)
|
||||||
|
{
|
||||||
|
if (a[$5]) {print $1" "a[$5] >"/tmp/tmphost"; }
|
||||||
|
}
|
||||||
|
print "#programaddend" >"/tmp/tmphost";
|
||||||
|
}'
|
||||||
|
grep programaddstart /etc/hosts >/dev/null 2>&1
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
sed -i '/programaddstart/,/programaddend/c\#programaddstart' /etc/hosts
|
||||||
|
sed -i '/programaddstart/'r/tmp/tmphost /etc/hosts
|
||||||
|
else
|
||||||
|
echo "#programaddstart" >>/etc/hosts
|
||||||
|
cat /tmp/tmphost >> /etc/hosts
|
||||||
|
fi
|
||||||
|
rm /tmp/tmphost
|
||||||
|
checkmd5 "$2"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
table inet adguardhome {
|
||||||
|
chain prerouting {
|
||||||
|
type nat hook prerouting priority dstnat; policy accept;
|
||||||
|
|
||||||
|
iifname { "eth0" } return
|
||||||
|
|
||||||
|
fib daddr type local udp dport 53 redirect to :__AGH_PORT__
|
||||||
|
fib daddr type local tcp dport 53 redirect to :__AGH_PORT__
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
AdGuardHome_enable=$(uci get AdGuardHome.AdGuardHome.enabled)
|
||||||
|
redirect=$(uci get AdGuardHome.AdGuardHome.redirect)
|
||||||
|
|
||||||
|
if [ $AdGuardHome_enable -eq 1 -a "$redirect" == "redirect" ]; then
|
||||||
|
/etc/init.d/AdGuardHome do_redirect 1
|
||||||
|
fi
|
||||||
20
luci-app-adguardhome/root/usr/share/AdGuardHome/getsyslog.sh
Normal file
20
luci-app-adguardhome/root/usr/share/AdGuardHome/getsyslog.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
logread -e AdGuardHome > /tmp/AdGuardHometmp.log
|
||||||
|
logread -e AdGuardHome -f >> /tmp/AdGuardHometmp.log &
|
||||||
|
pid=$!
|
||||||
|
echo "1">/var/run/AdGuardHomesyslog
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
sleep 12
|
||||||
|
watchdog=$(cat /var/run/AdGuardHomesyslog)
|
||||||
|
if [ "$watchdog"x == "0"x ]; then
|
||||||
|
kill $pid
|
||||||
|
rm /tmp/AdGuardHometmp.log
|
||||||
|
rm /var/run/AdGuardHomesyslog
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "0">/var/run/AdGuardHomesyslog
|
||||||
|
fi
|
||||||
|
done
|
||||||
89
luci-app-adguardhome/root/usr/share/AdGuardHome/gfw2adg.sh
Normal file
89
luci-app-adguardhome/root/usr/share/AdGuardHome/gfw2adg.sh
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
|
checkmd5(){
|
||||||
|
local nowmd5=$(md5sum /tmp/adguard.list 2>/dev/null)
|
||||||
|
nowmd5=${nowmd5%% *}
|
||||||
|
local lastmd5=$(uci get AdGuardHome.AdGuardHome.gfwlistmd5 2>/dev/null)
|
||||||
|
if [ "$nowmd5" != "$lastmd5" ]; then
|
||||||
|
uci set AdGuardHome.AdGuardHome.gfwlistmd5="$nowmd5"
|
||||||
|
uci commit AdGuardHome
|
||||||
|
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configpath=$(uci get AdGuardHome.AdGuardHome.configpath 2>/dev/null)
|
||||||
|
[ "$1" == "del" ] && sed -i '/programaddstart/,/programaddend/d' $configpath && checkmd5 "$2" && exit 0
|
||||||
|
gfwupstream=$(uci get AdGuardHome.AdGuardHome.gfwupstream 2>/dev/null)
|
||||||
|
if [ -z $gfwupstream ]; then
|
||||||
|
gfwupstream="tcp://208.67.220.220:5353"
|
||||||
|
fi
|
||||||
|
if [ ! -f "$configpath" ]; then
|
||||||
|
echo "please make a config first"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O- | base64 -d > /tmp/gfwlist.txt
|
||||||
|
cat /tmp/gfwlist.txt | awk -v upst="$gfwupstream" 'BEGIN{getline;}{
|
||||||
|
s1=substr($0,1,1);
|
||||||
|
if (s1=="!")
|
||||||
|
{next;}
|
||||||
|
if (s1=="@"){
|
||||||
|
$0=substr($0,3);
|
||||||
|
s1=substr($0,1,1);
|
||||||
|
white=1;}
|
||||||
|
else{
|
||||||
|
white=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s1=="|")
|
||||||
|
{s2=substr($0,2,1);
|
||||||
|
if (s2=="|")
|
||||||
|
{
|
||||||
|
$0=substr($0,3);
|
||||||
|
split($0,d,"/");
|
||||||
|
$0=d[1];
|
||||||
|
}else{
|
||||||
|
split($0,d,"/");
|
||||||
|
$0=d[3];
|
||||||
|
}}
|
||||||
|
else{
|
||||||
|
split($0,d,"/");
|
||||||
|
$0=d[1];
|
||||||
|
}
|
||||||
|
star=index($0,"*");
|
||||||
|
if (star!=0)
|
||||||
|
{
|
||||||
|
$0=substr($0,star+1);
|
||||||
|
dot=index($0,".");
|
||||||
|
if (dot!=0)
|
||||||
|
$0=substr($0,dot+1);
|
||||||
|
else
|
||||||
|
next;
|
||||||
|
s1=substr($0,1,1);
|
||||||
|
}
|
||||||
|
if (s1==".")
|
||||||
|
{fin=substr($0,2);}
|
||||||
|
else{fin=$0;}
|
||||||
|
if (index(fin,".")==0) next;
|
||||||
|
if (index(fin,"%")!=0) next;
|
||||||
|
if (index(fin,":")!=0) next;
|
||||||
|
match(fin,"^[0-9\.]+")
|
||||||
|
if (RSTART==1 && RLENGTH==length(fin)) {print "ipset add gfwlist "fin>"/tmp/doipset.sh";next;}
|
||||||
|
if (fin=="" || finl==fin) next;
|
||||||
|
finl=fin;
|
||||||
|
if (white==0)
|
||||||
|
{print(" - '\''[/"fin"/]"upst"'\''");}
|
||||||
|
else{
|
||||||
|
print(" - '\''[/"fin"/]#'\''");}
|
||||||
|
}END{print(" - '\''[/programaddend/]#'\''")}' > /tmp/adguard.list
|
||||||
|
grep programaddstart $configpath
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
sed -i '/programaddstart/,/programaddend/c\ - '\''\[\/programaddstart\/\]#'\''' $configpath
|
||||||
|
sed -i '/programaddstart/'r/tmp/adguard.list $configpath
|
||||||
|
else
|
||||||
|
sed -i '1i\ - '\''[/programaddstart/]#'\''' /tmp/adguard.list
|
||||||
|
sed -i '/upstream_dns:/'r/tmp/adguard.list $configpath
|
||||||
|
fi
|
||||||
|
checkmd5 "$2"
|
||||||
|
rm -f /tmp/gfwlist.txt /tmp/adguard.list
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
mkdir -p "/etc/AdGuardHome"
|
||||||
|
checkmd5(){
|
||||||
|
local nowmd5=$(md5sum /tmp/adguard.list 2>/dev/null)
|
||||||
|
nowmd5=${nowmd5%% *}
|
||||||
|
local lastmd5=$(uci get AdGuardHome.AdGuardHome.ipsetlistmd5 2>/dev/null)
|
||||||
|
if [ "$nowmd5" != "$lastmd5" ]; then
|
||||||
|
uci set AdGuardHome.AdGuardHome.ipsetlistmd5="$nowmd5"
|
||||||
|
uci commit AdGuardHome
|
||||||
|
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
ipstok=1
|
||||||
|
configpath=$(uci get AdGuardHome.AdGuardHome.configpath 2>/dev/null)
|
||||||
|
if [ "$1" == "del" ]; then
|
||||||
|
#sed -i -r 's/upstream_dns_file:\s*['\"]?.*['\"]?/upstream_dns_file: ""/' $configpath
|
||||||
|
sed -i -r 's/ipset_file:\s*['\"]?.*['\"]?/ipset_file: ""/' $configpath
|
||||||
|
checkmd5 "$2"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
gfwupstream=$(uci get AdGuardHome.AdGuardHome.gfwupstream 2>/dev/null)
|
||||||
|
if [ -z $gfwupstream ]; then
|
||||||
|
gfwupstream="tcp://208.67.220.220:5353"
|
||||||
|
fi
|
||||||
|
if [ ! -f "$configpath" ]; then
|
||||||
|
echo "please make a config first"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O- | base64 -d > /tmp/gfwlist.txt
|
||||||
|
cat /tmp/gfwlist.txt | awk -v upst="$gfwupstream" 'BEGIN{getline;}{
|
||||||
|
s1=substr($0,1,1);
|
||||||
|
if (s1=="!")
|
||||||
|
{next;}
|
||||||
|
if (s1=="@"){
|
||||||
|
$0=substr($0,3);
|
||||||
|
s1=substr($0,1,1);
|
||||||
|
white=1;}
|
||||||
|
else{
|
||||||
|
white=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s1=="|")
|
||||||
|
{s2=substr($0,2,1);
|
||||||
|
if (s2=="|")
|
||||||
|
{
|
||||||
|
$0=substr($0,3);
|
||||||
|
split($0,d,"/");
|
||||||
|
$0=d[1];
|
||||||
|
}else{
|
||||||
|
split($0,d,"/");
|
||||||
|
$0=d[3];
|
||||||
|
}}
|
||||||
|
else{
|
||||||
|
split($0,d,"/");
|
||||||
|
$0=d[1];
|
||||||
|
}
|
||||||
|
star=index($0,"*");
|
||||||
|
if (star!=0)
|
||||||
|
{
|
||||||
|
$0=substr($0,star+1);
|
||||||
|
dot=index($0,".");
|
||||||
|
if (dot!=0)
|
||||||
|
$0=substr($0,dot+1);
|
||||||
|
else
|
||||||
|
next;
|
||||||
|
s1=substr($0,1,1);
|
||||||
|
}
|
||||||
|
if (s1==".")
|
||||||
|
{fin=substr($0,2);}
|
||||||
|
else{fin=$0;}
|
||||||
|
if (index(fin,".")==0) next;
|
||||||
|
if (index(fin,"%")!=0) next;
|
||||||
|
if (index(fin,":")!=0) next;
|
||||||
|
match(fin,"^[0-9\.]+")
|
||||||
|
if (RSTART==1 && RLENGTH==length(fin)) {print "ipset add gfwlist "fin>"/tmp/doipset.sh";next;}
|
||||||
|
if (fin=="" || finl==fin) next;
|
||||||
|
finl=fin;
|
||||||
|
if (white==0)
|
||||||
|
{print(" - '\''[/"fin"/]"upst"'\''");}
|
||||||
|
else{
|
||||||
|
print(" - '\''[/"fin"/]#'\''");}
|
||||||
|
}END{print(" - '\''[/programaddend/]#'\''")}' > /tmp/adguard.list
|
||||||
|
cat /tmp/adguard.list 2>/dev/null |sed -r -e "s/\s+\-\s+'//" -e "s/'//" -e "/programaddend/d" > /etc/AdGuardHome/gfw.txt
|
||||||
|
cat /etc/AdGuardHome/gfw.txt 2>/dev/null |sed -e 's:\[\/::' -e 's:\/\].*:\/gfwlist:' -e "/#/d" |sort -u > /etc/AdGuardHome/ipset.txt
|
||||||
|
#sed -i -r 's/upstream_dns_file:\s*['\"].*['\"]/upstream_dns_file: \/etc\/AdGuardHome\/gfw.txt/' $configpath
|
||||||
|
which ipset >/dev/null || ipstok=0
|
||||||
|
if [ -s /etc/AdGuardHome/ipset.txt -a $ipstok -eq 1 ];then
|
||||||
|
ipset list gfwlist >/dev/null 2>&1 || ipset create gfwlist hash:ip 2>/dev/null
|
||||||
|
sed -i -r 's/ipset_file:\s*['\"].*['\"]/ipset_file: \/etc\/AdGuardHome\/ipset.txt/' $configpath
|
||||||
|
fi
|
||||||
|
checkmd5 "$2"
|
||||||
|
rm -f /tmp/gfwlist.txt /tmp/adguard.list
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
https://github.com/AdguardTeam/AdGuardHome/releases/download/${latest_ver}/AdGuardHome_linux_${Arch}.tar.gz
|
||||||
|
https://static.adguard.com/adguardhome/release/AdGuardHome_linux_${Arch}.tar.gz
|
||||||
|
https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_${Arch}.tar.gz
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
tail -n $1 "$2" > /var/run/tailtmp
|
||||||
|
cat /var/run/tailtmp > "$2"
|
||||||
|
rm /var/run/tailtmp
|
||||||
223
luci-app-adguardhome/root/usr/share/AdGuardHome/update_core.sh
Normal file
223
luci-app-adguardhome/root/usr/share/AdGuardHome/update_core.sh
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
update_mode=$1
|
||||||
|
binpath=$(uci get AdGuardHome.AdGuardHome.binpath)
|
||||||
|
if [ -z "$binpath" ]; then
|
||||||
|
uci set AdGuardHome.AdGuardHome.binpath="/tmp/AdGuardHome/AdGuardHome"
|
||||||
|
binpath="/tmp/AdGuardHome/AdGuardHome"
|
||||||
|
fi
|
||||||
|
[[ ! -d ${binpath%/*} ]] && mkdir -p ${binpath%/*}
|
||||||
|
upxflag=$(uci get AdGuardHome.AdGuardHome.upxflag 2>/dev/null)
|
||||||
|
|
||||||
|
[[ -z ${upxflag} ]] && upxflag=off
|
||||||
|
enabled=$(uci get AdGuardHome.AdGuardHome.enabled 2>/dev/null)
|
||||||
|
core_version=$(uci get AdGuardHome.AdGuardHome.core_version 2>/dev/null)
|
||||||
|
case "${core_version}" in
|
||||||
|
beta)
|
||||||
|
core_api_url=https://api.github.com/repos/AdguardTeam/AdGuardHome/releases
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
core_api_url=https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
Check_Task(){
|
||||||
|
running_tasks="$(ps -efww | grep -v grep | grep "AdGuardHome" | grep "update_core" | awk '{print $1}' | wc -l)"
|
||||||
|
case $1 in
|
||||||
|
force)
|
||||||
|
echo -e "执行: 强制更新核心"
|
||||||
|
echo -e "清除 ${running_tasks} 个进程 ..."
|
||||||
|
ps -efww | grep -v grep | grep -v $$ | grep "AdGuardHome" | grep "update_core" | awk '{print $1}' | xargs kill -9 2> /dev/null
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
[[ ${running_tasks} -gt 2 ]] && echo -e "已经有 ${running_tasks} 个任务正在运行, 请等待其执行结束或将其强行停止!" && EXIT 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
Check_Downloader(){
|
||||||
|
which curl > /dev/null 2>&1 && PKG="curl" && return
|
||||||
|
echo -e "\n未安装 curl"
|
||||||
|
which wget-ssl > /dev/null 2>&1 && PKG="wget-ssl" && return
|
||||||
|
echo "未安装 curl 和 wget, 无法检测更新!" && EXIT 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Check_Updates(){
|
||||||
|
Check_Downloader
|
||||||
|
case "${PKG}" in
|
||||||
|
curl)
|
||||||
|
Downloader="curl -L -k -o"
|
||||||
|
_Downloader="curl -s"
|
||||||
|
;;
|
||||||
|
wget-ssl)
|
||||||
|
Downloader="wget-ssl --no-check-certificate -T 5 -O"
|
||||||
|
_Downloader="wget-ssl -q -O -"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "[${PKG}] 开始检查更新, 请耐心等待 ..."
|
||||||
|
Cloud_Version="$(${_Downloader} ${core_api_url} 2>/dev/null | grep 'tag_name' | grep -Eo "v[0-9].+[0-9.]" | awk 'NR==1')"
|
||||||
|
[[ -z ${Cloud_Version} ]] && echo -e "\n检查更新失败, 请检查网络或稍后重试!" && EXIT 1
|
||||||
|
if [[ -f ${binpath} ]]; then
|
||||||
|
Current_Version="$(${binpath} --version 2>/dev/null | grep -Eo "v[0-9].+[0-9]" | sed -r 's/(.*), c(.*)/\1/')"
|
||||||
|
else
|
||||||
|
Current_Version="未知"
|
||||||
|
fi
|
||||||
|
[[ -z ${Current_Version} ]] && Current_Version="未知"
|
||||||
|
echo -e "\n执行文件: ${binpath}\n正在检查更新, 请耐心等待 ..."
|
||||||
|
echo -e "\n当前 AdGuardHome 版本: ${Current_Version}\n云端 AdGuardHome 版本: ${Cloud_Version}"
|
||||||
|
if [[ ! "${Cloud_Version}" == "${Current_Version}" || "$1" == force ]]; then
|
||||||
|
Update_Core
|
||||||
|
else
|
||||||
|
echo -e "\n已是最新版本, 无需更新!"
|
||||||
|
EXIT 0
|
||||||
|
fi
|
||||||
|
EXIT 0
|
||||||
|
}
|
||||||
|
|
||||||
|
UPX_Compress(){
|
||||||
|
Arch_upx=$(GET_Arch )
|
||||||
|
# https://github.com/upx/upx/releases/download/v5.0.0/upx-5.0.0-amd64_linux.tar.xz
|
||||||
|
upx_latest_ver="$(${_Downloader} https://api.github.com/repos/upx/upx/releases/latest 2>/dev/null | grep -E 'tag_name' | grep -E '[0-9.]+' -o 2>/dev/null)"
|
||||||
|
upx_name="upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz"
|
||||||
|
echo -e "开始下载 ${upx_name} ...\n"
|
||||||
|
$Downloader /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz "https://github.com/upx/upx/releases/download/v${upx_latest_ver}/${upx_name}"
|
||||||
|
if [[ ! -e /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz ]]; then
|
||||||
|
echo -e "\n${upx_name} 下载失败!\n"
|
||||||
|
EXIT 1
|
||||||
|
else
|
||||||
|
echo -e "\n${upx_name} 下载成功!\n"
|
||||||
|
fi
|
||||||
|
which xz > /dev/null 2>&1 || (opkg list | grep ^xz || opkg update > /dev/null 2>&1 && opkg install xz --force-depends) || (echo "软件包 xz 安装失败!" && EXIT 1)
|
||||||
|
mkdir -p /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux
|
||||||
|
echo -e "正在解压 ${upx_name} ...\n"
|
||||||
|
xz -d -c /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz | tar -x -C "/tmp"
|
||||||
|
[[ ! -f /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux/upx ]] && echo -e "\n${upx_name} 解压失败!" && EXIT 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Update_Core(){
|
||||||
|
rm -r /tmp/AdGuardHome_Update > /dev/null 2>&1
|
||||||
|
mkdir -p "/tmp/AdGuardHome_Update"
|
||||||
|
|
||||||
|
Arch=$(GET_Arch )
|
||||||
|
eval link=$(uci get AdGuardHome.AdGuardHome.update_url 2>/dev/null)
|
||||||
|
echo -e "下载链接:${link}"
|
||||||
|
echo -e "文件名称:${link##*/}"
|
||||||
|
echo -e "\n开始下载 AdGuardHome 核心文件 ...\n"
|
||||||
|
$Downloader /tmp/AdGuardHome_Update/${link##*/} ${link}
|
||||||
|
if [[ $? != 0 ]];then
|
||||||
|
echo -e "\nAdGuardHome 核心下载失败 ..."
|
||||||
|
rm -r /tmp/AdGuardHome_Update
|
||||||
|
EXIT 1
|
||||||
|
fi
|
||||||
|
if [[ ${link##*.} == gz ]]; then
|
||||||
|
echo -e "\n正在解压 AdGuardHome ..."
|
||||||
|
tar -zxf "/tmp/AdGuardHome_Update/${link##*/}" -C "/tmp/AdGuardHome_Update/"
|
||||||
|
if [[ ! -e /tmp/AdGuardHome_Update/AdGuardHome ]]
|
||||||
|
then
|
||||||
|
echo "AdGuardHome 核心解压失败!"
|
||||||
|
rm -rf "/tmp/AdGuardHome_Update" > /dev/null 2>&1
|
||||||
|
EXIT 1
|
||||||
|
fi
|
||||||
|
downloadbin="/tmp/AdGuardHome_Update/AdGuardHome/AdGuardHome"
|
||||||
|
else
|
||||||
|
downloadbin="/tmp/AdGuardHome_Update/${link##*/}"
|
||||||
|
fi
|
||||||
|
chmod +x ${downloadbin}
|
||||||
|
echo -e "\nAdGuardHome 核心体积: $(awk 'BEGIN{printf "%.2fMB\n",'$((`ls -l $downloadbin | awk '{print $5}'`))'/1000000}')"
|
||||||
|
if [[ ${upxflag} != off ]]; then
|
||||||
|
UPX_Compress
|
||||||
|
echo -e "使用 UPX 压缩可能会花很长时间, 期间请耐心等待!\n正在压缩 $downloadbin ..."
|
||||||
|
/tmp/upx-${upx_latest_ver}-${Arch_upx}_linux/upx $upxflag $downloadbin > /dev/null 2>&1
|
||||||
|
echo -e "\n压缩后的核心体积: $(awk 'BEGIN{printf "%.2fMB\n",'$((`ls -l $downloadbin | awk '{print $5}'`))'/1000000}')"
|
||||||
|
else
|
||||||
|
echo "未启用 UPX 压缩, 跳过操作..."
|
||||||
|
fi
|
||||||
|
/etc/init.d/AdGuardHome stop > /dev/null 2>&1
|
||||||
|
echo -e "\n移动 AdGuardHome 核心文件到 ${binpath%/*} ..."
|
||||||
|
rm -rf ${binpath}
|
||||||
|
mv -f ${downloadbin} ${binpath} > /dev/null 2>&1
|
||||||
|
if [[ ! -s ${binpath} && $? != 0 ]]; then
|
||||||
|
echo -e "AdGuardHome 核心移动失败!\n可能是设备空间不足导致, 请尝试开启 UPX 压缩, 或更改 [执行文件路径] 为 /tmp/AdGuardHome"
|
||||||
|
EXIT 1
|
||||||
|
fi
|
||||||
|
rm -f /tmp/upx*.tar.xz
|
||||||
|
rm -rf /tmp/upx*
|
||||||
|
rm -rf /tmp/AdGuardHome_Update
|
||||||
|
chmod +x ${binpath}
|
||||||
|
if [[ ${enabled} == 1 ]]; then
|
||||||
|
echo -e "\n正在重启 AdGuardHome 服务..."
|
||||||
|
/etc/init.d/AdGuardHome restart
|
||||||
|
fi
|
||||||
|
echo -e "\nAdGuardHome 核心更新成功!"
|
||||||
|
}
|
||||||
|
|
||||||
|
GET_Arch() {
|
||||||
|
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
|
||||||
|
case "${Archt}" in
|
||||||
|
"i386")
|
||||||
|
Arch="386"
|
||||||
|
;;
|
||||||
|
"i686")
|
||||||
|
Arch="386"
|
||||||
|
;;
|
||||||
|
"x86")
|
||||||
|
Arch="amd64"
|
||||||
|
;;
|
||||||
|
"mipsel")
|
||||||
|
Arch="mipsle"
|
||||||
|
;;
|
||||||
|
"mips64el")
|
||||||
|
Arch="mips64le"
|
||||||
|
Arch="mipsle"
|
||||||
|
echo -e "mips64el use $Arch may have bug"
|
||||||
|
;;
|
||||||
|
"mips")
|
||||||
|
Arch="mips"
|
||||||
|
;;
|
||||||
|
"mips64")
|
||||||
|
Arch="mips64"
|
||||||
|
Arch="mips"
|
||||||
|
echo -e "mips64 use $Arch may have bug"
|
||||||
|
;;
|
||||||
|
"arm")
|
||||||
|
Arch="arm"
|
||||||
|
;;
|
||||||
|
"aarch64")
|
||||||
|
Arch="arm64"
|
||||||
|
;;
|
||||||
|
"powerpc")
|
||||||
|
Arch="ppc"
|
||||||
|
echo -e "error not support $Archt"
|
||||||
|
EXIT 1
|
||||||
|
;;
|
||||||
|
"powerpc64")
|
||||||
|
Arch="ppc64"
|
||||||
|
echo -e "error not support $Archt"
|
||||||
|
EXIT 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo -e "error not support $Archt if you can use offical release please issue a bug"
|
||||||
|
EXIT 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "$Arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
EXIT(){
|
||||||
|
rm -rf /var/run/update_core $LOCKU 2>/dev/null
|
||||||
|
[[ $1 != 0 ]] && touch /var/run/update_core_error
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
main(){
|
||||||
|
Check_Task ${update_mode}
|
||||||
|
Check_Updates ${update_mode}
|
||||||
|
}
|
||||||
|
|
||||||
|
trap "EXIT 1" SIGTERM SIGINT
|
||||||
|
touch /var/run/update_core
|
||||||
|
rm - rf /var/run/update_core_error 2>/dev/null
|
||||||
|
|
||||||
|
main
|
||||||
35
luci-app-adguardhome/root/usr/share/AdGuardHome/waitnet.sh
Normal file
35
luci-app-adguardhome/root/usr/share/AdGuardHome/waitnet.sh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
count=0
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
ping -c 1 -W 1 -q www.baidu.com 1>/dev/null 2>&1
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
/etc/init.d/AdGuardHome force_reload
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
ping -c 1 -W 1 -q 202.108.22.5 1>/dev/null 2>&1
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
/etc/init.d/AdGuardHome force_reload
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
ping -c 1 -W 1 -q www.google.com 1>/dev/null 2>&1
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
/etc/init.d/AdGuardHome force_reload
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
ping -c 1 -W 1 -q 8.8.8.8 1>/dev/null 2>&1
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
/etc/init.d/AdGuardHome force_reload
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
count=$((count+1))
|
||||||
|
if [ $count -gt 18 ]; then
|
||||||
|
/etc/init.d/AdGuardHome force_reload
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
configpath=$(uci get AdGuardHome.AdGuardHome.configpath)
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
sleep 10
|
||||||
|
if [ -f "$configpath" ]; then
|
||||||
|
/etc/init.d/AdGuardHome do_redirect 1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"luci-app-adguardhome": {
|
||||||
|
"description": "Grant UCI access for luci-app-adguardhome",
|
||||||
|
"read": {
|
||||||
|
"file": {
|
||||||
|
"/usr/share/AdGuardHome/addhost.sh": [ "exec" ],
|
||||||
|
"/usr/share/AdGuardHome/AdGuardHome_template.yaml": [ "read" ],
|
||||||
|
"/usr/share/AdGuardHome/getsyslog.sh": [ "exec" ],
|
||||||
|
"/usr/share/AdGuardHome/gfw2adg.sh": [ "exec" ],
|
||||||
|
"/usr/share/AdGuardHome/gfwipset2adg.sh": [ "exec" ],
|
||||||
|
"/usr/share/AdGuardHome/update_core.sh": [ "exec" ],
|
||||||
|
"/usr/share/AdGuardHome/waitnet.sh": [ "exec" ],
|
||||||
|
"/usr/share/AdGuardHome/watchconfig.sh": [ "exec" ],
|
||||||
|
"/etc/init.d/AdGuardHome": [ "exec" ],
|
||||||
|
"/etc/init.d/dnsmasq": [ "exec" ],
|
||||||
|
"/usr/bin/AdGuardHome/AdGuardHome": [ "exec" ]
|
||||||
|
},
|
||||||
|
"uci": [ "AdGuardHome" ]
|
||||||
|
},
|
||||||
|
"write": {
|
||||||
|
"uci": [ "AdGuardHome" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/addon/fold/foldcode.js
vendored
Normal file
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/addon/fold/foldcode.js
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(n){"object"==typeof exports&&"object"==typeof module?n(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function e(e,o,i,t){if(i&&i.call){var l=i;i=null}else l=r(e,i,"rangeFinder");"number"==typeof o&&(o=n.Pos(o,0));var f=r(e,i,"minFoldSize");function d(n){var r=l(e,o);if(!r||r.to.line-r.from.line<f)return null;for(var i=e.findMarksAt(r.from),d=0;d<i.length;++d)if(i[d].__isFold&&"fold"!==t){if(!n)return null;r.cleared=!0,i[d].clear()}return r}var u=d(!0);if(r(e,i,"scanUp"))for(;!u&&o.line>e.firstLine();)o=n.Pos(o.line-1,0),u=d(!1);if(u&&!u.cleared&&"unfold"!==t){var a=function(n,e){var o=r(n,e,"widget");if("string"==typeof o){var i=document.createTextNode(o);(o=document.createElement("span")).appendChild(i),o.className="CodeMirror-foldmarker"}else o&&(o=o.cloneNode(!0));return o}(e,i);n.on(a,"mousedown",function(e){c.clear(),n.e_preventDefault(e)});var c=e.markText(u.from,u.to,{replacedWith:a,clearOnEnter:r(e,i,"clearOnEnter"),__isFold:!0});c.on("clear",function(o,r){n.signal(e,"unfold",e,o,r)}),n.signal(e,"fold",e,u.from,u.to)}}n.newFoldFunction=function(n,o){return function(r,i){e(r,i,{rangeFinder:n,widget:o})}},n.defineExtension("foldCode",function(n,o,r){e(this,n,o,r)}),n.defineExtension("isFolded",function(n){for(var e=this.findMarksAt(n),o=0;o<e.length;++o)if(e[o].__isFold)return!0}),n.commands.toggleFold=function(n){n.foldCode(n.getCursor())},n.commands.fold=function(n){n.foldCode(n.getCursor(),null,"fold")},n.commands.unfold=function(n){n.foldCode(n.getCursor(),null,"unfold")},n.commands.foldAll=function(e){e.operation(function(){for(var o=e.firstLine(),r=e.lastLine();o<=r;o++)e.foldCode(n.Pos(o,0),null,"fold")})},n.commands.unfoldAll=function(e){e.operation(function(){for(var o=e.firstLine(),r=e.lastLine();o<=r;o++)e.foldCode(n.Pos(o,0),null,"unfold")})},n.registerHelper("fold","combine",function(){var n=Array.prototype.slice.call(arguments,0);return function(e,o){for(var r=0;r<n.length;++r){var i=n[r](e,o);if(i)return i}}}),n.registerHelper("fold","auto",function(n,e){for(var o=n.getHelpers(e,"fold"),r=0;r<o.length;r++){var i=o[r](n,e);if(i)return i}});var o={rangeFinder:n.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1,clearOnEnter:!0};function r(n,e,r){if(e&&void 0!==e[r])return e[r];var i=n.options.foldOptions;return i&&void 0!==i[r]?i[r]:o[r]}n.defineOption("foldOptions",null),n.defineExtension("foldOption",function(n,e){return r(this,n,e)})});
|
||||||
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/addon/fold/foldgutter.css
vendored
Normal file
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/addon/fold/foldgutter.css
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.CodeMirror-foldmarker{color:blue;text-shadow:#b9f 1px 1px 2px,#b9f -1px -1px 2px,#b9f 1px -1px 2px,#b9f -1px 1px 2px;font-family:arial;line-height:.3;cursor:pointer}.CodeMirror-foldgutter{width:.7em}.CodeMirror-foldgutter-open,.CodeMirror-foldgutter-folded{cursor:pointer}.CodeMirror-foldgutter-open:after{content:"\25BE"}.CodeMirror-foldgutter-folded:after{content:"\25B8"}
|
||||||
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/addon/fold/foldgutter.js
vendored
Normal file
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/addon/fold/foldgutter.js
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("./foldcode")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./foldcode"],t):t(CodeMirror)}(function(t){"use strict";t.defineOption("foldGutter",!1,function(o,e,r){r&&r!=t.Init&&(o.clearGutter(o.state.foldGutter.options.gutter),o.state.foldGutter=null,o.off("gutterClick",a),o.off("changes",d),o.off("viewportChange",u),o.off("fold",l),o.off("unfold",l),o.off("swapDoc",d)),e&&(o.state.foldGutter=new function(t){this.options=t,this.from=this.to=0}(function(t){!0===t&&(t={});null==t.gutter&&(t.gutter="CodeMirror-foldgutter");null==t.indicatorOpen&&(t.indicatorOpen="CodeMirror-foldgutter-open");null==t.indicatorFolded&&(t.indicatorFolded="CodeMirror-foldgutter-folded");return t}(e)),f(o),o.on("gutterClick",a),o.on("changes",d),o.on("viewportChange",u),o.on("fold",l),o.on("unfold",l),o.on("swapDoc",d))});var o=t.Pos;function e(t,e){for(var r=t.findMarks(o(e,0),o(e+1,0)),n=0;n<r.length;++n)if(r[n].__isFold){var i=r[n].find(-1);if(i&&i.line===e)return r[n]}}function r(t){if("string"==typeof t){var o=document.createElement("div");return o.className=t+" CodeMirror-guttermarker-subtle",o}return t.cloneNode(!0)}function n(t,n,f){var a=t.state.foldGutter.options,d=n-1,u=t.foldOption(a,"minFoldSize"),l=t.foldOption(a,"rangeFinder"),c="string"==typeof a.indicatorFolded&&i(a.indicatorFolded),s="string"==typeof a.indicatorOpen&&i(a.indicatorOpen);t.eachLine(n,f,function(n){++d;var i=null,f=n.gutterMarkers;if(f&&(f=f[a.gutter]),e(t,d)){if(c&&f&&c.test(f.className))return;i=r(a.indicatorFolded)}else{var p=o(d,0),m=l&&l(t,p);if(m&&m.to.line-m.from.line>=u){if(s&&f&&s.test(f.className))return;i=r(a.indicatorOpen)}}(i||f)&&t.setGutterMarker(n,a.gutter,i)})}function i(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}function f(t){var o=t.getViewport(),e=t.state.foldGutter;e&&(t.operation(function(){n(t,o.from,o.to)}),e.from=o.from,e.to=o.to)}function a(t,r,n){var i=t.state.foldGutter;if(i){var f=i.options;if(n==f.gutter){var a=e(t,r);a?a.clear():t.foldCode(o(r,0),f)}}}function d(t){var o=t.state.foldGutter;if(o){var e=o.options;o.from=o.to=0,clearTimeout(o.changeUpdate),o.changeUpdate=setTimeout(function(){f(t)},e.foldOnChangeTimeSpan||600)}}function u(t){var o=t.state.foldGutter;if(o){var e=o.options;clearTimeout(o.changeUpdate),o.changeUpdate=setTimeout(function(){var e=t.getViewport();o.from==o.to||e.from-o.to>20||o.from-e.to>20?f(t):t.operation(function(){e.from<o.from&&(n(t,e.from,o.from),o.from=e.from),e.to>o.to&&(n(t,o.to,e.to),o.to=e.to)})},e.updateViewportTimeSpan||400)}}function l(t,o){var e=t.state.foldGutter;if(e){var r=o.line;r>=e.from&&r<e.to&&n(t,r,r+1)}}});
|
||||||
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/addon/fold/indent-fold.js
vendored
Normal file
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/addon/fold/indent-fold.js
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function n(n,t){var i=n.getLine(t),o=i.search(/\S/);return-1==o||/\bcomment\b/.test(n.getTokenTypeAt(e.Pos(t,o+1)))?-1:e.countColumn(i,null,n.getOption("tabSize"))}e.registerHelper("fold","indent",function(t,i){var o=n(t,i.line);if(!(o<0)){for(var r=null,l=i.line+1,f=t.lastLine();l<=f;++l){var u=n(t,l);if(-1==u);else{if(!(u>o))break;r=l}}return r?{from:e.Pos(i.line,t.getLine(i.line).length),to:e.Pos(r,t.getLine(r).length)}:void 0}})});
|
||||||
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/lib/codemirror.css
vendored
Normal file
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/lib/codemirror.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/lib/codemirror.js
vendored
Normal file
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/lib/codemirror.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/mode/yaml/yaml.js
vendored
Normal file
1
luci-app-adguardhome/root/www/luci-static/resources/codemirror/mode/yaml/yaml.js
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("yaml",function(){var e=new RegExp("\\b(("+["true","false","on","off","yes","no"].join(")|(")+"))$","i");return{token:function(i,t){var r=i.peek(),n=t.escaped;if(t.escaped=!1,"#"==r&&(0==i.pos||/\s/.test(i.string.charAt(i.pos-1))))return i.skipToEnd(),"comment";if(i.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))return"string";if(t.literal&&i.indentation()>t.keyCol)return i.skipToEnd(),"string";if(t.literal&&(t.literal=!1),i.sol()){if(t.keyCol=0,t.pair=!1,t.pairStart=!1,i.match(/---/))return"def";if(i.match(/\.\.\./))return"def";if(i.match(/\s*-\s+/))return"meta"}if(i.match(/^(\{|\}|\[|\])/))return"{"==r?t.inlinePairs++:"}"==r?t.inlinePairs--:"["==r?t.inlineList++:t.inlineList--,"meta";if(t.inlineList>0&&!n&&","==r)return i.next(),"meta";if(t.inlinePairs>0&&!n&&","==r)return t.keyCol=0,t.pair=!1,t.pairStart=!1,i.next(),"meta";if(t.pairStart){if(i.match(/^\s*(\||\>)\s*/))return t.literal=!0,"meta";if(i.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i))return"variable-2";if(0==t.inlinePairs&&i.match(/^\s*-?[0-9\.\,]+\s?$/))return"number";if(t.inlinePairs>0&&i.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/))return"number";if(i.match(e))return"keyword"}return!t.pair&&i.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)?(t.pair=!0,t.keyCol=i.indentation(),"atom"):t.pair&&i.match(/^:\s*/)?(t.pairStart=!0,"meta"):(t.pairStart=!1,t.escaped="\\"==r,i.next(),null)},startState:function(){return{pair:!1,pairStart:!1,keyCol:0,inlinePairs:0,inlineList:0,literal:!1,escaped:!1}},lineComment:"#",fold:"indent"}}),e.defineMIME("text/x-yaml","yaml"),e.defineMIME("text/yaml","yaml")});
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user