v2rayA: add new package
authorTianling Shen <cnsztl@immortalwrt.org>
Thu, 26 Aug 2021 13:13:59 +0000 (21:13 +0800)
committerRosen Penev <rosenp@gmail.com>
Sun, 29 Aug 2021 17:13:45 +0000 (10:13 -0700)
v2rayA is a Linux web GUI client of Project V which supports V2Ray,
Xray, Shadowsocks, ShadowsocksR, Trojan and Pingtunnel.

Wiki: https://github.com/v2rayA/v2rayA/wiki

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
net/v2raya/Makefile [new file with mode: 0644]
net/v2raya/files/v2raya.config [new file with mode: 0644]
net/v2raya/files/v2raya.init [new file with mode: 0755]
net/v2raya/test.sh [new file with mode: 0644]

diff --git a/net/v2raya/Makefile b/net/v2raya/Makefile
new file mode 100644 (file)
index 0000000..d06f5fe
--- /dev/null
@@ -0,0 +1,75 @@
+# SPDX-License-Identifier: GPL-3.0-only
+#
+# Copyright (C) 2021 ImmortalWrt.org
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=v2rayA
+PKG_VERSION:=1.5.1
+PKG_RELEASE:=$(AUTORELEASE)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/v2rayA/v2rayA/tar.gz/v$(PKG_VERSION)?
+PKG_HASH:=232e61b76a03f28ab48cddc314ddf445ea3c625d7983679428a1328e8e84858e
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/service
+
+PKG_LICENSE:=GPL-3.0-only
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
+
+PKG_BUILD_DEPENDS:=golang/host node/host node-yarn/host
+PKG_BUILD_PARALLEL:=1
+PKG_USE_MIPS16:=0
+
+GO_PKG:=github.com/v2rayA/v2rayA
+GO_PKG_LDFLAGS:=-s -w
+GO_PKG_LDFLAGS_X:=$(GO_PKG)/global.Version=$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+include ../../lang/golang/golang-package.mk
+
+TAR_OPTIONS+= --strip-components 1
+TAR_CMD=$(HOST_TAR) -C $(1)/.. $(TAR_OPTIONS)
+
+define Package/v2rayA
+  TITLE:=A Linux web GUI client of Project V
+  SECTION:=net
+  CATEGORY:=Network
+  SUBMENU:=Web Servers/Proxies
+  DEPENDS:=$(GO_ARCH_DEPENDS) \
+    +ca-bundle \
+    +iptables-mod-filter \
+    +iptables-mod-tproxy \
+    +kmod-ipt-nat6 \
+    +xray-core
+  URL:=https://v2raya.org
+endef
+
+define Package/v2rayA/description
+  v2rayA is a V2Ray Linux client supporting global transparent proxy,
+  compatible with SS, SSR, Trojan(trojan-go), PingTunnel protocols.
+endef
+
+define Build/Compile
+       ( \
+               pushd $(PKG_BUILD_DIR)/../gui ; \
+               yarn ; \
+               OUTPUT_DIR=../service/server/router/web yarn build ; \
+               popd ; \
+               $(call GoPackage/Build/Compile) ; \
+       )
+endef
+
+define Package/v2rayA/install
+       $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
+       $(INSTALL_DIR) $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2rayA $(1)/usr/bin/v2raya
+
+       $(INSTALL_DIR) $(1)/etc/config/
+       $(INSTALL_CONF) $(CURDIR)/files/v2raya.config $(1)/etc/config/v2raya
+       $(INSTALL_DIR) $(1)/etc/init.d/
+       $(INSTALL_BIN) $(CURDIR)/files/v2raya.init $(1)/etc/init.d/v2raya
+endef
+
+$(eval $(call GoBinPackage,v2rayA))
+$(eval $(call BuildPackage,v2rayA))
diff --git a/net/v2raya/files/v2raya.config b/net/v2raya/files/v2raya.config
new file mode 100644 (file)
index 0000000..7a79268
--- /dev/null
@@ -0,0 +1,25 @@
+
+config v2raya 'config'
+       option enabled '0'
+
+       # Listening address
+       option address '0.0.0.0:2017'
+
+       # v2rayA configuration directory
+       option config '/etc/v2raya'
+
+       # force open ipv6
+       option force_ipv6_on '0'
+
+       # ssr, pingTunnel, etc.
+       option plugin_listen_port '32346'
+
+       # Executable v2ray binary path. Auto-detect if put it empty
+       option v2ray_bin ''
+
+       # Additional v2ray config directory, files in it will be combined with config generated by v2rayA
+       option v2ray_config ''
+
+       # Print detailed v2ray-core log to stdout
+       option verbose '0'
+
diff --git a/net/v2raya/files/v2raya.init b/net/v2raya/files/v2raya.init
new file mode 100755 (executable)
index 0000000..e98ad5c
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>
+
+USE_PROCD=1
+START=99
+
+CONF="v2raya"
+PROG="/usr/bin/v2raya"
+
+is_enabled() {
+       local enabled
+       config_get enabled "$1" "$2" "${3:-0}"
+       if [ "$enabled" -eq "1" ]; then
+               return 0
+       else
+               return 1
+       fi
+}
+
+append_param() {
+       procd_append_param command "$1" $2
+}
+
+append_param_arg() {
+       local value
+       config_get value "$1" "$2" $4
+       [ -n "$value" ] && append_param "$3" "$value"
+}
+
+start_service() {
+       config_load "$CONF"
+
+       is_enabled "config" "enabled" || exit 1
+
+       procd_open_instance "$CONF"
+       procd_set_param command "$PROG"
+
+       append_param_arg "config" "address" "--address" "0.0.0.0:2017"
+       append_param_arg "config" "config" "--config" "/etc/v2raya"
+       append_param_arg "config" "plugin_listen_port" "--pluginlistenport" "32346"
+       append_param_arg "config" "v2ray_bin" "--v2ray-bin"
+       append_param_arg "config" "v2ray_config" "--v2ray-config"
+       is_enabled "config" "force_ipv6_on" && append_param "--force_ipv6_on"
+       is_enabled "config" "verbose" && append_param "--verbose"
+
+       procd_set_param limits core="unlimited"
+       procd_set_param respawn
+
+       procd_close_instance
+}
+
+reload_service() {
+       stop
+       start
+}
+
+service_triggers() {
+       procd_add_reload_trigger "$CONF"
+}
diff --git a/net/v2raya/test.sh b/net/v2raya/test.sh
new file mode 100644 (file)
index 0000000..2c53d5f
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+v2raya --version | grep "$PKG_VERSION"