From e56960b81e820dd1dbcd78ab3fbdb68619c3f70b Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Thu, 26 Aug 2021 21:13:59 +0800 Subject: [PATCH] v2rayA: add new package 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 (cherry picked from commit 90ec599f9ef7aa011febe5528ba8b0b2016bfe02) --- net/v2raya/Makefile | 75 ++++++++++++++++++++++++++++++++++ net/v2raya/files/v2raya.config | 25 ++++++++++++ net/v2raya/files/v2raya.init | 59 ++++++++++++++++++++++++++ net/v2raya/test.sh | 3 ++ 4 files changed, 162 insertions(+) create mode 100644 net/v2raya/Makefile create mode 100644 net/v2raya/files/v2raya.config create mode 100755 net/v2raya/files/v2raya.init create mode 100644 net/v2raya/test.sh diff --git a/net/v2raya/Makefile b/net/v2raya/Makefile new file mode 100644 index 0000000000..d06f5fedaa --- /dev/null +++ b/net/v2raya/Makefile @@ -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 + +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 index 0000000000..7a7926873f --- /dev/null +++ b/net/v2raya/files/v2raya.config @@ -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 index 0000000000..e98ad5cd9a --- /dev/null +++ b/net/v2raya/files/v2raya.init @@ -0,0 +1,59 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2021 Tianling Shen + +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 index 0000000000..2c53d5fe14 --- /dev/null +++ b/net/v2raya/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +v2raya --version | grep "$PKG_VERSION" -- 2.30.2