merge to LEDE 17.01.3 stable version

This commit is contained in:
coolsnowwolf 2017-10-09 23:46:23 +08:00
parent 6b790ae7c1
commit 91911262a6
124 changed files with 5208 additions and 929 deletions

View File

@ -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)

View File

@ -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)))

2
include/site/darwin Normal file
View File

@ -0,0 +1,2 @@
ac_cv_func_futimens=no
ac_cv_func_utimensat=no

View File

@ -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),)

View File

@ -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

View File

@ -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
;;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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)"

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -70,7 +70,8 @@ o.description = translate(string.format("%s<br /><br />", Status))
o.description = translate(string.format("<strong>Lazy Rule</strong>%s <strong>&nbsp;&nbsp;Video Rule</strong>%s<br /><strong>Third Party Subscription Rule</strong>%d lines&nbsp;&nbsp;<strong>User-defined Rule</strong>%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("<strong><font color=blue>Adblock Plus Host List</font></strong> %s Lines<br /><br />", ND))
updatead = s:taboption("advanced", Button, "updatead", translate("Manually force update<br />Adblock Plus Host List"), translate("Note: It needs to download and convert the rules. The background process may takes 60-120 seconds to run. <br / > 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

View File

@ -114,5 +114,12 @@ msgstr "<strong><font color=blue>Adblock Plus Host 列表:</font></strong>"
msgid "Note: It needs to download and convert the rules. The background process may takes 60-120 seconds to run. <br / > 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 "优先从官方网站更新规则"

View File

@ -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

View File

@ -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.

View File

@ -0,0 +1,86 @@
#
# Copyright (C) 2016 chenhw2 <chenhw2@github.com>
#
# 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 <chenhw2@github.com>
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))

View File

@ -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

View File

@ -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 "上游服务器"

View File

@ -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"),
"<a target=\"_blank\" href=\"http://%s:%s\">%s</a>" %{
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

View File

@ -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'

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,247 @@
/*
* lmo - Lua Machine Objects - PO to LMO conversion tool
*
* Copyright (C) 2009-2012 Jo-Philipp Wich <xm@subsignal.org>
*
* 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);
}

View File

@ -0,0 +1,328 @@
/*
* lmo - Lua Machine Objects - Base functions
*
* Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
*
* 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;
}
}
}

View File

@ -0,0 +1,92 @@
/*
* lmo - Lua Machine Objects - General header
*
* Copyright (C) 2009-2012 Jo-Philipp Wich <xm@subsignal.org>
*
* 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 <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <errno.h>
#include <fnmatch.h>
#include <dirent.h>
#include <ctype.h>
#include <limits.h>
#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

View File

@ -0,0 +1,35 @@
#
# Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
# 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 <kuoruan@gmail.com>
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

View File

@ -0,0 +1,120 @@
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
-- 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

View File

@ -0,0 +1,182 @@
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
-- 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

View File

@ -0,0 +1,71 @@
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
-- 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

View File

@ -0,0 +1,112 @@
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
-- 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

View File

@ -0,0 +1,486 @@
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
-- 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

View File

@ -0,0 +1,19 @@
<%#
Copyright 2017 Hsing-wang Liao <kuoruan@gmail.com>
Licensed to the public under the Apache License 2.0.
-%>
<%+cbi/valueheader%>
<% if self:cfgvalue(section) ~= false then %>
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" 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")
%> />
<span id="<%=self.id or cbid%>-detail"></span>
<% else %>
-
<% end %>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,74 @@
<%#
Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
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%>
<div class="cbi-map">
<h2 name="content"><%:Kcptun%> - <%:Log Data%></h2>
<fieldset class="cbi-section">
<div class="cbi-section-descr">
<input type="button" class="cbi-button" value="<%:Clear Log File%>" placeholder="<%:Clear Log File%>" onclick="return log_clear('client', this)" />
</div>
<fieldset class="cbi-section-node">
<div id="log_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /><%:Collecting data...%></div>
<div style="text-align:right"><small><%:Refresh every 5 seconds.%></small></div>
</fieldset>
</fieldset>
</div>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
function log_clear(type, btn) {
btn.disabled = true;
btn.value = '<%:Processing...%>';
(new XHR()).get('<%=luci.dispatcher.build_url("admin/services/kcptun/log/clear")%>/' + type,
{ token: '<%=token%>' },
function(x, json) {
btn.disabled = false;
btn.value = btn.placeholder;
}
);
return false;
}
(function(doc) {
var log_elm = doc.getElementById('log_text');
XHR.poll(5, '<%=luci.dispatcher.build_url("admin/services/kcptun/log/data")%>', null,
function(x, data) {
if (log_elm && data) {
log_elm.innerHTML = String.format(
'<pre>%s%s%s%s</pre>',
'<span class="description"><%:Last 50 lines of log file:%></span><br/><br/>',
data.client || '<%:No log data.%>',
'<br/><br/><span class="description"><%:Last 50 lines of syslog:%></span><br/><br/>',
data.syslog || '<%:No log data.%>'
);
} else if (log_elm) {
log_elm.innerHTML = '<strong><%:Error get log data.%></strong>';
}
}
);
}(document));
//]]></script>
<%+footer%>

View File

@ -0,0 +1,258 @@
<%#
Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
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()
-%>
<fieldset class="cbi-section">
<legend><%:Running Status%></legend>
<table width="100%" cellspacing="10" id="_kcptun-status_table">
<tr>
<td width="33%"><%:Client Version%></td>
<td>
<% if client_version == "" then -%>
<em><%:Invalid Client File.%></em>
<% else -%>
<%=pcdata(client_version)%>
<%- end %>
</td>
</tr>
<tr><td width="33%"><%:Client Status%></td><td id="_kcptun-client_status"><em><%:Collecting data...%></em></td></tr>
<% if luci_version ~= "" then -%>
<tr><td width="33%"><%:LuCI Version%></td><td><%=pcdata(luci_version)%></td></tr>
<% end -%>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
var client_status = document.getElementById('_kcptun-client_status');
XHR.poll(5, '<%=dsp.build_url("admin/services/kcptun/status")%>', null,
function(x, json) {
if (x && x.status == 200) {
client_status.innerHTML = json.client ? '<%:Running%>' : '<%:Not Running%>';
}
});
function add_remove_page_notice(isAdd) {
if (isAdd) {
window.onbeforeunload = function(e) {
var dialogText = '<%:Update in progress. Are you sure to close window?%>';
e.returnValue = dialogText;
return dialogText;
};
} else {
window.onbeforeunload = null;
}
}
function on_update_success(btn) {
add_remove_page_notice(false);
var success = '<%:Update Success.%>';
if (btn) {
btn.value = success;
btn.placeholder = success;
btn.disabled = true;
}
alert(success);
window.setTimeout(function () {
window.location.reload();
}, 500);
}
function on_request_error(btn, json) {
add_remove_page_notice(false);
if (btn) {
btn.disabled = false;
btn.value = btn.placeholder;
}
if (json && json.error) {
alert(json.error);
}
}
function createVersionUrl(version, url) {
var urlNode = '';
if (url) {
urlNode += '<a href="' + url + '" target="_blank">';
}
urlNode += '<em style="color:red;">' + version + '</em>';
if (url) {
urlNode += '</a>';
}
return urlNode;
}
var kcptun_info, luci_info;
var token_str = '<%=token%>';
var arch_select;
function init_arch_select() {
if (!arch_select) {
arch_select = document.getElementById('cbid.kcptun.general.arch');
arch_select.addEventListener('change', function() {
kcptun_info = null;
var check_kcptun_btn = document.getElementById('_kcptun-check_kcptun');
var text = '<%:Check Kcptun Update%>';
check_kcptun_btn.value = text;
check_kcptun_btn.placeholder = text;
check_kcptun_btn.setAttribute('onclick', 'check_update(\'kcptun\', this);');
var detail = document.getElementById('_kcptun-check_kcptun-detail');
detail.innerHTML = '';
});
}
}
function check_update(type, btn) {
btn.disabled = true;
btn.value = '<%:Processing...%>';
init_arch_select();
add_remove_page_notice(true);
(new XHR()).get('<%=dsp.build_url("admin/services/kcptun/check")%>/' + type, {
token: token_str,
arch: arch_select ? arch_select.value : ""
}, function(x, json) {
if (x && x.status == 200) {
var detailElm = document.getElementById(btn.id + '-detail');
if (json.code == 0) {
add_remove_page_notice(false);
if (json.update) {
eval(type + '_info = json');
btn.disabled = false;
btn.value = '<%:Click to Update%>';
btn.placeholder = '<%:Click to Update%>';
btn.setAttribute('onclick', 'do_' + type + '_update(this);');
if (detailElm) {
detailElm.innerHTML = createVersionUrl(json.version, json.url.html);
}
} else {
btn.disabled = true;
btn.value = '<%:No Update Found%>';
if (detailElm) {
detailElm.innerHTML = '';
}
}
} else {
if (detailElm && json.html_url) {
detailElm.innerHTML = createVersionUrl(json.version, json.html_url)
}
on_request_error(btn, json);
}
} else {
on_request_error(btn);
}
});
}
function do_kcptun_update(btn) {
btn.disabled = true;
btn.value = '<%:Downloading...%>';
add_remove_page_notice(true);
var kcptun_update_url = '<%=dsp.build_url("admin/services/kcptun/update/kcptun")%>';
(new XHR()).get(kcptun_update_url, {
token: token_str,
url: kcptun_info ? kcptun_info.url.download : ''
}, function (x, json) {
if (x && x.status == 200) {
if (json.code == 0) {
btn.value = '<%:Extracting...%>';
(new XHR()).get(kcptun_update_url, {
token: token_str,
task: "extract",
file: json.file,
subfix: kcptun_info ? kcptun_info.type : ''
}, function (x, json) {
if (x && x.status == 200) {
if (json.code == 0) {
btn.value = '<%:Moving...%>';
(new XHR()).get(kcptun_update_url, {
token: token_str,
task: "move",
file: json.file
}, function (x, json) {
if (x && x.status == 200) {
if (json.code == 0) {
on_update_success(btn);
} else {
on_request_error(btn, json);
}
} else {
on_request_error(btn);
}
});
} else {
on_request_error(btn, json);
}
} else {
on_request_error(btn);
}
});
} else {
on_request_error(btn, json);
}
} else {
on_request_error(btn);
}
});
}
function do_luci_update(btn) {
btn.disabled = true;
btn.value = '<%:Processing...%>';
add_remove_page_notice(true);
var save_config = document.getElementById('cbid.kcptun.general.save_config');
(new XHR()).get('<%=dsp.build_url("admin/services/kcptun/update/luci")%>', {
token: token_str,
url: luci_info ? luci_info.url.luci : '',
save: save_config ? save_config.checked : false
}, function(x, json) {
btn.disabled = false;
btn.value = btn.placeholder;
if (x && x.status == 200) {
if (json.code == 0) {
on_update_success(btn);
} else {
on_request_error(btn, json);
}
} else {
on_request_error(btn);
}
});
}
//]]></script>

View File

@ -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 ""

View File

@ -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 ""

View File

@ -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'

View File

@ -0,0 +1,244 @@
#!/bin/sh /etc/rc.common
#
# Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
#
# 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
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,25 @@
<%#
Copyright (C) 2017 Jian Chang <aa65535@live.com>
Licensed to the public under the GNU General Public License v3.
-%>
<script type="text/javascript" src="<%=resource%>/md5.js"></script>
<script type="text/javascript" src="<%=resource%>/sha1.js"></script>
<script type="text/javascript" src="<%=resource%>/rsa.js"></script>
<script type="text/javascript">
var kn = 'AC69F5CCC8BDE47CD3D371603748378C9CFAD2938A6B021E0E191013975AD683F5CBF9ADE8BD7D46B4D2EC2D78AF146F1DD2D50DC51446BB8880B8CE88D476694DFC60594393BEEFAA16F5DBCEBE22F89D640F5336E42F587DC4AFEDEFEAC36CF007009CCCE5C1ACB4FF06FBA69802A8085C2C54BADD0597FC83E6870F1E36FD';
var ke = '010001';
var rsa = new RSAKey();
rsa.setPublic(kn, ke);
</script>
<% include("cbi/map") %>
<script type="text/javascript">
<!-- var mac = document.getElementById('cbid.kuainiao.base.wanmac').value;-->
<!--var fake_device_id = md5(mac);-->
<!--var device_sign = "div100."+fake_device_id+md5(hex_sha1(fake_device_id+"com.xunlei.vip.swjsq68700d1872b772946a6940e4b51827e8af")); -->
var password = document.getElementById('cbid.kuainiao.base.kuainiao_passwd').value;
var encrypted_pwd = rsa.encrypt(md5(password));
var kuainiao_conf_pwd=encrypted_pwd.toUpperCase();
document.getElementById('cbid.kuainiao.base.kuainiao_config_pwd').value = kuainiao_conf_pwd;
<!-- document.getElementById('cbid.kuainiao.base.device_sign').value = device_sign; -->
</script>

View File

@ -0,0 +1,38 @@
<%#
Copyright 2017 Lede by stones
-%>
<% include("cbi/map") %>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "kuainiao", "status")%>', null,
function(x, result)
{
var status = document.getElementById('kuainiao_status');
status.innerHTML = result.running?'<font color=green><%=translate("RUNNING")%></font>':'<font color=red><%=translate("NOT RUNNING")%></font>';
}
);
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "kuainiao", "dwonstatus")%>', null,
function(x, result)
{
var dwonstatus = document.getElementById('dwon_status');
dwonstatus.innerHTML = (result.dwonstatus?result.dwonstatus:"--");
}
);
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "kuainiao", "upstatus")%>', null,
function(x, result)
{
var upstatus = document.getElementById('up_status');
upstatus.innerHTML = (result.upstatus?result.upstatus:"--");
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<%:快鸟运行状态:%><em id="kuainiao_status"><%:Collecting data...%></em>
<legend></legend>
<legend></legend>
<%:下行提速状态:%><em id="dwon_status"><%:Collecting data...%></em>
<legend></legend>
<%:上行提速状态:%><em id="up_status"><%:Collecting data...%></em>
</fieldset>

View File

@ -0,0 +1,4 @@
msgid "Kuai Niao"
msgstr "迅雷快鸟"

View File

@ -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'

View File

@ -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;
}

View File

@ -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 "<font color=red>暂无加速信息</font>" > /usr/share/kuainiao/kuainiao_down_state
echo "<font color=red>暂无加速信息</font>" > /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
}
}

View File

@ -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

View File

@ -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 "<font color=green>$kuainiao_down_state</font>" > $down_state_file
else
echo "<font color=red>$kuainiao_down_state</font>" > $down_state_file
fi
}
log_up(){
kuainiao_up_state=$1
status=$2
if [ "$status" -eq 1 ]; then
echo "<font color=green>$kuainiao_up_state</font>" > $up_state_file
else
echo "<font color=red>$kuainiao_up_state</font>" > $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 "<font color=red>暂无加速信息</font>" > $down_state_file
# echo "<font color=red>暂无加速信息</font>" > $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 "<font color=red>暂无加速信息</font>" > $down_state_file
echo "<font color=red>暂无加速信息</font>" > $up_state_file
exit 0
}
}

View File

@ -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

View File

@ -0,0 +1 @@
暂无加速信息

View File

@ -0,0 +1 @@
暂无加速信息

View File

@ -0,0 +1 @@
var md5; md5 || (md5 = function(){function i(a,b){a[b>>5]|=128<<b%32,a[(b+64>>>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<<b|a>>>32-b}function r(a){for(var b=[],d=(1<<c)-1,e=0;a.length*c>e;e+=c)b[e>>5]|=(a.charCodeAt(e/c)&d)<<e%32;return b}function t(b){for(var c=a?"0123456789ABCDEF":"0123456789abcdef",d="",e=0;b.length*4>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))}}());

File diff suppressed because one or more lines are too long

View File

@ -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;
}

View File

@ -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))

View File

@ -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

View File

@ -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+

View File

@ -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.
*/

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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
}
}

View File

@ -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;

View File

@ -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));

