make kcptun/v2ray/ss as option of ssr plus

This commit is contained in:
coolsnowwolf 2018-11-11 01:13:29 +08:00
parent 2121e97d32
commit 366ad4ca67
2 changed files with 89 additions and 24 deletions

View File

@ -1,18 +1,83 @@
# 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 SSR Plus
LUCI_DEPENDS:=+shadowsocksr-libev-alt +shadowsocks-libev-ss-redir +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +bash +pdnsd-alt +wget
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-ssr-plus
PKG_VERSION:=1
PKG_RELEASE:=38
PO2LMO:=$(BUILD_DIR)/luci-base/po2lmo
include $(TOPDIR)/feeds/luci/luci.mk
include $(INCLUDE_DIR)/package.mk
# call BuildPackage - OpenWrt buildroot signature
define Package/$(PKG_NAME)/config
menu "Optional Packages"
depends on PACKAGE_$(PKG_NAME)
config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks
bool "Include Shadowsocks"
default n
config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray
bool "Include V2ray"
default n
config PACKAGE_$(PKG_NAME)_INCLUDE_kcptun
bool "Include kcptun"
default n
config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server
bool "Include ShadowsocksR Server"
default n
endmenu
endef
define Package/luci-app-ssr-plus
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=SS/SSR/V2Ray LuCI interface
PKGARCH:=all
DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +bash +pdnsd-alt +wget \
+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \
+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \
+PACKAGE_$(PKG_NAME)_INCLUDE_kcptun:kcptun \
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server:shadowsocksr-libev-server
endef
define Build/Prepare
endef
define Build/Compile
endef
define Package/luci-app-ssr-plus/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
cp -pR ./luasrc/* $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/
cp -pR ./root/* $(1)/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(PO2LMO) ./po/zh-cn/ssr-plus.po $(1)/usr/lib/lua/luci/i18n/ssr-plus.zh-cn.lmo
find $(1) -name *.lua -exec luac -s -o {} {} \;
endef
define Package/luci-app-ssr-plus/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
( . /etc/uci-defaults/luci-ssr-plus ) && rm -f /etc/uci-defaults/luci-ssr-plus
rm -f /tmp/luci-indexcache
chmod 755 /etc/init.d/shadowsocksr >/dev/null 2>&1
/etc/init.d/shadowsocksr enable >/dev/null 2>&1
fi
exit 0
endef
define Package/luci-app-ssr-plus/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
/etc/init.d/shadowsocksr disable
/etc/init.d/shadowsocksr stop
fi
exit 0
endef
$(eval $(call BuildPackage,luci-app-ssr-plus))

View File

@ -123,18 +123,18 @@ o:depends("type", "ssr")
o = s:option(Value, "alias", translate("Alias(optional)"))
if nixio.fs.access("/usr/bin/v2ray") then
o = s:option(ListValue, "type", translate("Server Node Type"))
o:value("ssr", translate("ShadowsocksR"))
if nixio.fs.access("/usr/bin/ss-redir") then
o:value("ss", translate("Shadowsocks New Version"))
o:value("v2ray", translate("V2Ray"))
o.description = translate("Using incorrect encryption mothod may causes service fail to start")
else
o = s:option(ListValue, "type", translate("Server Node Type"))
o:value("ssr", translate("ShadowsocksR"))
o:value("ss", translate("Shadowsocks New Version"))
o.description = translate("Using incorrect encryption mothod may causes service fail to start")
end
if nixio.fs.access("/usr/bin/v2ray/v2ray") then
o:value("v2ray", translate("V2Ray"))
end
o.description = translate("Using incorrect encryption mothod may causes service fail to start")
o = s:option(Value, "server", translate("Server Address"))
o.datatype = "host"
@ -347,18 +347,18 @@ function o.validate(self, value, section)
return value
end
kcp_enable:depends("type", "ssr")
kcp_enable:depends("type", "ss")
o:depends("type", "ssr")
o:depends("type", "ss")
o = s:option(Value, "kcp_password", translate("KcpTun Password"))
o.password = true
kcp_enable:depends("type", "ssr")
kcp_enable:depends("type", "ss")
o:depends("type", "ssr")
o:depends("type", "ss")
o = s:option(Value, "kcp_param", translate("KcpTun Param"))
o.default = "--nocomp"
kcp_enable:depends("type", "ssr")
kcp_enable:depends("type", "ss")
o:depends("type", "ssr")
o:depends("type", "ss")
end