diff --git a/include/host-build.mk b/include/host-build.mk index 70bf6e5a39..b5f1a6bfa7 100644 --- a/include/host-build.mk +++ b/include/host-build.mk @@ -77,6 +77,10 @@ HOST_MAKE_FLAGS = HOST_CONFIGURE_CMD = $(BASH) ./configure +ifeq ($(HOST_OS),Darwin) + HOST_CONFIG_SITE:=$(INCLUDE_DIR)/site/darwin +endif + define Host/Configure/Default $(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \ if [ -x configure ]; then \ @@ -127,6 +131,7 @@ define Host/Exports/Default $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig:$$(HOST_BUILD_PREFIX)/lib/pkgconfig $(1) : export PKG_CONFIG_LIBDIR=$$(HOST_BUILD_PREFIX)/lib/pkgconfig $(1) : export CCACHE_DIR:=$(STAGING_DIR_HOST)/ccache + $(if $(HOST_CONFIG_SITE),$(1) : export CONFIG_SITE:=$(HOST_CONFIG_SITE)) $(if $(IS_PACKAGE_BUILD),$(1) : export PATH=$$(TARGET_PATH_PKG)) endef Host/Exports=$(Host/Exports/Default) diff --git a/include/kernel-version.mk b/include/kernel-version.mk index 13b5b83118..b4e29ff39a 100644 --- a/include/kernel-version.mk +++ b/include/kernel-version.mk @@ -3,10 +3,10 @@ LINUX_RELEASE?=1 LINUX_VERSION-3.18 = .43 -LINUX_VERSION-4.4 = .87 +LINUX_VERSION-4.4 = .89 LINUX_KERNEL_HASH-3.18.43 = 1236e8123a6ce537d5029232560966feed054ae31776fe8481dd7d18cdd5492c -LINUX_KERNEL_HASH-4.4.87 = 1ab05222c3c55e062c3f7418976137ee529f92174261ccb0cd5a7d3370ff6f5b +LINUX_KERNEL_HASH-4.4.89 = a81d1b1306e4fddee5d6f7219090a616073b02f4069e44522a9c0454b17f2b67 ifdef KERNEL_PATCHVER LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER))) diff --git a/include/site/darwin b/include/site/darwin new file mode 100644 index 0000000000..ec38f67be6 --- /dev/null +++ b/include/site/darwin @@ -0,0 +1,2 @@ +ac_cv_func_futimens=no +ac_cv_func_utimensat=no diff --git a/include/target.mk b/include/target.mk index b38369bddd..a5356bb769 100644 --- a/include/target.mk +++ b/include/target.mk @@ -14,12 +14,13 @@ DEVICE_TYPE?=router # Default packages - the really basic set DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd \ -iptables-mod-nat-extra kmod-macvlan block-mount default-settings ipset-lists luci luci-app-ddns luci-app-sqm luci-app-upnp luci-app-adbyby-plus luci-app-autoreboot \ -luci-app-filetransfer luci-app-shadowsocksr-pro luci-app-usb-printer +iptables-mod-nat-extra kmod-nf-nathelper kmod-nf-nathelper-extra kmod-macvlan block-mount \ +default-settings ipset-lists luci luci-app-ddns luci-app-sqm luci-app-upnp luci-app-adbyby-plus luci-app-autoreboot \ +luci-app-filetransfer luci-app-shadowsocksr-pro luci-app-usb-printer luci-app-vsftpd luci-app-sfe # For nas targets DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm # For router targets -DEFAULT_PACKAGES.router:=dnsmasq-full iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd odhcp6c +DEFAULT_PACKAGES.router:=dnsmasq iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd odhcp6c DEFAULT_PACKAGES.bootloader:= ifneq ($(DUMP),) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 305d0bfd33..fdeda95a17 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/version.mk PKG_NAME:=base-files -PKG_RELEASE:=173 +PKG_RELEASE:=173.1 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ @@ -138,6 +138,7 @@ define Package/base-files/install mkdir -p $(1)/CONTROL mkdir -p $(1)/dev + mkdir -p $(1)/etc/config mkdir -p $(1)/etc/crontabs mkdir -p $(1)/etc/rc.d mkdir -p $(1)/overlay diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 6230b0892f..a8311fc595 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -119,17 +119,14 @@ generate_network() { ;; pppoe) - # fixup IPv6 slave interface - ifname="pppoe-$1" - uci -q batch <<-EOF set network.$1.proto='pppoe' set network.$1.username='username' set network.$1.password='password' - set network.$1.ipv6='auto' + set network.$1.ipv6='1' delete network.${1}6 set network.${1}6='interface' - set network.${1}6.ifname='$ifname' + set network.${1}6.ifname='@${1}' set network.${1}6.proto='dhcpv6' EOF ;; diff --git a/package/kernel/lantiq/ltq-vdsl-mei/Makefile b/package/kernel/lantiq/ltq-vdsl-mei/Makefile index c6830ca3a1..6724dc0852 100644 --- a/package/kernel/lantiq/ltq-vdsl-mei/Makefile +++ b/package/kernel/lantiq/ltq-vdsl-mei/Makefile @@ -9,7 +9,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-vdsl-vr9-mei PKG_VERSION:=1.5.17.6 -PKG_RELEASE:=1 +PKG_RELEASE:=3 PKG_BASE_NAME:=drv_mei_cpe PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz diff --git a/package/kernel/lantiq/ltq-vdsl/Makefile b/package/kernel/lantiq/ltq-vdsl/Makefile index c9667c9945..3770d1067d 100644 --- a/package/kernel/lantiq/ltq-vdsl/Makefile +++ b/package/kernel/lantiq/ltq-vdsl/Makefile @@ -9,7 +9,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-vdsl-vr9 PKG_VERSION:=4.17.18.6 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_BASE_NAME:=drv_dsl_cpe_api PKG_SOURCE:=$(PKG_BASE_NAME)_vrx-$(PKG_VERSION).tar.gz diff --git a/package/kernel/lantiq/ltq-vdsl/patches/110-semaphore-lock.patch b/package/kernel/lantiq/ltq-vdsl/patches/110-semaphore-lock.patch new file mode 100644 index 0000000000..12c00c33ec --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl/patches/110-semaphore-lock.patch @@ -0,0 +1,107 @@ +--- a/src/include/drv_dsl_cpe_pm_core.h ++++ b/src/include/drv_dsl_cpe_pm_core.h +@@ -1510,9 +1510,9 @@ typedef struct + /** Common PM module mutex*/ + DSL_DRV_Mutex_t pmMutex; + /** PM module direction Near-End mutex*/ +- DSL_DRV_Mutex_t pmNeMutex; ++ struct semaphore pmNeMutex; + /** PM module direction Far-End mutex*/ +- DSL_DRV_Mutex_t pmFeMutex; ++ struct semaphore pmFeMutex; + /** PM module Near-End access mutex*/ + DSL_DRV_Mutex_t pmNeAccessMutex; + /** PM module Far-End access mutex*/ +--- a/src/pm/drv_dsl_cpe_api_pm.c ++++ b/src/pm/drv_dsl_cpe_api_pm.c +@@ -220,9 +220,9 @@ DSL_Error_t DSL_DRV_PM_Start( + /* init PM module common mutex */ + DSL_DRV_MUTEX_INIT(DSL_DRV_PM_CONTEXT(pContext)->pmMutex); + /* init PM module direction Near-End mutex */ +- DSL_DRV_MUTEX_INIT(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex); ++ sema_init(&(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex),1); + /* init PM module direction Far-End mutex */ +- DSL_DRV_MUTEX_INIT(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex); ++ sema_init(&(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex),1); + /* init PM module Near-End access mutex */ + DSL_DRV_MUTEX_INIT(DSL_DRV_PM_CONTEXT(pContext)->pmNeAccessMutex); + /* init PM module Far-End access mutex */ +@@ -592,7 +592,7 @@ DSL_Error_t DSL_DRV_PM_Stop( + if( DSL_DRV_PM_CONTEXT(pContext)->pmThreadFe.bRun != DSL_TRUE ) + { + DSL_DEBUG(DSL_DBG_WRN, +- (pContext, SYS_DBG_WRN"DSL[%02d]: PM module Near-End thread already stopped" ++ (pContext, SYS_DBG_WRN"DSL[%02d]: PM module Far-End thread already stopped" + DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); + } + else +--- a/src/pm/drv_dsl_cpe_pm_core.c ++++ b/src/pm/drv_dsl_cpe_pm_core.c +@@ -1022,7 +1022,7 @@ DSL_Error_t DSL_DRV_PM_DirectionMutexCon + { + if( bLock ) + { +- if( DSL_DRV_MUTEX_LOCK(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex) ) ++ if(down_interruptible(&(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex))) + { + DSL_DEBUG( DSL_DBG_ERR, + (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - Couldn't lock PM NE mutex!" +@@ -1034,14 +1034,14 @@ DSL_Error_t DSL_DRV_PM_DirectionMutexCon + else + { + /* Unlock PM module NE Mutex*/ +- DSL_DRV_MUTEX_UNLOCK(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex); ++ up(&(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex)); + } + } + else + { + if( bLock ) + { +- if( DSL_DRV_MUTEX_LOCK(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex) ) ++ if(down_interruptible(&(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex))) + { + DSL_DEBUG( DSL_DBG_ERR, + (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - Couldn't lock PM FE mutex!" +@@ -1053,7 +1053,7 @@ DSL_Error_t DSL_DRV_PM_DirectionMutexCon + else + { + /* Unlock PM module FE Mutex*/ +- DSL_DRV_MUTEX_UNLOCK(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex); ++ up(&(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex)); + } + } + +@@ -1139,7 +1139,7 @@ DSL_Error_t DSL_DRV_PM_Lock(DSL_Context_ + if( !(DSL_DRV_PM_CONTEXT(pContext)->bPmLock) ) + { + /* Lock PM module Near-End Mutex*/ +- if( DSL_DRV_MUTEX_LOCK(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex) ) ++ if(down_interruptible(&(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex))) + { + DSL_DEBUG( DSL_DBG_ERR, + (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - Couldn't lock PM NE mutex!" +@@ -1148,8 +1148,8 @@ DSL_Error_t DSL_DRV_PM_Lock(DSL_Context_ + return DSL_ERR_SEMAPHORE_GET; + } + +- /* Lock PM module Near-End Mutex*/ +- if( DSL_DRV_MUTEX_LOCK(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex) ) ++ /* Lock PM module Far-End Mutex*/ ++ if( down_interruptible(&(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex)) ) + { + DSL_DEBUG( DSL_DBG_ERR, + (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - Couldn't lock PM FE mutex!" +@@ -1193,10 +1193,10 @@ DSL_Error_t DSL_DRV_PM_UnLock(DSL_Contex + if( DSL_DRV_PM_CONTEXT(pContext)->bPmLock ) + { + /* Unlock PM module NE Mutex*/ +- DSL_DRV_MUTEX_UNLOCK(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex); ++ up(&(DSL_DRV_PM_CONTEXT(pContext)->pmNeMutex)); + + /* Unlock PM module FE Mutex*/ +- DSL_DRV_MUTEX_UNLOCK(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex); ++ up(&(DSL_DRV_PM_CONTEXT(pContext)->pmFeMutex)); + + /* Clear bPmLock flag*/ + DSL_DRV_PM_CONTEXT(pContext)->bPmLock = DSL_FALSE; diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile index 8ec05a343a..3a96472b88 100644 --- a/package/kernel/mac80211/Makefile +++ b/package/kernel/mac80211/Makefile @@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 PKG_VERSION:=2017-01-31 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources PKG_BACKPORT_VERSION:= PKG_HASH:=75e6d39e34cf156212a2509172a4a62b673b69eb4a1d9aaa565f7fa719fa2317 diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh index 4bfc7424b2..940fb52ac2 100644 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh @@ -92,7 +92,7 @@ detect_mac80211() { htmode="VHT80" } - [ -n $htmode ] && ht_capab="set wireless.radio${devidx}.htmode=$htmode" + [ -n "$htmode" ] && ht_capab="set wireless.radio${devidx}.htmode=$htmode" if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then path="$(readlink -f /sys/class/ieee80211/${dev}/device)" diff --git a/package/lean/default-settings/Makefile b/package/lean/default-settings/Makefile index cfdbb500b2..3d47004399 100644 --- a/package/lean/default-settings/Makefile +++ b/package/lean/default-settings/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=default-settings PKG_VERSION:=1.0 -PKG_RELEASE:=21 +PKG_RELEASE:=22 PKG_LICENSE:=GPLv3 PKG_LICENSE_FILES:=LICENSE @@ -21,6 +21,7 @@ define Package/default-settings CATEGORY:=LuCI TITLE:=LuCI support for Default Settings PKGARCH:=all + DEPENDS:=+@LUCI_LANG_zh-cn endef define Package/default-settings/description diff --git a/package/lean/default-settings/files/zzz-default-settings b/package/lean/default-settings/files/zzz-default-settings index 1e7e6086c7..ee88e8b45e 100755 --- a/package/lean/default-settings/files/zzz-default-settings +++ b/package/lean/default-settings/files/zzz-default-settings @@ -47,9 +47,9 @@ sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh wifi up sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release -echo "DISTRIB_REVISION='R7.4 By Lean'" >> /etc/openwrt_release +echo "DISTRIB_REVISION='R7.4.2 By Lean'" >> /etc/openwrt_release sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release -echo "DISTRIB_DESCRIPTION='LEDE 17.01.2'" >> /etc/openwrt_release +echo "DISTRIB_DESCRIPTION='LEDE 17.01.3'" >> /etc/openwrt_release exit 0 diff --git a/package/lean/libcryptopp/Makefile b/package/lean/libcryptopp/Makefile new file mode 100644 index 0000000000..f37b6088be --- /dev/null +++ b/package/lean/libcryptopp/Makefile @@ -0,0 +1,66 @@ +# +# Copyright (C) 2009-2012 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libcryptopp +PKG_VERSION:=5.6.4 +PKG_RELEASE:=1 + +PKG_SOURCE:=cryptopp$(subst .,,$(PKG_VERSION)).zip +PKG_SOURCE_URL:=http://www.cryptopp.com/ +PKG_MD5SUM:=4ee7e5cdd4a45a14756c169eaf2a77fc + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION) + +CMAKE_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/libcryptopp + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libpthread +libstdcpp + TITLE:=Crypto++ is library for creating C++ programs which use cryptographic algorithms + URL:=http://packages.debian.org/sid/libcrypto++-dev +endef + +define Package/package/libcryptopp + Crypto++ is library for creating C++ programs which use cryptographic algorithms. + The library uses a Pipes & Filters architecture with heavy use of templates and + abstract base classes. +endef + +#CONFIGURE_ARGS += \ +# --enable-static \ +# --enable-shared + +#TARGET_LDFLAGS += \ +# -lpthread +CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS="$(FPIC)" +CMAKE_OPTIONS += -DBUILD_STATIC=ON +CMAKE_OPTIONS += -DBUILD_SHARED=ON + +UNPACK_CMD=cd $(PKG_BUILD_DIR) && unzip "$(DL_DIR)/$(PKG_SOURCE)" +define Build/Prepare + $(Build/Prepare/Default) + cd $(PKG_BUILD_DIR) && rm -f GNUmakefile GNUmakefile-cross +endef +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/cryptopp + $(CP) $(PKG_INSTALL_DIR)/usr/include/cryptopp/* $(1)/usr/include/cryptopp/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcryptopp.{a,so*} $(1)/usr/lib/ +endef + +define Package/libcryptopp/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcryptopp.so* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libcryptopp)) diff --git a/package/lean/luci-app-adbyby-plus/Makefile b/package/lean/luci-app-adbyby-plus/Makefile index c08b00b153..d0125d1112 100644 --- a/package/lean/luci-app-adbyby-plus/Makefile +++ b/package/lean/luci-app-adbyby-plus/Makefile @@ -10,7 +10,7 @@ LUCI_DEPENDS:=+adbyby +wget +ipset +coreutils +coreutils-nohup +dnsmasq-full LUCI_PKGARCH:=all PKG_NAME:=luci-app-adbyby-plus PKG_VERSION:=2.0 -PKG_RELEASE:=19 +PKG_RELEASE:=21 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-adbyby-plus/luasrc/model/cbi/adbyby.lua b/package/lean/luci-app-adbyby-plus/luasrc/model/cbi/adbyby.lua index 694dbbb125..87b9971d4d 100644 --- a/package/lean/luci-app-adbyby-plus/luasrc/model/cbi/adbyby.lua +++ b/package/lean/luci-app-adbyby-plus/luasrc/model/cbi/adbyby.lua @@ -70,7 +70,8 @@ o.description = translate(string.format("%s", Status)) o.description = translate(string.format("Lazy Rule:%s Video Rule:%sThird Party Subscription Rule:%d lines User-defined Rule:%d lines", DL, DV, math.abs(NR-NU), NR)) o.inputstyle = "reload" o.write = function() - SYS.call("/etc/init.d/adbyby restart") + SYS.call("nohup sh /usr/share/adbyby/adupdate.sh > /tmp/adupdate.log 2>&1 &") + SYS.call("sleep 4") HTTP.redirect(DISP.build_url("admin", "services", "adbyby")) end @@ -82,7 +83,6 @@ o.default = 0 o.rmempty = false o.description = translate(string.format("Adblock Plus Host List: %s Lines", ND)) - updatead = s:taboption("advanced", Button, "updatead", translate("Manually force updateAdblock Plus Host List"), translate("Note: It needs to download and convert the rules. The background process may takes 60-120 seconds to run. After completed it would automatically refresh, please do not duplicate click!")) updatead.inputtitle = translate("Manually force update") updatead.inputstyle = "apply" @@ -90,6 +90,11 @@ updatead.write = function() SYS.call("nohup sh /usr/share/adbyby/adblock.sh > /tmp/adupdate.log 2>&1 &") end +o = s:taboption("advanced", Flag, "update_source") +o.title = translate("Update adbyby rules form official website first") +o.default = 1 +o.rmempty = false + o = s:taboption("advanced", Flag, "block_ios") o.title = translate("Block Apple iOS OTA update") o.default = 0 diff --git a/package/lean/luci-app-adbyby-plus/po/zh-cn/adbyby.po b/package/lean/luci-app-adbyby-plus/po/zh-cn/adbyby.po index 045517d216..b0842860c6 100644 --- a/package/lean/luci-app-adbyby-plus/po/zh-cn/adbyby.po +++ b/package/lean/luci-app-adbyby-plus/po/zh-cn/adbyby.po @@ -114,5 +114,12 @@ msgstr "Adblock Plus Host 列表:" msgid "Note: It needs to download and convert the rules. The background process may takes 60-120 seconds to run. After completed it would automatically refresh, please do not duplicate click!" msgstr "注意:需要下载并转换规则。后台进程可能需要60-120秒运行。完成后会自动刷新,请不要重复点击!" +msgid "No filter" +msgstr "不过滤" +msgid "Global filter" +msgstr "全局过滤" + +msgid "Update adbyby rules form official website first" +msgstr "优先从官方网站更新规则" diff --git a/package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adupdate.sh b/package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adupdate.sh index 2f47f35dad..83b4a79829 100755 --- a/package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adupdate.sh +++ b/package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adupdate.sh @@ -1,11 +1,17 @@ #!/bin/sh -wget -t 1 -T 10 -O /tmp/lazy.txt http://update.adbyby.com/rule3/lazy.jpg -wget -t 1 -T 10 -O /tmp/video.txt http://update.adbyby.com/rule3/video.jpg -wget -t 1 -T 10 -O /tmp/user.action http://update.adbyby.com/rule3/user.action +update_source=$(uci get adbyby.@adbyby[0].update_source 2>/dev/null) -[ ! -s "/tmp/lazy.txt" ] && wget --no-check-certificate -O /tmp/lazy.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/lazy.txt -[ ! -s "/tmp/video.txt" ] && wget --no-check-certificate -O /tmp/video.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/video.txt +rm -f /usr/share/adbyby/data/*.bak + +if [ $update_source -eq 1 ]; then + wget -t 1 -T 10 -O /tmp/lazy.txt http://update.adbyby.com/rule3/lazy.jpg + wget -t 1 -T 10 -O /tmp/video.txt http://update.adbyby.com/rule3/video.jpg + wget -t 1 -T 10 -O /tmp/user.action http://update.adbyby.com/rule3/user.action +fi + +[ ! -s "/tmp/lazy.txt" ] && wget-ssl --no-check-certificate -O /tmp/lazy.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/lazy.txt +[ ! -s "/tmp/video.txt" ] && wget-ssl --no-check-certificate -O /tmp/video.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/video.txt [ -s "/tmp/lazy.txt" ] && ( ! cmp -s /tmp/lazy.txt /usr/share/adbyby/data/lazy.txt ) && mv /tmp/lazy.txt /usr/share/adbyby/data/lazy.txt [ -s "/tmp/video.txt" ] && ( ! cmp -s /tmp/video.txt /usr/share/adbyby/data/video.txt ) && mv /tmp/video.txt /usr/share/adbyby/data/video.txt diff --git a/package/lean/luci-app-haproxy/LICENSE b/package/lean/luci-app-haproxy/LICENSE new file mode 100644 index 0000000000..e09a55e377 --- /dev/null +++ b/package/lean/luci-app-haproxy/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 chenhw2 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/package/lean/luci-app-haproxy/Makefile b/package/lean/luci-app-haproxy/Makefile new file mode 100644 index 0000000000..3bb7287dbf --- /dev/null +++ b/package/lean/luci-app-haproxy/Makefile @@ -0,0 +1,86 @@ +# +# Copyright (C) 2016 chenhw2 +# +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci-app-haproxy-tcp +PKG_VERSION:=0.1.4 +PKG_RELEASE:=2 + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=LICENSE +PKG_MAINTAINER:=chenhw2 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/luci-app-haproxy-tcp + SECTION:=luci + CATEGORY:=LuCI + SUBMENU:=3. Applications + TITLE:=LuCI Support for HAProxy-TCP + PKGARCH:=all + DEPENDS:=+haproxy-nossl +endef + +define Package/luci-app-haproxy-tcp/description + LuCI Support for HAProxy-TCP. +endef + +define Build/Prepare + $(foreach po,$(wildcard ${CURDIR}/files/luci/i18n/*.po), \ + po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/luci-app-haproxy-tcp/postinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + if [ -f /etc/uci-defaults/luci-haproxy-tcp ]; then + ( . /etc/uci-defaults/luci-haproxy-tcp ) && \ + rm -f /etc/uci-defaults/luci-haproxy-tcp + fi + rm -rf /tmp/luci-indexcache /tmp/luci-modulecache +fi +exit 0 +endef + +define Package/luci-app-haproxy-tcp/prerm +#!/bin/sh +/etc/init.d/haproxy-tcp disable +/etc/init.d/haproxy-tcp stop +rm -f /usr/sbin/haproxy-tcp +exit 0 +endef + +define Package/luci-app-haproxy-tcp/conffiles +/etc/config/haproxy-tcp +endef + +define Package/luci-app-haproxy-tcp/install + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n + $(INSTALL_DATA) $(PKG_BUILD_DIR)/haproxy-tcp.*.lmo $(1)/usr/lib/lua/luci/i18n/ + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller + $(INSTALL_DATA) ./files/luci/controller/*.lua $(1)/usr/lib/lua/luci/controller/ + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi + $(INSTALL_DATA) ./files/luci/model/cbi/*.lua $(1)/usr/lib/lua/luci/model/cbi/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/root/etc/config/haproxy-tcp $(1)/etc/config/haproxy-tcp + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/root/etc/init.d/haproxy-tcp $(1)/etc/init.d/haproxy-tcp + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-haproxy-tcp $(1)/etc/uci-defaults/luci-haproxy-tcp + $(INSTALL_DIR) $(1)/usr/sbin + $(LN) haproxy $(1)/usr/sbin/haproxy-tcp +endef + +$(eval $(call BuildPackage,luci-app-haproxy-tcp)) diff --git a/package/lean/luci-app-haproxy/files/luci/controller/haproxy-tcp.lua b/package/lean/luci-app-haproxy/files/luci/controller/haproxy-tcp.lua new file mode 100644 index 0000000000..bb83188878 --- /dev/null +++ b/package/lean/luci-app-haproxy/files/luci/controller/haproxy-tcp.lua @@ -0,0 +1,7 @@ +module("luci.controller.haproxy-tcp", package.seeall) + +function index() + entry( + {"admin", "services", "haproxy-tcp"}, + cbi("haproxy-tcp"), _("HAProxy-TCP"), 55) +end diff --git a/package/lean/luci-app-haproxy/files/luci/i18n/haproxy-tcp.zh-cn.po b/package/lean/luci-app-haproxy/files/luci/i18n/haproxy-tcp.zh-cn.po new file mode 100644 index 0000000000..0c2d3eb2df --- /dev/null +++ b/package/lean/luci-app-haproxy/files/luci/i18n/haproxy-tcp.zh-cn.po @@ -0,0 +1,35 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + +msgid "%u seconds" +msgstr "%u 秒" + +msgid "Enable" +msgstr "启用" + +msgid "General Setting" +msgstr "基本设置" + +msgid "HAProxy-TCP" +msgstr "负载均衡-TCP" + +msgid "Listen Address:Port" +msgstr "服务地址" + +msgid "Retries" +msgstr "重试次数" + +msgid "Status Admin" +msgstr "状态管理" + +msgid "Startup Delay" +msgstr "自启动延时" + +msgid "Port" +msgstr "端口" + +msgid "Timeout Connect (ms)" +msgstr "连接超时 (毫秒)" + +msgid "UpStream Server" +msgstr "上游服务器" diff --git a/package/lean/luci-app-haproxy/files/luci/model/cbi/haproxy-tcp.lua b/package/lean/luci-app-haproxy/files/luci/model/cbi/haproxy-tcp.lua new file mode 100644 index 0000000000..4bfdb8d479 --- /dev/null +++ b/package/lean/luci-app-haproxy/files/luci/model/cbi/haproxy-tcp.lua @@ -0,0 +1,57 @@ +local m, s, o + +if luci.sys.call("pgrep haproxy-tcp >/dev/null") == 0 then + m = Map("haproxy-tcp", translate("HAProxy-TCP"), "%s - %s" %{translate("HAProxy-TCP"), translate("RUNNING")}) +else + m = Map("haproxy-tcp", translate("HAProxy-TCP"), "%s - %s" %{translate("HAProxy-TCP"), translate("NOT RUNNING")}) +end + +s = m:section(TypedSection, "general", translate("General Setting"), + "%s" %{ + luci.sys.exec("uci get network.lan.ipaddr | tr -d '\r\n'"), + luci.sys.exec("uci get haproxy-tcp.general.admin_stats | tr -d '\r\n'"), + translate("Status Admin") + }) +s.anonymous = true + +o = s:option(Flag, "enable", translate("Enable")) +o.rmempty = false + +o = s:option(Value, "startup_delay", translate("Startup Delay")) +o:value(0, translate("Not enabled")) +for _, v in ipairs({5, 10, 15, 25, 40}) do + o:value(v, translate("%u seconds") %{v}) +end +o.datatype = "uinteger" +o.default = 0 +o.rmempty = false + +o = s:option(Value, "admin_stats", "%s%s" %{translate("Status Admin"), translate("Port")}) +o.placeholder = "7777" +o.default = "7777" +o.datatype = "port" +o.rmempty = false + +o = s:option(Value, "listen", translate("Listen Address:Port")) +o.placeholder = "0.0.0.0:6666" +o.default = "0.0.0.0:6666" +o.rmempty = false + +o = s:option(Value, "timeout", translate("Timeout Connect (ms)")) +o.placeholder = "666" +o.default = "666" +o.datatype = "range(33, 10000)" +o.rmempty = false + +o = s:option(Value, "retries", translate("Retries")) +o.placeholder = "1" +o.default = "1" +o.datatype = "range(1, 10)" +o.rmempty = false + + +o = s:option(DynamicList, "upstreams", translate("UpStream Server"), translate("e.g. [8.8.8.8:53 weight 100]")) +o.placeholder = "8.8.8.8:53" +o.rmempty = false + +return m diff --git a/package/lean/luci-app-haproxy/files/root/etc/config/haproxy-tcp b/package/lean/luci-app-haproxy/files/root/etc/config/haproxy-tcp new file mode 100644 index 0000000000..833ca571d9 --- /dev/null +++ b/package/lean/luci-app-haproxy/files/root/etc/config/haproxy-tcp @@ -0,0 +1,9 @@ + +config general 'general' + option enable '0' + option retries '1' + option timeout '1000' + option listen '0.0.0.0:6666' + option admin_stats '7777' + option startup_delay '5' + list upstreams '1.2.3.4:8388' diff --git a/package/lean/luci-app-haproxy/files/root/etc/init.d/haproxy-tcp b/package/lean/luci-app-haproxy/files/root/etc/init.d/haproxy-tcp new file mode 100644 index 0000000000..1d978e314e --- /dev/null +++ b/package/lean/luci-app-haproxy/files/root/etc/init.d/haproxy-tcp @@ -0,0 +1,74 @@ +#!/bin/sh /etc/rc.common + +START=85 +NAME=haproxy-tcp + +genline_srv(){ + line="$1" + hash="$(echo -n $line | md5sum | cut -c1-6)" + hash="$(echo -n $line | tr -d '\t ' | cut -c1-8)__$hash" + echo " server $hash $line" | tr -d "\'" +} + +boot() { + local delay=$(uci -q get $NAME.general.startup_delay) + (sleep ${delay:-0} && start >/dev/null 2>&1) & + return 0 +} + +start() { + enable=$(uci -q get $NAME.general.enable) + [ "$enable" = 1 ] || return 0 + listen=$(uci -q get $NAME.general.listen) + admin_stats=$(uci -q get $NAME.general.admin_stats) + retries=$(uci -q get $NAME.general.retries) + timeout=$(uci -q get $NAME.general.timeout) + upstreams=$(uci -q get $NAME.general.upstreams) + + mkdir -p /var/etc + cat <<-EOF > /var/etc/$NAME.cfg + global + nbproc 2 + + defaults + mode tcp + retries ${retries:-2} + timeout connect ${timeout:-1000} + + listen admin_stats + bind 0.0.0.0:${admin_stats:-7777} + mode http + stats uri / + stats refresh 10s + + frontend tcp-in + bind ${listen:-0.0.0.0:6666} + default_backend tcp-out + + backend tcp-out + $( if [ 0 -lt $(grep -c weight /etc/config/$NAME) ]; then + echo " balance static-rr" + sed -n 's/.*upstreams[\t ]*//p' /etc/config/$NAME | + while read upstream; do + genline_srv "$upstream" + done + else + for upstream in $upstreams; do + genline_srv "$upstream" + done + fi + ) + +EOF + + /usr/sbin/$NAME -q -D -f /var/etc/$NAME.cfg -p /var/run/$NAME.pid +} + +kill_all() { + kill -9 $(pgrep -f $@) >/dev/null 2>&1 +} + +stop() { + kill_all "$NAME.pid" + rm -rf /var/etc/$NAME.cfg +} diff --git a/package/lean/luci-app-haproxy/files/root/etc/uci-defaults/luci-haproxy-tcp b/package/lean/luci-app-haproxy/files/root/etc/uci-defaults/luci-haproxy-tcp new file mode 100644 index 0000000000..a8923938ce --- /dev/null +++ b/package/lean/luci-app-haproxy/files/root/etc/uci-defaults/luci-haproxy-tcp @@ -0,0 +1,15 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@haproxy-tcp[-1] + add ucitrack haproxy-tcp + set ucitrack.@haproxy-tcp[-1].init=haproxy-tcp + commit ucitrack +EOF + +/etc/init.d/haproxy stop +/etc/init.d/haproxy disable + +/etc/init.d/haproxy-tcp enable + +exit 0 diff --git a/package/lean/luci-app-haproxy/tools/po2lmo/Makefile b/package/lean/luci-app-haproxy/tools/po2lmo/Makefile new file mode 100644 index 0000000000..ad2c133207 --- /dev/null +++ b/package/lean/luci-app-haproxy/tools/po2lmo/Makefile @@ -0,0 +1,12 @@ + +INSTALL = install +PREFIX = /usr/bin + +po2lmo: src/po2lmo.o src/template_lmo.o + $(CC) $(LDFLAGS) -o src/po2lmo src/po2lmo.o src/template_lmo.o + +install: + $(INSTALL) -m 755 src/po2lmo $(PREFIX) + +clean: + $(RM) src/po2lmo src/*.o diff --git a/package/lean/luci-app-haproxy/tools/po2lmo/src/po2lmo.c b/package/lean/luci-app-haproxy/tools/po2lmo/src/po2lmo.c new file mode 100644 index 0000000000..0da792b680 --- /dev/null +++ b/package/lean/luci-app-haproxy/tools/po2lmo/src/po2lmo.c @@ -0,0 +1,247 @@ +/* + * lmo - Lua Machine Objects - PO to LMO conversion tool + * + * Copyright (C) 2009-2012 Jo-Philipp Wich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "template_lmo.h" + +static void die(const char *msg) +{ + fprintf(stderr, "Error: %s\n", msg); + exit(1); +} + +static void usage(const char *name) +{ + fprintf(stderr, "Usage: %s input.po output.lmo\n", name); + exit(1); +} + +static void print(const void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + if( fwrite(ptr, size, nmemb, stream) == 0 ) + die("Failed to write stdout"); +} + +static int extract_string(const char *src, char *dest, int len) +{ + int pos = 0; + int esc = 0; + int off = -1; + + for( pos = 0; (pos < strlen(src)) && (pos < len); pos++ ) + { + if( (off == -1) && (src[pos] == '"') ) + { + off = pos + 1; + } + else if( off >= 0 ) + { + if( esc == 1 ) + { + switch (src[pos]) + { + case '"': + case '\\': + off++; + break; + } + dest[pos-off] = src[pos]; + esc = 0; + } + else if( src[pos] == '\\' ) + { + dest[pos-off] = src[pos]; + esc = 1; + } + else if( src[pos] != '"' ) + { + dest[pos-off] = src[pos]; + } + else + { + dest[pos-off] = '\0'; + break; + } + } + } + + return (off > -1) ? strlen(dest) : -1; +} + +static int cmp_index(const void *a, const void *b) +{ + uint32_t x = ((const lmo_entry_t *)a)->key_id; + uint32_t y = ((const lmo_entry_t *)b)->key_id; + + if (x < y) + return -1; + else if (x > y) + return 1; + + return 0; +} + +static void print_uint32(uint32_t x, FILE *out) +{ + uint32_t y = htonl(x); + print(&y, sizeof(uint32_t), 1, out); +} + +static void print_index(void *array, int n, FILE *out) +{ + lmo_entry_t *e; + + qsort(array, n, sizeof(*e), cmp_index); + + for (e = array; n > 0; n--, e++) + { + print_uint32(e->key_id, out); + print_uint32(e->val_id, out); + print_uint32(e->offset, out); + print_uint32(e->length, out); + } +} + +int main(int argc, char *argv[]) +{ + char line[4096]; + char key[4096]; + char val[4096]; + char tmp[4096]; + int state = 0; + int offset = 0; + int length = 0; + int n_entries = 0; + void *array = NULL; + lmo_entry_t *entry = NULL; + uint32_t key_id, val_id; + + FILE *in; + FILE *out; + + if( (argc != 3) || ((in = fopen(argv[1], "r")) == NULL) || ((out = fopen(argv[2], "w")) == NULL) ) + usage(argv[0]); + + memset(line, 0, sizeof(key)); + memset(key, 0, sizeof(val)); + memset(val, 0, sizeof(val)); + + while( (NULL != fgets(line, sizeof(line), in)) || (state >= 2 && feof(in)) ) + { + if( state == 0 && strstr(line, "msgid \"") == line ) + { + switch(extract_string(line, key, sizeof(key))) + { + case -1: + die("Syntax error in msgid"); + case 0: + state = 1; + break; + default: + state = 2; + } + } + else if( state == 1 || state == 2 ) + { + if( strstr(line, "msgstr \"") == line || state == 2 ) + { + switch(extract_string(line, val, sizeof(val))) + { + case -1: + state = 4; + break; + default: + state = 3; + } + } + else + { + switch(extract_string(line, tmp, sizeof(tmp))) + { + case -1: + state = 2; + break; + default: + strcat(key, tmp); + } + } + } + else if( state == 3 ) + { + switch(extract_string(line, tmp, sizeof(tmp))) + { + case -1: + state = 4; + break; + default: + strcat(val, tmp); + } + } + + if( state == 4 ) + { + if( strlen(key) > 0 && strlen(val) > 0 ) + { + key_id = sfh_hash(key, strlen(key)); + val_id = sfh_hash(val, strlen(val)); + + if( key_id != val_id ) + { + n_entries++; + array = realloc(array, n_entries * sizeof(lmo_entry_t)); + entry = (lmo_entry_t *)array + n_entries - 1; + + if (!array) + die("Out of memory"); + + entry->key_id = key_id; + entry->val_id = val_id; + entry->offset = offset; + entry->length = strlen(val); + + length = strlen(val) + ((4 - (strlen(val) % 4)) % 4); + + print(val, length, 1, out); + offset += length; + } + } + + state = 0; + memset(key, 0, sizeof(key)); + memset(val, 0, sizeof(val)); + } + + memset(line, 0, sizeof(line)); + } + + print_index(array, n_entries, out); + + if( offset > 0 ) + { + print_uint32(offset, out); + fsync(fileno(out)); + fclose(out); + } + else + { + fclose(out); + unlink(argv[2]); + } + + fclose(in); + return(0); +} diff --git a/package/lean/luci-app-haproxy/tools/po2lmo/src/template_lmo.c b/package/lean/luci-app-haproxy/tools/po2lmo/src/template_lmo.c new file mode 100644 index 0000000000..27205a7228 --- /dev/null +++ b/package/lean/luci-app-haproxy/tools/po2lmo/src/template_lmo.c @@ -0,0 +1,328 @@ +/* + * lmo - Lua Machine Objects - Base functions + * + * Copyright (C) 2009-2010 Jo-Philipp Wich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "template_lmo.h" + +/* + * Hash function from http://www.azillionmonkeys.com/qed/hash.html + * Copyright (C) 2004-2008 by Paul Hsieh + */ + +uint32_t sfh_hash(const char *data, int len) +{ + uint32_t hash = len, tmp; + int rem; + + if (len <= 0 || data == NULL) return 0; + + rem = len & 3; + len >>= 2; + + /* Main loop */ + for (;len > 0; len--) { + hash += sfh_get16(data); + tmp = (sfh_get16(data+2) << 11) ^ hash; + hash = (hash << 16) ^ tmp; + data += 2*sizeof(uint16_t); + hash += hash >> 11; + } + + /* Handle end cases */ + switch (rem) { + case 3: hash += sfh_get16(data); + hash ^= hash << 16; + hash ^= data[sizeof(uint16_t)] << 18; + hash += hash >> 11; + break; + case 2: hash += sfh_get16(data); + hash ^= hash << 11; + hash += hash >> 17; + break; + case 1: hash += *data; + hash ^= hash << 10; + hash += hash >> 1; + } + + /* Force "avalanching" of final 127 bits */ + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + + return hash; +} + +uint32_t lmo_canon_hash(const char *str, int len) +{ + char res[4096]; + char *ptr, prev; + int off; + + if (!str || len >= sizeof(res)) + return 0; + + for (prev = ' ', ptr = res, off = 0; off < len; prev = *str, off++, str++) + { + if (isspace(*str)) + { + if (!isspace(prev)) + *ptr++ = ' '; + } + else + { + *ptr++ = *str; + } + } + + if ((ptr > res) && isspace(*(ptr-1))) + ptr--; + + return sfh_hash(res, ptr - res); +} + +lmo_archive_t * lmo_open(const char *file) +{ + int in = -1; + uint32_t idx_offset = 0; + struct stat s; + + lmo_archive_t *ar = NULL; + + if (stat(file, &s) == -1) + goto err; + + if ((in = open(file, O_RDONLY)) == -1) + goto err; + + if ((ar = (lmo_archive_t *)malloc(sizeof(*ar))) != NULL) + { + memset(ar, 0, sizeof(*ar)); + + ar->fd = in; + ar->size = s.st_size; + + fcntl(ar->fd, F_SETFD, fcntl(ar->fd, F_GETFD) | FD_CLOEXEC); + + if ((ar->mmap = mmap(NULL, ar->size, PROT_READ, MAP_SHARED, ar->fd, 0)) == MAP_FAILED) + goto err; + + idx_offset = ntohl(*((const uint32_t *) + (ar->mmap + ar->size - sizeof(uint32_t)))); + + if (idx_offset >= ar->size) + goto err; + + ar->index = (lmo_entry_t *)(ar->mmap + idx_offset); + ar->length = (ar->size - idx_offset - sizeof(uint32_t)) / sizeof(lmo_entry_t); + ar->end = ar->mmap + ar->size; + + return ar; + } + +err: + if (in > -1) + close(in); + + if (ar != NULL) + { + if ((ar->mmap != NULL) && (ar->mmap != MAP_FAILED)) + munmap(ar->mmap, ar->size); + + free(ar); + } + + return NULL; +} + +void lmo_close(lmo_archive_t *ar) +{ + if (ar != NULL) + { + if ((ar->mmap != NULL) && (ar->mmap != MAP_FAILED)) + munmap(ar->mmap, ar->size); + + close(ar->fd); + free(ar); + + ar = NULL; + } +} + + +lmo_catalog_t *_lmo_catalogs = NULL; +lmo_catalog_t *_lmo_active_catalog = NULL; + +int lmo_load_catalog(const char *lang, const char *dir) +{ + DIR *dh = NULL; + char pattern[16]; + char path[PATH_MAX]; + struct dirent *de = NULL; + + lmo_archive_t *ar = NULL; + lmo_catalog_t *cat = NULL; + + if (!lmo_change_catalog(lang)) + return 0; + + if (!dir || !(dh = opendir(dir))) + goto err; + + if (!(cat = malloc(sizeof(*cat)))) + goto err; + + memset(cat, 0, sizeof(*cat)); + + snprintf(cat->lang, sizeof(cat->lang), "%s", lang); + snprintf(pattern, sizeof(pattern), "*.%s.lmo", lang); + + while ((de = readdir(dh)) != NULL) + { + if (!fnmatch(pattern, de->d_name, 0)) + { + snprintf(path, sizeof(path), "%s/%s", dir, de->d_name); + ar = lmo_open(path); + + if (ar) + { + ar->next = cat->archives; + cat->archives = ar; + } + } + } + + closedir(dh); + + cat->next = _lmo_catalogs; + _lmo_catalogs = cat; + + if (!_lmo_active_catalog) + _lmo_active_catalog = cat; + + return 0; + +err: + if (dh) closedir(dh); + if (cat) free(cat); + + return -1; +} + +int lmo_change_catalog(const char *lang) +{ + lmo_catalog_t *cat; + + for (cat = _lmo_catalogs; cat; cat = cat->next) + { + if (!strncmp(cat->lang, lang, sizeof(cat->lang))) + { + _lmo_active_catalog = cat; + return 0; + } + } + + return -1; +} + +static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash) +{ + unsigned int m, l, r; + uint32_t k; + + l = 0; + r = ar->length - 1; + + while (1) + { + m = l + ((r - l) / 2); + + if (r < l) + break; + + k = ntohl(ar->index[m].key_id); + + if (k == hash) + return &ar->index[m]; + + if (k > hash) + { + if (!m) + break; + + r = m - 1; + } + else + { + l = m + 1; + } + } + + return NULL; +} + +int lmo_translate(const char *key, int keylen, char **out, int *outlen) +{ + uint32_t hash; + lmo_entry_t *e; + lmo_archive_t *ar; + + if (!key || !_lmo_active_catalog) + return -2; + + hash = lmo_canon_hash(key, keylen); + + for (ar = _lmo_active_catalog->archives; ar; ar = ar->next) + { + if ((e = lmo_find_entry(ar, hash)) != NULL) + { + *out = ar->mmap + ntohl(e->offset); + *outlen = ntohl(e->length); + return 0; + } + } + + return -1; +} + +void lmo_close_catalog(const char *lang) +{ + lmo_archive_t *ar, *next; + lmo_catalog_t *cat, *prev; + + for (prev = NULL, cat = _lmo_catalogs; cat; prev = cat, cat = cat->next) + { + if (!strncmp(cat->lang, lang, sizeof(cat->lang))) + { + if (prev) + prev->next = cat->next; + else + _lmo_catalogs = cat->next; + + for (ar = cat->archives; ar; ar = next) + { + next = ar->next; + lmo_close(ar); + } + + free(cat); + break; + } + } +} diff --git a/package/lean/luci-app-haproxy/tools/po2lmo/src/template_lmo.h b/package/lean/luci-app-haproxy/tools/po2lmo/src/template_lmo.h new file mode 100644 index 0000000000..57f59aa56b --- /dev/null +++ b/package/lean/luci-app-haproxy/tools/po2lmo/src/template_lmo.h @@ -0,0 +1,92 @@ +/* + * lmo - Lua Machine Objects - General header + * + * Copyright (C) 2009-2012 Jo-Philipp Wich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _TEMPLATE_LMO_H_ +#define _TEMPLATE_LMO_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (defined(__GNUC__) && defined(__i386__)) +#define sfh_get16(d) (*((const uint16_t *) (d))) +#else +#define sfh_get16(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ + +(uint32_t)(((const uint8_t *)(d))[0]) ) +#endif + + +struct lmo_entry { + uint32_t key_id; + uint32_t val_id; + uint32_t offset; + uint32_t length; +} __attribute__((packed)); + +typedef struct lmo_entry lmo_entry_t; + + +struct lmo_archive { + int fd; + int length; + uint32_t size; + lmo_entry_t *index; + char *mmap; + char *end; + struct lmo_archive *next; +}; + +typedef struct lmo_archive lmo_archive_t; + + +struct lmo_catalog { + char lang[6]; + struct lmo_archive *archives; + struct lmo_catalog *next; +}; + +typedef struct lmo_catalog lmo_catalog_t; + + +uint32_t sfh_hash(const char *data, int len); +uint32_t lmo_canon_hash(const char *data, int len); + +lmo_archive_t * lmo_open(const char *file); +void lmo_close(lmo_archive_t *ar); + + +extern lmo_catalog_t *_lmo_catalogs; +extern lmo_catalog_t *_lmo_active_catalog; + +int lmo_load_catalog(const char *lang, const char *dir); +int lmo_change_catalog(const char *lang); +int lmo_translate(const char *key, int keylen, char **out, int *outlen); +void lmo_close_catalog(const char *lang); + +#endif diff --git a/package/lean/luci-app-kcptun/Makefile b/package/lean/luci-app-kcptun/Makefile new file mode 100644 index 0000000000..fcdc65d47a --- /dev/null +++ b/package/lean/luci-app-kcptun/Makefile @@ -0,0 +1,35 @@ +# +# Copyright 2016-2017 Xingwang Liao +# Licensed to the public under the Apache License 2.0. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci-app-kcptun +PKG_VERSION:=1.4.3 +PKG_RELEASE:=1 + +PKG_LICENSE:=Apache-2.0 +PKG_MAINTAINER:=Xingwang Liao + +LUCI_TITLE:=LuCI support for Kcptun +LUCI_DEPENDS:=+jshn +wget +luci-lib-jsonc +LUCI_PKGARCH:=all + +define Package/$(PKG_NAME)/conffiles +/etc/config/kcptun +endef + +include $(TOPDIR)/feeds/luci/luci.mk + +define Package/$(PKG_NAME)/postinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + ( . /etc/uci-defaults/40_luci-kcptun ) && rm -f /etc/uci-defaults/40_luci-kcptun +fi +chmod 755 $${IPKG_INSTROOT}/etc/init.d/kcptun >/dev/null 2>&1 +$${IPKG_INSTROOT}/etc/init.d/kcptun enable >/dev/null 2>&1 +exit 0 +endef + +# call BuildPackage - OpenWrt buildroot signature diff --git a/package/lean/luci-app-kcptun/luasrc/controller/kcptun.lua b/package/lean/luci-app-kcptun/luasrc/controller/kcptun.lua new file mode 100644 index 0000000000..736830a1f3 --- /dev/null +++ b/package/lean/luci-app-kcptun/luasrc/controller/kcptun.lua @@ -0,0 +1,120 @@ +-- Copyright 2016-2017 Xingwang Liao +-- Licensed to the public under the Apache License 2.0. + +module("luci.controller.kcptun", package.seeall) + +local http = require "luci.http" +local kcp = require "luci.model.kcptun" + +function index() + if not nixio.fs.access("/etc/config/kcptun") then + return + end + + entry({"admin", "services", "kcptun"}, + firstchild(), _("Kcptun Client")).dependent = false + + entry({"admin", "services", "kcptun", "settings"}, + cbi("kcptun/settings"), _("Settings"), 1) + + entry({"admin", "services", "kcptun", "servers"}, + arcombine(cbi("kcptun/servers"), cbi("kcptun/servers-detail")), + _("Server Manage"), 2).leaf = true + + entry({"admin", "services", "kcptun", "log"}, + template("kcptun/log_view"), _("Log"), 3) + + entry({"admin", "services", "kcptun", "status"}, call("action_status")) + + entry({"admin", "services", "kcptun", "check"}, call("action_check")).leaf = true + + entry({"admin", "services", "kcptun", "update"}, call("action_update")).leaf = true + + entry({"admin", "services", "kcptun", "log", "data"}, call("action_log_data")) + + entry({"admin", "services", "kcptun", "log", "clear"}, call("action_log_clear")).leaf = true +end + +local function http_write_json(content) + http.prepare_content("application/json") + http.write_json(content or { code = 1 }) +end + +function action_status() + local client_file = kcp.get_config_option("client_file") + + http_write_json({ + client = kcp.is_running(client_file) + }) +end + +function action_check(type) + local json = nil + if type == "kcptun" then + json = kcp.check_kcptun(http.formvalue("arch")) + elseif type == "luci" then + json = kcp.check_luci() + else + http.status(500, "Bad address") + return + end + + http_write_json(json) +end + +function action_update(type) + local json = nil + if type == "kcptun" then + local task = http.formvalue("task") + if task == "extract" then + json = kcp.extract_kcptun(http.formvalue("file"), http.formvalue("subfix")) + elseif task == "move" then + json = kcp.move_kcptun(http.formvalue("file")) + else + json = kcp.download_kcptun(http.formvalue("url")) + end + elseif type == "luci" then + json = kcp.update_luci(http.formvalue("url"), http.formvalue("save")) + else + http.status(500, "Bad address") + return + end + + http_write_json(json) +end + +function action_log_data() + local util = require "luci.util" + + local log_data = { } + + local enable_logging = kcp.get_config_option("enable_logging", "0") == "1" + + if enable_logging then + local client_log_file = kcp.get_current_log_file("client") + log_data.client = util.trim( + util.exec("tail -n 50 %s 2>/dev/null | sed 'x;1!H;$!d;x'" % client_log_file)) + end + + log_data.syslog = util.trim( + util.exec("logread | grep kcptun | tail -n 50 | sed 'x;1!H;$!d;x'")) + + http_write_json(log_data) +end + +function action_log_clear(type) + if type and type ~= "" then + local log_file = kcp.get_current_log_file(type) + + local fs = require "nixio.fs" + + if fs.access(log_file) then + fs.writefile(log_file, "") + else + http.status(404, "Not found") + return + end + end + + http_write_json({ code = 0 }) +end diff --git a/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/servers-detail.lua b/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/servers-detail.lua new file mode 100644 index 0000000000..a9214b4e1a --- /dev/null +++ b/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/servers-detail.lua @@ -0,0 +1,182 @@ +-- Copyright 2016-2017 Xingwang Liao +-- Licensed to the public under the Apache License 2.0. + +local dsp = require "luci.dispatcher" + +local m, s, o +local sid = arg[1] + +local encrypt_methods = { + "aes", + "aes-128", + "aes-192", + "salsa20", + "blowfish", + "twofish", + "cast5", + "3des", + "tea", + "xtea", + "xor", + "none", +} + +local modes = { + "normal", + "fast", + "fast2", + "fast3", + "manual", +} + +m = Map("kcptun", "%s - %s" % { translate("Kcptun"), translate("Edit Server") }) +m.redirect = dsp.build_url("admin/services/kcptun/servers") + +if m.uci:get("kcptun", sid) ~= "servers" then + luci.http.redirect(m.redirect) + return +end + +s = m:section(NamedSection, sid, "servers") +s.anonymous = true +s.addremove = false + +o = s:option(Value, "alias", "%s (%s)" % { translate("Alias"), translate("optional") }) + +o = s:option(Value, "server_addr", translate("Server")) +o.datatype = "host" +o.rmempty = false + +o = s:option(Value, "server_port", translate("Server Port")) +o.datatype = "port" +o.placeholder = "29900" + +o = s:option(Value, "listen_addr", "%s (%s)" % { translate("Local Listen Host"), translate("optional") }, + translate("Local listen host.")) +o.datatype = "host" +o.placeholder = "0.0.0.0" + +o = s:option(Value, "listen_port", translate("Local Port"), translate("Local Listen Port.")) +o.datatype = "port" +o.placeholder = "12948" + +o = s:option(Value, "key", "%s (%s)" % { translate("Key"), translate("optional") }, + translate("Pre-shared secret for client and server.")) +o.password = true +o.placeholder = "it's a secret" + +o = s:option(Value, "crypt", translate("crypt"), translate("Encrypt Method")) +for _, v in ipairs(encrypt_methods) do + o:value(v, v:upper()) +end +o.default = "aes" + +o = s:option(ListValue, "mode", translate("mode"), translate("Embedded Mode")) +for _, v in ipairs(modes) do + o:value(v, v:upper()) +end +o.default = "fast" + +o = s:option(Flag, "nodelay", translate("nodelay"), translate("Enable nodelay Mode.")) +o:depends("mode", "manual") + +o = s:option(Value, "interval", translate("interval")) +o:depends("mode", "manual") +o.datatype = "uinteger" +o.placeholder = "50" + +o = s:option(ListValue, "resend", translate("resend")) +o:depends("mode", "manual") +o:value("0", translate("Off")) +o:value("1", translate("On")) +o:value("2", translate("2nd ACK")) + +o = s:option(Flag, "nc", translate("nc")) +o:depends("mode", "manual") + +o = s:option(Value, "mtu", "%s (%s)" % { translate("mtu"), translate("optional") }, + translate("Maximum transmission unit of UDP packets.")) +o.datatype = "range(64,9200)" +o.placeholder = "1350" + +o = s:option(Value, "sndwnd", "%s (%s)" % { translate("sndwnd"), translate("optional") }, + translate("Send Window Size(num of packets).")) +o.datatype = "min(1)" +o.default = "128" +o.placeholder = "128" + +o = s:option(Value, "rcvwnd", "%s (%s)" % { translate("rcvwnd"), translate("optional") }, + translate("Receive Window Size(num of packets).")) +o.datatype = "min(1)" +o.default = "512" +o.placeholder = "512" + +o = s:option(Value, "datashard", "%s (%s)" % { translate("datashard"), translate("optional") }, + translate("Reed-solomon Erasure Coding - datashard.")) +o.datatype = "uinteger" +o.placeholder = "10" + +o = s:option(Value, "parityshard", "%s (%s)" % { translate("parityshard"), translate("optional") }, + translate("Reed-solomon Erasure Coding - parityshard.")) +o.datatype = "uinteger" +o.placeholder = "3" + +o = s:option(Value, "dscp", "%s (%s)" % { translate("dscp"), translate("optional") }, translate("DSCP(6bit)")) +o.datatype = "uinteger" +o.placeholder = "0" + +o = s:option(Flag, "nocomp", translate("nocomp"), translate("Disable Compression?")) +o.enabled = "true" +o.disabled = "false" +o.rmempty = false + +o = s:option(Flag, "acknodelay", translate("acknodelay")) +o.enabled = "true" +o.disabled = "false" + +o = s:option(Value, "conn", "%s (%s)" %{ translate("conn"), translate("optional") }, + translate("Number of UDP connections to server.")) +o.datatype = "min(1)" +o.placeholder = "1" + +o = s:option(Value, "autoexpire", "%s (%s)" % { translate("autoexpire"), translate("optional") }, + translate("Auto expiration time(in seconds) for a single UDP connection, 0 to disable.")) +o.datatype = "uinteger" +o.placeholder = "0" + +o = s:option(Value, "scavengettl", "%s (%s)" % { translate("scavengettl"), translate("optional") }, + translate("How long an expired connection can live(in sec), -1 to disable.")) +o.datatype = "min(-1)" +o.placeholder = "600" + +o = s:option(Value, "sockbuf", "%s (%s)" % { translate("sockbuf"), translate("optional") }, + translate("Send/secv buffer size of udp sockets, default unit is MB.")) +o.datatype = "uinteger" +o.placeholder = "4" +o.cfgvalue = function(...) + local value = Value.cfgvalue(...) + + if value then + return tonumber(value) / 1024 / 1024 + end +end +o.write = function(self, section, value) + local number = tonumber(value) + if number then + Value.write(self, section, number * 1024 * 1024) + else + Value.remove(self, section) + end +end + +o = s:option(Value, "keepalive", "%s (%s)" % { translate("keepalive"), translate("optional") }, + translate("NAT keepalive interval to prevent your router from removing port mapping, default unit is seconds.")) +o.datatype = "uinteger" +o.placeholder = "10" + +o = s:option(Value, "snmpperiod", "%s (%s)" % { translate("snmpperiod"), + translate("optional") }, translate("SNMP collect period, in seconds")) +o.datatype = "min(1)" +o.placeholder = "60" + +return m diff --git a/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/servers.lua b/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/servers.lua new file mode 100644 index 0000000000..9a44cac1ef --- /dev/null +++ b/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/servers.lua @@ -0,0 +1,71 @@ +-- Copyright 2016-2017 Xingwang Liao +-- Licensed to the public under the Apache License 2.0. + +local dsp = require "luci.dispatcher" +local http = require "luci.http" + +local m, s, o + +local function get_ip_string(ip) + if ip and ip:find(":") then + return "[%s]" % ip + else + return ip or "" + end +end + +m = Map("kcptun", "%s - %s" % { translate("Kcptun"), translate("Server List") }) + +s = m:section(TypedSection, "servers") +s.anonymous = true +s.addremove = true +s.sortable = true +s.template = "cbi/tblsection" +s.extedit = dsp.build_url("admin/services/kcptun/servers/%s") +function s.create(...) + local sid = TypedSection.create(...) + if sid then + m.uci:save("kcptun") + http.redirect(s.extedit % sid) + return + end +end + +o = s:option(DummyValue, "alias", translate("Alias")) +function o.cfgvalue(self, section) + return Value.cfgvalue(self, section) or translate("None") +end + +o = s:option(DummyValue, "_server_address", translate("Server Address")) +function o.cfgvalue(self, section) + local server = m.uci:get("kcptun", section, "server_addr") or "?" + local server_port = m.uci:get("kcptun", section, "server_port") or "29900" + return "%s:%s" % { get_ip_string(server), server_port } +end + +o = s:option(DummyValue, "_listen_addres", translate("Listen Address")) +function o.cfgvalue(self, section) + local local_host = m.uci.get("kcptun", section, "listen_addr") or "0.0.0.0" + local local_port = m.uci.get("kcptun", section, "listen_port") or "12984" + return "%s:%s" % { get_ip_string(local_host), local_port } +end + +o = s:option(DummyValue, "crypt", translate("Encrypt Method")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + return v and v:upper() or "?" +end + +o = s:option(DummyValue, "mode", translate("Embedded Mode")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + return v and v:upper() or "?" +end + +o = s:option(DummyValue, "nocomp", translate("Disable Compression")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + return v == "true" and translate("True") or translate("False") +end + +return m diff --git a/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/settings.lua b/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/settings.lua new file mode 100644 index 0000000000..6d63eb5de6 --- /dev/null +++ b/package/lean/luci-app-kcptun/luasrc/model/cbi/kcptun/settings.lua @@ -0,0 +1,112 @@ +-- Copyright 2016-2017 Xingwang Liao +-- Licensed to the public under the Apache License 2.0. + +local uci = require "luci.model.uci".cursor() +local util = require "luci.util" +local sys = require "luci.sys" +local fs = require "nixio.fs" + +local m, s, o +local server_table = { } + +local function get_ip_string(ip) + if ip and ip:find(":") then + return "[%s]" % ip + else + return ip or "" + end +end + +uci:foreach("kcptun", "servers", function(s) + if s.alias then + server_table[s[".name"]] = s.alias + elseif s.server_addr and s.server_port then + server_table[s[".name"]] = "%s:%s" % { get_ip_string(s.server_addr), s.server_port } + end +end) + +m = Map("kcptun", "%s - %s" % { translate("Kcptun"), translate("Settings") }) +m:append(Template("kcptun/status")) + +s = m:section(NamedSection, "general", "general", translate("General Settings")) +s.anonymous = true +s.addremove = false + +o = s:option(ListValue, "server", translate("Server")) +o:value("", translate("Disable")) +for k, v in pairs(server_table) do + o:value(k, v) +end + +o = s:option(Value, "client_file", translate("Client File")) +o.rmempty = false + +o = s:option(ListValue, "daemon_user", translate("Run Daemon as User")) +for u in util.execi("cat /etc/passwd | cut -d ':' -f1") do + o:value(u) +end + +o = s:option(Flag, "enable_logging", translate("Enable Logging")) +o.rmempty = false + +o = s:option(Value, "log_folder", translate("Log Folder")) +o.datatype = "directory" +o.placeholder = "/var/log/kcptun" +o:depends("enable_logging", "1") +o.formvalue = function(...) + local v = (Value.formvalue(...) or ""):trim() + if v ~= "" then + v = string.gsub(v, "\\", "/") + if v:sub(1, 1) ~= "/" then + v = "/" .. v + end + + while v:sub(-1) == "/" do + v = v:sub(1, -2) + end + end + + return v +end +o.validate = function(self, value, section) + if value and not fs.stat(value) then + local res, code, msg = fs.mkdir(value) + if not res then + return nil, msg + end + end + return Value.validate(self, value, section) +end + +o = s:option(ListValue, "arch", translate("CPU Architecture"), + translate("The ARCH for checking updates." .. + " Note: Make sure OpenWrt/LEDE 'MIPS FPU Emulator' is enabled on MIPS/MIPSLE devices.")) +o:value("", translate("Auto")) +o:value("i386", "x86") +o:value("x86_64", "x86_64") +o:value("armv5", "ARMv5") +o:value("armv6", "ARMv6") +o:value("armv7", "ARMv7+") +o:value("ar71xx", "MIPS") +o:value("ramips", "MIPSLE") + +o = s:option(Button, "_check_kcptun", translate("Check Kcptun Update"), + translate("Make sure that the 'Client File' dictionary has enough space.")) +o.template = "kcptun/button" +o.inputstyle = "apply" +o.placeholder = translate("Check Kcptun Update") +o.btnclick = "check_update('kcptun', this);" +o.id = "_kcptun-check_kcptun" + +o = s:option(Flag, "save_config", translate("Save Config File"), + translate("Save config file while upgrade LuCI.")) + +o = s:option(Button, "_check_luci", translate("Check LuCI Update"), + translate("You may need to reload current page after update LuCI. Note that translation will not be updated.")) +o.template = "kcptun/button" +o.inputstyle = "apply" +o.placeholder = translate("Check LuCI Update") +o.btnclick = "check_update('luci', this);" +o.id = "_kcptun-check_luci" + +return m diff --git a/package/lean/luci-app-kcptun/luasrc/model/kcptun.lua b/package/lean/luci-app-kcptun/luasrc/model/kcptun.lua new file mode 100644 index 0000000000..4484ff606b --- /dev/null +++ b/package/lean/luci-app-kcptun/luasrc/model/kcptun.lua @@ -0,0 +1,486 @@ +-- Copyright 2016-2017 Xingwang Liao +-- Licensed to the public under the Apache License 2.0. + +local fs = require "nixio.fs" +local sys = require "luci.sys" +local uci = require "luci.model.uci".cursor() +local util = require "luci.util" +local i18n = require "luci.i18n" + +module("luci.model.kcptun", package.seeall) + +local kcptun_api = "https://api.github.com/repos/xtaci/kcptun/releases/latest" +local luci_api = "https://api.github.com/repos/kuoruan/luci-app-kcptun/releases/latest" + +local wget = "/usr/bin/wget" +local wget_args = { "--no-check-certificate", "--quiet", "--timeout=10", "--tries=2" } +local command_timeout = 40 + +local function _unpack(t, i) + i = i or 1 + if t[i] ~= nil then + return t[i], _unpack(t, i + 1) + end +end + +local function exec(cmd, args, writer, timeout) + local os = require "os" + local nixio = require "nixio" + + local fdi, fdo = nixio.pipe() + local pid = nixio.fork() + + if pid > 0 then + fdo:close() + + if writer or timeout then + local starttime = os.time() + while true do + if timeout and os.difftime(os.time(), starttime) >= timeout then + nixio.kill(pid, nixio.const.SIGTERM) + return 1 + end + + if writer then + local buffer = fdi:read(2048) + if buffer and #buffer > 0 then + writer(buffer) + end + end + + local wpid, stat, code = nixio.waitpid(pid, "nohang") + + if wpid and stat == "exited" then + return code + end + + if not writer and timeout then + nixio.nanosleep(1) + end + end + else + local wpid, stat, code = nixio.waitpid(pid) + return wpid and stat == "exited" and code + end + elseif pid == 0 then + nixio.dup(fdo, nixio.stdout) + fdi:close() + fdo:close() + nixio.exece(cmd, args, nil) + nixio.stdout:close() + os.exit(1) + end +end + +local function compare_versions(ver1, comp, ver2) + local table = table + + local av1 = util.split(ver1, "[%.%-]", nil, true) + local av2 = util.split(ver2, "[%.%-]", nil, true) + + local max = table.getn(av1) + local n2 = table.getn(av2) + if (max < n2) then + max = n2 + end + + for i = 1, max, 1 do + local s1 = av1[i] or "" + local s2 = av2[i] or "" + + if comp == "~=" and (s1 ~= s2) then return true end + if (comp == "<" or comp == "<=") and (s1 < s2) then return true end + if (comp == ">" or comp == ">=") and (s1 > s2) then return true end + if (s1 ~= s2) then return false end + end + + return not (comp == "<" or comp == ">") +end + +local function auto_get_arch() + local arch = nixio.uname().machine or "" + + if arch == "mips" then + if fs.access("/usr/lib/os-release") then + arch = sys.exec("grep 'LEDE_BOARD' /usr/lib/os-release | grep -oE 'ramips|ar71xx'") + elseif fs.access("/etc/openwrt_release") then + arch = sys.exec("grep 'DISTRIB_TARGET' /etc/openwrt_release | grep -oE 'ramips|ar71xx'") + end + end + + return util.trim(arch) +end + +local function get_file_info(arch) + local file_tree = "" + local sub_version = "" + + if arch == "x86_64" then + file_tree = "amd64" + elseif arch == "ramips" then + file_tree = "mipsle" + elseif arch == "ar71xx" then + file_tree = "mips" + elseif arch:match("^i[%d]86$") then + file_tree = "386" + elseif arch:match("^armv[5-8]") then + file_tree = "arm" + sub_version = arch:match("[5-8]") + end + + return file_tree, sub_version +end + +local function get_api_json(url) + local jsonc = require "luci.jsonc" + + local output = { } + exec(wget, { "-O-", url, _unpack(wget_args) }, + function(chunk) output[#output + 1] = chunk end) + + local json_content = util.trim(table.concat(output)) + + if json_content == "" then + return { } + end + + return jsonc.parse(json_content) or { } +end + +function get_config_option(option, default) + return uci:get("kcptun", "general", option) or default +end + +function get_current_log_file(type) + local log_folder = get_config_option("log_folder", "/var/log/kcptun") + return "%s/%s.%s.log" % { log_folder, type, "general" } +end + +function is_running(client) + if client and client ~= "" then + local file_name = client:match(".*/([^/]+)$") or "" + if file_name ~= "" then + return sys.call("pidof %s >/dev/null" % file_name) == 0 + end + end + + return false +end + +function get_kcptun_version(file) + if file and file ~= "" then + if not fs.access(file, "rwx", "rx", "rx") then + fs.chmod(file, 755) + end + + local info = util.trim(sys.exec("%s -v 2>/dev/null" % file)) + + if info ~= "" then + local tb = util.split(info, "%s+", nil, true) + return tb[1] == "kcptun" and tb[3] or "" + end + end + + return "" +end + +function get_luci_version() + local ipkg = require "luci.model.ipkg" + + local package_name = "luci-app-kcptun" + local package_info = ipkg.info(package_name) or {} + + if next(package_info) ~= nil then + return package_info[package_name]["Version"] + end + return "" +end + +function check_kcptun(arch) + if not arch or arch == "" then + arch = auto_get_arch() + end + + local file_tree, sub_version = get_file_info(arch) + + if file_tree == "" then + return { + code = 1, + error = i18n.translate("Can't determine ARCH, or ARCH not supported. Please select manually.") + } + end + + local json = get_api_json(kcptun_api) + + if json.tag_name == nil then + return { + code = 1, + error = i18n.translate("Get remote version info failed.") + } + end + + local remote_version = json.tag_name:match("[^v]+") + + local client_file = get_config_option("client_file") + + local needs_update = compare_versions(get_kcptun_version(client_file), "<", remote_version) + local html_url, download_url + + if needs_update then + html_url = json.html_url + for _, v in ipairs(json.assets) do + if v.name and v.name:match("linux%-" .. file_tree) then + download_url = v.browser_download_url + break + end + end + end + + if needs_update and not download_url then + return { + code = 1, + version = remote_version, + html_url = html_url, + error = i18n.translate("New version found, but failed to get new version download url.") + } + end + + return { + code = 0, + update = needs_update, + version = remote_version, + url = { + html = html_url, + download = download_url + }, + type = file_tree .. sub_version + } +end + +function check_luci() + local json = get_api_json(luci_api) + + if json.tag_name == nil then + return { + code = 1, + error = i18n.translate("Get remote version info failed.") + } + end + + local remote_version = json.tag_name:match("[^v]+") + + local needs_update = compare_versions(get_luci_version(), "<", remote_version) + local html_url, luci_url + local i18n_urls = { } + + if needs_update then + html_url = json.html_url + for _, v in ipairs(json.assets) do + local n = v.name + if n then + if n:match("luci%-app%-kcptun") then + luci_url = v.browser_download_url + elseif n:match("luci%-i18n%-kcptun") then + i18n_urls[#i18n_urls + 1] = v.browser_download_url + end + end + end + end + + if needs_update and not luci_url then + return { + code = 1, + version = remote_version, + html_url = html_url, + error = i18n.translate("New version found, but failed to get new version download url.") + } + end + + return { + code = 0, + update = needs_update, + version = remote_version, + url = { + html = html_url, + luci = luci_url, + i18n = i18n_urls + } + } +end + +function download_kcptun(url) + if not url or url == "" then + return { + code = 1, + error = i18n.translate("Download url is required.") + } + end + + sys.call("/bin/rm -f /tmp/kcptun_download.*") + + local tmp_file = util.trim(util.exec("mktemp -u -t kcptun_download.XXXXXX")) + + local result = exec(wget, { + "-O", tmp_file, url, _unpack(wget_args) }, nil, command_timeout) == 0 + + if not result then + exec("/bin/rm", { "-f", tmp_file }) + return { + code = 1, + error = i18n.translatef("File download failed or timed out: %s", url) + } + end + + return { + code = 0, + file = tmp_file + } +end + +function extract_kcptun(file, subfix) + if not file or file == "" or not fs.access(file) then + return { + code = 1, + error = i18n.translate("File path required.") + } + end + + sys.call("/bin/rm -rf /tmp/kcptun_extract.*") + local tmp_dir = util.trim(util.exec("mktemp -d -t kcptun_extract.XXXXXX")) + + local output = { } + exec("/bin/tar", { "-C", tmp_dir, "-zxvf", file }, + function(chunk) output[#output + 1] = chunk end) + + local files = util.split(table.concat(output)) + + exec("/bin/rm", { "-f", file }) + + local new_file = nil + for _, f in pairs(files) do + if f:match("client_linux_%s" % subfix) then + new_file = tmp_dir .. "/" .. util.trim(f) + break + end + end + + if not new_file then + for _, f in pairs(files) do + if f:match("client_") then + new_file = tmp_dir .. "/" .. util.trim(f) + break + end + end + end + + if not new_file then + exec("/bin/rm", { "-rf", tmp_dir }) + return { + code = 1, + error = i18n.translatef("Can't find client in file: %s", file) + } + end + + return { + code = 0, + file = new_file + } +end + +function move_kcptun(file) + if not file or file == "" or not fs.access(file) then + sys.call("/bin/rm -rf /tmp/kcptun_extract.*") + return { + code = 1, + error = i18n.translate("Client file is required.") + } + end + + local version = get_kcptun_version(file) + if version == "" then + sys.call("/bin/rm -rf /tmp/kcptun_extract.*") + return { + code = 1, + error = i18n.translate("The client file is not suitable for current device. Please reselect ARCH.") + } + end + + local client_file = get_config_option("client_file", "/var/kcptun_client") + local client_file_bak + + if fs.access(client_file) then + client_file_bak = client_file .. ".bak" + exec("/bin/mv", { "-f", client_file, client_file_bak }) + end + + local result = exec("/bin/mv", { "-f", file, client_file }, nil, command_timeout) == 0 + + if not result or not fs.access(client_file) then + sys.call("/bin/rm -rf /tmp/kcptun_extract.*") + if client_file_bak then + exec("/bin/mv", { "-f", client_file_bak, client_file }) + end + return { + code = 1, + error = i18n.translatef("Can't move new file to path: %s", client_file) + } + end + + exec("/bin/chmod", { "755", client_file }) + + if client_file_bak then + exec("/bin/rm", { "-f", client_file_bak }) + end + + sys.call("/bin/rm -rf /tmp/kcptun_extract.*") + + uci:set("kcptun", "general", "client_file", client_file) + uci:commit("kcptun") + + return { code = 0 } +end + +function update_luci(url, save) + if not url or url == "" then + return { + code = 1, + error = i18n.translate("Download url is required.") + } + end + + sys.call("/bin/rm -f /tmp/luci_kcptun.*.ipk") + + local tmp_file = util.trim(util.exec("mktemp -u -t luci_kcptun.XXXXXX")) .. ".ipk" + + local result = exec("/usr/bin/wget", { + "-O", tmp_file, url, _unpack(wget_args) }, nil, command_timeout) == 0 + + if not result then + exec("/bin/rm", { "-f", tmp_file }) + return { + code = 1, + error = i18n.translatef("File download failed or timed out: %s", url) + } + end + + local opkg_args = { "--force-downgrade", "--force-reinstall" } + + if save ~= "true" then + opkg_args[#opkg_args + 1] = "--force-maintainer" + end + + result = exec("/bin/opkg", { "install", tmp_file, _unpack(opkg_args) }) == 0 + + if not result then + exec("/bin/rm", { "-f", tmp_file }) + return { + code = 1, + error = i18n.translate("Package update failed.") + } + end + + exec("/bin/rm", { "-f", tmp_file }) + exec("/bin/rm", { "-rf", "/tmp/luci-indexcache", "/tmp/luci-modulecache" }) + + return { code = 0 } +end diff --git a/package/lean/luci-app-kcptun/luasrc/view/kcptun/button.htm b/package/lean/luci-app-kcptun/luasrc/view/kcptun/button.htm new file mode 100644 index 0000000000..14ffb09a1b --- /dev/null +++ b/package/lean/luci-app-kcptun/luasrc/view/kcptun/button.htm @@ -0,0 +1,19 @@ +<%# + Copyright 2017 Hsing-wang Liao + Licensed to the public under the Apache License 2.0. +-%> + +<%+cbi/valueheader%> + <% if self:cfgvalue(section) ~= false then %> + " type="button"<%= + attr("name", cbid) .. + attr("id", self.id or cbid) .. + attr("value", self.inputtitle or self.title) .. + ifattr(self.btnclick, "onclick", self.btnclick) .. + ifattr(self.placeholder, "placeholder") + %> /> + + <% else %> + - + <% end %> +<%+cbi/valuefooter%> diff --git a/package/lean/luci-app-kcptun/luasrc/view/kcptun/log_view.htm b/package/lean/luci-app-kcptun/luasrc/view/kcptun/log_view.htm new file mode 100644 index 0000000000..b16c45a12c --- /dev/null +++ b/package/lean/luci-app-kcptun/luasrc/view/kcptun/log_view.htm @@ -0,0 +1,74 @@ +<%# + Copyright 2016-2017 Xingwang Liao + Licensed to the public under the Apache License 2.0. +-%> + +<% css = [[ + + #log_text { + padding: 10px; + text-align: left; + } + #log_text pre { + word-break: break-all; + margin: 0; + } + .description { + background-color: #33ccff; + } + +]] +%> + +<%+header%> + + + <%:Kcptun%> - <%:Log Data%> + + + + + + <%:Collecting data...%> + <%:Refresh every 5 seconds.%> + + + + + + + +<%+footer%> diff --git a/package/lean/luci-app-kcptun/luasrc/view/kcptun/status.htm b/package/lean/luci-app-kcptun/luasrc/view/kcptun/status.htm new file mode 100644 index 0000000000..d799635fd1 --- /dev/null +++ b/package/lean/luci-app-kcptun/luasrc/view/kcptun/status.htm @@ -0,0 +1,258 @@ +<%# + Copyright 2016-2017 Xingwang Liao + Licensed to the public under the Apache License 2.0. +-%> + +<% +local kcp = require "luci.model.kcptun" +local dsp = require "luci.dispatcher" + +local client_file = kcp.get_config_option("client_file") +local client_version = kcp.get_kcptun_version(client_file) +local luci_version = kcp.get_luci_version() +-%> + + + <%:Running Status%> + + + <%:Client Version%> + + <% if client_version == "" then -%> + <%:Invalid Client File.%> + <% else -%> + <%=pcdata(client_version)%> + <%- end %> + + + <%:Client Status%><%:Collecting data...%> + <% if luci_version ~= "" then -%> + <%:LuCI Version%><%=pcdata(luci_version)%> + <% end -%> + + + + diff --git a/package/lean/luci-app-kcptun/po/templates/kcptun.pot b/package/lean/luci-app-kcptun/po/templates/kcptun.pot new file mode 100644 index 0000000000..3f07759ebd --- /dev/null +++ b/package/lean/luci-app-kcptun/po/templates/kcptun.pot @@ -0,0 +1,346 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +msgid "2nd ACK" +msgstr "" + +msgid "Alias" +msgstr "" + +msgid "Auto" +msgstr "" + +msgid "" +"Auto expiration time(in seconds) for a single UDP connection, 0 to disable." +msgstr "" + +msgid "CPU Architecture" +msgstr "" + +msgid "Can't determine ARCH, or ARCH not supported. Please select manually." +msgstr "" + +msgid "Can't find client in file: %s" +msgstr "" + +msgid "Can't move new file to path: %s" +msgstr "" + +msgid "Check Kcptun Update" +msgstr "" + +msgid "Check LuCI Update" +msgstr "" + +msgid "Clear Log File" +msgstr "" + +msgid "Click to Update" +msgstr "" + +msgid "Client File" +msgstr "" + +msgid "Client Status" +msgstr "" + +msgid "Client Version" +msgstr "" + +msgid "Client file is required." +msgstr "" + +msgid "Collecting data..." +msgstr "" + +msgid "DSCP(6bit)" +msgstr "" + +msgid "Disable" +msgstr "" + +msgid "Disable Compression" +msgstr "" + +msgid "Disable Compression?" +msgstr "" + +msgid "Download url is required." +msgstr "" + +msgid "Downloading..." +msgstr "" + +msgid "Edit Server" +msgstr "" + +msgid "Embedded Mode" +msgstr "" + +msgid "Enable Logging" +msgstr "" + +msgid "Enable nodelay Mode." +msgstr "" + +msgid "Encrypt Method" +msgstr "" + +msgid "Error get log data." +msgstr "" + +msgid "Extracting..." +msgstr "" + +msgid "False" +msgstr "" + +msgid "File download failed or timed out: %s" +msgstr "" + +msgid "File path required." +msgstr "" + +msgid "General Settings" +msgstr "" + +msgid "Get remote version info failed." +msgstr "" + +msgid "How long an expired connection can live(in sec), -1 to disable." +msgstr "" + +msgid "Invalid Client File." +msgstr "" + +msgid "Kcptun" +msgstr "" + +msgid "Kcptun Client" +msgstr "" + +msgid "Key" +msgstr "" + +msgid "Last 50 lines of log file:" +msgstr "" + +msgid "Last 50 lines of syslog:" +msgstr "" + +msgid "Listen Address" +msgstr "" + +msgid "Loading" +msgstr "" + +msgid "Local Listen Host" +msgstr "" + +msgid "Local Listen Port." +msgstr "" + +msgid "Local Port" +msgstr "" + +msgid "Local listen host." +msgstr "" + +msgid "Log" +msgstr "" + +msgid "Log Data" +msgstr "" + +msgid "Log Folder" +msgstr "" + +msgid "LuCI Version" +msgstr "" + +msgid "Make sure that the 'Client File' dictionary has enough space." +msgstr "" + +msgid "Maximum transmission unit of UDP packets." +msgstr "" + +msgid "Moving..." +msgstr "" + +msgid "" +"NAT keepalive interval to prevent your router from removing port mapping, " +"default unit is seconds." +msgstr "" + +msgid "New version found, but failed to get new version download url." +msgstr "" + +msgid "No Update Found" +msgstr "" + +msgid "No log data." +msgstr "" + +msgid "None" +msgstr "" + +msgid "Not Running" +msgstr "" + +msgid "Number of UDP connections to server." +msgstr "" + +msgid "Off" +msgstr "" + +msgid "On" +msgstr "" + +msgid "Package update failed." +msgstr "" + +msgid "Pre-shared secret for client and server." +msgstr "" + +msgid "Processing..." +msgstr "" + +msgid "Receive Window Size(num of packets)." +msgstr "" + +msgid "Reed-solomon Erasure Coding - datashard." +msgstr "" + +msgid "Reed-solomon Erasure Coding - parityshard." +msgstr "" + +msgid "Refresh every 5 seconds." +msgstr "" + +msgid "Run Daemon as User" +msgstr "" + +msgid "Running" +msgstr "" + +msgid "Running Status" +msgstr "" + +msgid "SNMP collect period, in seconds" +msgstr "" + +msgid "Save Config File" +msgstr "" + +msgid "Save config file while upgrade LuCI." +msgstr "" + +msgid "Send Window Size(num of packets)." +msgstr "" + +msgid "Send/secv buffer size of udp sockets, default unit is MB." +msgstr "" + +msgid "Server" +msgstr "" + +msgid "Server Address" +msgstr "" + +msgid "Server List" +msgstr "" + +msgid "Server Manage" +msgstr "" + +msgid "Server Port" +msgstr "" + +msgid "Settings" +msgstr "" + +msgid "" +"The ARCH for checking updates. Note: Make sure OpenWrt/LEDE 'MIPS FPU " +"Emulator' is enabled on MIPS/MIPSLE devices." +msgstr "" + +msgid "" +"The client file is not suitable for current device. Please reselect ARCH." +msgstr "" + +msgid "True" +msgstr "" + +msgid "Update Success." +msgstr "" + +msgid "Update in progress. Are you sure to close window?" +msgstr "" + +msgid "" +"You may need to reload current page after update LuCI. Note that translation " +"will not be updated." +msgstr "" + +msgid "acknodelay" +msgstr "" + +msgid "autoexpire" +msgstr "" + +msgid "conn" +msgstr "" + +msgid "crypt" +msgstr "" + +msgid "datashard" +msgstr "" + +msgid "dscp" +msgstr "" + +msgid "interval" +msgstr "" + +msgid "keepalive" +msgstr "" + +msgid "mode" +msgstr "" + +msgid "mtu" +msgstr "" + +msgid "nc" +msgstr "" + +msgid "nocomp" +msgstr "" + +msgid "nodelay" +msgstr "" + +msgid "optional" +msgstr "" + +msgid "parityshard" +msgstr "" + +msgid "rcvwnd" +msgstr "" + +msgid "resend" +msgstr "" + +msgid "scavengettl" +msgstr "" + +msgid "sndwnd" +msgstr "" + +msgid "snmpperiod" +msgstr "" + +msgid "sockbuf" +msgstr "" diff --git a/package/lean/luci-app-kcptun/po/zh-cn/kcptun.po b/package/lean/luci-app-kcptun/po/zh-cn/kcptun.po new file mode 100644 index 0000000000..6859c977ea --- /dev/null +++ b/package/lean/luci-app-kcptun/po/zh-cn/kcptun.po @@ -0,0 +1,348 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + +msgid "2nd ACK" +msgstr "2次 ACK 跨越重传" + +msgid "Alias" +msgstr "别名" + +msgid "Auto" +msgstr "自动" + +msgid "" +"Auto expiration time(in seconds) for a single UDP connection, 0 to disable." +msgstr "单个 UDP 连接的自动过期时间(秒),设置 0 来禁用" + +msgid "CPU Architecture" +msgstr "CPU 架构" + +msgid "Can't determine ARCH, or ARCH not supported. Please select manually." +msgstr "无法自动确定 ARCH,或者不支持该 ARCH,请手动重新选择。" + +msgid "Can't find client in file: %s" +msgstr "无法在文件中找到客户端:%s" + +msgid "Can't move new file to path: %s" +msgstr "无法移动新文件到:%s" + +msgid "Check Kcptun Update" +msgstr "检查 Kcptun 更新" + +msgid "Check LuCI Update" +msgstr "检查 LuCI 更新" + +msgid "Clear Log File" +msgstr "清理日志文件" + +msgid "Click to Update" +msgstr "点击更新" + +msgid "Client File" +msgstr "客户端文件" + +msgid "Client Status" +msgstr "客户端状态" + +msgid "Client Version" +msgstr "客户端版本" + +msgid "Client file is required." +msgstr "请指定客户端文件。" + +msgid "Collecting data..." +msgstr "正在收集数据..." + +msgid "DSCP(6bit)" +msgstr "DSCP(6bit)" + +msgid "Disable" +msgstr "禁用" + +msgid "Disable Compression" +msgstr "禁用压缩" + +msgid "Disable Compression?" +msgstr "是否禁用压缩?" + +msgid "Download url is required." +msgstr "请指定下载链接。" + +msgid "Downloading..." +msgstr "正在下载..." + +msgid "Edit Server" +msgstr "编辑服务端" + +msgid "Embedded Mode" +msgstr "内置模式" + +msgid "Enable Logging" +msgstr "启用日志记录" + +msgid "Enable nodelay Mode." +msgstr "启用 nodelay 模式" + +msgid "Encrypt Method" +msgstr "加密方式" + +msgid "Error get log data." +msgstr "获取日志数据失败。" + +msgid "Extracting..." +msgstr "正在解压..." + +msgid "False" +msgstr "否" + +msgid "File download failed or timed out: %s" +msgstr "文件下载失败或超时:%s" + +msgid "File path required." +msgstr "请指定文件路径。" + +msgid "General Settings" +msgstr "基本设置" + +msgid "Get remote version info failed." +msgstr "获取远程版本信息失败。" + +msgid "How long an expired connection can live(in sec), -1 to disable." +msgstr "过期连接保留多长时间(秒),设置 -1 来禁用" + +msgid "Invalid Client File." +msgstr "客户端文件配置有误" + +msgid "Kcptun" +msgstr "" + +msgid "Kcptun Client" +msgstr "Kcptun 客户端" + +msgid "Key" +msgstr "密码" + +msgid "Last 50 lines of log file:" +msgstr "日志文件的最新 50 行:" + +msgid "Last 50 lines of syslog:" +msgstr "系统日志的最新 50 行:" + +msgid "Listen Address" +msgstr "监听地址" + +msgid "Loading" +msgstr "正在加载..." + +msgid "Local Listen Host" +msgstr "本地监听地址" + +msgid "Local Listen Port." +msgstr "本地监听端口" + +msgid "Local Port" +msgstr "本地端口" + +msgid "Local listen host." +msgstr "本地监听主机" + +msgid "Log" +msgstr "日志" + +msgid "Log Data" +msgstr "日志数据" + +msgid "Log Folder" +msgstr "日志文件夹" + +msgid "LuCI Version" +msgstr "LuCI 版本" + +msgid "Make sure that the 'Client File' dictionary has enough space." +msgstr "请确保“客户端文件”所在的文件夹具有足够的空间。" + +msgid "Maximum transmission unit of UDP packets." +msgstr "UDP数据包的最大传输单元" + +msgid "Moving..." +msgstr "正在移动..." + +msgid "" +"NAT keepalive interval to prevent your router from removing port mapping, " +"default unit is seconds." +msgstr "NAT Keepalive 包间隔时间(秒), 防止路由器删除端口映射" + +msgid "New version found, but failed to get new version download url." +msgstr "发现新版本,但是获取下载地址失败。" + +msgid "No Update Found" +msgstr "未发现更新" + +msgid "No log data." +msgstr "无日志数据。" + +msgid "None" +msgstr "无" + +msgid "Not Running" +msgstr "未运行" + +msgid "Number of UDP connections to server." +msgstr "到服务端的UDP连接数量" + +msgid "Off" +msgstr "关闭" + +msgid "On" +msgstr "开启" + +msgid "Package update failed." +msgstr "软件包升级失败。" + +msgid "Pre-shared secret for client and server." +msgstr "客户端和服务端的通信密码" + +msgid "Processing..." +msgstr "正在操作..." + +msgid "Receive Window Size(num of packets)." +msgstr "接收窗口大小 (数据包数量)" + +msgid "Reed-solomon Erasure Coding - datashard." +msgstr "前向纠错 - datashard" + +msgid "Reed-solomon Erasure Coding - parityshard." +msgstr "前向纠错 - parityshard" + +msgid "Refresh every 5 seconds." +msgstr "每 5 秒刷新。" + +msgid "Run Daemon as User" +msgstr "以该用户启动" + +msgid "Running" +msgstr "运行中" + +msgid "Running Status" +msgstr "运行状态" + +msgid "SNMP collect period, in seconds" +msgstr "SNMP采集周期(秒)" + +msgid "Save Config File" +msgstr "保留配置文件" + +msgid "Save config file while upgrade LuCI." +msgstr "在更新 LuCI 时保留配置文件" + +msgid "Send Window Size(num of packets)." +msgstr "发送窗口大小 (数据包数量)" + +msgid "Send/secv buffer size of udp sockets, default unit is MB." +msgstr "发送/接收UDP数据包的缓冲区大小(MB)" + +msgid "Server" +msgstr "服务端地址" + +msgid "Server Address" +msgstr "服务端地址" + +msgid "Server List" +msgstr "服务端列表" + +msgid "Server Manage" +msgstr "服务端管理" + +msgid "Server Port" +msgstr "服务端端口" + +msgid "Settings" +msgstr "设置" + +msgid "" +"The ARCH for checking updates. Note: Make sure OpenWrt/LEDE 'MIPS FPU " +"Emulator' is enabled on MIPS/MIPSLE devices." +msgstr "" +"用于检查更新的 ARCH。注意: 在 MIPS/MIPSLE 设备上,请确保 OpenWrt/LEDE 的 " +"'MIPS FPU Emulator' 已经启用。" + +msgid "" +"The client file is not suitable for current device. Please reselect ARCH." +msgstr "客户端文件不适用于当前设备,请重新选择 ARCH。" + +msgid "True" +msgstr "是" + +msgid "Update Success." +msgstr "更新成功!" + +msgid "Update in progress. Are you sure to close window?" +msgstr "正在更新,确定关闭窗口?" + +msgid "" +"You may need to reload current page after update LuCI. Note that translation " +"will not be updated." +msgstr "更新 LuCI 之后你可能需要手动刷新当前页面。注意:翻译不会被更新" + +msgid "acknodelay" +msgstr "" + +msgid "autoexpire" +msgstr "" + +msgid "conn" +msgstr "" + +msgid "crypt" +msgstr "" + +msgid "datashard" +msgstr "" + +msgid "dscp" +msgstr "" + +msgid "interval" +msgstr "" + +msgid "keepalive" +msgstr "" + +msgid "mode" +msgstr "" + +msgid "mtu" +msgstr "" + +msgid "nc" +msgstr "" + +msgid "nocomp" +msgstr "" + +msgid "nodelay" +msgstr "" + +msgid "optional" +msgstr "可选" + +msgid "parityshard" +msgstr "" + +msgid "rcvwnd" +msgstr "" + +msgid "resend" +msgstr "" + +msgid "scavengettl" +msgstr "" + +msgid "sndwnd" +msgstr "" + +msgid "snmpperiod" +msgstr "" + +msgid "sockbuf" +msgstr "" diff --git a/package/lean/luci-app-kcptun/root/etc/config/kcptun b/package/lean/luci-app-kcptun/root/etc/config/kcptun new file mode 100644 index 0000000000..8c9564ce3a --- /dev/null +++ b/package/lean/luci-app-kcptun/root/etc/config/kcptun @@ -0,0 +1,15 @@ + +config general 'general' + option server '' + option client_file '/var/kcptun_client' + option daemon_user 'root' + option enable_logging '1' + +config servers 'default' + option server_addr '' + option server_port '29900' + option listen_addr '0.0.0.0' + option listen_port '12948' + option crypt 'aes' + option mode 'fast' + option nocomp 'false' diff --git a/package/lean/luci-app-kcptun/root/etc/init.d/kcptun b/package/lean/luci-app-kcptun/root/etc/init.d/kcptun new file mode 100755 index 0000000000..c8bc3dc34d --- /dev/null +++ b/package/lean/luci-app-kcptun/root/etc/init.d/kcptun @@ -0,0 +1,244 @@ +#!/bin/sh /etc/rc.common +# +# Copyright 2016-2017 Xingwang Liao +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +START=99 +USE_PROCD=1 + +KCPTUN=kcptun +CONFIG_FOLDER=/var/etc/$KCPTUN + +if [ -r /usr/share/libubox/jshn.sh ]; then + . /usr/share/libubox/jshn.sh +elif [ -r /lib/functions/jshn.sh ]; then + . /lib/functions/jshn.sh +else + logger -p daemon.err -t "$KCPTUN" \ + "Package required: jshn." + exit 1 +fi + +_log() { + local level="$1" + local msg="$2" + + logger -p "daemon.${level}" -t "$KCPTUN" "$msg" +} + +gen_client_config_file() { + local config_file="$1" + + json_init + json_add_string "remoteaddr" "${server_addr}:${server_port}" + json_add_string "localaddr" "${listen_addr}:${listen_port}" + + add_configs() { + local type="$1"; shift + local k v + + for k in "$@"; do + v="$(eval echo "\$$k")" + + if [ -n "$v" ]; then + if [ "$type" = "string" ]; then + json_add_string "$k" "$v" + elif [ "$type" = "int" ]; then + json_add_int "$k" "$v" + elif [ "$type" = "boolean" ]; then + if [ "$v" = "true" ]; then + json_add_boolean "$k" "1" + else + json_add_boolean "$k" "0" + fi + fi + fi + done + } + + add_configs "string" key crypt mode + add_configs "int" conn autoexpire mtu sndwnd rcvwnd datashard parityshard dscp \ + nodelay interval resend nc sockbuf keepalive scavengettl snmpperiod + add_configs "boolean" nocomp acknodelay + + if [ -n "$log_file" ]; then + json_add_string "log" "$log_file" + fi + + json_close_object + + json_dump -i >"$config_file" +} + +setup_iptables_chain() { + if ! ( iptables -nL "$KCPTUN" >/dev/null 2>&1 ); then + iptables -N "$KCPTUN" 2>/dev/null + fi + + iptables -C OUTPUT -j "$KCPTUN" 2>/dev/null || \ + iptables -A OUTPUT -j "$KCPTUN" 2>/dev/null + iptables -C INPUT -j "$KCPTUN" 2>/dev/null || \ + iptables -A INPUT -j "$KCPTUN" 2>/dev/null +} + +clear_iptables_chain() { + iptables -F "$KCPTUN" >/dev/null 2>&1 +} + +add_iptables_rule() { + local port="$1" + local type="$2" + + if [ "$type" = "client" ]; then + ( iptables -C "$KCPTUN" -p tcp --dport "$port" -m comment \ + --comment "$type" -j ACCEPT 2>/dev/null ) && return 0 + + iptables -A "$KCPTUN" -p tcp --dport "$port" -m comment \ + --comment "$type" -j ACCEPT 2>/dev/null + elif [ "$type" = "server" ]; then + ( iptables -C "$KCPTUN" -p udp --dport "$port" -m comment \ + --comment "$type" -j ACCEPT 2>/dev/null ) && return 0 + + iptables -A "$KCPTUN" -p udp --dport "$port" -m comment \ + --comment "$type" -j ACCEPT 2>/dev/null + fi +} + +validate_config_section() { + uci_validate_section "$KCPTUN" general "$1" \ + 'server:uciname' \ + 'client_file:string' \ + 'daemon_user:string:root' \ + 'enable_logging:bool:0' \ + 'log_folder:directory:/var/log/kcptun' +} + +validate_server_section() { + uci_validate_section "$KCPTUN" servers "$1" \ + 'server_addr:host' \ + 'server_port:port:29900' \ + 'listen_addr:host:0.0.0.0' \ + 'listen_port:port:12948' \ + 'key:string' \ + 'crypt:string:aes' \ + 'mode:or("normal","fast","fast2","fast3","manual"):fast' \ + 'conn:min(1)' \ + 'autoexpire:uinteger' \ + 'scavengettl:min(-1)' \ + 'mtu:range(64,9200)' \ + 'sndwnd:min(1)' \ + 'rcvwnd:min(1)' \ + 'datashard:uinteger' \ + 'parityshard:uinteger' \ + 'dscp:uinteger' \ + 'nocomp:or("true", "false")' \ + 'nodelay:bool' \ + 'interval:uinteger' \ + 'resend:range(0,2)' \ + 'nc:bool' \ + 'acknodelay:or("true", "false")' \ + 'sockbuf:uinteger' \ + 'keepalive:uinteger' \ + 'snmpperiod:min(1)' +} + +validate_client_file() { + local file="$1" + + if [ ! -f "$file" ]; then + return 1 + fi + + [ -x "$file" ] || chmod 755 "$file" + + ( $file -v 2>/dev/null | grep -q "$KCPTUN" ) +} + +start_kcptun_instance() { + local section="$1" + + if ! validate_config_section "$section" ; then + _log "err" "Config validate failed." + return 1 + fi + + if [ -z "$server" ] || [ "$server" = "nil" ]; then + _log "info" "No server selected, Client will stop." + return 0 + elif ! validate_server_section "$server"; then + _log "err" "Server config validation failed." + return 1 + elif [ -z "$server_addr" ] || [ -z "$listen_port" ]; then + _log "err" "Server config validation failed." + return 1 + fi + + if [ -z "$client_file" ]; then + _log "err" "Please set client file path, or use auto download." + return 1; + elif ! validate_client_file "$client_file"; then + _log "err" "Client file validation failed." + return 1 + fi + + is_ipv6_address() { + echo "$1" | grep -q ":" + } + + is_ipv6_address "$server_addr" && server_addr="[${server_addr}]" + is_ipv6_address "$listen_addr" && listen_addr="[${listen_addr}]" + + [ -d "$CONFIG_FOLDER" ] || mkdir -p "$CONFIG_FOLDER" + + log_file="" + if [ "$enable_logging" = "1" ]; then + mkdir -p "$log_folder" + chown -R "$daemon_user" "$log_folder" + log_file="${log_folder}/client.${section}.log" + fi + + local config_file=${CONFIG_FOLDER}/client.${section}.json + + if ! ( gen_client_config_file "$config_file" ); then + _log "err" "Can't create config file". + return 1 + fi + + add_iptables_rule "$listen_port" "client" + + procd_open_instance + procd_set_param command "$client_file" + procd_append_param command -c "$config_file" + procd_set_param respawn + procd_set_param user "$daemon_user" + procd_set_param file "$config_file" + procd_close_instance +} + +service_triggers() { + procd_add_reload_trigger "$KCPTUN" +} + +start_service() { + clear_iptables_chain + setup_iptables_chain + + config_load "$KCPTUN" + config_foreach start_kcptun_instance "general" +} + +stop_service() { + clear_iptables_chain +} diff --git a/package/lean/luci-app-kcptun/root/etc/uci-defaults/40_luci-kcptun b/package/lean/luci-app-kcptun/root/etc/uci-defaults/40_luci-kcptun new file mode 100755 index 0000000000..c759ba19e3 --- /dev/null +++ b/package/lean/luci-app-kcptun/root/etc/uci-defaults/40_luci-kcptun @@ -0,0 +1,25 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@kcptun[-1] + add ucitrack kcptun + set ucitrack.@kcptun[-1].init=kcptun + commit ucitrack +EOF + +general=$(uci -q get kcptun.@general[-1]) + +if [ -z "$general" ]; then + uci -q add kcptun general +fi + +if [ ."$general" != ."general" ]; then + uci -q batch <<-EOF >/dev/null + rename kcptun.@general[-1]="general" + set kcptun.general.server="" + commit kcptun + EOF +fi + +rm -rf /tmp/luci-indexcache /tmp/luci-modulecache +exit 0 diff --git a/package/lean/luci-app-kuainiao/Makefile b/package/lean/luci-app-kuainiao/Makefile new file mode 100644 index 0000000000..6e8319b3f8 --- /dev/null +++ b/package/lean/luci-app-kuainiao/Makefile @@ -0,0 +1,17 @@ +# Copyright (C) 2016 Openwrt.org +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI support for Kuainiao +LUCI_DEPENDS:=+kmod-ppp +openssl-util +wget +kmod-mppe +LUCI_PKGARCH:=all +PKG_VERSION:=1.0 +PKG_RELEASE:=3 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + diff --git a/package/lean/luci-app-kuainiao/luasrc/controller/kuainiao.lua b/package/lean/luci-app-kuainiao/luasrc/controller/kuainiao.lua new file mode 100644 index 0000000000..378517c42a --- /dev/null +++ b/package/lean/luci-app-kuainiao/luasrc/controller/kuainiao.lua @@ -0,0 +1,34 @@ +module("luci.controller.kuainiao", package.seeall) + +function index() + local fs = luci.fs or nixio.fs + if not fs.access("/etc/config/kuainiao") then + return + end + + local page = entry({"admin", "services", "kuainiao"}, cbi("kuainiao"), _("Kuai Niao"),201) + page.dependent = true + entry({"admin","services","kuainiao","status"},call("kuainiao_status")).leaf=true + entry({"admin","services","kuainiao","dwonstatus"},call("down_status")).leaf=true + entry({"admin","services","kuainiao","upstatus"},call("up_status")).leaf=true +end + +function kuainiao_status() +local e={} +e.running=luci.sys.exec("ps |grep -v grep |grep -w '/usr/bin/kuainiao' ") +luci.http.prepare_content("application/json") +luci.http.write_json(e) +end + +function up_status() +local e={} +e.upstatus=luci.sys.exec("cat /usr/share/kuainiao/kuainiao_up_state") +luci.http.prepare_content("application/json") +luci.http.write_json(e) +end +function down_status() +local e={} +e.dwonstatus=luci.sys.exec("cat /usr/share/kuainiao/kuainiao_down_state") +luci.http.prepare_content("application/json") +luci.http.write_json(e) +end diff --git a/package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua b/package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua new file mode 100644 index 0000000000..3fec7cd005 --- /dev/null +++ b/package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua @@ -0,0 +1,59 @@ +#fork from https://github.com/zz090923610/thunder-fastNiao,thanks to zz090923610 +require("luci.sys") +require("luci.sys.zoneinfo") +require("luci.config") +local fs = require "nixio.fs" +local ut = require "luci.util" +local o=require"luci.model.network".init() +local sys = require "luci.sys" +local m,t,e +m = Map("kuainiao", translate("迅雷快鸟"),translate("迅雷快鸟是迅雷联合宽带运营商推出的一款致力于帮助用户解决宽带低、网速慢、上网体验差的专业级宽带加速软件。")) +m:section(SimpleSection).template = "kuainiao/kuainiao_status" +s = m:section(NamedSection, "base", "kuainiao", translate("首次使用请填写完帐号密码保存提交一次,之后再启用。")) +s.addremove = false +s:tab("base",translate("Basic Settings")) +s:tab("log",translate("快鸟日志")) +enabled = s:taboption("base",Flag, "enabled", translate("Enable")) +enabled.default=0 +enabled.rmempty = false +enable_down = s:taboption("base",Flag, "enable_down", translate("开启下行加速")) +enable_down.default=1 +enabled.rmempty = false +enable_down:depends("enabled",1) + +enable_up = s:taboption("base",Flag, "enable_up", translate("开启上行加速")) +enable_up.default=0 +enabled.rmempty = false +enable_up:depends("enabled",1) +local a +speed_wan=s:taboption("base",ListValue,"speed_wan",translate("指定加速的接口")) +for a,s in ipairs(o:get_networks())do +if s:name()~="loopback" and s:name()~="lan" then speed_wan:value(s:name())end +end +username = s:taboption("base",Value, "kuainiao_name", translate("迅雷快鸟帐号")) +username.datatype = "minlength(1)" +username.rmempty = false +password = s:taboption("base",Value, "kuainiao_passwd", translate("迅雷快鸟密码")) +password.password = true +password.datatype = "minlength(1)" +password.rmempty = false +kuainiao_config_pwd = s:taboption("base",Value, "kuainiao_config_pwd", translate("加密后密码(自动生成,勿修改)")) +kuainiao_config_pwd.password = true +kuainiao_config_pwd.datatype = "minlength(1)" +kuainiao_config_pwd.rmempty = true +--kuainiao_config_pwd.readonly=true +log=s:taboption("log",TextValue,"log") +log.rows=26 +log.wrap="off" +log.readonly=true +log.cfgvalue=function(t,t) +return nixio.fs.readfile("/var/log/kuainiao.log")or"" +end +log.write=function(log,log,log) +end +m:section(SimpleSection).template = "kuainiao/kuainiao_rsa" +local apply = luci.http.formvalue("cbi.apply") +if apply then + io.popen("luci_kuainiao_apply") +end +return m diff --git a/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_rsa.htm b/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_rsa.htm new file mode 100644 index 0000000000..9d8c458716 --- /dev/null +++ b/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_rsa.htm @@ -0,0 +1,25 @@ +<%# + Copyright (C) 2017 Jian Chang + Licensed to the public under the GNU General Public License v3. +-%> + + + + +<% include("cbi/map") %> + + diff --git a/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_status.htm b/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_status.htm new file mode 100644 index 0000000000..93c28e5790 --- /dev/null +++ b/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_status.htm @@ -0,0 +1,38 @@ +<%# + Copyright 2017 Lede by stones +-%> + +<% include("cbi/map") %> + + + + <%:快鸟运行状态:%><%:Collecting data...%> + + + <%:下行提速状态:%><%:Collecting data...%> + + <%:上行提速状态:%><%:Collecting data...%> + \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po b/package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po new file mode 100644 index 0000000000..fc29d88494 --- /dev/null +++ b/package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po @@ -0,0 +1,4 @@ +msgid "Kuai Niao" +msgstr "迅雷快鸟" + + diff --git a/package/lean/luci-app-kuainiao/root/etc/config/kuainiao b/package/lean/luci-app-kuainiao/root/etc/config/kuainiao new file mode 100644 index 0000000000..0c4db8d66a --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/etc/config/kuainiao @@ -0,0 +1,8 @@ + +config kuainiao 'base' + option kuainiao_name '' + option kuainiao_passwd '' + option speed_wan 'wan' + option enabled '0' + option enable_down '1' + option enable_up '0' diff --git a/package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao b/package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao new file mode 100755 index 0000000000..2f42f3093e --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao @@ -0,0 +1,15 @@ +#!/bin/sh +. /lib/functions.sh + +enabled=`uci -q get kuainiao.base.enabled` +[ "enabled" -eq 1 ] || exit 0 +[ "$ACTION" = ifup ] && { + logger -t Thunder kuainiao has reloaded due to Device: $DEVICE Action: $ACTION ; + /etc/init.d/kuainiao stop && sleep 2; + /etc/init.d/kuainiao start; +} + +[ "$ACTION" = ifdown ] && { + logger -t Thunder KuaiNiao has stoped due to Device: $DEVICE Action: $ACTION ; + /etc/init.d/kuainiao stop; +} \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao b/package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao new file mode 100755 index 0000000000..29f7c8adb5 --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao @@ -0,0 +1,45 @@ +#!/bin/sh /etc/rc.common + +USE_PROCD=1 +START=99 +STOP=15 +SERVICE_WRITE_PID=1 +SERVICE_DAEMONIZE=1 +LOGFILE=/var/log/kuainiao.log + +start_service() +{ + procd_open_instance + procd_set_param command /usr/bin/kuainiao + procd_set_param respawn ${respawn_threshold:-5} ${respawn_timeout:-300} ${respawn_retry:-10} + procd_close_instance +} + +stop_service(){ + clean_log + pid_kuainiao=`ps | grep -v grep | grep -w "/usr/bin/kuainiao" |awk '{print $1}' 2>/dev/null` + [ -n "$pid_kuainiao" ] && { + for pid in $pid_kuainiao + do + echo "Stop service kuainiao PID: $pid" + kill $pid 2>/dev/null + for spid in `pgrep sleep` + do + ppid=`cat /proc/$spid/status | grep -w "PPid" | awk '{print $2}'` + [ "$ppid" -eq "$pid" ] && kill $spid 2>/dev/null && echo "Stop service kuainiao SPID: $spid" + done + done + } + echo "暂无加速信息" > /usr/share/kuainiao/kuainiao_down_state + echo "暂无加速信息" > /usr/share/kuainiao/kuainiao_up_state +} + +clean_log() { + [ -f "$LOGFILE" ] && { + logsnum=$(cat $LOGFILE | grep -c .) + if [ $logsnum -gt 300 ];then + rm -f $LOGFILE >/dev/null 2>&1 & + echo "$(date): 日志文件过长,清空处理!" >> $LOGFILE + fi + } +} diff --git a/package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao b/package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao new file mode 100755 index 0000000000..b8b12cac82 --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao @@ -0,0 +1,9 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@kuainiao[-1] + add ucitrack kuainiao + set ucitrack.@kuainiao[-1].init=kuainiao + commit ucitrack +EOF +exit 0 \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/usr/bin/kuainiao b/package/lean/luci-app-kuainiao/root/usr/bin/kuainiao new file mode 100755 index 0000000000..f5e5205405 --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/usr/bin/kuainiao @@ -0,0 +1,606 @@ +#!/bin/sh +#2017/05/01 by kenney +#2017/07/19 update for lede by stones +. /lib/functions.sh + +LOGFILE=/var/log/kuainiao.log +down_state_file=/usr/share/kuainiao/kuainiao_down_state +up_state_file=/usr/share/kuainiao/kuainiao_up_state +version="0.4" +app_version="2.0.3.4" +protocolVersion=108 +sdkVersion=17550 +logmore=0 #打印更详细日志排查 + + +logmore(){ + data=$1 + [ "$logmore" -eq 1 ] && { + echo $(date): $data >> $LOGFILE + } +} + +log_down(){ + kuainiao_down_state=$1 + status=$2 + if [ "$status" -eq 1 ]; then + echo "$kuainiao_down_state" > $down_state_file + else + echo "$kuainiao_down_state" > $down_state_file + fi +} + +log_up(){ + kuainiao_up_state=$1 + status=$2 + if [ "$status" -eq 1 ]; then + echo "$kuainiao_up_state" > $up_state_file + else + echo "$kuainiao_up_state" > $up_state_file + fi +} + +#WAN接口IP判断 +get_bind_address(){ + ifname=$(uci -P /var/state get network.$kuainiao_config_wan.ifname 2>/dev/null) + [ $? -eq 1 ] && echo $(date): "获取网络 $kuainiao_config_wan 信息出错" >>$LOGFILE && echo >>$LOGFILE && return + logmore "ifname is $ifname" + ##wan_selected 所选接口IP + wan_selected=$(ifconfig $ifname 2>/dev/null | grep 'inet addr' | awk '{print $2}' | cut -d: -f2 2>/dev/null) + [ -z "$wan_selected" ] && echo $(date): "获取网络 $kuainiao_config_wan 接口 $ifname 信息出错" >>$LOGFILE && echo >>$LOGFILE && return + if [ "$wan_selected" != "0.0.0.0" ]; then + bind_address=$wan_selected + else + bind_address="" + fi +} + +#定义请求函数 +#bind_address='113.248.3.11' +get_http_req(){ + if [ -n "$bind_address" ]; then + HTTP_REQ="wget --bind-address=$bind_address --no-check-certificate -O - " + POST_ARG="--post-data=" + else + HTTP_REQ="wget --no-check-certificate -O - " + POST_ARG="--post-data=" + fi + kuainiao_HTTP_REQ=$HTTP_REQ + kuainiao_POST_ARG=$POST_ARG +} + +#数据mock + +generate_pwd_rsa_hex() +{ + # calculate passwd_md5 + logmore "Generating passwd md5" + passwd_md5=`echo -n "$kuainiao_config_pwd" | md5sum | tr -d " -"` + + if [ `echo -n "$passwd_md5" | wc -c` -ne 32 ]; then + logmore "md5sum should be 32 chars, exit." + exit 1 + fi + + logmore "Generating PWD RSA HEX" + #first, encoding passwd using rsa + a=`echo "$passwd_md5" | openssl rsautl -raw -pubin -inkey /etc/thunder.key -hexdump | tr [a-z] [A-Z]` + a=`echo $a | grep -o '00[0-9]0 \- \([A-Z0-9]\{2\}[- ]\)\{16\}' | sed 's/00[0-9]0 - //g' | tr -d " \-\n"` + echo -n "$a" + +} + +#pwd='702CFAF5824E4306516F488DEAFC2D24F76C82FA53BA3396F5615FDD32E4430E45B254E136056ED5F3C5B404A08E2178B51330999A4EC3C2D2989D554D7863BDE8F058F44808E6B65F4D071B5D5C7210210DA9ED8D729312CECA39E0F4516143E33C089F616ABE93E14D3224BEB311D3D6EF65A6CE265D3E4ABA285523F14320' + +get_device_sign(){ + ifname=$(uci get network.$kuainiao_config_wan.ifname 2>/dev/null) + wan_mac=$(ifconfig $ifname | grep 'HWaddr' | awk '{print $5}') + fake_device_id=$(echo -n "$wan_mac" | md5sum | cut -d ' ' -f1) + fake_device_id_tmp1=$(echo -n "$fake_device_id"com.xunlei.vip.swjsq68700d1872b772946a6940e4b51827e8af"" | openssl sha1 -hmac | awk '{print $2}') + devicesign="div100."${fake_device_id}$(echo -n "$fake_device_id_tmp1" | md5sum | cut -d ' ' -f1) +} + + +#verifyCode=$kuainiao_config_verifyCode +#verifyKey=$kuainiao_verifyKey + +#获取用户真实MAC地址 +get_mac_addr(){ + if [ -n "$bind_address" ]; then + ifname=$(uci get network.$kuainiao_config_wan.ifname 2>/dev/null) + peerid=$(ifconfig $ifname | grep 'HWaddr' | awk '{print $5}' | awk 'gsub(/:/, "")')004V + fi + #peerid='000C29212478004V' +} + + +#获取迅雷用户uid +get_xunlei_uid(){ + get_http_req + logmore "HTTP_REQ is $HTTP_REQ" + logmore "POST_ARG is $POST_ARG" + uname=$kuainiao_config_uname + #get_mac_addr + logmore "peerid is $peerid" + [ -z "$peerid" ] && exit 0 + #pwd=$generate_pwd_rsa_hex + pwd=$kuainiao_config_pwd + get_device_sign + logmore "devicesign is $devicesign" + ret=`$HTTP_REQ --header "User-Agent:android-async-http/xl-acc-sdk/version-1.6.1.177600" https://login.mobile.reg2t.sandai.net:443/ $POST_ARG"{\"userName\":\""$uname"\",\"businessType\":68,\"clientVersion\":\"$app_version\",\"appName\":\"ANDROID-com.xunlei.vip.swjsq\",\"isCompressed\":0,\"sequenceNo\":1000001,\"sessionID\":\"\",\"loginType\":0,\"rsaKey\":{\"e\":\"010001\",\"n\":\"AC69F5CCC8BDE47CD3D371603748378C9CFAD2938A6B021E0E191013975AD683F5CBF9ADE8BD7D46B4D2EC2D78AF146F1DD2D50DC51446BB8880B8CE88D476694DFC60594393BEEFAA16F5DBCEBE22F89D640F5336E42F587DC4AFEDEFEAC36CF007009CCCE5C1ACB4FF06FBA69802A8085C2C54BADD0597FC83E6870F1E36FD\"},\"cmdID\":1,\"verifyCode\":\"$verifyCode\",\"peerID\":\""$peerid"\",\"protocolVersion\":$protocolVersion,\"platformVersion\":1,\"passWord\":\""$pwd"\",\"extensionList\":\"\",\"verifyKey\":\"$verifyKey\",\"sdkVersion\":$sdkVersion,\"devicesign\":\""$devicesign"\"}"` + #判断是否登陆成功 + #echo $ret >>test.txt + logmore "........................" + logmore "ret is $ret" + logmore "........................" + session=`echo $ret|awk -F '"sessionID":' '{print $2}'|awk -F '[,}]' '{print $1}'|grep -oE "[A-F,0-9]{32}"` + logmore "session is $session" + #vcode=`echo $ret|awk -F '"errorDescUrl":' '{print $2}'|awk -F '}' '{print $1}'` + #vcode=`echo $vcode|sed 's/\\//g'` + errcode=`echo $ret|awk -F '"errorCode":' '{print $2}'|awk -F '[,}]' '{print $1}'` + logmore "errcode is $errcode" + if [ -z "$session" ]; then + if [ $errcode == 6 ];then + #kuainiao_vcodeimg_url="$vcode" + #kuainiao_verifyKey='F9F6FBE928911784D809EBF046ABE0A6A467583F3944507099EA54BC9B5DA7BD' + kuainiao_last_act="您的账号不安全,需要输入验证码! $(date "+%Y-%m-%d %H:%M:%S")" + + elif [ $errcode == 12 ];then + #kuainiao_vcodeimg_url="" + #kuainiao_verifyKey='' + kuainiao_last_act="登陆协议无效,请更新!$(date "+%Y-%m-%d %H:%M:%S")" + + elif [ $errcode == 3 ];then + #kuainiao_vcodeimg_url="" + #kuainiao_verifyKey='' + kuainiao_last_act="用户名密码错误,请检查!$(date "+%Y-%m-%d %H:%M:%S")" + + else + #kuainiao_vcodeimg_url="" + #kuainiao_verifyKey='' + kuainiao_last_act="迅雷账号登陆失败,请检查输入的用户名密码! $(date "+%Y-%m-%d %H:%M:%S")" + + fi + #echo "迅雷账号登陆失败,请检查输入的用户名密码!" + log_down "$kuainiao_last_act" 0 + + else + uid=`echo $ret|awk -F '"userID":' '{print $2}'|awk -F '[,}]' '{print $1}'` + kuainiao_config_uid=$uid + kuainiao_config_session=$session + kuainiao_last_act="迅雷快鸟已登陆成功!" + log_down "$kuainiao_last_act" 1 + fi + echo $(date): "$kuainiao_last_act" >> $LOGFILE +} + +#获取加速API +get_kuainiao_api(){ + portal=`$HTTP_REQ http://api.portal.swjsq.vip.xunlei.com:81/v2/queryportal` + portal_ip=`echo $portal|grep -oE '([0-9]{1,3}[\.]){3}[0-9]{1,3}'` + portal_port_temp=`echo $portal|grep -oE "port...[0-9]{1,5}"` + portal_port=`echo $portal_port_temp|grep -oE '[0-9]{1,5}'` + + logmore "portal is $portal" >> $LOGFILE + logmore "portal_ip is $portal_ip" >> $LOGFILE + logmore "portal_port_temp is $portal_port_temp" >> $LOGFILE + logmore "portal_port is $portal_port" >> $LOGFILE + + if [ -z "$portal_ip" ]; then + kuainiao_down_state="迅雷快鸟下行API获取失败,请检查网络环境,或稍后再试!" + echo $(date): "$kuainiao_down_state" >> $LOGFILE + log_down "$kuainiao_down_state" 0 + else + api_url="http://$portal_ip:$portal_port/v2" + kuainiao_config_api=$api_url + fi +} + +#获取上行加速API +get_kuainiao_upapi(){ + upportal=`$HTTP_REQ http://api.upportal.swjsq.vip.xunlei.com/v2/queryportal` + upportal_ip=`echo $upportal|grep -oE '([0-9]{1,3}[\.]){3}[0-9]{1,3}'` + upportal_port_temp=`echo $upportal|grep -oE "port...[0-9]{1,5}"` + upportal_port=`echo $upportal_port_temp|grep -oE '[0-9]{1,5}'` + + logmore "upportal is $upportal" + logmore "upportal_ip is $upportal_ip" + logmore "upportal_port_temp is $upportal_port_temp" + logmore "upportal_port is $upportal_port" + + if [ -z "$upportal_ip" ]; then + kuainiao_up_state="迅雷快鸟上行API获取失败,请检查网络环境,或稍后再试!" + #echo "迅雷快鸟服务API获取失败,请检查网络环境,或稍后再试!" + echo $(date): "$kuainiao_up_state" >> $LOGFILE + log_up "$kuainiao_up_state" 0 + else + upapi_url="http://$upportal_ip:$upportal_port/v2" + kuainiao_config_upapi=$upapi_url + fi + logmore "$(date): upapi_url is $upapi_url" +} + + +#检测快鸟加速信息 +get_bandwidth(){ + + logmore "api_url is $api_url" + logmore "peerid is $peerid" + if [ -n "$api_url" ]; then + [ -n "$portal_port_temp" ] && [ -n "$portal_port" ] && bandwidth + band=$width + logmore "band is $band" + can_upgrade=`echo $band|awk -F '"can_upgrade":' '{print $2}'|awk -F '[,}]' '{print $1}'` + logmore "can_upgrade is $can_upgrade" + kuainiao_can_upgrade=$can_upgrade + logmore "kuainiao_can_upgrade is $kuainiao_can_upgrade" + dial_account=`echo $band|awk -F '"dial_account":"' '{print $2}'|awk -F '[,}"]' '{print $1}'` + kuainiao_dial_account=$dial_account + logmore "kuainiao_dial_account is $kuainiao_dial_account" + #判断是否满足加速条件 + if [ "$can_upgrade" -eq 1 ]; then + #echo "迅雷快鸟可以加速~~~愉快的开始加速吧~~" + #获取加速详细信息 + old_downstream=`echo $band|awk -F '"bandwidth":' '{print $2}'|awk -F '"downstream":' '{print $2}'|awk -F '[,}]' '{print $1}'` + max_downstream=`echo $band|awk -F '"max_bandwidth":' '{print $2}'|awk -F '"downstream":' '{print $2}'|awk -F '[,}]' '{print $1}'` + down_state="下行可以加速" + kuainiao_old_downstream=$(expr $old_downstream / 1024) + kuainiao_max_downstream=$(expr $max_downstream / 1024) + logmore "kuainiao_old_downstream is $kuainiao_old_downstream" + logmore "kuainiao_max_downstream is $kuainiao_max_downstream" + else + down_state="下行不满足加速条件" + #echo "T_T 不能加速啊,不满足加速条件哦~~" + log_down "$down_state" 0 + fi + echo $(date): "$down_state" >> $LOGFILE + # kuainiao_down_state=$down_state + + fi +} + +#检测快鸟上行加速信息 +get_upbandwidth(){ + logmore "upapi_url is $upapi_url" + if [ -n "$upapi_url" ]; then + [ -n "$upportal_port_temp" ] && [ -n "$upportal_port" ] && upbandwidth + band=$upwidth + logmore "upwidth is $upwidth" + can_upgrade=`echo $band|awk -F '"can_upgrade":' '{print $2}'|awk -F '[,}]' '{print $1}'` + kuainiao_can_upupgrade=$can_upgrade + updial_account=`echo $band|awk -F '"dial_account":"' '{print $2}'|awk -F '[,}"]' '{print $1}'` + kuainiao_dial_upaccount=$updial_account + logmore "can_upgrade is $can_upgrade" + logmore "kuainiao_can_upupgrade is $kuainiao_can_upupgrade" + logmore "updial_account is $updial_account" + logmore "kuainiao_dial_upaccount is $kuainiao_dial_upaccount" + #判断是否满足加速条件 + if [ "$can_upgrade" -eq 1 ]; then + #echo "迅雷快鸟可以加速~~~愉快的开始加速吧~~" + #获取加速详细信息 + old_upstream=`echo $band|awk -F '"bandwidth":' '{print $2}'|awk -F '"upstream":' '{print $2}'|awk -F '[,}]' '{print $1}'` + max_upstream=`echo $band|awk -F '"max_bandwidth":' '{print $2}'|awk -F '"upstream":' '{print $2}'|awk -F '[,}]' '{print $1}'` + up_state="上行可以加速" + kuainiao_old_upstream=$(expr $old_upstream / 1024) + kuainiao_max_upstream=$(expr $max_upstream / 1024) + logmore "kuainiao_old_upstream is $kuainiao_old_upstream" + logmore "kuainiao_max_upstream is $kuainiao_max_upstream" + else + up_state="上行不满足加速条件" + log_up "$up_state" 0 + fi + echo "$(date): $up_state" >> $LOGFILE + kuainiao_up_state=$up_state + + fi +} + + +#检测试用加速信息 +query_try_info(){ + info=`$HTTP_REQ "$api_url/query_try_info?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session"` + echo $info +} +##{"errno":0,"message":"","number_of_try":0,"richmessage":"","sequence":0,"timestamp":1455936922,"try_duration":10} + +query_try_upinfo(){ + info=`$HTTP_REQ "$upapi_url/query_try_info?peerid=$peerid&userid=$uid&client_type=android-uplink-2.3.3.9&client_version=andrioduplink-2.3.3.9&os=android-7.0.24DUK-AL20&sessionid=$session"` + echo $info +} +##{"errno":0,"exp_day_len":0,"is_exp_day":0,"message":"","number_of_try":1,"richmessage":"","sequence":268435461,"timestamp":1493469390,"try_duration":10} + +get_upgrade_down(){ + _ts=`date +%s`000 + ret=`$HTTP_REQ "$api_url/upgrade?peerid=$peerid&userid=$uid&user_type=1&sessionid=$kuainiao_config_session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"` + errcode=`echo $ret|awk -F '"errno":' '{print $2}'|awk -F '[,}"]' '{print $1}'` + if [ "$errcode" == "0" ]; then + down_state="$down_state (您的下行带宽已从$kuainiao_old_downstream M提升到$kuainiao_max_downstream M)" + log_down "$down_state" 1 + else + down_state="$down_state 下行带宽提升失败,请检查宽带账号是否绑定正确" + log_down "$down_state" 0 + fi + echo $(date): "$down_state" >> $LOGFILE + # kuainiao_down_state=$down_state +} + +get_upgrade_up(){ + _ts=`date +%s`000 + up_ret=`$HTTP_REQ --header "User-Agent:android-async-http/xl-acc-sdk/version-1.0.0.1" "$upapi_url/upgrade?peerid=$peerid&userid=$uid&client_type=android-uplink-2.3.3.9&client_version=andrioduplink-2.3.3.9&os=android-7.0.24DUK-AL20&sessionid=$session&user_type=1&dial_account=$updial_account"` + errcode=`echo $up_ret|awk -F '"errno":' '{print $2}'|awk -F '[,}"]' '{print $1}'` + if [ "$errcode" == "0" ] || [ "$errcode" == "812" ];then + up_state="$up_state (您的上行带宽已从$kuainiao_old_upstream M提升到$kuainiao_max_upstream M)" + log_up "$up_state" 1 + else + up_state="$up_state 上行带宽提升失败,请检查宽带账号是否绑定正确" + log_up "$up_state" 0 + fi + echo $(date): "$up_state" >> $LOGFILE + # kuainiao_up_state=$up_state + # echo "$kuainiao_up_state" > $up_state_file +} + +#迅雷快鸟上行加速心跳包 +keepalive_up(){ + _ts=`date +%s`000 + up_ret=`$HTTP_REQ --header "User-Agent:android-async-http/xl-acc-sdk/version-1.0.0.1" "$upapi_url/keepalive?peerid=$peerid&userid=$uid&client_type=android-uplink-2.3.3.9&client_version=andrioduplink-2.3.3.9&os=android-7.0.24DUK-AL20&sessionid=$session&user_type=1&dial_account=$kuainiao_dial_upaccount"` + errcode=`echo $up_ret|awk -F '"errno":' '{print $2}'|awk -F '[,}"]' '{print $1}'` + if [ "$errcode" != "0" ];then + #kuainiao_run_upid=0 + kuainiao_up_state="迅雷上行提速失效!$(date '+%Y-%m-%d %H:%M:%S')" + kuainiao_run_upstatus=0 + log_up "$kuainiao_up_state" 0 + else + #kuainiao_run_upid=$(expr $kuainiao_run_upid + 1) + kuainiao_up_state="您的上行带宽已从${kuainiao_old_upstream}M提升到${kuainiao_max_upstream}M $(date '+%Y-%m-%d %H:%M:%S')" + kuainiao_run_upstatus=1 + log_up "$kuainiao_up_state" 1 + fi +} + + +#检测提速带宽 +bandwidth(){ + [ "$logmore" -eq 1 ] && { + echo $(date): "bandwidth start" >> $LOGFILE + echo $(date): "peerid is $peerid" >> $LOGFILE + echo $(date): "uid is $uid" >> $LOGFILE + echo $(date): "session is $session" >> $LOGFILE + } + _ts=`date +%s`000 + width=`$HTTP_REQ "$api_url/bandwidth?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"` + #echo $width +} +##{"bandwidth":{"downstream":51200,"upstream":0},"can_upgrade":1,"dial_account":"100001318645","errno":0,"max_bandwidth":{"downstream":102400,"upstream":0},"message":"","province":"bei_jing","province_name":"北京","richmessage":"","sequence":0,"sp":"cnc","sp_name":"联通","timestamp":1455936922} + +upbandwidth(){ + _ts=`date +%s`000 + upwidth=`$HTTP_REQ "$upapi_url/bandwidth?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"` + #echo $upwidth +} + + +#迅雷快鸟下行加速心跳包 +keepalive_down(){ + _ts=`date +%s`000 + ret=`$HTTP_REQ "$api_url/keepalive?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"` + errcode=`echo $ret|awk -F '"errno":' '{print $2}'|awk -F '[,}"]' '{print $1}'` + if [ "$errcode" != "0" ];then + #kuainiao_run_upid=0 + kuainiao_down_state="迅雷下行提速失效!"$(date "+%Y-%m-%d %H:%M:%S") + log_down "$kuainiao_down_state" 0 + kuainiao_run_status=0 + else + #kuainiao_run_upid=$(expr $kuainiao_run_upid + 1) + kuainiao_down_state="您的下行带宽已从${kuainiao_old_downstream}M提升到${kuainiao_max_downstream}M $(date '+%Y-%m-%d %H:%M:%S')" + log_down "$kuainiao_down_state" 1 + kuainiao_run_status=1 + + fi + echo $(date): "$kuainiao_down_state" >> $LOGFILE +} + +sigterm(){ + + [ "$kuainiao_can_upgrade" -eq 1 ] && kuainiao_recover + [ "$kuainiao_can_upupgrade" -eq 1 ] && kuainiao_uprecover + logmore "trap sigterm exit" + exit 0 + +} + +#快鸟加速注销 +kuainiao_recover(){ + _ts=`date +%s`000 + recover=`$HTTP_REQ "$api_url/recover?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"` + #echo $recover + echo $(date): "快鸟下行带宽加速已注销" >> $LOGFILE +} + +kuainiao_uprecover(){ + _ts=`date +%s`000 + recover=`$HTTP_REQ "$upapi_url/recover?peerid=$peerid&userid=$uid&client_type=android-uplink-2.3.3.9&client_version=andrioduplink-2.3.3.9&os=android-7.0.24DUK-AL20&sessionid=$session&user_type=1&dial_account=$updial_account"` + #echo $recover + echo $(date): "快鸟上行带宽加速已注销" >> $LOGFILE +} + +#执行初始化 +kuainiao_init(){ + local kuainiao_last_act="" + local kuainiao_can_upgrade=0 + local kuainiao_can_upupgrade=0 + local kuainiao_down_state="" + local kuainiao_up_state="" +} + +##主逻辑 +trap 'sigterm' TERM +trap 'sigterm' INT + +kuainiao_init +config_load kuainiao +config_get_bool enabled base enabled 0 +config_get_bool kuainiao_downenable base enable_down 0 +config_get_bool kuainiao_upenable base enable_up 0 +config_get kuainiao_config_wan base speed_wan +config_get kuainiao_config_uname base kuainiao_name +config_get kuainiao_config_pwd base kuainiao_config_pwd + +[ "$enabled" -eq 0 ] || [ -z "$kuainiao_config_pwd" ] && exit 0 +[ "$kuainiao_downenable" -eq 0 ] && [ "$kuainiao_upenable" -eq 0 ] && exit 0 +[ -z "$kuainiao_config_uname" ] && exit 0 + +logmore "enabled is $enabled" +logmore "kuainiao_downenable is $kuainiao_downenable" +logmore "kuainiao_upenable is $kuainiao_upenable" +logmore "kuainiao_config_wan is $kuainiao_config_wan" +logmore "kuainiao_config_uname is $kuainiao_config_uname" +logmore "kuainiao_config_pwd is $kuainiao_config_pwd" + +if [ "$kuainiao_downenable" -eq 1 ] || [ "$kuainiao_upenable" -eq 1 ]; then + + logmore "启动延时 7s" + sleep 7s + + #登陆迅雷获取uid + logmore "get_bind_address start" + get_bind_address + logmore "bind_address is $bind_address" + logmore "get_mac_addr start" + get_mac_addr + logmore "peerid is $peerid" + logmore "get_xunlei_uid start" + get_xunlei_uid + logmore "get_xunlei_uid is done" + logmore "id is $uid" + #判断是否登陆成功 + if [ -n "$uid" ]; then + if [ "$kuainiao_downenable" -eq 1 ]; then + logmore "get_kuainiao_api is started......." + get_kuainiao_api + logmore "get_bandwidth is started......." + get_bandwidth + kuainiao_config_downstream=$(expr $old_downstream / 1024) + kuainiao_config_max_downstream=$(expr $max_downstream / 1024) + logmore "kuainiao_config_downstream is $kuainiao_config_downstream" + logmore "kuainiao_config_max_downstream is $kuainiao_config_max_downstream" + logmore "kuainiao_can_upgrade is $kuainiao_can_upgrade" + + if [ "$kuainiao_can_upgrade" -eq 1 ]; then + logmore "get_upgrade_down is started......." + get_upgrade_down + logmore "get_upgrade_down is done......." + sleep 1s + #keepalive_down + fi + fi + if [ "$kuainiao_upenable" -eq 1 ]; then + logmore "get_kuainiao_upapi start" + get_kuainiao_upapi + logmore "get_upbandwidth start" + get_upbandwidth + kuainiao_config_upstream=$(expr $old_upstream / 1024) + kuainiao_config_max_upstream=$(expr $max_upstream / 1024) + logmore "kuainiao_config_upstream is $kuainiao_config_upstream" + logmore "kuainiao_config_max_upstream is $kuainiao_config_max_upstream" + logmore "kuainiao_can_upupgrade is $kuainiao_can_upupgrade" + + if [ "$kuainiao_can_upupgrade" -eq 1 ]; then + logmore "get_upgrade_up start" + get_upgrade_up + sleep 1s + #keepalive_up + fi + fi + fi +fi + +# [ -z "$kuainiao_can_upgrade" ] && [ -z "$kuainiao_can_upupgrade" ] && { + # logmore "exit kuainiao...." + # sleep 7s + # echo "暂无加速信息" > $down_state_file + # echo "暂无加速信息" > $up_state_file + # exit 0 + +# } +while true; +do + sleep 295s + if [ "$kuainiao_downenable" -eq 1 ] && [ "$kuainiao_can_upgrade" -eq 1 ];then + keepalive_down + [ "$kuainiao_run_status" -eq 0 ] && restart_kuainiao + fi + if [ "$kuainiao_upenable" -eq 1 ] && [ "$kuainiao_can_upupgrade" -eq 1 ];then + keepalive_up + [ "$kuainiao_run_upstatus" -eq 0 ] && restart_kuainiao + fi +done + + +restart_kuainiao(){ + kuainiao_init + config_load kuainiao + config_get_bool enabled base enabled 0 + config_get_bool kuainiao_downenable base enable_down 0 + config_get_bool kuainiao_upenable base enable_up 0 + config_get kuainiao_config_wan base speed_wan + config_get kuainiao_config_uname base kuainiao_name + config_get kuainiao_config_pwd base kuainiao_config_pwd + + if [ "$kuainiao_downenable" -eq 1 ] || [ "$kuainiao_upenable" -eq 1 ]; then + logmore "启动延时 7s" + sleep 7s + + #登陆迅雷获取uid + logmore "get_bind_address start" + get_bind_address + logmore "bind_address is $bind_address" + logmore "get_mac_addr start" + get_mac_addr + logmore "peerid is $peerid" + logmore "get_xunlei_uid start" + get_xunlei_uid + logmore "get_xunlei_uid is done" + logmore "id is $uid" + #判断是否登陆成功 + if [ -n "$uid" ]; then + if [ "$kuainiao_downenable" -eq 1 ]; then + logmore "get_kuainiao_api is started......." + get_kuainiao_api + logmore "get_bandwidth is started......." + get_bandwidth + kuainiao_config_downstream=$(expr $old_downstream / 1024) + kuainiao_config_max_downstream=$(expr $max_downstream / 1024) + if [ "$kuainiao_can_upgrade" -eq 1 ]; then + [ "$logmore" -eq 1 ] && logmore "get_upgrade_down is started......." + get_upgrade_down + logmore "get_upgrade_down is done......." + sleep 1s + #keepalive_down + fi + fi + if [ "$kuainiao_upenable" -eq 1 ]; then + logmore "get_kuainiao_upapi start" + get_kuainiao_upapi + logmore "get_upbandwidth start" + get_upbandwidth + kuainiao_config_upstream=$(expr $old_upstream / 1024) + kuainiao_config_max_upstream=$(expr $max_upstream / 1024) + if [ "$kuainiao_can_upupgrade" -eq 1 ]; then + logmore "get_upgrade_up start" + get_upgrade_up + sleep 1s + #keepalive_up + fi + fi + fi + #add_kuainiao_cru + fi + [ -z "$kuainiao_can_upgrade" ] && [ -z "$kuainiao_can_upupgrade" ] && { + logmore "exit kuainiao...." + sleep 7s + echo "暂无加速信息" > $down_state_file + echo "暂无加速信息" > $up_state_file + exit 0 + } +} diff --git a/package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply b/package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply new file mode 100755 index 0000000000..ce48ef8932 --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply @@ -0,0 +1,12 @@ +#!/bin/sh + +enabled=`uci get kuainiao.base.enabled` + +if [ "$enabled" -eq 0 ]; then + /etc/init.d/kuainiao stop + /etc/init.d/kuainiao disable +else + /etc/init.d/kuainiao stop + /etc/init.d/kuainiao start + /etc/init.d/kuainiao enable +fi \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_down_state b/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_down_state new file mode 100644 index 0000000000..f01ccd0f02 --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_down_state @@ -0,0 +1 @@ +暂无加速信息 \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_up_state b/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_up_state new file mode 100644 index 0000000000..f01ccd0f02 --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_up_state @@ -0,0 +1 @@ +暂无加速信息 \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/www/luci-static/resources/md5.js b/package/lean/luci-app-kuainiao/root/www/luci-static/resources/md5.js new file mode 100644 index 0000000000..c1d09a94dc --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/www/luci-static/resources/md5.js @@ -0,0 +1 @@ +var md5; md5 || (md5 = function(){function i(a,b){a[b>>5]|=128<>>9<<4)+14]=b;for(var c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=0;a.length>g;g+=16){var h=c,i=d,j=e,o=f;c=k(c,d,e,f,a[g+0],7,-680876936),f=k(f,c,d,e,a[g+1],12,-389564586),e=k(e,f,c,d,a[g+2],17,606105819),d=k(d,e,f,c,a[g+3],22,-1044525330),c=k(c,d,e,f,a[g+4],7,-176418897),f=k(f,c,d,e,a[g+5],12,1200080426),e=k(e,f,c,d,a[g+6],17,-1473231341),d=k(d,e,f,c,a[g+7],22,-45705983),c=k(c,d,e,f,a[g+8],7,1770035416),f=k(f,c,d,e,a[g+9],12,-1958414417),e=k(e,f,c,d,a[g+10],17,-42063),d=k(d,e,f,c,a[g+11],22,-1990404162),c=k(c,d,e,f,a[g+12],7,1804603682),f=k(f,c,d,e,a[g+13],12,-40341101),e=k(e,f,c,d,a[g+14],17,-1502002290),d=k(d,e,f,c,a[g+15],22,1236535329),c=l(c,d,e,f,a[g+1],5,-165796510),f=l(f,c,d,e,a[g+6],9,-1069501632),e=l(e,f,c,d,a[g+11],14,643717713),d=l(d,e,f,c,a[g+0],20,-373897302),c=l(c,d,e,f,a[g+5],5,-701558691),f=l(f,c,d,e,a[g+10],9,38016083),e=l(e,f,c,d,a[g+15],14,-660478335),d=l(d,e,f,c,a[g+4],20,-405537848),c=l(c,d,e,f,a[g+9],5,568446438),f=l(f,c,d,e,a[g+14],9,-1019803690),e=l(e,f,c,d,a[g+3],14,-187363961),d=l(d,e,f,c,a[g+8],20,1163531501),c=l(c,d,e,f,a[g+13],5,-1444681467),f=l(f,c,d,e,a[g+2],9,-51403784),e=l(e,f,c,d,a[g+7],14,1735328473),d=l(d,e,f,c,a[g+12],20,-1926607734),c=m(c,d,e,f,a[g+5],4,-378558),f=m(f,c,d,e,a[g+8],11,-2022574463),e=m(e,f,c,d,a[g+11],16,1839030562),d=m(d,e,f,c,a[g+14],23,-35309556),c=m(c,d,e,f,a[g+1],4,-1530992060),f=m(f,c,d,e,a[g+4],11,1272893353),e=m(e,f,c,d,a[g+7],16,-155497632),d=m(d,e,f,c,a[g+10],23,-1094730640),c=m(c,d,e,f,a[g+13],4,681279174),f=m(f,c,d,e,a[g+0],11,-358537222),e=m(e,f,c,d,a[g+3],16,-722521979),d=m(d,e,f,c,a[g+6],23,76029189),c=m(c,d,e,f,a[g+9],4,-640364487),f=m(f,c,d,e,a[g+12],11,-421815835),e=m(e,f,c,d,a[g+15],16,530742520),d=m(d,e,f,c,a[g+2],23,-995338651),c=n(c,d,e,f,a[g+0],6,-198630844),f=n(f,c,d,e,a[g+7],10,1126891415),e=n(e,f,c,d,a[g+14],15,-1416354905),d=n(d,e,f,c,a[g+5],21,-57434055),c=n(c,d,e,f,a[g+12],6,1700485571),f=n(f,c,d,e,a[g+3],10,-1894986606),e=n(e,f,c,d,a[g+10],15,-1051523),d=n(d,e,f,c,a[g+1],21,-2054922799),c=n(c,d,e,f,a[g+8],6,1873313359),f=n(f,c,d,e,a[g+15],10,-30611744),e=n(e,f,c,d,a[g+6],15,-1560198380),d=n(d,e,f,c,a[g+13],21,1309151649),c=n(c,d,e,f,a[g+4],6,-145523070),f=n(f,c,d,e,a[g+11],10,-1120210379),e=n(e,f,c,d,a[g+2],15,718787259),d=n(d,e,f,c,a[g+9],21,-343485551),c=p(c,h),d=p(d,i),e=p(e,j),f=p(f,o)}return[c,d,e,f]}function j(a,b,c,d,e,f){return p(q(p(p(b,a),p(d,f)),e),c)}function k(a,b,c,d,e,f,g){return j(b&c|~b&d,a,b,e,f,g)}function l(a,b,c,d,e,f,g){return j(b&d|c&~d,a,b,e,f,g)}function m(a,b,c,d,e,f,g){return j(b^c^d,a,b,e,f,g)}function n(a,b,c,d,e,f,g){return j(c^(b|~d),a,b,e,f,g)}function p(a,b){var c=(a&65535)+(b&65535),d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535}function q(a,b){return a<>>32-b}function r(a){for(var b=[],d=(1<e;e+=c)b[e>>5]|=(a.charCodeAt(e/c)&d)<e;e++)d+=c.charAt(b[e>>2]>>e%4*8+4&15)+c.charAt(b[e>>2]>>e%4*8&15);return d}var a=0,c=8;return function(a){return t(i(r(a),a.length*c))}}()); \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/www/luci-static/resources/rsa.js b/package/lean/luci-app-kuainiao/root/www/luci-static/resources/rsa.js new file mode 100644 index 0000000000..0e012c3000 --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/www/luci-static/resources/rsa.js @@ -0,0 +1 @@ +var b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b64padchar="=";function hex2b64(h){var i;var c;var ret="";for(i=0;i+3<=h.length;i+=3){c=parseInt(h.substring(i,i+3),16);ret+=b64map.charAt(c>>6)+b64map.charAt(c&63)}if(i+1==h.length){c=parseInt(h.substring(i,i+1),16);ret+=b64map.charAt(c<<2)}else{if(i+2==h.length){c=parseInt(h.substring(i,i+2),16);ret+=b64map.charAt(c>>2)+b64map.charAt((c&3)<<4)}}while((ret.length&3)>0){ret+=b64padchar}return ret}function b64tohex(s){var ret="";var i;var k=0;var slop;for(i=0;i>2);slop=v&3;k=1}else{if(k==1){ret+=int2char((slop<<2)|(v>>4));slop=v&15;k=2}else{if(k==2){ret+=int2char(slop);ret+=int2char(v>>2);slop=v&3;k=3}else{ret+=int2char((slop<<2)|(v>>4));ret+=int2char(v&15);k=0}}}}if(k==1){ret+=int2char(slop<<2)}return ret}function b64toBA(s){var h=b64tohex(s);var i;var a=new Array();for(i=0;2*i=0){var v=x*this[i++]+w[j]+c;c=Math.floor(v/67108864);w[j++]=v&67108863}return c}function am2(i,x,w,j,c,n){var xl=x&32767,xh=x>>15;while(--n>=0){var l=this[i]&32767;var h=this[i++]>>15;var m=xh*l+h*xl;l=xl*l+((m&32767)<<15)+w[j]+(c&1073741823);c=(l>>>30)+(m>>>15)+xh*h+(c>>>30);w[j++]=l&1073741823}return c}function am3(i,x,w,j,c,n){var xl=x&16383,xh=x>>14;while(--n>=0){var l=this[i]&16383;var h=this[i++]>>14;var m=xh*l+h*xl;l=xl*l+((m&16383)<<14)+w[j]+c;c=(l>>28)+(m>>14)+xh*h;w[j++]=l&268435455}return c}if(j_lm&&(navigator.appName=="Microsoft Internet Explorer")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!="Netscape")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--i){r[i]=this[i]}r.t=this.t;r.s=this.s}function bnpFromInt(x){this.t=1;this.s=(x<0)?-1:0;if(x>0){this[0]=x}else{if(x<-1){this[0]=x+this.DV}else{this.t=0}}}function nbv(i){var r=nbi();r.fromInt(i);return r}function bnpFromString(s,b){var k;if(b==16){k=4}else{if(b==8){k=3}else{if(b==256){k=8}else{if(b==2){k=1}else{if(b==32){k=5}else{if(b==4){k=2}else{this.fromRadix(s,b);return}}}}}}this.t=0;this.s=0;var i=s.length,mi=false,sh=0;while(--i>=0){var x=(k==8)?s[i]&255:intAt(s,i);if(x<0){if(s.charAt(i)=="-"){mi=true}continue}mi=false;if(sh==0){this[this.t++]=x}else{if(sh+k>this.DB){this[this.t-1]|=(x&((1<<(this.DB-sh))-1))<>(this.DB-sh))}else{this[this.t-1]|=x<=this.DB){sh-=this.DB}}if(k==8&&(s[0]&128)!=0){this.s=-1;if(sh>0){this[this.t-1]|=((1<<(this.DB-sh))-1)<0&&this[this.t-1]==c){--this.t}}function bnToString(b){if(this.s<0){return"-"+this.negate().toString(b)}var k;if(b==16){k=4}else{if(b==8){k=3}else{if(b==2){k=1}else{if(b==32){k=5}else{if(b==4){k=2}else{return this.toRadix(b)}}}}}var km=(1<0){if(p>p)>0){m=true;r=int2char(d)}while(i>=0){if(p>(p+=this.DB-k)}else{d=(this[i]>>(p-=k))&km;if(p<=0){p+=this.DB;--i}}if(d>0){m=true}if(m){r+=int2char(d)}}}return m?r:"0"}function bnNegate(){var r=nbi();BigInteger.ZERO.subTo(this,r);return r}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(a){var r=this.s-a.s;if(r!=0){return r}var i=this.t;r=i-a.t;if(r!=0){return(this.s<0)?-r:r}while(--i>=0){if((r=this[i]-a[i])!=0){return r}}return 0}function nbits(x){var r=1,t;if((t=x>>>16)!=0){x=t;r+=16}if((t=x>>8)!=0){x=t;r+=8}if((t=x>>4)!=0){x=t;r+=4}if((t=x>>2)!=0){x=t;r+=2}if((t=x>>1)!=0){x=t;r+=1}return r}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i){r[i+n]=this[i]}for(i=n-1;i>=0;--i){r[i]=0}r.t=this.t+n;r.s=this.s}function bnpDRShiftTo(n,r){for(var i=n;i=0;--i){r[i+ds+1]=(this[i]>>cbs)|c;c=(this[i]&bm)<=0;--i){r[i]=0}r[ds]=c;r.t=this.t+ds+1;r.s=this.s;r.clamp()}function bnpRShiftTo(n,r){r.s=this.s;var ds=Math.floor(n/this.DB);if(ds>=this.t){r.t=0;return}var bs=n%this.DB;var cbs=this.DB-bs;var bm=(1<>bs;for(var i=ds+1;i>bs}if(bs>0){r[this.t-ds-1]|=(this.s&bm)<>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c-=a.s}r.s=(c<0)?-1:0;if(c<-1){r[i++]=this.DV+c}else{if(c>0){r[i++]=c}}r.t=i;r.clamp()}function bnpMultiplyTo(a,r){var x=this.abs(),y=a.abs();var i=x.t;r.t=i+y.t;while(--i>=0){r[i]=0}for(i=0;i=0){r[i]=0}for(i=0;i=x.DV){r[i+x.t]-=x.DV;r[i+x.t+1]=1}}if(r.t>0){r[r.t-1]+=x.am(i,x[i],r,2*i,0,1)}r.s=0;r.clamp()}function bnpDivRemTo(m,q,r){var pm=m.abs();if(pm.t<=0){return}var pt=this.abs();if(pt.t0){pm.lShiftTo(nsh,y);pt.lShiftTo(nsh,r)}else{pm.copyTo(y);pt.copyTo(r)}var ys=y.t;var y0=y[ys-1];if(y0==0){return}var yt=y0*(1<1)?y[ys-2]>>this.F2:0);var d1=this.FV/yt,d2=(1<=0){r[r.t++]=1;r.subTo(t,r)}BigInteger.ONE.dlShiftTo(ys,t);t.subTo(y,y);while(y.t=0){var qd=(r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);if((r[i]+=y.am(0,qd,r,j,0,ys))0){r.rShiftTo(nsh,r)}if(ts<0){BigInteger.ZERO.subTo(r,r)}}function bnMod(a){var r=nbi();this.abs().divRemTo(a,null,r);if(this.s<0&&r.compareTo(BigInteger.ZERO)>0){a.subTo(r,r)}return r}function Classic(m){this.m=m}function cConvert(x){if(x.s<0||x.compareTo(this.m)>=0){return x.mod(this.m)}else{return x}}function cRevert(x){return x}function cReduce(x){x.divRemTo(this.m,null,x)}function cMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}function cSqrTo(x,r){x.squareTo(r);this.reduce(r)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var x=this[0];if((x&1)==0){return 0}var y=x&3;y=(y*(2-(x&15)*y))&15;y=(y*(2-(x&255)*y))&255;y=(y*(2-(((x&65535)*y)&65535)))&65535;y=(y*(2-x*y%this.DV))%this.DV;return(y>0)?this.DV-y:-y}function Montgomery(m){this.m=m;this.mp=m.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(m.DB-15))-1;this.mt2=2*m.t}function montConvert(x){var r=nbi();x.abs().dlShiftTo(this.m.t,r);r.divRemTo(this.m,null,r);if(x.s<0&&r.compareTo(BigInteger.ZERO)>0){this.m.subTo(r,r)}return r}function montRevert(x){var r=nbi();x.copyTo(r);this.reduce(r);return r}function montReduce(x){while(x.t<=this.mt2){x[x.t++]=0}for(var i=0;i>15)*this.mpl)&this.um)<<15))&x.DM;j=i+this.m.t;x[j]+=this.m.am(0,u0,x,i,0,this.m.t);while(x[j]>=x.DV){x[j]-=x.DV;x[++j]++}}x.clamp();x.drShiftTo(this.m.t,x);if(x.compareTo(this.m)>=0){x.subTo(this.m,x)}}function montSqrTo(x,r){x.squareTo(r);this.reduce(r)}function montMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(e,z){if(e>4294967295||e<1){return BigInteger.ONE}var r=nbi(),r2=nbi(),g=z.convert(this),i=nbits(e)-1;g.copyTo(r);while(--i>=0){z.sqrTo(r,r2);if((e&(1<0){z.mulTo(r2,g,r)}else{var t=r;r=r2;r2=t}}return z.revert(r)}function bnModPowInt(e,m){var z;if(e<256||m.isEven()){z=new Classic(m)}else{z=new Montgomery(m)}return this.exp(e,z)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function Arcfour(){this.i=0;this.j=0;this.S=new Array()}function ARC4init(key){var i,j,t;for(i=0;i<256;++i){this.S[i]=i}j=0;for(i=0;i<256;++i){j=(j+this.S[i]+key[i%key.length])&255;t=this.S[i];this.S[i]=this.S[j];this.S[j]=t}this.i=0;this.j=0}function ARC4next(){var t;this.i=(this.i+1)&255;this.j=(this.j+this.S[this.i])&255;t=this.S[this.i];this.S[this.i]=this.S[this.j];this.S[this.j]=t;return this.S[(t+this.S[this.i])&255]}Arcfour.prototype.init=ARC4init;Arcfour.prototype.next=ARC4next;function prng_newstate(){return new Arcfour()}var rng_psize=256;var rng_state;var rng_pool;var rng_pptr;function rng_seed_int(x){rng_pool[rng_pptr++]^=x&255;rng_pool[rng_pptr++]^=(x>>8)&255;rng_pool[rng_pptr++]^=(x>>16)&255;rng_pool[rng_pptr++]^=(x>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window.crypto&&window.crypto.getRandomValues){var ua=new Uint8Array(32);window.crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}if(navigator.appName=="Netscape"&&navigator.appVersion<"5"&&window.crypto){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&n>0){var c=s.charCodeAt(i--);if(c<128){ba[--n]=c}else{if((c>127)&&(c<2048)){ba[--n]=(c&63)|128;ba[--n]=(c>>6)|192}else{ba[--n]=(c&63)|128;ba[--n]=((c>>6)&63)|128;ba[--n]=(c>>12)|224}}}ba[--n]=0;var rng=new SecureRandom();var x=new Array();while(n>2){x[0]=0;while(x[0]==0){rng.nextBytes(x)}ba[--n]=x[0]}ba[--n]=0;ba[--n]=0;return new BigInteger(ba)}function pkcs1pad3(s,n){if(n127)&&(c<2048)){ba[j++]=(c>>6)|192;ba[j++]=(c&63)|128}else{ba[j++]=(c>>12)|224;ba[j++]=((c>>6)&63)|128;ba[j++]=(c&63)|128}}}ba[j++]=0;var rng=new SecureRandom();var x=new Array();while(j0&&E.length>0){this.n=parseBigInt(N,16);this.e=parseInt(E,16)}else{alert("Invalid RSA public key")}}function RSADoPublic(x){return x.modPowInt(this.e,this.n)}function RSAEncrypt(text){var m=pkcs1pad3(text,(this.n.bitLength()+7)>>3);if(m==null){return null}var c=this.doPublic(m);if(c==null){return null}var h=c.toString(16);if((h.length&1)==0){return h}else{return"0"+h}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt; \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/www/luci-static/resources/sha1.js b/package/lean/luci-app-kuainiao/root/www/luci-static/resources/sha1.js new file mode 100644 index 0000000000..11014f81d2 --- /dev/null +++ b/package/lean/luci-app-kuainiao/root/www/luci-static/resources/sha1.js @@ -0,0 +1,202 @@ +/* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined + * in FIPS PUB 180-1 + * Version 2.1a Copyright Paul Johnston 2000 - 2002. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for details. + */ + +/* + * Configurable variables. You may need to tweak these to be compatible with + * the server-side, but the defaults work in most cases. + */ +var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ +var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ +var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ + +/* + * These are the functions you'll usually want to call + * They take string arguments and return either hex or base-64 encoded strings + */ +function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));} +function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));} +function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));} +function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));} +function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));} +function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));} + +/* + * Perform a simple self-test to see if the VM is working + */ +function sha1_vm_test() +{ + return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d"; +} + +/* + * Calculate the SHA-1 of an array of big-endian words, and a bit length + */ +function core_sha1(x, len) +{ + /* append padding */ + x[len >> 5] |= 0x80 << (24 - len % 32); + x[((len + 64 >> 9) << 4) + 15] = len; + + var w = Array(80); + var a = 1732584193; + var b = -271733879; + var c = -1732584194; + var d = 271733878; + var e = -1009589776; + + for(var i = 0; i < x.length; i += 16) + { + var olda = a; + var oldb = b; + var oldc = c; + var oldd = d; + var olde = e; + + for(var j = 0; j < 80; j++) + { + if(j < 16) w[j] = x[i + j]; + else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1); + var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), + safe_add(safe_add(e, w[j]), sha1_kt(j))); + e = d; + d = c; + c = rol(b, 30); + b = a; + a = t; + } + + a = safe_add(a, olda); + b = safe_add(b, oldb); + c = safe_add(c, oldc); + d = safe_add(d, oldd); + e = safe_add(e, olde); + } + return Array(a, b, c, d, e); + +} + +/* + * Perform the appropriate triplet combination function for the current + * iteration + */ +function sha1_ft(t, b, c, d) +{ + if(t < 20) return (b & c) | ((~b) & d); + if(t < 40) return b ^ c ^ d; + if(t < 60) return (b & c) | (b & d) | (c & d); + return b ^ c ^ d; +} + +/* + * Determine the appropriate additive constant for the current iteration + */ +function sha1_kt(t) +{ + return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : + (t < 60) ? -1894007588 : -899497514; +} + +/* + * Calculate the HMAC-SHA1 of a key and some data + */ +function core_hmac_sha1(key, data) +{ + var bkey = str2binb(key); + if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz); + + var ipad = Array(16), opad = Array(16); + for(var i = 0; i < 16; i++) + { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5C5C5C5C; + } + + var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz); + return core_sha1(opad.concat(hash), 512 + 160); +} + +/* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ +function safe_add(x, y) +{ + var lsw = (x & 0xFFFF) + (y & 0xFFFF); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); +} + +/* + * Bitwise rotate a 32-bit number to the left. + */ +function rol(num, cnt) +{ + return (num << cnt) | (num >>> (32 - cnt)); +} + +/* + * Convert an 8-bit or 16-bit string to an array of big-endian words + * In 8-bit function, characters >255 have their hi-byte silently ignored. + */ +function str2binb(str) +{ + var bin = Array(); + var mask = (1 << chrsz) - 1; + for(var i = 0; i < str.length * chrsz; i += chrsz) + bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32); + return bin; +} + +/* + * Convert an array of big-endian words to a string + */ +function binb2str(bin) +{ + var str = ""; + var mask = (1 << chrsz) - 1; + for(var i = 0; i < bin.length * 32; i += chrsz) + str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask); + return str; +} + +/* + * Convert an array of big-endian words to a hex string. + */ +function binb2hex(binarray) +{ + var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; + var str = ""; + for(var i = 0; i < binarray.length * 4; i++) + { + str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + + hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); + } + return str; +} + +/* + * Convert an array of big-endian words to a base-64 string + */ +function binb2b64(binarray) +{ + var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + var str = ""; + for(var i = 0; i < binarray.length * 4; i += 3) + { + var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16) + | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 ) + | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF); + for(var j = 0; j < 4; j++) + { + if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; + else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); + } + } + return str; +} diff --git a/package/lean/wxbase/Makefile b/package/lean/wxbase/Makefile new file mode 100644 index 0000000000..97f6e70150 --- /dev/null +++ b/package/lean/wxbase/Makefile @@ -0,0 +1,136 @@ +# +# Copyright (C) 2007-2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=wxbase +PKG_VERSION:=2.8.12 +PKG_RELEASE:=1 + +PKG_SOURCE:=wxGTK-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=@SF/wxwindows +PKG_MD5SUM:=08f81ab60647308058f6ce99712b14f8 + +PKG_BUILD_DIR:=$(BUILD_DIR)/wxGTK-$(PKG_VERSION) + +PKG_INSTALL:=1 + +PKG_CHECK_FORMAT_SECURITY:=0 + +include $(INCLUDE_DIR)/package.mk + +define Package/libwxbase + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Cross-platform C++ framework + URL:=http://www.wxwidgets.org/ + DEPENDS:=+libexpat +libstdcpp +zlib +libpthread +endef + +define Package/libwxbase/description + wxBase contains most of the non-GUI classes from the wxWindows cross- + -platform C++ framework. There are 2 categories: generally useful portable + code (date/time handling, command line parsing, regular expression support) + and wrappers for the OS objects (files, directories, sockets, threads, + etc.) allowing you to write portable programs easily. +endef + +TARGET_CFLAGS += $(FPIC) + +# XXX: aMule *needs* the following configure options to be enabled: +# --enable-intl +# --enable-largefile +# --disable-no_rtti +# --with-regex +# --enable-unicode +CONFIGURE_ARGS+= \ + --enable-shared \ + --disable-rpath \ + --with-gnu-ld \ + --disable-gui \ + --disable-monolithic \ + --enable-plugins \ + --disable-universal \ + --disable-nanox \ + --disable-gtk2 \ + --disable-gpe \ + --disable-optimise \ + --disable-debug \ + --disable-stl \ + --disable-omf \ + --disable-debug_flag \ + --disable-debug_info \ + --disable-debug_gdb \ + --disable-debug_cntxt \ + --disable-mem_tracing \ + --disable-profile \ + --disable-no_rtti \ + --disable-no_exceptions \ + --disable-compat22 \ + --disable-compat24 \ + --enable-intl \ + --disable-backtrace \ + --enable-exceptions \ + --disable-sound \ + --enable-largefile \ + \ + --without-gtk \ + --without-motif \ + --without-mac \ + --without-cocoa \ + --without-wine \ + --without-msw \ + --without-pm \ + --without-mgl \ + --without-microwin \ + --without-x11 \ + --without-libpng \ + --without-libjpeg \ + --without-libtiff \ + --without-libxpm \ + --without-libmspack \ + --without-sdl \ + --without-gnomeprint \ + --without-opengl \ + --without-dmalloc \ + --with-regex="sys" \ + --with-zlib="sys" \ + --without-odbc \ + --with-expat="sys" \ + --without-gtk-prefix \ + --without-x \ + --without-libiconv-prefix \ + --without-sdl-prefix \ + --without-cppunit-prefix \ + --disable-precomp-headers + +UNICODE=yes + +ifeq ($(UNICODE),yes) + CONFIGURE_ARGS+= --enable-unicode + LIB_PFX:=u +else + CONFIGURE_ARGS+= --disable-unicode + LIB_PFX:= +endif + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/include $(1)/usr/lib + $(CP) -L $(PKG_BUILD_DIR)/wx-config $(1)/usr/bin/ + $(CP) $(PKG_INSTALL_DIR)/usr/include/wx-2.8 $(1)/usr/include/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libwx_base$(LIB_PFX){,_net,_xml}-*.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/wx $(1)/usr/lib/ + $(SED) 's,-I$$$${includedir}/wx-2.8,-I$(STAGING_DIR)/usr/include/wx-2.8,g' $(1)/usr/bin/wx-config + $(SED) 's,-I$$$${libdir}/wx/include,-I$(STAGING_DIR)/usr/lib/wx/include,g' $(1)/usr/bin/wx-config +endef + +define Package/libwxbase/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libwx_base$(LIB_PFX){,_net,_xml}-*.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libwxbase)) diff --git a/package/lean/wxbase/patches/wxGTK-2.8.12-abicheck.patch b/package/lean/wxbase/patches/wxGTK-2.8.12-abicheck.patch new file mode 100644 index 0000000000..97055ba46f --- /dev/null +++ b/package/lean/wxbase/patches/wxGTK-2.8.12-abicheck.patch @@ -0,0 +1,15 @@ +diff -up wxGTK-2.8.12/src/common/appbase.cpp.abicheck wxGTK-2.8.12/src/common/appbase.cpp +--- wxGTK-2.8.12/src/common/appbase.cpp.abicheck 2015-03-12 17:15:18.000000000 +0100 ++++ wxGTK-2.8.12/src/common/appbase.cpp 2015-03-12 17:15:57.000000000 +0100 +@@ -424,10 +424,7 @@ bool wxAppConsole::CheckBuildOptions(con + msg.Printf(_T("Mismatch between the program and library build versions detected.\nThe library used %s,\nand %s used %s."), + lib.c_str(), progName.c_str(), prog.c_str()); + +- wxLogFatalError(msg.c_str()); +- +- // normally wxLogFatalError doesn't return +- return false; ++ wxLogWarning(msg.c_str()); + } + #undef wxCMP + diff --git a/package/libs/mbedtls/Makefile b/package/libs/mbedtls/Makefile index 101324de07..0e3383150d 100644 --- a/package/libs/mbedtls/Makefile +++ b/package/libs/mbedtls/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mbedtls -PKG_VERSION:=2.5.1 -PKG_RELEASE:=2 +PKG_VERSION:=2.6.0 +PKG_RELEASE:=1 PKG_USE_MIPS16:=0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-gpl.tgz PKG_SOURCE_URL:=https://tls.mbed.org/download/ -PKG_HASH:=312f020006f0d8e9ede3ed8e73d907a629baf6475229703941769372ab0adee2 +PKG_HASH:=a99959d7360def22f9108d2d487c9de384fe76c349697176b1f22370080d5810 PKG_BUILD_PARALLEL:=1 PKG_LICENSE:=GPL-2.0+ diff --git a/package/libs/mbedtls/patches/200-config.patch b/package/libs/mbedtls/patches/200-config.patch index fb5a74fc65..ce32be76a5 100644 --- a/package/libs/mbedtls/patches/200-config.patch +++ b/package/libs/mbedtls/patches/200-config.patch @@ -1,6 +1,6 @@ --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h -@@ -191,7 +191,7 @@ +@@ -220,7 +220,7 @@ * * Uncomment to get errors on using deprecated functions. */ @@ -9,7 +9,7 @@ /* \} name SECTION: System support */ -@@ -504,17 +504,17 @@ +@@ -539,17 +539,17 @@ * * Comment macros to disable the curve and functions for it */ @@ -35,7 +35,7 @@ #define MBEDTLS_ECP_DP_CURVE25519_ENABLED /** -@@ -539,8 +539,8 @@ +@@ -574,8 +574,8 @@ * Requires: MBEDTLS_HMAC_DRBG_C * * Comment this macro to disable deterministic ECDSA. @@ -45,7 +45,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -@@ -586,7 +586,7 @@ +@@ -621,7 +621,7 @@ * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA */ @@ -54,7 +54,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -@@ -605,8 +605,8 @@ +@@ -640,8 +640,8 @@ * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA @@ -64,7 +64,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -@@ -631,7 +631,7 @@ +@@ -666,7 +666,7 @@ * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA */ @@ -73,7 +73,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -@@ -758,7 +758,7 @@ +@@ -793,7 +793,7 @@ * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 */ @@ -82,7 +82,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -@@ -782,7 +782,7 @@ +@@ -817,7 +817,7 @@ * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 */ @@ -91,7 +91,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED -@@ -886,7 +886,7 @@ +@@ -921,7 +921,7 @@ * This option is only useful if both MBEDTLS_SHA256_C and * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. */ @@ -100,7 +100,7 @@ /** * \def MBEDTLS_ENTROPY_NV_SEED -@@ -980,14 +980,14 @@ +@@ -1015,14 +1015,14 @@ * Uncomment this macro to disable the use of CRT in RSA. * */ @@ -117,7 +117,7 @@ /** * \def MBEDTLS_SHA256_SMALLER -@@ -1003,7 +1003,7 @@ +@@ -1038,7 +1038,7 @@ * * Uncomment to enable the smaller implementation of SHA256. */ @@ -126,7 +126,7 @@ /** * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES -@@ -1122,8 +1122,8 @@ +@@ -1157,8 +1157,8 @@ * misuse/misunderstand. * * Comment this to disable support for renegotiation. @@ -136,7 +136,7 @@ /** * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO -@@ -1297,8 +1297,8 @@ +@@ -1332,8 +1332,8 @@ * callbacks are provided by MBEDTLS_SSL_TICKET_C. * * Comment this macro to disable support for SSL session tickets @@ -146,7 +146,7 @@ /** * \def MBEDTLS_SSL_EXPORT_KEYS -@@ -1328,7 +1328,7 @@ +@@ -1363,7 +1363,7 @@ * * Comment this macro to disable support for truncated HMAC in SSL */ @@ -155,7 +155,7 @@ /** * \def MBEDTLS_THREADING_ALT -@@ -1362,8 +1362,8 @@ +@@ -1397,8 +1397,8 @@ * Requires: MBEDTLS_VERSION_C * * Comment this to disable run-time checking and save ROM space @@ -165,7 +165,7 @@ /** * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 -@@ -1684,7 +1684,7 @@ +@@ -1719,7 +1719,7 @@ * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 */ @@ -174,7 +174,7 @@ /** * \def MBEDTLS_CCM_C -@@ -1698,7 +1698,7 @@ +@@ -1733,7 +1733,7 @@ * This module enables the AES-CCM ciphersuites, if other requisites are * enabled as well. */ @@ -183,7 +183,7 @@ /** * \def MBEDTLS_CERTS_C -@@ -1710,7 +1710,7 @@ +@@ -1745,7 +1745,7 @@ * * This module is used for testing (ssl_client/server). */ @@ -192,7 +192,7 @@ /** * \def MBEDTLS_CIPHER_C -@@ -1763,7 +1763,7 @@ +@@ -1798,7 +1798,7 @@ * * This module provides debugging functions. */ @@ -201,7 +201,7 @@ /** * \def MBEDTLS_DES_C -@@ -1788,8 +1788,8 @@ +@@ -1823,8 +1823,8 @@ * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA * * PEM_PARSE uses DES/3DES for decrypting encrypted keys. @@ -211,7 +211,7 @@ /** * \def MBEDTLS_DHM_C -@@ -1943,8 +1943,8 @@ +@@ -1978,8 +1978,8 @@ * Requires: MBEDTLS_MD_C * * Uncomment to enable the HMAC_DRBG random number geerator. @@ -221,7 +221,7 @@ /** * \def MBEDTLS_MD_C -@@ -2221,7 +2221,7 @@ +@@ -2256,7 +2256,7 @@ * Caller: library/md.c * */ @@ -230,7 +230,7 @@ /** * \def MBEDTLS_RSA_C -@@ -2299,8 +2299,8 @@ +@@ -2334,8 +2334,8 @@ * Caller: * * Requires: MBEDTLS_SSL_CACHE_C @@ -240,7 +240,7 @@ /** * \def MBEDTLS_SSL_COOKIE_C -@@ -2321,8 +2321,8 @@ +@@ -2356,8 +2356,8 @@ * Caller: * * Requires: MBEDTLS_CIPHER_C @@ -250,7 +250,7 @@ /** * \def MBEDTLS_SSL_CLI_C -@@ -2421,8 +2421,8 @@ +@@ -2456,8 +2456,8 @@ * Module: library/version.c * * This module provides run-time version information. @@ -260,7 +260,7 @@ /** * \def MBEDTLS_X509_USE_C -@@ -2532,7 +2532,7 @@ +@@ -2567,7 +2567,7 @@ * Module: library/xtea.c * Caller: */ @@ -269,7 +269,7 @@ /* \} name SECTION: mbed TLS modules */ -@@ -2646,7 +2646,7 @@ +@@ -2681,7 +2681,7 @@ * recommended because of it is possible to generte SHA-1 collisions, however * this may be safe for legacy infrastructure where additional controls apply. */ diff --git a/package/network/config/gre/Makefile b/package/network/config/gre/Makefile index 90f92d4da7..9193f5c9fb 100644 --- a/package/network/config/gre/Makefile +++ b/package/network/config/gre/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gre PKG_VERSION:=1 -PKG_RELEASE:=6 +PKG_RELEASE:=7 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/config/gre/files/gre.sh b/package/network/config/gre/files/gre.sh index cd327ea2da..3301cee005 100755 --- a/package/network/config/gre/files/gre.sh +++ b/package/network/config/gre/files/gre.sh @@ -25,7 +25,7 @@ gre_generic_setup() { json_add_string mode "$mode" json_add_int mtu "${mtu:-1280}" [ -n "$df" ] && json_add_boolean df "$df" - [ -n "ttl" ] && json_add_int ttl "$ttl" + [ -n "$ttl" ] && json_add_int ttl "$ttl" [ -n "$tos" ] && json_add_string tos "$tos" json_add_boolean multicast "$multicast" json_add_string local "$local" diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile index 29079795c1..94fd70232c 100644 --- a/package/network/services/dnsmasq/Makefile +++ b/package/network/services/dnsmasq/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=dnsmasq -PKG_VERSION:=2.76 -PKG_RELEASE:=12 +PKG_VERSION:=2.78 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq -PKG_MD5SUM:=00f5ee66b4e4b7f14538bf62ae3c9461 +PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq/ +PKG_HASH:=89949f438c74b0c7543f06689c319484bd126cc4b1f8c745c742ab397681252b PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=COPYING @@ -88,22 +88,22 @@ define Package/dnsmasq-full/config config PACKAGE_dnsmasq_full_dhcpv6 bool "Build with DHCPv6 support." depends on IPV6 - default n + default y config PACKAGE_dnsmasq_full_dnssec bool "Build with DNSSEC support." - default n + default y config PACKAGE_dnsmasq_full_auth bool "Build with the facility to act as an authoritative DNS server." - default n + default y config PACKAGE_dnsmasq_full_ipset bool "Build with IPset support." default y config PACKAGE_dnsmasq_full_conntrack bool "Build with Conntrack support." - default n + default y config PACKAGE_dnsmasq_full_noid bool "Build with NO_ID. (hide *.bind pseudo domain)" - default n + default y config PACKAGE_dnsmasq_full_broken_rtc bool "Build with HAVE_BROKEN_RTC." default n diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index b1f9e2e290..a762cd3309 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -23,22 +23,22 @@ xappend() { } hex_to_hostid() { - local var="$1" - local hex="${2#0x}" # strip optional "0x" prefix + local var="$1" + local hex="${2#0x}" # strip optional "0x" prefix - if [ -n "${hex//[0-9a-fA-F]/}" ]; then - # is invalid hex literal - return 1 - fi + if [ -n "${hex//[0-9a-fA-F]/}" ]; then + # is invalid hex literal + return 1 + fi - # convert into host id - export "$var=$( - printf "%0x:%0x" \ - $(((0x$hex >> 16) % 65536)) \ - $(( 0x$hex % 256)) - )" + # convert into host id + export "$var=$( + printf "%0x:%0x" \ + $(((0x$hex >> 16) % 65536)) \ + $(( 0x$hex % 65536)) + )" - return 0 + return 0 } dhcp_calc() { @@ -278,6 +278,7 @@ dhcp_host_add() { config_get tag "$cfg" tag if [ "$DHCPv6CAPABLE" -eq 1 ]; then + config_get duid "$cfg" duid config_get hostid "$cfg" hostid if [ -n "$hostid" ]; then hex_to_hostid hostid "$hostid" @@ -289,7 +290,7 @@ dhcp_host_add() { config_get leasetime "$cfg" leasetime - xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}${leasetime:+,$leasetime}" + xappend "--dhcp-host=$macs${duid:+,id:$duid}${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}${leasetime:+,$leasetime}" } dhcp_tag_add() { @@ -391,6 +392,14 @@ dhcp_add() { dhcp_option_add "$cfg" "$networkid" } +dhcp_option_append() { + local option="$1" + local networkid="$2" + local force="$3" + + xappend "--dhcp-option${force:+-force}=${networkid:+$networkid,}$option" +} + dhcp_option_add() { local cfg="$1" local networkid="$2" @@ -398,11 +407,21 @@ dhcp_option_add() { [ "$force" = "0" ] && force= - config_get dhcp_option "$cfg" dhcp_option - for o in $dhcp_option; do - xappend "--dhcp-option${force:+-force}=${networkid:+$networkid,}$o" - done + local list_len + config_get list_len "$cfg" dhcp_option_LENGTH + if [ -n "$list_len" ]; then + config_list_foreach "$cfg" dhcp_option dhcp_option_append "$networkid" "$force" + else + config_get dhcp_option "$cfg" dhcp_option + + [ -n "$dhcp_option" ] && echo "Warning: the 'option dhcp_option' syntax is deprecated, use 'list dhcp_option'" >&2 + + local option + for option in $dhcp_option; do + dhcp_option_append "$option" "$networkid" "$force" + done + fi } dhcp_domain_add() { @@ -507,7 +526,8 @@ dhcp_relay_add() { if [ -z "$interface" ]; then xappend "--dhcp-relay=$local_addr,$server_addr" else - xappend "--dhcp-relay=$local_addr,$server_addr,$interface" + network_get_device ifname "$interface" || return + xappend "--dhcp-relay=$local_addr,$server_addr,$ifname" fi } @@ -561,7 +581,7 @@ dnsmasq_start() append_bool "$cfg" boguspriv "--bogus-priv" append_bool "$cfg" expandhosts "--expand-hosts" config_get tftp_root "$cfg" "tftp_root" - [ -d "$tftp_root" ] && append_bool "$cfg" enable_tftp "--enable-tftp" + [ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" enable_tftp "--enable-tftp" append_bool "$cfg" tftp_no_fail "--tftp-no-fail" append_bool "$cfg" nonwildcard "--bind-dynamic" append_bool "$cfg" fqdn "--dhcp-fqdn" @@ -573,6 +593,7 @@ dnsmasq_start() append_bool "$cfg" allservers "--all-servers" append_bool "$cfg" noping "--no-ping" + append_parm "$cfg" logfacility "--log-facility" append_parm "$cfg" dhcpscript "--dhcp-script" append_parm "$cfg" cachesize "--cache-size" append_parm "$cfg" dnsforwardmax "--dns-forward-max" @@ -670,7 +691,7 @@ dnsmasq_start() xappend "--dhcp-broadcast=tag:needs-broadcast" - xappend "--addn-hosts=$HOSTFILE" + xappend "--addn-hosts=$(dirname $HOSTFILE)" config_get dnsmasqconfdir "$cfg" confdir "/tmp/dnsmasq.d" [ ! -d "$dnsmasqconfdir" ] && mkdir -p $dnsmasqconfdir diff --git a/package/network/services/dnsmasq/files/dnsmasqsec.hotplug b/package/network/services/dnsmasq/files/dnsmasqsec.hotplug index 5c69314bd9..a155eb0f6e 100644 --- a/package/network/services/dnsmasq/files/dnsmasqsec.hotplug +++ b/package/network/services/dnsmasq/files/dnsmasqsec.hotplug @@ -1,5 +1,7 @@ #!/bin/sh +. /lib/functions/procd.sh + TIMEVALIDFILE="/var/state/dnsmasqsec" [ "$ACTION" = stratum ] || exit 0 @@ -7,8 +9,6 @@ TIMEVALIDFILE="/var/state/dnsmasqsec" [ -f "$TIMEVALIDFILE" ] || { echo "ntpd says time is valid" >$TIMEVALIDFILE /etc/init.d/dnsmasq enabled && { - pid=$(pidof dnsmasq) - [ "$(readlink /proc/$pid/exe)" = "/usr/sbin/dnsmasq" ] && kill -SIGHUP $pid \ - || /etc/init.d/dnsmasq restart + procd_send_signal dnsmasq } } diff --git a/package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch b/package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch deleted file mode 100644 index 5fc62ffab3..0000000000 --- a/package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/src/dhcp.c -+++ b/src/dhcp.c -@@ -147,7 +147,7 @@ void dhcp_packet(time_t now, int pxe_fd) - ssize_t sz; - int iface_index = 0, unicast_dest = 0, is_inform = 0; - int rcvd_iface_index; -- struct in_addr iface_addr; -+ struct in_addr iface_addr, *addrp = NULL; - struct iface_param parm; - #ifdef HAVE_LINUX_NETWORK - struct arpreq arp_req; -@@ -277,11 +277,9 @@ void dhcp_packet(time_t now, int pxe_fd) - { - ifr.ifr_addr.sa_family = AF_INET; - if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 ) -- iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr; -- else - { -- my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name); -- return; -+ addrp = &iface_addr; -+ iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr; - } - - for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next) -@@ -300,7 +298,7 @@ void dhcp_packet(time_t now, int pxe_fd) - parm.relay_local.s_addr = 0; - parm.ind = iface_index; - -- if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name, NULL)) -+ if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name, NULL)) - { - /* If we failed to match the primary address of the interface, see if we've got a --listen-address - for a secondary */ -@@ -320,6 +318,12 @@ void dhcp_packet(time_t now, int pxe_fd) - complete_context(match.addr, iface_index, NULL, match.netmask, match.broadcast, &parm); - } - -+ if (!addrp) -+ { -+ my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name); -+ return; -+ } -+ - if (!iface_enumerate(AF_INET, &parm, complete_context)) - return; - diff --git a/package/network/services/dnsmasq/patches/110-ipset-remove-old-kernel-support.patch b/package/network/services/dnsmasq/patches/110-ipset-remove-old-kernel-support.patch index 61b09d5b2c..88e334b0fc 100644 --- a/package/network/services/dnsmasq/patches/110-ipset-remove-old-kernel-support.patch +++ b/package/network/services/dnsmasq/patches/110-ipset-remove-old-kernel-support.patch @@ -44,67 +44,22 @@ (buffer = safe_malloc(BUFF_SZ)) && (ipset_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER)) != -1 && (bind(ipset_sock, (struct sockaddr *)&snl, sizeof(snl)) != -1)) -@@ -168,62 +149,16 @@ static int new_add_to_ipset(const char * - } - - --static int old_add_to_ipset(const char *setname, const struct all_addr *ipaddr, int remove) --{ -- socklen_t size; -- struct ip_set_req_adt_get { -- unsigned op; -- unsigned version; -- union { -- char name[IPSET_MAXNAMELEN]; -- uint16_t index; -- } set; -- char typename[IPSET_MAXNAMELEN]; -- } req_adt_get; -- struct ip_set_req_adt { -- unsigned op; -- uint16_t index; -- uint32_t ip; -- } req_adt; -- -- if (strlen(setname) >= sizeof(req_adt_get.set.name)) -- { -- errno = ENAMETOOLONG; -- return -1; -- } -- -- req_adt_get.op = 0x10; -- req_adt_get.version = 3; -- strcpy(req_adt_get.set.name, setname); -- size = sizeof(req_adt_get); -- if (getsockopt(ipset_sock, SOL_IP, 83, &req_adt_get, &size) < 0) -- return -1; -- req_adt.op = remove ? 0x102 : 0x101; -- req_adt.index = req_adt_get.set.index; -- req_adt.ip = ntohl(ipaddr->addr.addr4.s_addr); -- if (setsockopt(ipset_sock, SOL_IP, 83, &req_adt, sizeof(req_adt)) < 0) -- return -1; -- -- return 0; --} -- -- -- - int add_to_ipset(const char *setname, const struct all_addr *ipaddr, int flags, int remove) - { - int af = AF_INET; - - #ifdef HAVE_IPV6 +@@ -217,17 +198,10 @@ int add_to_ipset(const char *setname, co if (flags & F_IPV6) -- { + { af = AF_INET6; - /* old method only supports IPv4 */ - if (old_kernel) -- return -1; -- } +- { +- errno = EAFNOSUPPORT ; +- ret = -1; +- } + } #endif -- return old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove); -+ return new_add_to_ipset(setname, ipaddr, af, remove); - } +- if (ret != -1) +- ret = old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove); ++ ret = new_add_to_ipset(setname, ipaddr, af, remove); - #endif + if (ret == -1) + my_syslog(LOG_ERR, _("failed to update ipset %s: %s"), setname, strerror(errno)); diff --git a/package/network/services/dnsmasq/patches/120-dnsmasq-compile-time-option-NO_ID.patch b/package/network/services/dnsmasq/patches/120-dnsmasq-compile-time-option-NO_ID.patch deleted file mode 100644 index 152d1a7fa9..0000000000 --- a/package/network/services/dnsmasq/patches/120-dnsmasq-compile-time-option-NO_ID.patch +++ /dev/null @@ -1,149 +0,0 @@ -From f6bea86c78ba9efbd01da3dd2fb18764ec806290 Mon Sep 17 00:00:00 2001 -From: Kevin Darbyshire-Bryant -Date: Wed, 7 Sep 2016 09:35:07 +0100 -Subject: [PATCH] dnsmasq: compile time option NO_ID - -Some consider it good practice to obscure software version numbers to -clients. Compiling with -DNO_ID removes the *.bind info structure. -This includes: version, author, copyright, cachesize, cache insertions, -evictions, misses & hits, auth & servers. - -Signed-off-by: Kevin Darbyshire-Bryant ---- - src/cache.c | 2 ++ - src/config.h | 5 +++++ - src/dnsmasq.h | 4 ++++ - src/option.c | 8 ++++++-- - src/rfc1035.c | 3 ++- - 5 files changed, 19 insertions(+), 3 deletions(-) - ---- a/src/cache.c -+++ b/src/cache.c -@@ -1290,6 +1290,7 @@ void cache_add_dhcp_entry(char *host_nam - } - #endif - -+#ifndef NO_ID - int cache_make_stat(struct txt_record *t) - { - static char *buff = NULL; -@@ -1385,6 +1386,7 @@ int cache_make_stat(struct txt_record *t - *buff = len; - return 1; - } -+#endif - - /* There can be names in the cache containing control chars, don't - mess up logging or open security holes. */ ---- a/src/config.h -+++ b/src/config.h -@@ -120,6 +120,8 @@ HAVE_LOOP - HAVE_INOTIFY - use the Linux inotify facility to efficiently re-read configuration files. - -+NO_ID -+ Don't report *.bind CHAOS info to clients. - NO_IPV6 - NO_TFTP - NO_DHCP -@@ -434,6 +436,9 @@ static char *compile_opts = - "no-" - #endif - "DNSSEC " -+#ifdef NO_ID -+"no-ID " -+#endif - #ifndef HAVE_LOOP - "no-" - #endif ---- a/src/dnsmasq.h -+++ b/src/dnsmasq.h -@@ -286,6 +286,7 @@ struct naptr { - struct naptr *next; - }; - -+#ifndef NO_ID - #define TXT_STAT_CACHESIZE 1 - #define TXT_STAT_INSERTS 2 - #define TXT_STAT_EVICTIONS 3 -@@ -293,6 +294,7 @@ struct naptr { - #define TXT_STAT_HITS 5 - #define TXT_STAT_AUTH 6 - #define TXT_STAT_SERVERS 7 -+#endif - - struct txt_record { - char *name; -@@ -1078,7 +1080,9 @@ void cache_add_dhcp_entry(char *host_nam - struct in_addr a_record_from_hosts(char *name, time_t now); - void cache_unhash_dhcp(void); - void dump_cache(time_t now); -+#ifndef NO_ID - int cache_make_stat(struct txt_record *t); -+#endif - char *cache_get_name(struct crec *crecp); - char *cache_get_cname_target(struct crec *crecp); - struct crec *cache_enumerate(int init); ---- a/src/option.c -+++ b/src/option.c -@@ -657,7 +657,8 @@ static int atoi_check8(char *a, int *res - return 1; - } - #endif -- -+ -+#ifndef NO_ID - static void add_txt(char *name, char *txt, int stat) - { - struct txt_record *r = opt_malloc(sizeof(struct txt_record)); -@@ -670,13 +671,14 @@ static void add_txt(char *name, char *tx - *(r->txt) = len; - memcpy((r->txt)+1, txt, len); - } -- -+ - r->stat = stat; - r->name = opt_string_alloc(name); - r->next = daemon->txt; - daemon->txt = r; - r->class = C_CHAOS; - } -+#endif - - static void do_usage(void) - { -@@ -4515,6 +4517,7 @@ void read_opts(int argc, char **argv, ch - daemon->soa_expiry = SOA_EXPIRY; - daemon->max_port = MAX_PORT; - -+#ifndef NO_ID - add_txt("version.bind", "dnsmasq-" VERSION, 0 ); - add_txt("authors.bind", "Simon Kelley", 0); - add_txt("copyright.bind", COPYRIGHT, 0); -@@ -4527,6 +4530,7 @@ void read_opts(int argc, char **argv, ch - add_txt("auth.bind", NULL, TXT_STAT_AUTH); - #endif - add_txt("servers.bind", NULL, TXT_STAT_SERVERS); -+#endif - - while (1) - { ---- a/src/rfc1035.c -+++ b/src/rfc1035.c -@@ -1264,6 +1264,7 @@ size_t answer_request(struct dns_header - unsigned long ttl = daemon->local_ttl; - int ok = 1; - log_query(F_CONFIG | F_RRNAME, name, NULL, ""); -+#ifndef NO_ID - /* Dynamically generate stat record */ - if (t->stat != 0) - { -@@ -1271,7 +1272,7 @@ size_t answer_request(struct dns_header - if (!cache_make_stat(t)) - ok = 0; - } -- -+#endif - if (ok && add_resource_record(header, limit, &trunc, nameoffset, &ansp, - ttl, NULL, - T_TXT, t->class, "t", t->len, t->txt)) diff --git a/package/network/services/dnsmasq/patches/210-dnssec-improve-timestamp-heuristic.patch b/package/network/services/dnsmasq/patches/210-dnssec-improve-timestamp-heuristic.patch index ca5a806696..2f854d490b 100644 --- a/package/network/services/dnsmasq/patches/210-dnssec-improve-timestamp-heuristic.patch +++ b/package/network/services/dnsmasq/patches/210-dnssec-improve-timestamp-heuristic.patch @@ -35,13 +35,13 @@ Signed-off-by: Steven Barth + if (difftime(now, base) >= 0 && difftime(timestamp_time, now) <= 0) { /* time already OK, update timestamp, and do key checking from the start. */ - if (utime(daemon->timestamp_file, NULL) == -1) + if (utimes(daemon->timestamp_file, NULL) == -1) @@ -493,7 +500,7 @@ int setup_timestamp(void) close(fd); -- timestamp_time = timbuf.actime = timbuf.modtime = 1420070400; /* 1-1-2015 */ -+ timestamp_time = timbuf.actime = timbuf.modtime = base; - if (utime(daemon->timestamp_file, &timbuf) == 0) - goto check_and_exit; - } +- timestamp_time = 1420070400; /* 1-1-2015 */ ++ timestamp_time = base; /* 1-1-2015 */ + tv[0].tv_sec = tv[1].tv_sec = timestamp_time; + tv[0].tv_usec = tv[1].tv_usec = 0; + if (utimes(daemon->timestamp_file, tv) == 0) diff --git a/package/network/services/dnsmasq/patches/230-fix-poll-h-include-warning-on-musl.patch b/package/network/services/dnsmasq/patches/230-fix-poll-h-include-warning-on-musl.patch index 19300f7d66..37b11abc1d 100644 --- a/package/network/services/dnsmasq/patches/230-fix-poll-h-include-warning-on-musl.patch +++ b/package/network/services/dnsmasq/patches/230-fix-poll-h-include-warning-on-musl.patch @@ -7,7 +7,7 @@ Signed-off-by: Kevin Darbyshire-Bryant --- a/src/dnsmasq.h +++ b/src/dnsmasq.h -@@ -82,7 +82,7 @@ typedef unsigned long long u64; +@@ -88,7 +88,7 @@ typedef unsigned long long u64; #if defined(HAVE_SOLARIS_NETWORK) # include #endif diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile index b7cc6b9c34..8a1f083217 100644 --- a/package/network/services/hostapd/Makefile +++ b/package/network/services/hostapd/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=hostapd -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE_URL:=http://w1.fi/hostap.git PKG_SOURCE_PROTO:=git diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh index 57d74d8a79..5340b568e0 100644 --- a/package/network/services/hostapd/files/hostapd.sh +++ b/package/network/services/hostapd/files/hostapd.sh @@ -620,7 +620,7 @@ wpa_supplicant_add_network() { scan_ssid="" } - [[ "$_w_mode" = "adhoc" -o "$_w_mode" = "mesh" ]] && append network_data "$_w_modestr" "$N$T" + [ "$_w_mode" = "adhoc" -o "$_w_mode" = "mesh" ] && append network_data "$_w_modestr" "$N$T" case "$auth_type" in none) ;; diff --git a/package/network/services/odhcpd/Makefile b/package/network/services/odhcpd/Makefile index 21b50d9d0b..5ba9e7c7eb 100644 --- a/package/network/services/odhcpd/Makefile +++ b/package/network/services/odhcpd/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=odhcpd -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(LEDE_GIT)/project/odhcpd.git -PKG_SOURCE_DATE:=2017-04-28 -PKG_SOURCE_VERSION:=9268ca65d6e000b6cd4ed72d4a8fa427dada6f06 -PKG_MIRROR_HASH:=3c375291de38034f0965c92e509ca17788d3b31fe13abbc8f541b2e2452bc7fe +PKG_SOURCE_DATE:=2017-10-02 +PKG_SOURCE_VERSION:=c6f3d5d4ea5154e5971fa0b1b1e9a9c07119429f +PKG_MIRROR_HASH:=5ce8f52b5c6acea27d9733918e9c3bc8a154d516a02eef9b172c5e3d459f494c PKG_MAINTAINER:=Hans Dedecker PKG_LICENSE:=GPL-2.0 diff --git a/package/network/services/odhcpd/files/odhcpd.defaults b/package/network/services/odhcpd/files/odhcpd.defaults index d079ec0f80..175e56e9bf 100644 --- a/package/network/services/odhcpd/files/odhcpd.defaults +++ b/package/network/services/odhcpd/files/odhcpd.defaults @@ -2,12 +2,27 @@ uci -q get dhcp.odhcpd && exit 0 touch /etc/config/dhcp +. /usr/share/libubox/jshn.sh + +json_load "$(cat /etc/board.json)" +json_select network +json_select lan +json_get_vars protocol +json_select .. +json_select .. + +case "$protocol" in +# only enable server mode on statically addressed lan ports +"static") MODE=server ;; +*) MODE=disabled ;; +esac + uci batch </dev/null) - json_init json_add_string name "${PPP_IPPARAM}_6" json_add_string ifname "@$PPP_IPPARAM" json_add_string proto "dhcpv6" - [ -n "$ZONE" ] && json_add_string zone "$ZONE" [ -n "$EXTENDPREFIX" ] && json_add_string extendprefix 1 [ -n "$IP6TABLE" ] && json_add_string ip6table $IP6TABLE [ -n "$PEERDNS" ] && json_add_boolean peerdns $PEERDNS diff --git a/package/network/services/ppp/files/ppp.sh b/package/network/services/ppp/files/ppp.sh index 875714b353..73bc3161cd 100755 --- a/package/network/services/ppp/files/ppp.sh +++ b/package/network/services/ppp/files/ppp.sh @@ -223,16 +223,7 @@ proto_pppoe_setup() { json_get_var service service json_get_var host_uniq host_uniq -#By 蝈蝈:并发拨号同步的前期准备 - syncppp_option="" - [ "$(uci get syncdial.config.enabled)" == "1" ] && { - ppp_if_cnt=$(cat /etc/config/network | grep -c "proto 'pppoe'") - syncppp_option="syncppp $ppp_if_cnt" - shellsync $ppp_if_cnt 10 - } - ppp_generic_setup "$config" \ - $syncppp_option \ plugin rp-pppoe.so \ ${ac:+rp_pppoe_ac "$ac"} \ ${service:+rp_pppoe_service "$service"} \ diff --git a/package/network/services/ppp/patches/140-pppoe_compile_fix.patch b/package/network/services/ppp/patches/140-pppoe_compile_fix.patch index d9c9b83a33..2983a75c42 100644 --- a/package/network/services/ppp/patches/140-pppoe_compile_fix.patch +++ b/package/network/services/ppp/patches/140-pppoe_compile_fix.patch @@ -1,27 +1,23 @@ +--- a/pppd/plugins/rp-pppoe/plugin.c ++++ b/pppd/plugins/rp-pppoe/plugin.c +@@ -46,10 +46,10 @@ static char const RCSID[] = + #include + #include + #include +-#include + #include + #include + #include ++#include + + #ifndef _ROOT_PATH + #define _ROOT_PATH "" --- a/pppd/plugins/rp-pppoe/pppoe.h +++ b/pppd/plugins/rp-pppoe/pppoe.h -@@ -48,11 +48,7 @@ - #endif +@@ -86,17 +86,6 @@ typedef unsigned long UINT32_t; - /* Ugly header files on some Linux boxes... */ --#if defined(HAVE_LINUX_IF_H) --#include --#elif defined(HAVE_NET_IF_H) - #include --#endif - - #ifdef HAVE_NET_IF_TYPES_H - #include -@@ -80,22 +76,8 @@ typedef unsigned long UINT32_t; - #error Could not find a 32-bit integer type - #endif - --#ifdef HAVE_LINUX_IF_ETHER_H --#include --#endif -- #include -- + -#ifdef HAVE_NETINET_IF_ETHER_H -#include - @@ -32,10 +28,21 @@ -#include -#endif -#endif -+#include +- + /* Ethernet frame types according to RFC 2516 */ +--- a/pppd/plugins/rp-pppoe/if.c ++++ b/pppd/plugins/rp-pppoe/if.c +@@ -31,7 +31,7 @@ static char const RCSID[] = + #endif + #ifdef HAVE_NET_ETHERNET_H +-#include ++#include + #endif + + #ifdef HAVE_ASM_TYPES_H --- a/pppd/plugins/rp-pppoe/pppoe-discovery.c +++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c @@ -16,6 +16,7 @@ @@ -46,7 +53,18 @@ #ifdef HAVE_UNISTD_H #include -@@ -717,6 +718,23 @@ char *xstrdup(const char *s) +@@ -27,10 +28,6 @@ + #include + #endif + +-#ifdef HAVE_NET_ETHERNET_H +-#include +-#endif +- + #ifdef HAVE_ASM_TYPES_H + #include + #endif +@@ -717,6 +714,23 @@ char *xstrdup(const char *s) return ret; } diff --git a/package/network/services/ppp/patches/511-syncppp.patch b/package/network/services/ppp/patches/511-syncppp.patch deleted file mode 100644 index fe58b8cc81..0000000000 --- a/package/network/services/ppp/patches/511-syncppp.patch +++ /dev/null @@ -1,214 +0,0 @@ -diff -Naur ppp-2.4.5.0/pppd/chap-new.c ppp-2.4.5/pppd/chap-new.c ---- ppp-2.4.5.0/pppd/chap-new.c 2012-04-18 15:44:46.000000000 +0800 -+++ ppp-2.4.5/pppd/chap-new.c 2012-04-19 20:24:28.000000000 +0800 -@@ -37,6 +37,8 @@ - #include "chap-new.h" - #include "chap-md5.h" - -+#include "syncppp.h" -+ - #ifdef CHAPMS - #include "chap_ms.h" - #define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5) -@@ -481,6 +483,19 @@ - p[2] = len >> 8; - p[3] = len; - -+ if (npppd > 1) { -+ if (syncppp(npppd) < 0) { -+ error("syncppp sync fail"); -+ sem_unlink(SEM_COUNT_NAME); -+ sem_unlink(SEM_BLOCK_NAME); -+ } else { -+ info("syncppp sync succeeded"); -+ } -+ } else { -+ info("syncppp not active"); -+ } -+ -+ - output(0, response, PPP_HDRLEN + len); - } - -diff -Naur ppp-2.4.5.0/pppd/Makefile.linux ppp-2.4.5/pppd/Makefile.linux ---- ppp-2.4.5.0/pppd/Makefile.linux 2012-04-18 15:44:46.000000000 +0800 -+++ ppp-2.4.5/pppd/Makefile.linux 2012-04-19 20:01:05.000000000 +0800 -@@ -13,16 +13,16 @@ - - PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \ - ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \ -- demand.c utils.c tty.c eap.c chap-md5.c session.c -+ demand.c utils.c tty.c eap.c chap-md5.c session.c syncppp.c - - HEADERS = ccp.h session.h chap-new.h ecp.h fsm.h ipcp.h \ - ipxcp.h lcp.h magic.h md5.h patchlevel.h pathnames.h pppd.h \ -- upap.h eap.h -+ upap.h eap.h syncppp.h - - MANPAGES = pppd.8 - PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \ - ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o \ -- eap.o chap-md5.o session.o -+ eap.o chap-md5.o session.o syncppp.o - - # - # include dependencies if present -@@ -33,7 +33,7 @@ - # CC = gcc - # - COPTS = -O2 -pipe -Wall -g --LIBS = -+LIBS = -lpthread - - # Uncomment the next 2 lines to include support for Microsoft's - # MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux. -diff -Naur ppp-2.4.5.0/pppd/options.c ppp-2.4.5/pppd/options.c ---- ppp-2.4.5.0/pppd/options.c 2012-04-18 15:44:46.000000000 +0800 -+++ ppp-2.4.5/pppd/options.c 2012-04-19 20:24:49.000000000 +0800 -@@ -126,6 +126,7 @@ - bool dryrun; /* print out option values and exit */ - char *domain; /* domain name set by domain option */ - int child_wait = 5; /* # seconds to wait for children at exit */ -+int npppd = 0; /* synchronize between multiple pppd */ - struct userenv *userenv_list; /* user environment variables */ - - #ifdef MAXOCTETS -@@ -311,6 +312,10 @@ - "Set pathname of ipv6-down script", - OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN }, - -+ { "syncppp", o_int, &npppd, -+ "sync among multiple pppd when sending chap/pap respond", OPT_PRIO }, -+ -+ - #ifdef HAVE_MULTILINK - { "multilink", o_bool, &multilink, - "Enable multilink operation", OPT_PRIO | 1 }, -diff -Naur ppp-2.4.5.0/pppd/pppd.h ppp-2.4.5/pppd/pppd.h ---- ppp-2.4.5.0/pppd/pppd.h 2012-04-18 15:44:46.000000000 +0800 -+++ ppp-2.4.5/pppd/pppd.h 2012-04-19 20:25:02.000000000 +0800 -@@ -327,6 +327,7 @@ - extern bool dump_options; /* print out option values */ - extern bool dryrun; /* check everything, print options, exit */ - extern int child_wait; /* # seconds to wait for children at end */ -+extern int npppd; /* synchronize between multiple pppd */ - - #ifdef MAXOCTETS - extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ -diff -Naur ppp-2.4.5.0/pppd/syncppp.c ppp-2.4.5/pppd/syncppp.c ---- ppp-2.4.5.0/pppd/syncppp.c 1970-01-01 08:00:00.000000000 +0800 -+++ ppp-2.4.5/pppd/syncppp.c 2012-04-18 15:46:59.000000000 +0800 -@@ -0,0 +1,75 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include "pppd.h" -+#include "syncppp.h" -+ -+int syncppp(int nproc) -+{ -+ int flags; -+ int value; -+ sem_t *block; -+ sem_t *count; -+ struct timespec ts; -+ -+ if (nproc <= 1) { -+ error("syncppp: number of pppd should be larger than 1"); -+ return -1; -+ } -+ -+ if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { -+ error("clock_gettime error"); -+ return -1; -+ } -+ ts.tv_sec += SYNCPPP_TIMEOUT; -+ -+ -+ flags = O_RDWR | O_CREAT; -+ block = sem_open(SEM_BLOCK_NAME, flags, 0644, 0); -+ count = sem_open(SEM_COUNT_NAME, flags, 0644, 0); -+ if (block == SEM_FAILED || count == SEM_FAILED) { -+ error("syncppp: sem_open failed"); -+ return -1; -+ } -+ -+ if (sem_post(count) < 0) { -+ error("syncppp: sem_post failed"); -+ return -1; -+ } -+ if (sem_getvalue(count, &value) < 0) { -+ error("syncppp: sem_getvalue failed"); -+ return -1; -+ } -+ info("%d pppd have arrived, waiting for the left %d", value, nproc-value); -+ if (value >= nproc) { -+ while (nproc-1 > 0) { -+ if (sem_post(block) < 0) { -+ error("syncppp: sem_post failed"); -+ return -1; -+ } -+ nproc--; -+ } -+ } else { -+ if (sem_timedwait(block, &ts) < 0) { -+ if (errno == ETIMEDOUT) { -+ error("syncppp: sem_timewait time out"); -+ } else { -+ error("syncppp: sem_timewait error"); -+ } -+ return -1; -+ } -+ -+ } -+ -+ sem_close(count); -+ sem_close(block); -+ -+ sem_unlink(SEM_COUNT_NAME); -+ sem_unlink(SEM_BLOCK_NAME); -+ -+ return 0; -+} -+ -diff -Naur ppp-2.4.5.0/pppd/syncppp.h ppp-2.4.5/pppd/syncppp.h ---- ppp-2.4.5.0/pppd/syncppp.h 1970-01-01 08:00:00.000000000 +0800 -+++ ppp-2.4.5/pppd/syncppp.h 2012-04-18 15:46:59.000000000 +0800 -@@ -0,0 +1,3 @@ -+#define SEM_BLOCK_NAME "block" -+#define SEM_COUNT_NAME "count" -+#define SYNCPPP_TIMEOUT 5 -diff -Naur ppp-2.4.5.0/pppd/upap.c ppp-2.4.5/pppd/upap.c ---- ppp-2.4.5.0/pppd/upap.c 2012-04-18 15:44:46.000000000 +0800 -+++ ppp-2.4.5/pppd/upap.c 2012-04-19 20:26:22.000000000 +0800 -@@ -52,6 +52,8 @@ - #include "pppd.h" - #include "upap.h" - -+#include "syncppp.h" -+ - static const char rcsid[] = RCSID; - - static bool hide_password = 1; -@@ -568,6 +570,18 @@ - PUTCHAR(u->us_passwdlen, outp); - BCOPY(u->us_passwd, outp, u->us_passwdlen); - -+ if (npppd > 1) { -+ if (syncppp(npppd) < 0) { -+ error("syncppp sync fail"); -+ sem_unlink(SEM_COUNT_NAME); -+ sem_unlink(SEM_BLOCK_NAME); -+ } else { -+ info("syncppp sync succeeded"); -+ } -+ } else { -+ info("syncppp not active"); -+ } -+ - output(u->us_unit, outpacket_buf, outlen + PPP_HDRLEN); - - TIMEOUT(upap_timeout, u, u->us_timeouttime); diff --git a/package/network/services/ppp/patches/520-uniq.patch b/package/network/services/ppp/patches/520-uniq.patch index 65d0e96bc0..54c0d62712 100644 --- a/package/network/services/ppp/patches/520-uniq.patch +++ b/package/network/services/ppp/patches/520-uniq.patch @@ -147,7 +147,7 @@ strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); --- a/pppd/plugins/rp-pppoe/pppoe-discovery.c +++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c -@@ -348,7 +348,7 @@ packetIsForMe(PPPoEConnection *conn, PPP +@@ -344,7 +344,7 @@ packetIsForMe(PPPoEConnection *conn, PPP if (memcmp(packet->ethHdr.h_dest, conn->myEth, ETH_ALEN)) return 0; /* If we're not using the Host-Unique tag, then accept the packet */ @@ -156,7 +156,7 @@ parsePacket(packet, parseForHostUniq, &forMe); return forMe; -@@ -474,16 +474,12 @@ sendPADI(PPPoEConnection *conn) +@@ -470,16 +470,12 @@ sendPADI(PPPoEConnection *conn) cursor += namelen + TAG_HDR_SIZE; /* If we're using Host-Uniq, copy it over */ @@ -179,7 +179,7 @@ } packet.length = htons(plen); -@@ -645,7 +641,7 @@ int main(int argc, char *argv[]) +@@ -641,7 +637,7 @@ int main(int argc, char *argv[]) memset(conn, 0, sizeof(PPPoEConnection)); @@ -188,7 +188,7 @@ switch(opt) { case 'S': conn->serviceName = xstrdup(optarg); -@@ -654,7 +650,23 @@ int main(int argc, char *argv[]) +@@ -650,7 +646,23 @@ int main(int argc, char *argv[]) conn->acName = xstrdup(optarg); break; case 'U': @@ -224,7 +224,7 @@ /* How do we access raw Ethernet devices? */ #undef USE_LINUX_PACKET -@@ -217,7 +219,7 @@ typedef struct PPPoEConnectionStruct { +@@ -224,7 +226,7 @@ typedef struct PPPoEConnectionStruct { char *serviceName; /* Desired service name, if any */ char *acName; /* Desired AC name, if any */ int synchronous; /* Use synchronous PPP */ @@ -233,7 +233,7 @@ int printACNames; /* Just print AC names */ FILE *debugFile; /* Debug file for dumping packets */ int numPADOs; /* Number of PADO packets received */ -@@ -273,6 +275,33 @@ void pppoe_printpkt(PPPoEPacket *packet, +@@ -280,6 +282,33 @@ void pppoe_printpkt(PPPoEPacket *packet, void (*printer)(void *, char *, ...), void *arg); void pppoe_log_packet(const char *prefix, PPPoEPacket *packet); diff --git a/package/network/services/shellsync/Makefile b/package/network/services/shellsync/Makefile deleted file mode 100644 index 6dce14b35c..0000000000 --- a/package/network/services/shellsync/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -include $(TOPDIR)/rules.mk - -PKG_NAME:=shellsync -PKG_VERSION:=0.2 -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/package.mk - -define Package/shellsync - CATEGORY:=Utilities - TITLE:=shellsync - DEPENDS:=+libpthread -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Package/shellsync/description -A tool to sync different shell scripts.Based on syncppp patch by morfast. -endef - -define Build/Compile - $(TARGET_CROSS)gcc -pthread -o $(PKG_BUILD_DIR)/shellsync $(PKG_BUILD_DIR)/shellsync.c -endef - -define Package/shellsync/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/shellsync $(1)/usr/bin -endef - - -$(eval $(call BuildPackage,shellsync)) diff --git a/package/network/services/shellsync/src/shellsync.c b/package/network/services/shellsync/src/shellsync.c deleted file mode 100644 index 4aef1e9ba2..0000000000 --- a/package/network/services/shellsync/src/shellsync.c +++ /dev/null @@ -1,106 +0,0 @@ -/************************************************************************* - > File Name: shellsync.c - > Author: GuoGuo - > Mail: gch981213@gmail.com - > Created Time: 2014年11月06日 星期四 19时15分30秒 - ************************************************************************/ -#include -#include -#include -#include -#include -#include -#define SEM_BLOCK_NAME "SYNCSHELL_block" -#define SEM_COUNT_NAME "SYNCSHELL_count" -int wait_timeout; -int sync_wait(int nproc) -{ - int flags; - int value; - sem_t *block; - sem_t *count; - struct timespec ts; - - if (nproc <= 1) { - printf("sync_wait: number of processes should be larger than 1\n"); - return -1; - } - - if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { - printf("clock_gettime error\n"); - return -1; - } - ts.tv_sec += wait_timeout; - - - flags = O_RDWR | O_CREAT; - block = sem_open(SEM_BLOCK_NAME, flags, 0644, 0); - count = sem_open(SEM_COUNT_NAME, flags, 0644, 0); - if (block == SEM_FAILED || count == SEM_FAILED) { - printf("sync_wait: sem_open failed\n"); - return -1; - } - - if (sem_post(count) < 0) { - printf("sync_wait: sem_post failed\n"); - return -1; - } - if (sem_getvalue(count, &value) < 0) { - printf("sync_wait: sem_getvalue failed\n"); - return -1; - } - printf("%d processes have arrived, waiting for the left %d\n", value, nproc-value); - if (value >= nproc) { - while (nproc-1 > 0) { - if (sem_post(block) < 0) { - printf("sync_wait: sem_post failed\n"); - return -1; - } - nproc--; - } - } else { - if (sem_timedwait(block, &ts) < 0) { - if (errno == ETIMEDOUT) { - printf("sync_wait: sem_timewait time out\n"); - } else { - printf("sync_wait: sem_timewait error\n"); - } - return -1; - } - - } - - sem_close(count); - sem_close(block); - - sem_unlink(SEM_COUNT_NAME); - sem_unlink(SEM_BLOCK_NAME); - - return 0; -} - -int main(int argc,char *argv[]) -{ - if(argc!=3) - { - printf("Usage: shellsync \n"); - } - else - { - int proc_num; - sscanf(argv[1],"%d",&proc_num); - sscanf(argv[2],"%d",&wait_timeout); - if(sync_wait(proc_num)<0) - { - printf("Processes sync failed.\n"); - sem_unlink(SEM_COUNT_NAME); - sem_unlink(SEM_BLOCK_NAME); - return 1; - } - else - { - printf("Processes sync succeed.\n"); - return 0; - } - } -} diff --git a/package/network/services/uhttpd/Makefile b/package/network/services/uhttpd/Makefile index 39e8894ebc..609c9df007 100644 --- a/package/network/services/uhttpd/Makefile +++ b/package/network/services/uhttpd/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(LEDE_GIT)/project/uhttpd.git -PKG_SOURCE_DATE:=2016-10-25 -PKG_SOURCE_VERSION:=1628fa4b34aa143187353f81e8001b9a15286bda -PKG_MIRROR_HASH:=2ac4ba8dc0b349d72174aac9ff693a73a214295a9890fe3d2a8eedcad54d06e3 +PKG_SOURCE_DATE:=2017-08-19 +PKG_SOURCE_VERSION:=3fd58e9b6da7d9e1a4710dbeefc2d289baea09fb +PKG_MIRROR_HASH:=69bba3b04c5e1975b99dee4fc47672ebf5ab282f115249a46be0fe0b961eb34b PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=ISC diff --git a/package/network/utils/comgt/Makefile b/package/network/utils/comgt/Makefile index 3926016581..ce99a2a688 100644 --- a/package/network/utils/comgt/Makefile +++ b/package/network/utils/comgt/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=comgt PKG_VERSION:=0.32 -PKG_RELEASE:=28 +PKG_RELEASE:=29 PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz PKG_SOURCE_URL:=@SF/comgt diff --git a/package/network/utils/comgt/files/3g.sh b/package/network/utils/comgt/files/3g.sh index d438cb7a6d..0d02d4c4b9 100644 --- a/package/network/utils/comgt/files/3g.sh +++ b/package/network/utils/comgt/files/3g.sh @@ -109,4 +109,4 @@ proto_3g_teardown() { proto_kill_command "$interface" } -[ -z "NOT_INCLUDED" ] || add_protocol 3g +[ -z "$NOT_INCLUDED" ] || add_protocol 3g diff --git a/package/network/utils/comgt/files/directip.sh b/package/network/utils/comgt/files/directip.sh index 381bfb0000..3452fa5db7 100644 --- a/package/network/utils/comgt/files/directip.sh +++ b/package/network/utils/comgt/files/directip.sh @@ -44,8 +44,7 @@ proto_directip_setup() { return 1 } - cardinfo=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom) - [ -n $(echo "$cardinfo" | grep -q "Sierra Wireless") ] || { + gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | grep -q "Sierra Wireless" || { proto_notify_error "$interface" BAD_DEVICE proto_block_restart "$interface" return 1 diff --git a/package/network/utils/curl/Makefile b/package/network/utils/curl/Makefile index 9b357a0aa5..758532e30a 100644 --- a/package/network/utils/curl/Makefile +++ b/package/network/utils/curl/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=curl PKG_VERSION:=7.52.1 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=http://curl.haxx.se/download/ \ diff --git a/package/network/utils/curl/patches/103-CVE-2017-1000100.patch b/package/network/utils/curl/patches/103-CVE-2017-1000100.patch new file mode 100644 index 0000000000..93ab97bd14 --- /dev/null +++ b/package/network/utils/curl/patches/103-CVE-2017-1000100.patch @@ -0,0 +1,41 @@ +From 358b2b131ad6c095696f20dcfa62b8305263f898 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Tue, 1 Aug 2017 17:16:46 +0200 +Subject: [PATCH] tftp: reject file name lengths that don't fit + +... and thereby avoid telling send() to send off more bytes than the +size of the buffer! + +CVE-2017-1000100 + +Bug: https://curl.haxx.se/docs/adv_20170809B.html +Reported-by: Even Rouault + +Credit to OSS-Fuzz for the discovery +--- + lib/tftp.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/lib/tftp.c ++++ b/lib/tftp.c +@@ -5,7 +5,7 @@ + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * +- * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. ++ * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms +@@ -490,6 +490,11 @@ static CURLcode tftp_send_first(tftp_sta + if(result) + return result; + ++ if(strlen(filename) > (state->blksize - strlen(mode) - 4)) { ++ failf(data, "TFTP file name too long\n"); ++ return CURLE_TFTP_ILLEGAL; /* too long file name field */ ++ } ++ + snprintf((char *)state->spacket.data+2, + state->blksize, + "%s%c%s%c", filename, '\0', mode, '\0'); diff --git a/package/network/utils/curl/patches/104-CVE-2017-1000101.patch b/package/network/utils/curl/patches/104-CVE-2017-1000101.patch new file mode 100644 index 0000000000..835b73eef9 --- /dev/null +++ b/package/network/utils/curl/patches/104-CVE-2017-1000101.patch @@ -0,0 +1,33 @@ +From 453e7a7a03a2cec749abd3878a48e728c515cca7 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Tue, 1 Aug 2017 17:16:07 +0200 +Subject: [PATCH] glob: do not continue parsing after a strtoul() overflow + range + +Added test 1289 to verify. + +CVE-2017-1000101 + +Bug: https://curl.haxx.se/docs/adv_20170809A.html +Reported-by: Brian Carpenter +--- + src/tool_urlglob.c | 5 ++++- + tests/data/Makefile.inc | 2 +- + tests/data/test1289 | 35 +++++++++++++++++++++++++++++++++++ + 3 files changed, 40 insertions(+), 2 deletions(-) + create mode 100644 tests/data/test1289 + +--- a/src/tool_urlglob.c ++++ b/src/tool_urlglob.c +@@ -272,7 +272,10 @@ static CURLcode glob_range(URLGlob *glob + } + errno = 0; + max_n = strtoul(pattern, &endp, 10); +- if(errno || (*endp == ':')) { ++ if(errno) ++ /* overflow */ ++ endp = NULL; ++ else if(*endp == ':') { + pattern = endp+1; + errno = 0; + step_n = strtoul(pattern, &endp, 10); diff --git a/package/network/utils/tcpdump/Makefile b/package/network/utils/tcpdump/Makefile index 0eef00db05..bb04369b50 100644 --- a/package/network/utils/tcpdump/Makefile +++ b/package/network/utils/tcpdump/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=tcpdump -PKG_VERSION:=4.9.1 +PKG_VERSION:=4.9.2 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=http://www.tcpdump.org/release/ \ - http://www.at.tcpdump.org/ -PKG_HASH:=f9448cf4deb2049acf713655c736342662e652ef40dbe0a8f6f8d5b9ce5bd8f3 +PKG_SOURCE_URL:=http://www.us.tcpdump.org/release/ \ + http://www.tcpdump.org/release/ +PKG_HASH:=798b3536a29832ce0cbb07fafb1ce5097c95e308a6f592d14052e1ef1505fe79 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) PKG_BUILD_PARALLEL:=1 @@ -76,7 +76,6 @@ endif MAKE_FLAGS += \ CCOPT="$(TARGET_CFLAGS)" INCLS="-I. $(TARGET_CPPFLAGS)" - define Package/tcpdump/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tcpdump $(1)/usr/sbin/ diff --git a/package/network/utils/tcpdump/patches/100-tcpdump_mini.patch b/package/network/utils/tcpdump/patches/100-tcpdump_mini.patch index 26dbe13e3a..593d428949 100644 --- a/package/network/utils/tcpdump/patches/100-tcpdump_mini.patch +++ b/package/network/utils/tcpdump/patches/100-tcpdump_mini.patch @@ -115,7 +115,7 @@ $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c --- a/addrtoname.c +++ b/addrtoname.c -@@ -566,8 +566,10 @@ linkaddr_string(netdissect_options *ndo, +@@ -578,8 +578,10 @@ linkaddr_string(netdissect_options *ndo, if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN) return (etheraddr_string(ndo, ep)); @@ -125,8 +125,8 @@ +#endif tp = lookup_bytestring(ndo, ep, len); - if (tp->e_name) -@@ -1202,6 +1204,7 @@ init_addrtoname(netdissect_options *ndo, + if (tp->bs_name) +@@ -1214,6 +1216,7 @@ init_addrtoname(netdissect_options *ndo, init_ipxsaparray(ndo); } @@ -134,7 +134,7 @@ const char * dnaddr_string(netdissect_options *ndo, u_short dnaddr) { -@@ -1221,6 +1224,7 @@ dnaddr_string(netdissect_options *ndo, u +@@ -1233,6 +1236,7 @@ dnaddr_string(netdissect_options *ndo, u return(tp->name); } @@ -247,7 +247,7 @@ return (1); @@ -368,6 +369,7 @@ ethertype_print(netdissect_options *ndo, } - isoclns_print(ndo, p + 1, length - 1, caplen - 1); + isoclns_print(ndo, p + 1, length - 1); return(1); +#endif @@ -335,7 +335,7 @@ break; --- a/print-ip6.c +++ b/print-ip6.c -@@ -303,6 +303,7 @@ ip6_print(netdissect_options *ndo, const +@@ -305,6 +305,7 @@ ip6_print(netdissect_options *ndo, const return; nh = *cp; break; @@ -343,13 +343,16 @@ case IPPROTO_FRAGMENT: advance = frag6_print(ndo, cp, (const u_char *)ip6); if (advance < 0 || ndo->ndo_snapend <= cp + advance) -@@ -324,16 +325,19 @@ ip6_print(netdissect_options *ndo, const - advance = mobility_print(ndo, cp, (const u_char *)ip6); +@@ -328,6 +329,7 @@ ip6_print(netdissect_options *ndo, const + return; nh = *cp; return; +#endif case IPPROTO_ROUTING: + ND_TCHECK(*cp); advance = rt6_print(ndo, cp, (const u_char *)ip6); +@@ -335,12 +337,14 @@ ip6_print(netdissect_options *ndo, const + return; nh = *cp; break; +#ifndef TCPDUMP_MINI @@ -363,15 +366,15 @@ case IPPROTO_TCP: tcp_print(ndo, cp, len, (const u_char *)ip6, fragmented); return; -@@ -343,6 +347,7 @@ ip6_print(netdissect_options *ndo, const +@@ -350,6 +354,7 @@ ip6_print(netdissect_options *ndo, const case IPPROTO_ICMPV6: icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented); return; +#ifndef TCPDUMP_MINI case IPPROTO_AH: advance = ah_print(ndo, cp); - nh = *cp; -@@ -371,6 +376,7 @@ ip6_print(netdissect_options *ndo, const + if (advance < 0) +@@ -382,6 +387,7 @@ ip6_print(netdissect_options *ndo, const case IPPROTO_PIM: pim_print(ndo, cp, len, (const u_char *)ip6); return; @@ -379,7 +382,7 @@ case IPPROTO_OSPF: ospf6_print(ndo, cp, len); -@@ -384,9 +390,11 @@ ip6_print(netdissect_options *ndo, const +@@ -395,9 +401,11 @@ ip6_print(netdissect_options *ndo, const ip_print(ndo, cp, len); return; @@ -393,7 +396,7 @@ gre_print(ndo, cp, len); --- a/print-ip.c +++ b/print-ip.c -@@ -329,6 +329,7 @@ ip_print_demux(netdissect_options *ndo, +@@ -344,6 +344,7 @@ ip_print_demux(netdissect_options *ndo, again: switch (ipds->nh) { @@ -401,7 +404,7 @@ case IPPROTO_AH: if (!ND_TTEST(*ipds->cp)) { ND_PRINT((ndo, "[|AH]")); -@@ -367,7 +368,9 @@ again: +@@ -382,7 +383,9 @@ again: */ break; } @@ -411,7 +414,7 @@ case IPPROTO_SCTP: sctp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len); break; -@@ -375,6 +378,7 @@ again: +@@ -390,6 +393,7 @@ again: case IPPROTO_DCCP: dccp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len); break; @@ -419,7 +422,7 @@ case IPPROTO_TCP: /* pass on the MF bit plus the offset to detect fragments */ -@@ -394,6 +398,7 @@ again: +@@ -409,6 +413,7 @@ again: ipds->off & (IP_MF|IP_OFFMASK)); break; @@ -427,7 +430,7 @@ case IPPROTO_PIGP: /* * XXX - the current IANA protocol number assignments -@@ -414,14 +419,17 @@ again: +@@ -429,14 +434,17 @@ again: case IPPROTO_EIGRP: eigrp_print(ndo, ipds->cp, ipds->len); break; @@ -445,7 +448,7 @@ case IPPROTO_OSPF: ospf_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip); -@@ -454,6 +462,7 @@ again: +@@ -469,6 +477,7 @@ again: gre_print(ndo, ipds->cp, ipds->len); break; @@ -453,14 +456,14 @@ case IPPROTO_MOBILE: mobile_print(ndo, ipds->cp, ipds->len); break; -@@ -482,6 +491,7 @@ again: +@@ -497,6 +506,7 @@ again: case IPPROTO_PGM: pgm_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip); break; +#endif default: - if (ndo->ndo_nflag==0 && (proto = getprotobynumber(ipds->nh)) != NULL) + if (ndo->ndo_nflag==0 && (p_name = netdb_protoname(ipds->nh)) != NULL) --- a/print-llc.c +++ b/print-llc.c @@ -206,6 +206,7 @@ llc_print(netdissect_options *ndo, const @@ -495,21 +498,22 @@ #ifdef ENABLE_SMB if (ssap == LLCSAP_NETBEUI && dsap == LLCSAP_NETBEUI -@@ -322,11 +326,13 @@ llc_print(netdissect_options *ndo, const +@@ -322,12 +326,13 @@ llc_print(netdissect_options *ndo, const return (hdrlen); } #endif +#ifndef TCPDUMP_MINI if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS && control == LLC_UI) { - isoclns_print(ndo, p, length, caplen); + isoclns_print(ndo, p, length); return (hdrlen); } +- +#endif - if (!ndo->ndo_eflag) { if (ssap == dsap) { -@@ -480,6 +486,7 @@ snap_print(netdissect_options *ndo, cons + if (src == NULL || dst == NULL) +@@ -480,6 +485,7 @@ snap_print(netdissect_options *ndo, cons case OUI_CISCO: switch (et) { @@ -517,7 +521,7 @@ case PID_CISCO_CDP: cdp_print(ndo, p, length, caplen); return (1); -@@ -492,6 +499,7 @@ snap_print(netdissect_options *ndo, cons +@@ -492,6 +498,7 @@ snap_print(netdissect_options *ndo, cons case PID_CISCO_VTP: vtp_print(ndo, p, length); return (1); @@ -525,7 +529,7 @@ case PID_CISCO_PVST: case PID_CISCO_VLANBRIDGE: stp_print(ndo, p, length); -@@ -504,6 +512,7 @@ snap_print(netdissect_options *ndo, cons +@@ -504,6 +511,7 @@ snap_print(netdissect_options *ndo, cons case OUI_RFC2684: switch (et) { @@ -533,7 +537,7 @@ case PID_RFC2684_ETH_FCS: case PID_RFC2684_ETH_NOFCS: /* -@@ -565,6 +574,7 @@ snap_print(netdissect_options *ndo, cons +@@ -565,6 +573,7 @@ snap_print(netdissect_options *ndo, cons */ fddi_print(ndo, p, length, caplen); return (1); @@ -549,7 +553,7 @@ +#ifndef TCPDUMP_MINI case BSD_AFNUM_ISO: - isoclns_print(ndo, p, length, caplen); + isoclns_print(ndo, p, length); break; @@ -127,6 +128,7 @@ null_if_print(netdissect_options *ndo, c case BSD_AFNUM_IPX: @@ -561,7 +565,7 @@ /* unknown AF_ value */ --- a/print-ppp.c +++ b/print-ppp.c -@@ -1358,6 +1358,7 @@ trunc: +@@ -1367,6 +1367,7 @@ trunc: return 0; } @@ -569,7 +573,7 @@ static void ppp_hdlc(netdissect_options *ndo, const u_char *p, int length) -@@ -1436,6 +1437,7 @@ trunc: +@@ -1445,6 +1446,7 @@ trunc: free(b); ND_PRINT((ndo, "[|ppp]")); } @@ -577,7 +581,7 @@ /* PPP */ -@@ -1443,10 +1445,12 @@ static void +@@ -1452,10 +1454,12 @@ static void handle_ppp(netdissect_options *ndo, u_int proto, const u_char *p, int length) { @@ -590,7 +594,7 @@ switch (proto) { case PPP_LCP: /* fall through */ -@@ -1479,6 +1483,7 @@ handle_ppp(netdissect_options *ndo, +@@ -1488,6 +1492,7 @@ handle_ppp(netdissect_options *ndo, case PPP_IPV6: ip6_print(ndo, p, length); break; @@ -598,7 +602,7 @@ case ETHERTYPE_IPX: /*XXX*/ case PPP_IPX: ipx_print(ndo, p, length); -@@ -1490,6 +1495,7 @@ handle_ppp(netdissect_options *ndo, +@@ -1499,6 +1504,7 @@ handle_ppp(netdissect_options *ndo, case PPP_MPLS_MCAST: mpls_print(ndo, p, length); break; @@ -606,7 +610,7 @@ case PPP_COMP: ND_PRINT((ndo, "compressed PPP data")); break; -@@ -1630,6 +1636,7 @@ ppp_if_print(netdissect_options *ndo, +@@ -1639,6 +1645,7 @@ ppp_if_print(netdissect_options *ndo, return (0); } @@ -614,7 +618,7 @@ /* * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547, -@@ -1857,6 +1864,7 @@ printx: +@@ -1866,6 +1873,7 @@ printx: #endif /* __bsdi__ */ return (hdrlength); } diff --git a/scripts/om-fwupgradecfg-gen.sh b/scripts/om-fwupgradecfg-gen.sh index a96adf9bc8..4960149f11 100644 --- a/scripts/om-fwupgradecfg-gen.sh +++ b/scripts/om-fwupgradecfg-gen.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh # # Copyright (C) 2011 OpenWrt.org # diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network index 01c947d531..cb707f6169 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -481,7 +481,8 @@ ar71xx_setup_macs() wan_mac=$(mtd_get_mac_binary caldata 6) ;; tl-wr1043nd-v4) - wan_mac=$(mtd_get_mac_binary config 0x1017c) + lan_mac=$(mtd_get_mac_binary product-info 8) + wan_mac=$(macaddr_add "$lan_mac" 1) ;; esr900) wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr") diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c index cb224f4611..b1539c5d71 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c @@ -57,7 +57,7 @@ #define TL_WR1043_V4_KEYS_POLL_INTERVAL 20 /* msecs */ #define TL_WR1043_V4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1043_V4_KEYS_POLL_INTERVAL) -#define TL_WR1043_V4_MAC_LOCATION 0x1ff80174 +#define TL_WR1043_V4_MAC_LOCATION 0x1ff50008 #define TL_WR1043_V4_EEPROM_ADDR 0x1fff0000 #define TL_WR1043_V4_WMAC_CALDATA_OFFSET 0x1000 diff --git a/target/linux/ar71xx/image/tp-link.mk b/target/linux/ar71xx/image/tp-link.mk index 312152f33a..b76ed02ca3 100644 --- a/target/linux/ar71xx/image/tp-link.mk +++ b/target/linux/ar71xx/image/tp-link.mk @@ -944,6 +944,7 @@ endef define Device/tl-wa850re-v1 $(Device/tplink-4mlzma) DEVICE_TITLE := TP-LINK TL-WA850RE + DEVICE_PACKAGES := rssileds BOARDNAME := TL-WA850RE DEVICE_PROFILE := TLWA850 TPLINK_HWID := 0x08500001 diff --git a/target/linux/brcm2708/patches-4.4/0111-mm-Remove-the-PFN-busy-warning.patch b/target/linux/brcm2708/patches-4.4/0111-mm-Remove-the-PFN-busy-warning.patch index 88f4939e0f..3a80486870 100644 --- a/target/linux/brcm2708/patches-4.4/0111-mm-Remove-the-PFN-busy-warning.patch +++ b/target/linux/brcm2708/patches-4.4/0111-mm-Remove-the-PFN-busy-warning.patch @@ -14,7 +14,7 @@ Signed-off-by: Eric Anholt --- a/mm/page_alloc.c +++ b/mm/page_alloc.c -@@ -6804,8 +6804,6 @@ int alloc_contig_range(unsigned long sta +@@ -6816,8 +6816,6 @@ int alloc_contig_range(unsigned long sta /* Make sure the range is really isolated. */ if (test_pages_isolated(outer_start, end, false)) { diff --git a/target/linux/generic/patches-4.4/103-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch b/target/linux/generic/patches-4.4/103-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch index 304cb874b5..6c9b12c2e1 100644 --- a/target/linux/generic/patches-4.4/103-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch +++ b/target/linux/generic/patches-4.4/103-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch @@ -75,7 +75,7 @@ Signed-off-by: Tobias Wolf --- a/mm/page_alloc.c +++ b/mm/page_alloc.c -@@ -5345,7 +5345,7 @@ static void __init_refok alloc_node_mem_ +@@ -5357,7 +5357,7 @@ static void __init_refok alloc_node_mem_ mem_map = NODE_DATA(0)->node_mem_map; #if defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP) || defined(CONFIG_FLATMEM) if (page_to_pfn(mem_map) != pgdat->node_start_pfn) diff --git a/target/linux/generic/patches-4.4/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch b/target/linux/generic/patches-4.4/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch index c6c65d9f39..c5f3e195da 100644 --- a/target/linux/generic/patches-4.4/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch +++ b/target/linux/generic/patches-4.4/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch @@ -143,7 +143,7 @@ Signed-off-by: Jonas Gorski static const struct rt6_info ip6_blk_hole_entry_template = { .dst = { .__refcnt = ATOMIC_INIT(1), -@@ -1889,6 +1906,11 @@ static struct rt6_info *ip6_route_info_c +@@ -1898,6 +1915,11 @@ static struct rt6_info *ip6_route_info_c rt->dst.output = ip6_pkt_prohibit_out; rt->dst.input = ip6_pkt_prohibit; break; @@ -155,7 +155,7 @@ Signed-off-by: Jonas Gorski case RTN_THROW: case RTN_UNREACHABLE: default: -@@ -2492,6 +2514,17 @@ static int ip6_pkt_prohibit_out(struct n +@@ -2501,6 +2523,17 @@ static int ip6_pkt_prohibit_out(struct n return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES); } @@ -173,7 +173,7 @@ Signed-off-by: Jonas Gorski /* * Allocate a dst for local (unicast / anycast) address. */ -@@ -2734,7 +2767,8 @@ static int rtm_to_fib6_config(struct sk_ +@@ -2743,7 +2776,8 @@ static int rtm_to_fib6_config(struct sk_ if (rtm->rtm_type == RTN_UNREACHABLE || rtm->rtm_type == RTN_BLACKHOLE || rtm->rtm_type == RTN_PROHIBIT || @@ -183,7 +183,7 @@ Signed-off-by: Jonas Gorski cfg->fc_flags |= RTF_REJECT; if (rtm->rtm_type == RTN_LOCAL) -@@ -3087,6 +3121,9 @@ static int rt6_fill_node(struct net *net +@@ -3096,6 +3130,9 @@ static int rt6_fill_node(struct net *net case -EACCES: rtm->rtm_type = RTN_PROHIBIT; break; @@ -193,7 +193,7 @@ Signed-off-by: Jonas Gorski case -EAGAIN: rtm->rtm_type = RTN_THROW; break; -@@ -3366,6 +3403,8 @@ static int ip6_route_dev_notify(struct n +@@ -3375,6 +3412,8 @@ static int ip6_route_dev_notify(struct n #ifdef CONFIG_IPV6_MULTIPLE_TABLES net->ipv6.ip6_prohibit_entry->dst.dev = dev; net->ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(dev); @@ -202,7 +202,7 @@ Signed-off-by: Jonas Gorski net->ipv6.ip6_blk_hole_entry->dst.dev = dev; net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev); #endif -@@ -3588,6 +3627,17 @@ static int __net_init ip6_route_net_init +@@ -3597,6 +3636,17 @@ static int __net_init ip6_route_net_init net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops; dst_init_metrics(&net->ipv6.ip6_blk_hole_entry->dst, ip6_template_metrics, true); @@ -220,7 +220,7 @@ Signed-off-by: Jonas Gorski #endif net->ipv6.sysctl.flush_delay = 0; -@@ -3606,6 +3656,8 @@ out: +@@ -3615,6 +3665,8 @@ out: return ret; #ifdef CONFIG_IPV6_MULTIPLE_TABLES @@ -229,7 +229,7 @@ Signed-off-by: Jonas Gorski out_ip6_prohibit_entry: kfree(net->ipv6.ip6_prohibit_entry); out_ip6_null_entry: -@@ -3623,6 +3675,7 @@ static void __net_exit ip6_route_net_exi +@@ -3632,6 +3684,7 @@ static void __net_exit ip6_route_net_exi #ifdef CONFIG_IPV6_MULTIPLE_TABLES kfree(net->ipv6.ip6_prohibit_entry); kfree(net->ipv6.ip6_blk_hole_entry); @@ -237,7 +237,7 @@ Signed-off-by: Jonas Gorski #endif dst_entries_destroy(&net->ipv6.ip6_dst_ops); } -@@ -3696,6 +3749,9 @@ void __init ip6_route_init_special_entri +@@ -3705,6 +3758,9 @@ void __init ip6_route_init_special_entri init_net.ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); init_net.ipv6.ip6_blk_hole_entry->dst.dev = init_net.loopback_dev; init_net.ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); diff --git a/target/linux/generic/patches-4.4/704-phy-no-genphy-soft-reset.patch b/target/linux/generic/patches-4.4/704-phy-no-genphy-soft-reset.patch deleted file mode 100644 index 7cec6d3226..0000000000 --- a/target/linux/generic/patches-4.4/704-phy-no-genphy-soft-reset.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/drivers/net/phy/phy_device.c -+++ b/drivers/net/phy/phy_device.c -@@ -1465,7 +1465,7 @@ static struct phy_driver genphy_driver[] - .phy_id = 0xffffffff, - .phy_id_mask = 0xffffffff, - .name = "Generic 10G PHY", -- .soft_reset = gen10g_soft_reset, -+ .soft_reset = genphy_no_soft_reset, - .config_init = gen10g_config_init, - .features = 0, - .config_aneg = gen10g_config_aneg, diff --git a/target/linux/generic/patches-4.4/811-pci_disable_usb_common_quirks.patch b/target/linux/generic/patches-4.4/811-pci_disable_usb_common_quirks.patch index c990681067..702c9fa2b5 100644 --- a/target/linux/generic/patches-4.4/811-pci_disable_usb_common_quirks.patch +++ b/target/linux/generic/patches-4.4/811-pci_disable_usb_common_quirks.patch @@ -10,7 +10,7 @@ static struct amd_chipset_info { struct pci_dev *nb_dev; struct pci_dev *smbus_dev; -@@ -457,6 +459,10 @@ void usb_amd_dev_put(void) +@@ -458,6 +460,10 @@ void usb_amd_dev_put(void) } EXPORT_SYMBOL_GPL(usb_amd_dev_put); @@ -21,7 +21,7 @@ /* * Make sure the controller is completely inactive, unable to * generate interrupts or do DMA. -@@ -536,8 +542,17 @@ reset_needed: +@@ -537,8 +543,17 @@ reset_needed: uhci_reset_hc(pdev, base); return 1; } @@ -39,7 +39,7 @@ static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask) { u16 cmd; -@@ -1102,3 +1117,4 @@ static void quirk_usb_early_handoff(stru +@@ -1103,3 +1118,4 @@ static void quirk_usb_early_handoff(stru } DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff); diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network index d88d7770dd..f13d1e3643 100755 --- a/target/linux/ipq806x/base-files/etc/board.d/02_network +++ b/target/linux/ipq806x/base-files/etc/board.d/02_network @@ -14,7 +14,6 @@ board=$(ipq806x_board_name) case "$board" in ap148 |\ -c2600 |\ d7800 |\ r7500 |\ r7500v2 |\ @@ -23,6 +22,10 @@ vr2600v) ucidef_add_switch "switch0" \ "1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0" ;; +c2600) + ucidef_add_switch "switch0" \ + "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "6@eth1" "5:wan" "0@eth0" + ;; db149) ucidef_set_interface_lan "eth1 eth2 eth3" ucidef_add_switch "switch0" \ diff --git a/target/linux/lantiq/patches-4.4/0001-MIPS-lantiq-add-pcie-driver.patch b/target/linux/lantiq/patches-4.4/0001-MIPS-lantiq-add-pcie-driver.patch index f417b3ef0f..e6bc3ff858 100644 --- a/target/linux/lantiq/patches-4.4/0001-MIPS-lantiq-add-pcie-driver.patch +++ b/target/linux/lantiq/patches-4.4/0001-MIPS-lantiq-add-pcie-driver.patch @@ -5506,7 +5506,7 @@ Signed-off-by: John Crispin unsigned long type); --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h -@@ -1054,6 +1054,12 @@ +@@ -1055,6 +1055,12 @@ #define PCI_DEVICE_ID_SGI_LITHIUM 0x1002 #define PCI_DEVICE_ID_SGI_IOC4 0x100a diff --git a/target/linux/lantiq/patches-4.4/0026-NET-multi-phy-support.patch b/target/linux/lantiq/patches-4.4/0026-NET-multi-phy-support.patch index f52f6f544b..3c2347979b 100644 --- a/target/linux/lantiq/patches-4.4/0026-NET-multi-phy-support.patch +++ b/target/linux/lantiq/patches-4.4/0026-NET-multi-phy-support.patch @@ -11,7 +11,7 @@ Signed-off-by: John Crispin --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c -@@ -893,7 +893,8 @@ void phy_state_machine(struct work_struc +@@ -890,7 +890,8 @@ void phy_state_machine(struct work_struc /* If the link is down, give up on negotiation for now */ if (!phydev->link) { phydev->state = PHY_NOLINK; @@ -21,7 +21,7 @@ Signed-off-by: John Crispin phydev->adjust_link(phydev->attached_dev); break; } -@@ -985,7 +986,8 @@ void phy_state_machine(struct work_struc +@@ -982,7 +983,8 @@ void phy_state_machine(struct work_struc netif_carrier_on(phydev->attached_dev); } else { phydev->state = PHY_NOLINK; @@ -31,7 +31,7 @@ Signed-off-by: John Crispin } phydev->adjust_link(phydev->attached_dev); -@@ -997,7 +999,8 @@ void phy_state_machine(struct work_struc +@@ -994,7 +996,8 @@ void phy_state_machine(struct work_struc case PHY_HALTED: if (phydev->link) { phydev->link = 0; diff --git a/target/linux/lantiq/patches-4.4/0061-USB-DWC2-make-the-lantiq-settings-match-vendor-drive.patch b/target/linux/lantiq/patches-4.4/0061-USB-DWC2-make-the-lantiq-settings-match-vendor-drive.patch index 1eda4cc4f1..d92e7b1dcf 100644 --- a/target/linux/lantiq/patches-4.4/0061-USB-DWC2-make-the-lantiq-settings-match-vendor-drive.patch +++ b/target/linux/lantiq/patches-4.4/0061-USB-DWC2-make-the-lantiq-settings-match-vendor-drive.patch @@ -23,16 +23,46 @@ Signed-off-by: Hauke Mehrtens --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c -@@ -116,7 +116,7 @@ static const struct dwc2_core_params par +@@ -116,7 +116,37 @@ static const struct dwc2_core_params par .hibernation = -1, }; -static const struct dwc2_core_params params_ltq = { ++static const struct dwc2_core_params params_danube = { ++ .otg_cap = 2, /* non-HNP/non-SRP */ ++ .otg_ver = -1, ++ .dma_enable = -1, ++ .dma_desc_enable = -1, ++ .speed = -1, ++ .enable_dynamic_fifo = -1, ++ .en_multiple_tx_fifo = -1, ++ .host_rx_fifo_size = -1, ++ .host_nperio_tx_fifo_size = -1, ++ .host_perio_tx_fifo_size = -1, ++ .max_transfer_size = -1, ++ .max_packet_count = -1, ++ .host_channels = -1, ++ .phy_type = -1, ++ .phy_utmi_width = -1, ++ .phy_ulpi_ddr = -1, ++ .phy_ulpi_ext_vbus = -1, ++ .i2c_enable = -1, ++ .ulpi_fs_ls = -1, ++ .host_support_fs_ls_low_power = -1, ++ .host_ls_low_power_phy_clk = -1, ++ .ts_dline = -1, ++ .reload_ctl = -1, ++ .ahbcfg = -1, ++ .uframe_sched = -1, ++ .external_id_pin_ctl = -1, ++ .hibernation = -1, ++}; ++ +static const struct dwc2_core_params params_ase = { .otg_cap = 2, /* non-HNP/non-SRP */ .otg_ver = -1, .dma_enable = -1, -@@ -127,8 +127,8 @@ static const struct dwc2_core_params par +@@ -127,8 +157,38 @@ static const struct dwc2_core_params par .host_rx_fifo_size = 288, /* 288 DWORDs */ .host_nperio_tx_fifo_size = 128, /* 128 DWORDs */ .host_perio_tx_fifo_size = 96, /* 96 DWORDs */ @@ -40,15 +70,17 @@ Signed-off-by: Hauke Mehrtens - .max_packet_count = 511, + .max_transfer_size = -1, + .max_packet_count = -1, - .host_channels = -1, - .phy_type = -1, - .phy_utmi_width = -1, -@@ -140,8 +140,37 @@ static const struct dwc2_core_params par - .host_ls_low_power_phy_clk = -1, - .ts_dline = -1, - .reload_ctl = -1, -- .ahbcfg = GAHBCFG_HBSTLEN_INCR16 << -- GAHBCFG_HBSTLEN_SHIFT, ++ .host_channels = -1, ++ .phy_type = -1, ++ .phy_utmi_width = -1, ++ .phy_ulpi_ddr = -1, ++ .phy_ulpi_ext_vbus = -1, ++ .i2c_enable = -1, ++ .ulpi_fs_ls = -1, ++ .host_support_fs_ls_low_power = -1, ++ .host_ls_low_power_phy_clk = -1, ++ .ts_dline = -1, ++ .reload_ctl = -1, + .ahbcfg = -1, + .uframe_sched = -1, + .external_id_pin_ctl = -1, @@ -68,28 +100,26 @@ Signed-off-by: Hauke Mehrtens + .host_perio_tx_fifo_size = 136, /* 136 DWORDs */ + .max_transfer_size = -1, + .max_packet_count = -1, -+ .host_channels = -1, -+ .phy_type = -1, -+ .phy_utmi_width = -1, -+ .phy_ulpi_ddr = -1, -+ .phy_ulpi_ext_vbus = -1, -+ .i2c_enable = -1, -+ .ulpi_fs_ls = -1, -+ .host_support_fs_ls_low_power = -1, -+ .host_ls_low_power_phy_clk = -1, -+ .ts_dline = -1, -+ .reload_ctl = -1, + .host_channels = -1, + .phy_type = -1, + .phy_utmi_width = -1, +@@ -140,8 +200,7 @@ static const struct dwc2_core_params par + .host_ls_low_power_phy_clk = -1, + .ts_dline = -1, + .reload_ctl = -1, +- .ahbcfg = GAHBCFG_HBSTLEN_INCR16 << +- GAHBCFG_HBSTLEN_SHIFT, + .ahbcfg = -1, .uframe_sched = -1, .external_id_pin_ctl = -1, .hibernation = -1, -@@ -341,8 +370,11 @@ static int dwc2_driver_remove(struct pla +@@ -341,8 +400,11 @@ static int dwc2_driver_remove(struct pla static const struct of_device_id dwc2_of_match_table[] = { { .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 }, { .compatible = "rockchip,rk3066-usb", .data = ¶ms_rk3066 }, - { .compatible = "lantiq,arx100-usb", .data = ¶ms_ltq }, - { .compatible = "lantiq,xrx200-usb", .data = ¶ms_ltq }, -+ { .compatible = "lantiq,danube-usb", .data = NULL }, ++ { .compatible = "lantiq,danube-usb", .data = ¶ms_danube }, + { .compatible = "lantiq,ase-usb", .data = ¶ms_ase }, + { .compatible = "lantiq,arx100-usb", .data = ¶ms_ase }, + { .compatible = "lantiq,xrx200-usb", .data = ¶ms_xrx200 }, diff --git a/target/linux/mediatek/patches-4.4/0001-NET-multi-phy-support.patch b/target/linux/mediatek/patches-4.4/0001-NET-multi-phy-support.patch index 6778dad0ba..717e2a5239 100644 --- a/target/linux/mediatek/patches-4.4/0001-NET-multi-phy-support.patch +++ b/target/linux/mediatek/patches-4.4/0001-NET-multi-phy-support.patch @@ -11,7 +11,7 @@ Signed-off-by: John Crispin --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c -@@ -893,7 +893,8 @@ void phy_state_machine(struct work_struc +@@ -890,7 +890,8 @@ void phy_state_machine(struct work_struc /* If the link is down, give up on negotiation for now */ if (!phydev->link) { phydev->state = PHY_NOLINK; @@ -21,7 +21,7 @@ Signed-off-by: John Crispin phydev->adjust_link(phydev->attached_dev); break; } -@@ -985,7 +986,8 @@ void phy_state_machine(struct work_struc +@@ -982,7 +983,8 @@ void phy_state_machine(struct work_struc netif_carrier_on(phydev->attached_dev); } else { phydev->state = PHY_NOLINK; @@ -31,7 +31,7 @@ Signed-off-by: John Crispin } phydev->adjust_link(phydev->attached_dev); -@@ -997,7 +999,8 @@ void phy_state_machine(struct work_struc +@@ -994,7 +996,8 @@ void phy_state_machine(struct work_struc case PHY_HALTED: if (phydev->link) { phydev->link = 0; diff --git a/target/linux/mvebu/patches-4.4/125-phy-provide-a-hook-for-link-up-link-down-events.patch b/target/linux/mvebu/patches-4.4/125-phy-provide-a-hook-for-link-up-link-down-events.patch index 75d30f6a08..a27e6baec3 100644 --- a/target/linux/mvebu/patches-4.4/125-phy-provide-a-hook-for-link-up-link-down-events.patch +++ b/target/linux/mvebu/patches-4.4/125-phy-provide-a-hook-for-link-up-link-down-events.patch @@ -22,7 +22,7 @@ Signed-off-by: Russell King --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c -@@ -852,6 +852,16 @@ void phy_start(struct phy_device *phydev +@@ -849,6 +849,16 @@ void phy_start(struct phy_device *phydev } EXPORT_SYMBOL(phy_start); @@ -39,7 +39,7 @@ Signed-off-by: Russell King /** * phy_state_machine - Handle the state machine * @work: work_struct that describes the work to be done -@@ -893,8 +903,7 @@ void phy_state_machine(struct work_struc +@@ -890,8 +900,7 @@ void phy_state_machine(struct work_struc /* If the link is down, give up on negotiation for now */ if (!phydev->link) { phydev->state = PHY_NOLINK; @@ -49,7 +49,7 @@ Signed-off-by: Russell King break; } -@@ -906,9 +915,7 @@ void phy_state_machine(struct work_struc +@@ -903,9 +912,7 @@ void phy_state_machine(struct work_struc /* If AN is done, we're running */ if (err > 0) { phydev->state = PHY_RUNNING; @@ -60,7 +60,7 @@ Signed-off-by: Russell King } else if (0 == phydev->link_timeout--) needs_aneg = true; break; -@@ -933,8 +940,7 @@ void phy_state_machine(struct work_struc +@@ -930,8 +937,7 @@ void phy_state_machine(struct work_struc } } phydev->state = PHY_RUNNING; @@ -70,7 +70,7 @@ Signed-off-by: Russell King } break; case PHY_FORCING: -@@ -944,13 +950,12 @@ void phy_state_machine(struct work_struc +@@ -941,13 +947,12 @@ void phy_state_machine(struct work_struc if (phydev->link) { phydev->state = PHY_RUNNING; @@ -86,7 +86,7 @@ Signed-off-by: Russell King break; case PHY_RUNNING: /* Only register a CHANGE if we are polling or ignoring -@@ -982,14 +987,12 @@ void phy_state_machine(struct work_struc +@@ -979,14 +984,12 @@ void phy_state_machine(struct work_struc if (phydev->link) { phydev->state = PHY_RUNNING; @@ -103,7 +103,7 @@ Signed-off-by: Russell King if (phy_interrupt_is_valid(phydev)) err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED); -@@ -997,8 +1000,7 @@ void phy_state_machine(struct work_struc +@@ -994,8 +997,7 @@ void phy_state_machine(struct work_struc case PHY_HALTED: if (phydev->link) { phydev->link = 0; @@ -113,7 +113,7 @@ Signed-off-by: Russell King do_suspend = true; } break; -@@ -1018,11 +1020,11 @@ void phy_state_machine(struct work_struc +@@ -1015,11 +1017,11 @@ void phy_state_machine(struct work_struc if (phydev->link) { phydev->state = PHY_RUNNING; @@ -127,7 +127,7 @@ Signed-off-by: Russell King } else { phydev->state = PHY_AN; phydev->link_timeout = PHY_AN_TIMEOUT; -@@ -1034,11 +1036,11 @@ void phy_state_machine(struct work_struc +@@ -1031,11 +1033,11 @@ void phy_state_machine(struct work_struc if (phydev->link) { phydev->state = PHY_RUNNING; diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh index 4ed18d7f0f..cf3d2ca9c9 100644 --- a/target/linux/ramips/base-files/etc/diag.sh +++ b/target/linux/ramips/base-files/etc/diag.sh @@ -24,6 +24,7 @@ get_status_led() { dir-860l-b1|\ e1700|\ fonera20n|\ + hg255d|\ kn_rc|\ kn_rf|\ kng_rc|\ diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index e27c405b3c..c2c0ae271d 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -38,7 +38,7 @@ define Device/ArcherC20i KERNEL := $(KERNEL_DTB) KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherC20i -c IMAGE/factory.bin := append-kernel | tplink-header ArcherC20i -j - IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherC20i -j | append-metadata + IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherC20i -j -s | append-metadata IMAGES += factory.bin DEVICE_TITLE := TP-Link ArcherC20i endef @@ -50,7 +50,7 @@ define Device/ArcherC50 KERNEL := $(KERNEL_DTB) KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherC50 -c IMAGE/factory.bin := append-kernel | tplink-header ArcherC50 -j - IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherC50 -j | append-metadata + IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherC50 -j -s | append-metadata IMAGES += factory.bin DEVICE_TITLE := TP-Link ArcherC50 endef @@ -61,7 +61,7 @@ define Device/ArcherMR200 SUPPORTED_DEVICES := mr200 KERNEL := $(KERNEL_DTB) KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherMR200 -c - IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherMR200 -j | append-metadata + IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherMR200 -j -s | append-metadata DEVICE_PACKAGES := kmod-usb2 kmod-usb-net kmod-usb-net-rndis kmod-usb-serial kmod-usb-serial-option adb DEVICE_TITLE := TP-Link ArcherMR200 endef diff --git a/target/linux/ramips/patches-4.4/0034-NET-multi-phy-support.patch b/target/linux/ramips/patches-4.4/0034-NET-multi-phy-support.patch index bb55c120da..b6ab65a553 100644 --- a/target/linux/ramips/patches-4.4/0034-NET-multi-phy-support.patch +++ b/target/linux/ramips/patches-4.4/0034-NET-multi-phy-support.patch @@ -11,7 +11,7 @@ Signed-off-by: John Crispin --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c -@@ -893,7 +893,8 @@ void phy_state_machine(struct work_struc +@@ -890,7 +890,8 @@ void phy_state_machine(struct work_struc /* If the link is down, give up on negotiation for now */ if (!phydev->link) { phydev->state = PHY_NOLINK; @@ -21,7 +21,7 @@ Signed-off-by: John Crispin phydev->adjust_link(phydev->attached_dev); break; } -@@ -985,7 +986,8 @@ void phy_state_machine(struct work_struc +@@ -982,7 +983,8 @@ void phy_state_machine(struct work_struc netif_carrier_on(phydev->attached_dev); } else { phydev->state = PHY_NOLINK; @@ -31,7 +31,7 @@ Signed-off-by: John Crispin } phydev->adjust_link(phydev->attached_dev); -@@ -997,7 +999,8 @@ void phy_state_machine(struct work_struc +@@ -994,7 +996,8 @@ void phy_state_machine(struct work_struc case PHY_HALTED: if (phydev->link) { phydev->link = 0; diff --git a/target/linux/sunxi/Makefile b/target/linux/sunxi/Makefile index b0bc1bab39..3c2f14b841 100644 --- a/target/linux/sunxi/Makefile +++ b/target/linux/sunxi/Makefile @@ -27,7 +27,7 @@ KERNELNAME:=zImage dtbs include $(INCLUDE_DIR)/target.mk -DEFAULT_PACKAGES += uboot-envtools kmod-eeprom-sunxi kmod-wdt-sunxi +DEFAULT_PACKAGES += uboot-envtools DEFAULT_PACKAGES += mkf2fs e2fsprogs $(eval $(call BuildTarget)) diff --git a/target/linux/sunxi/config-4.4 b/target/linux/sunxi/config-4.4 index 2253afa124..a978e9d15b 100644 --- a/target/linux/sunxi/config-4.4 +++ b/target/linux/sunxi/config-4.4 @@ -356,7 +356,7 @@ CONFIG_NO_HZ_COMMON=y CONFIG_NO_HZ_IDLE=y CONFIG_NR_CPUS=8 CONFIG_NVMEM=y -# CONFIG_NVMEM_SUNXI_SID is not set +CONFIG_NVMEM_SUNXI_SID=y CONFIG_OF=y CONFIG_OF_ADDRESS=y CONFIG_OF_EARLY_FLATTREE=y diff --git a/target/linux/sunxi/modules.mk b/target/linux/sunxi/modules.mk index 6f4991798d..99b82a3b5f 100644 --- a/target/linux/sunxi/modules.mk +++ b/target/linux/sunxi/modules.mk @@ -25,7 +25,7 @@ $(eval $(call KernelPackage,rtc-sunxi)) define KernelPackage/sunxi-ir SUBMENU:=$(OTHER_MENU) TITLE:=Sunxi SoC built-in IR support (A20) - DEPENDS:=@TARGET_sunxi @!LINUX_4_4 +kmod-input-core + DEPENDS:=@TARGET_sunxi +kmod-input-core $(call AddDepends/rtc) KCONFIG:= \ CONFIG_MEDIA_SUPPORT=y \ @@ -42,22 +42,6 @@ endef $(eval $(call KernelPackage,sunxi-ir)) -define KernelPackage/eeprom-sunxi - SUBMENU:=$(OTHER_MENU) - TITLE:=AllWinner Security ID fuse support - DEPENDS:=@TARGET_sunxi @!LINUX_4_4 - KCONFIG:= \ - CONFIG_EEPROM_SUNXI_SID - FILES:=$(LINUX_DIR)/drivers/misc/eeprom/sunxi_sid.ko - AUTOLOAD:=$(call AutoLoad,50,sunxi_sid) -endef - -define KernelPackage/eeprom-sunxi/description - Support for the AllWinner Security ID fuse support -endef - -$(eval $(call KernelPackage,eeprom-sunxi)) - define KernelPackage/ata-sunxi TITLE:=AllWinner sunXi AHCI SATA support SUBMENU:=$(BLOCK_MENU) @@ -76,7 +60,7 @@ $(eval $(call KernelPackage,ata-sunxi)) define KernelPackage/sun4i-emac SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=AllWinner EMAC Ethernet support - DEPENDS:=@TARGET_sunxi +LINUX_4_4:kmod-of-mdio +LINUX_4_4:kmod-libphy + DEPENDS:=@TARGET_sunxi +kmod-of-mdio +kmod-libphy KCONFIG:=CONFIG_SUN4I_EMAC FILES:=$(LINUX_DIR)/drivers/net/ethernet/allwinner/sun4i-emac.ko AUTOLOAD:=$(call AutoProbe,sun4i-emac) @@ -85,35 +69,11 @@ endef $(eval $(call KernelPackage,sun4i-emac)) -define KernelPackage/wdt-sunxi - SUBMENU:=$(OTHER_MENU) - TITLE:=AllWinner sunXi Watchdog timer - DEPENDS:=@TARGET_sunxi - KCONFIG:=CONFIG_SUNXI_WATCHDOG - FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/sunxi_wdt.ko - AUTOLOAD:=$(call AutoLoad,51,sunxi_wdt) -endef - -define KernelPackage/wdt-sunxi/description - Kernel module for AllWinner sunXi watchdog timer. -endef - -$(eval $(call KernelPackage,wdt-sunxi)) - - define KernelPackage/sound-soc-sunxi TITLE:=AllWinner built-in SoC sound support - KCONFIG:= \ - CONFIG_SND_SUNXI_SOC_CODEC \ - CONFIG_SND_SUN4I_CODEC -ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),lt,4.4.0)),1) - FILES+=$(LINUX_DIR)/sound/soc/sunxi/sunxi-codec.ko - AUTOLOAD:=$(call AutoLoad,65,sunxi-codec) -endif -ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,4.4.0)),1) + KCONFIG:=CONFIG_SND_SUN4I_CODEC FILES:=$(LINUX_DIR)/sound/soc/sunxi/sun4i-codec.ko AUTOLOAD:=$(call AutoLoad,65,sun4i-codec) -endif DEPENDS:=@TARGET_sunxi +kmod-sound-soc-core $(call AddDepends/sound) endef diff --git a/toolchain/gcc/patches/5.4.0/030-macos-header-fix-backport.patch b/toolchain/gcc/patches/5.4.0/030-macos-header-fix-backport.patch new file mode 100644 index 0000000000..37c774e0b2 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/030-macos-header-fix-backport.patch @@ -0,0 +1,10 @@ +--- a/gcc/system.h ++++ b/gcc/system.h +@@ -216,6 +216,7 @@ extern int errno; + + #ifdef __cplusplus + # include ++# include + # include + # include + #endif diff --git a/toolchain/gdb/Makefile b/toolchain/gdb/Makefile index 8a18d3ec07..e6c845a819 100644 --- a/toolchain/gdb/Makefile +++ b/toolchain/gdb/Makefile @@ -17,11 +17,11 @@ PKG_HASH:=6a91f86cc487c1548d3f5d4f29f7226d2019c0db8a63633aeabd5914a340f3f9 GDB_DIR:=binutils-$(PKG_NAME)-$(PKG_VERSION) PATCH_DIR:=./patches-arc else -PKG_VERSION:=7.12.1 +PKG_VERSION:=8.0.1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/gdb -PKG_HASH:=4607680b973d3ec92c30ad029f1b7dbde3876869e6b3a117d8a7e90081113186 +PKG_HASH:=3dbd5f93e36ba2815ad0efab030dcd0c7b211d7b353a40a53f4c02d7d56295e3 GDB_DIR:=$(PKG_NAME)-$(PKG_VERSION) endif diff --git a/toolchain/gdb/patches/110-no_testsuite.patch b/toolchain/gdb/patches/110-no_testsuite.patch index 68d1c90359..e86ba6d0cd 100644 --- a/toolchain/gdb/patches/110-no_testsuite.patch +++ b/toolchain/gdb/patches/110-no_testsuite.patch @@ -1,6 +1,6 @@ --- a/gdb/configure +++ b/gdb/configure -@@ -874,8 +874,7 @@ MAKEINFOFLAGS +@@ -869,8 +869,7 @@ MAKEINFOFLAGS YACC YFLAGS XMKMF' @@ -10,7 +10,7 @@ multi-ice gdbserver' -@@ -5617,7 +5616,7 @@ $as_echo "$with_auto_load_safe_path" >&6 +@@ -6473,7 +6472,7 @@ $as_echo "$with_auto_load_safe_path" >&6 diff --git a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch index 562902c50f..9ce91a024b 100644 --- a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch +++ b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch @@ -1,6 +1,6 @@ --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure -@@ -2476,7 +2476,7 @@ $as_echo "$as_me: error: \`$ac_var' was +@@ -2469,7 +2469,7 @@ $as_echo "$as_me: error: \`$ac_var' was ac_cache_corrupted=: ;; ,);; *) diff --git a/tools/cmake/patches/010-backport-macos-fix.patch b/tools/cmake/patches/010-backport-macos-fix.patch new file mode 100644 index 0000000000..76e92dcb0e --- /dev/null +++ b/tools/cmake/patches/010-backport-macos-fix.patch @@ -0,0 +1,15 @@ +--- a/Source/kwsys/kwsysPlatformTestsCXX.cxx ++++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx +@@ -265,6 +265,12 @@ int main() + #ifdef TEST_KWSYS_CXX_HAS_UTIMENSAT + #include + #include ++#if defined(__APPLE__) ++#include ++#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300 ++#error "utimensat not available on macOS < 10.13" ++#endif ++#endif + int main() + { + struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, UTIME_NOW } };