View File

@ -1,149 +0,0 @@
From f6bea86c78ba9efbd01da3dd2fb18764ec806290 Mon Sep 17 00:00:00 2001
From: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
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 <kevin@darbyshire-bryant.me.uk>
---
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, "<TXT>");
+#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))

View File

@ -35,13 +35,13 @@ Signed-off-by: Steven Barth <steven@midlink.org>
+ 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)

View File

@ -7,7 +7,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
--- 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 <sys/sockio.h>
#endif

View File

@ -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

View File

@ -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) ;;

View File

@ -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 <dedeckeh@gmail.com>
PKG_LICENSE:=GPL-2.0

View File

@ -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 <<EOF
set dhcp.odhcpd=odhcpd
set dhcp.odhcpd.maindhcp=0
set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
set dhcp.lan.dhcpv6=server
set dhcp.lan.ra=server
set dhcp.lan.dhcpv6=$MODE
set dhcp.lan.ra=$MODE
commit dhcp
EOF

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=openvpn
PKG_VERSION:=2.4.3
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE_URL:=\
https://build.openvpn.net/downloads/releases/ \

View File

@ -30,6 +30,7 @@ ecdh_curve
echo
engine
explicit_exit_notify
extra_certs
fragment
group
hand_window

View File

@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=ppp
PKG_VERSION:=2.4.7
PKG_RELEASE:=12
PKG_RELEASE:=11
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://download.samba.org/pub/ppp/
@ -35,7 +35,7 @@ endef
define Package/ppp
$(call Package/ppp/Default)
DEPENDS:=+kmod-ppp +libpthread +shellsync
DEPENDS:=+kmod-ppp
TITLE:=PPP daemon
VARIANT:=default
endef

