--- /dev/null
+# SPDX-License-Identifier: GPL-3.0-only
+#
+# Copyright (C) 2021 ImmortalWrt.org
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=v2rayA
+PKG_VERSION:=2.0.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/v2rayA/v2rayA/tar.gz/v$(PKG_VERSION)?
+PKG_HASH:=857600f5f2b47e4df9f360b88df6b373425c1f7e2bec5d9a3f15938903410f1c
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/service
+
+PKG_LICENSE:=AGPL-3.0-only
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
+
+PKG_BUILD_DEPENDS:=golang/host
+PKG_BUILD_PARALLEL:=1
+PKG_USE_MIPS16:=0
+
+GO_PKG:=github.com/v2rayA/v2rayA
+GO_PKG_LDFLAGS_X:=$(GO_PKG)/conf.Version=$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
+
+TAR_OPTIONS+= --strip-components 1
+TAR_CMD=$(HOST_TAR) -C $(1)/.. $(TAR_OPTIONS)
+
+define Package/v2raya-v5
+ TITLE:=A Linux web GUI client of Project V
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Web Servers/Proxies
+ DEPENDS:=$(GO_ARCH_DEPENDS) \
+ +ca-bundle \
+ +iptables \
+ +IPV6:ip6tables \
+ +iptables-mod-conntrack-extra \
+ +iptables-mod-extra \
+ +iptables-mod-filter \
+ +iptables-mod-tproxy \
+ +kmod-ipt-nat6 \
+ +v2ray-v5-core
+ CONFLICTS:=v2raya
+ URL:=https://v2raya.org
+endef
+
+define Package/v2raya-v5/description
+ v2rayA is a V2Ray Linux client supporting global transparent proxy,
+ compatible with SS, SSR, Trojan(trojan-go), PingTunnel protocols.
+endef
+
+define Package/v2raya-v5/conffiles
+/etc/v2raya/
+/etc/config/v2raya
+endef
+
+WEB_FILE:=$(PKG_NAME)-web-$(PKG_VERSION).tar.gz
+define Download/v2raya-web
+ URL:=https://codeload.github.com/v2rayA/v2raya-web/tar.gz/v$(PKG_VERSION)?
+ URL_FILE:=$(WEB_FILE)
+ FILE:=$(WEB_FILE)
+ HASH:=3132020db37e165e8c65fe343168f989fe4334549459289110960cc27b0c6c00
+endef
+
+GO_PKG_TARGET_VARS:=$(filter-out CGO_ENABLED=%,$(GO_PKG_TARGET_VARS)) CGO_ENABLED=0
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+
+ ( \
+ mkdir -p $(PKG_BUILD_DIR)/server/router/web ; \
+ gzip -dc $(DL_DIR)/$(WEB_FILE) | $(HOST_TAR) -C $(PKG_BUILD_DIR)/server/router/web $(TAR_OPTIONS) ; \
+ )
+endef
+
+define Package/v2raya-v5/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 Download,v2raya-web))
+$(eval $(call GoBinPackage,v2raya-v5))
+$(eval $(call BuildPackage,v2raya-v5))
--- /dev/null
+
+config v2raya 'config'
+ option enabled '0'
+
+ # Listening address
+ option address '0.0.0.0:2017'
+
+ # v2rayA configuration directory
+ option config '/etc/v2raya'
+
+ # Make sure your IPv6 network works fine before you turn it on.
+ # Optional values: auto, on, off.
+ option ipv6_support 'auto'
+
+ # Optional values: trace, debug, info, warn or error
+ option log_level 'info'
+
+ # The path of log file
+ option log_file '/var/log/v2raya/v2raya.log'
+
+ # Maximum number of days to keep log files
+ option log_max_days '3'
+
+ option log_disable_color '1'
+
+ option log_disable_timestamp '0'
+
+ # 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_confdir ''
+
+ # The executable file to run in the transparent proxy life-cycle.
+ # v2rayA will pass in the --transparent-type (tproxy, redirect)
+ # and --stage (pre-start, post-start, pre-stop, post-stop) arguments.
+ option transparent_hook ''
+
+ # The executable file to run in the v2ray-core life-cycle.
+ # v2rayA will pass in the --stage (pre-start, post-start, pre-stop, post-stop) argument.
+ option core_hook ''
+
+ # The executable file to run in the v2ray-core life-cycle.
+ # v2rayA will pass in the --stage (pre-start, post-start, pre-stop, post-stop) argument.
+ option plugin_manager ''
+
+ # Specify the certification path instead of automatically generating a self-signed certificate.
+ # Example: /etc/v2raya/grpc_certificate.crt,/etc/v2raya/grpc_private.key
+ option vless_grpc_inbound_cert_key ''
+
--- /dev/null
+#!/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_bool enabled "$1" "$2" "${3:-0}"
+ if [ "$enabled" -eq "1" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+append_env() {
+ procd_append_param env "V2RAYA_$(echo "$1" | tr "[a-z]" "[A-Z]")"="$2"
+}
+
+append_env_arg() {
+ local value
+ config_get value "$1" "$2" $3
+ [ -n "$value" ] && append_env "$2" "$value"
+}
+
+append_env_bool() {
+ is_enabled "$1" "$2" && append_env "$2" "true"
+}
+
+start_service() {
+ config_load "$CONF"
+
+ is_enabled "config" "enabled" || return 1
+
+ procd_open_instance "$CONF"
+ procd_set_param command "$PROG"
+ procd_set_param env XDG_DATA_HOME="/usr/share"
+
+ append_env_arg "config" "address" "0.0.0.0:2017"
+ append_env_arg "config" "config" "/etc/v2raya"
+ append_env_arg "config" "ipv6_support" "auto"
+ append_env_arg "config" "log_level" "info"
+ append_env_arg "config" "log_file" "/var/log/v2raya/v2raya.log"
+ append_env_arg "config" "log_max_days" "3"
+ append_env_arg "config" "v2ray_bin"
+ append_env_arg "config" "v2ray_confdir"
+ append_env_arg "config" "transparent_hook"
+ append_env_arg "config" "core_hook"
+ append_env_arg "config" "plugin_manager"
+ append_env_arg "config" "vless_grpc_inbound_cert_key"
+ append_env_bool "config" "log_disable_color"
+ append_env_bool "config" "log_disable_timestamp"
+
+ procd_set_param limits core="unlimited"
+ procd_set_param limits nofile="1000000 1000000"
+ procd_set_param respawn
+ procd_set_param stdout 1
+ procd_set_param stderr 1
+
+ procd_close_instance
+}
+
+reload_service() {
+ stop
+ start
+}
+
+service_triggers() {
+ procd_add_reload_trigger "$CONF"
+}
--- /dev/null
+From 38afbd4f03a7b1816b7da30e7c5f5f9eb167f222 Mon Sep 17 00:00:00 2001
+From: mzz2017 <mzz@tuta.io>
+Date: Sun, 11 Dec 2022 19:17:20 +0800
+Subject: [PATCH] fix: check the transport type to avoid abnormal exit of core
+
+---
+ service/core/serverObj/v2ray.go | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/core/serverObj/v2ray.go
++++ b/core/serverObj/v2ray.go
+@@ -333,6 +333,8 @@ func (v *V2Ray) Configuration(info Prior
+ Path: v.Path,
+ }
+ }
++ default:
++ return Configuration{}, fmt.Errorf("unexpected transport type: %v", v.Net)
+ }
+ if strings.ToLower(v.TLS) == "tls" {
+ core.StreamSettings.Security = "tls"
--- /dev/null
+#!/bin/sh
+
+v2raya --version | grep "$PKG_VERSION"