View File

@ -17,13 +17,10 @@ proto_send_update "$PPP_IPPARAM"
}
if [ -n "$AUTOIPV6" ]; then
ZONE=$(fw3 -q network $PPP_IPPARAM 2>/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

View File

@ -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"} \

View File

@ -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 <unistd.h>
#include <fcntl.h>
#include <signal.h>
-#include <net/ethernet.h>
#include <net/if_arp.h>
#include <linux/ppp_defs.h>
#include <linux/if_pppox.h>
+#include <linux/if_ether.h>
#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 <linux/if.h>
-#elif defined(HAVE_NET_IF_H)
#include <net/if.h>
-#endif
#ifdef HAVE_NET_IF_TYPES_H
#include <net/if_types.h>
@@ -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 <linux/if_ether.h>
-#endif
-
#include <netinet/in.h>
-
-#ifdef HAVE_NETINET_IF_ETHER_H
-#include <sys/types.h>
-
@ -32,10 +28,21 @@
-#include <netinet/if_ether.h>
-#endif
-#endif
+#include <net/ethernet.h>
-
/* 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 <net/ethernet.h>
+#include <linux/if_ether.h>
#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 <unistd.h>
@@ -717,6 +718,23 @@ char *xstrdup(const char *s)
@@ -27,10 +28,6 @@
#include <linux/if_packet.h>
#endif
-#ifdef HAVE_NET_ETHERNET_H
-#include <net/ethernet.h>
-#endif
-
#ifdef HAVE_ASM_TYPES_H
#include <asm/types.h>
#endif
@@ -717,6 +714,23 @@ char *xstrdup(const char *s)
return ret;
}

View File

@ -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<stdio.h>
+#include<semaphore.h>
+#include<fcntl.h>
+#include<stdlib.h>
+#include<time.h>
+#include<errno.h>
+#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);

View File

@ -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);

View File

@ -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))

View File

@ -1,106 +0,0 @@
/*************************************************************************
> File Name: shellsync.c
> Author: GuoGuo
> Mail: gch981213@gmail.com
> Created Time: 20141106 191530
************************************************************************/
#include<stdio.h>
#include<semaphore.h>
#include<fcntl.h>
#include<stdlib.h>
#include<time.h>
#include<errno.h>
#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 <process num> <wait_timeout>\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;
}
}
}

View File

@ -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 <nbd@nbd.name>
PKG_LICENSE:=ISC

View File

@ -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

View File

@ -109,4 +109,4 @@ proto_3g_teardown() {
proto_kill_command "$interface"
}
[ -z "NOT_INCLUDED" ] || add_protocol 3g
[ -z "$NOT_INCLUDED" ] || add_protocol 3g

View File

@ -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

View File

@ -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/ \

View File

@ -0,0 +1,41 @@
From 358b2b131ad6c095696f20dcfa62b8305263f898 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
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, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, 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');

View File

@ -0,0 +1,33 @@
From 453e7a7a03a2cec749abd3878a48e728c515cca7 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
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);

View File

@ -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/

View File

@ -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);
}

View File

@ -1,4 +1,4 @@
#/bin/sh
#!/bin/sh
#
# Copyright (C) 2011 OpenWrt.org
#

View File

@ -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")

Some files were not shown because too many files have changed in this diff Show More