✨ Sync 2026-11-11 01:22:09

This commit is contained in:
github-actions[bot] committed 2026-11-11 01:22:09 +08:00
1 parent 9c5aa2e662
commit cc21462d8a
48 files changed
+9760 -59

No files matched your search

+190
View File
@@ -0,0 +1,190 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
# Copyright (C) 2026 Amr Fateem <amr.fateem@yahoo.com>
#
# v2rayA OpenWrt packaging.
#
# The structure follows the packaging work by Tianling Shen
# <cnsztl@immortalwrt.org> in the v2raya-openwrt feed and the OpenWrt
# packages feed, updated for the 2.5.x layout where the service and the
# matching v2raya_core binary are separate Go modules.
include $(TOPDIR)/rules.mk
PKG_NAME:=v2raya
PKG_VERSION:=2.5.14
PKG_RELEASE:=3
PKG_SOURCE:=v2rayA-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/v2rayA/v2rayA/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=skip
PKG_BUILD_DIR:=$(BUILD_DIR)/v2rayA-$(PKG_VERSION)/service
PKG_LICENSE:=AGPL-3.0-only
PKG_LICENSE_FILES:=../LICENSE
PKG_MAINTAINER:=Amr Fateem <amr.fateem@yahoo.com>
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16
# v2rayA 2.5.x needs Go 1.26+ and v2raya_core needs Go 1.27+. The host Go
# shipped by older OpenWrt releases is older than that, so let GOTOOLCHAIN
# fetch the matching toolchain from proxy.golang.org during the build.
# scripts/update-version.sh refreshes this after a major Go bump.
V2RAYA_GO_TOOLCHAIN?=go1.27.3+auto
GO_PKG:=github.com/v2rayA/v2rayA
GO_PKG_BUILD_PKG:=github.com/v2rayA/v2rayA
GO_PKG_LDFLAGS_X:= \
$(GO_PKG)/conf.Version=$(PKG_VERSION) \
$(GO_PKG)/kernel/iptables.TproxyNotSkipBr=true
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
# v2rayA's SQLite layer has no pure-Go driver for mips* or loong64. Those
# targets must use cgo (and therefore the target C toolchain); all other
# targets get fully static, CGO-free binaries so one build runs on every
# OpenWrt release with the same CPU architecture.
V2RAYA_CGO:=0
ifneq ($(filter mips% loong64,$(GO_ARCH)),)
V2RAYA_CGO:=1
endif
GO_PKG_TARGET_VARS:=$(filter-out CGO_ENABLED=%,$(GO_PKG_TARGET_VARS)) CGO_ENABLED=$(V2RAYA_CGO)
ifeq ($(V2RAYA_CGO),0)
GO_PKG_DEFAULT_LDFLAGS:=$(filter-out -linkmode external,$(GO_PKG_DEFAULT_LDFLAGS))
endif
GO_PKG_BUILD_VARS:=$(filter-out GOTOOLCHAIN=%,$(GO_PKG_BUILD_VARS)) GOTOOLCHAIN=$(V2RAYA_GO_TOOLCHAIN)
TAR_OPTIONS+= --strip-components 1
TAR_CMD=$(HOST_TAR) -C $(1)/.. $(TAR_OPTIONS)
# geoip.dat and geosite.dat are intentionally not hard dependencies: v2rayA
# downloads missing files on first start. Install v2raya-geoip and
# v2raya-geosite for offline/package-managed data.
define Package/v2raya
TITLE:=v2rayA - web client for its own Xray-based core
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
DEPENDS:=$(GO_ARCH_DEPENDS) \
+v2raya-core \
+ca-bundle \
+nftables \
+kmod-nft-tproxy \
+ip-full \
+kmod-tun
CONFLICTS:=v2raya-nextgen
URL:=https://github.com/v2rayA/v2rayA
endef
define Package/v2raya/description
v2rayA is a web client for its own Xray-based core. It imports
subscriptions and share links, selects the fastest node, and provides
transparent proxy on Linux.
This package tracks the current upstream 2.5.x release. It installs the
service together with the matching v2raya_core binary.
endef
define Package/v2raya/conffiles
/etc/config/v2raya
endef
define Package/v2raya/postinst
#!/bin/sh
[ -n "$${IPKG_INSTROOT}" ] || {
mkdir -p /etc/v2raya /var/log/v2raya
chmod 750 /etc/v2raya
chmod 755 /var/log/v2raya
/etc/init.d/v2raya enable
if [ "$$(uci -q get v2raya.config.enabled)" = "1" ]; then
/etc/init.d/v2raya restart
fi
}
endef
define Package/v2raya/prerm
#!/bin/sh
[ -n "$${IPKG_INSTROOT}" ] || {
[ "$$1" = "upgrade" ] && exit 0
/etc/init.d/v2raya stop
/etc/init.d/v2raya disable
}
endef
# v2rayA publishes the built web UI as web.tar.gz on its releases. The
# GitHub release CDN has been returning 504/404 for it, which makes every
# matrix build fail. Keep the 871 KiB asset in the package instead; the
# hash of the upstream v2.5.13 asset is
# 76774f195ee74604fbc43a48fe74e5f3363e81ec68af02d1c26feeeacc0f63ae.
define Build/Prepare
$(call Build/Prepare/Default)
# OpenWrt's LAN is a bridge (br-lan). v2rayA 2.5.x defaults to excluding
# br-* from transparent proxy, which silently bypasses every LAN client.
# The old OpenWrt package removed that exclusion with TproxyNotSkipBr;
# 2.5.x moved it into this stored default, so strip it here as well.
$(SED) 's/,br-\*"/"/' $(PKG_BUILD_DIR)/db/configure/setting.go
# v2rayA 2.2.7 (the old OpenWrt package) did not hijack DNS. 2.5.x turns
# DNS interception on by default and sends queries through the proxy. With
# a vless/ws or other UDP-incapable node this breaks all client DNS, so the
# OpenWrt default stays off. Users can still enable it in the web UI.
$(SED) 's/DnsHijack: *Yes,/DnsHijack: No,/' \
$(PKG_BUILD_DIR)/db/configure/setting.go
$(SED) '/if setting.DnsHijack == ""/,/}/ s/setting.DnsHijack = Yes/setting.DnsHijack = No/' \
$(PKG_BUILD_DIR)/db/configure/migrate_dns.go
# Router defaults: warn-level logging reduces flash writes, QUIC
# sniffing is pointless when the LAN QUIC block is in place, and the
# DNS cache is bounded for the case where a user enables the DNS
# module later.
$(SED) 's/LogLevel: *"info"/LogLevel: "warn"/' \
$(PKG_BUILD_DIR)/db/configure/setting.go
$(SED) 's/InboundSniffing: *"http,tls,quic"/InboundSniffing: "http,tls"/' \
$(PKG_BUILD_DIR)/db/configure/setting.go
$(SED) 's/DnsCacheSize: *4096/DnsCacheSize: 1024/' \
$(PKG_BUILD_DIR)/db/configure/setting.go
$(SED) 's/DnsPrefetch: *true/DnsPrefetch: false/' \
$(PKG_BUILD_DIR)/db/configure/setting.go
$(SED) 's/DnsNegativeCache: *true/DnsNegativeCache: false/' \
$(PKG_BUILD_DIR)/db/configure/setting.go
( \
mkdir -p $(PKG_BUILD_DIR)/server/router/web ; \
gzip -dc $(CURDIR)/files/web.tar.gz | $(HOST_TAR) -C $(PKG_BUILD_DIR)/server/router/web $(TAR_OPTIONS) ; \
)
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
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(CURDIR)/files/v2raya-detect $(1)/usr/libexec/v2raya-detect
# Keep the database and the web password across sysupgrade. Listing
# /etc/v2raya as an opkg conffile copies the whole directory and has
# broken real upgrades.
$(INSTALL_DIR) $(1)/lib/upgrade/keep.d
$(INSTALL_DATA) $(CURDIR)/files/v2raya.keep $(1)/lib/upgrade/keep.d/v2raya
$(INSTALL_DIR) $(1)/usr/share/v2raya
endef
$(eval $(call GoBinPackage,v2raya))
$(eval $(call BuildPackage,v2raya))
+131
View File
@@ -0,0 +1,131 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2026 Amr Fateem <amr.fateem@yahoo.com>
#
# Emit a small key=value report about installed proxy cores and services.
# Called by the LuCI overview; values are single-line and contain no newlines.
#
# This script is read-only. It never installs, removes, starts or stops
# anything. It exists so the UI can show that an existing Xray-core or
# sing-box installation is present and will not be duplicated or replaced.
set -u
first_bin() {
for path in "$@"; do
if [ -x "$path" ]; then
printf '%s' "$path"
return 0
fi
done
return 1
}
version_line() {
bin="$1"
shift
[ -n "$bin" ] || return 0
"$bin" "$@" 2>/dev/null | sed -n '1p' | tr -d '\r'
}
pkg_list=""
if command -v opkg >/dev/null 2>&1; then
pkg_list=$(opkg list-installed 2>/dev/null | awk '{ print $1 }')
elif command -v apk >/dev/null 2>&1; then
pkg_list=$(apk info 2>/dev/null)
fi
pkg_has() {
printf '%s\n' "$pkg_list" | grep -qx "$1"
}
core_bin=$(first_bin /usr/bin/v2raya_core /usr/sbin/v2raya_core) || core_bin=""
xray_bin=$(first_bin /usr/bin/xray /usr/sbin/xray /usr/bin/xray-core) || xray_bin=""
singbox_bin=$(first_bin /usr/bin/sing-box /usr/sbin/sing-box /usr/bin/singbox /usr/sbin/singbox) || singbox_bin=""
v2ray_bin=$(first_bin /usr/bin/v2ray /usr/sbin/v2ray /usr/bin/v2ray-core) || v2ray_bin=""
xray_pkg=0
pkg_has xray-core && xray_pkg=1
pkg_has xray && xray_pkg=1
singbox_pkg=0
pkg_has sing-box && singbox_pkg=1
v2ray_pkg=0
pkg_has v2ray-core && v2ray_pkg=1
pkg_has v2ray && v2ray_pkg=1
pkg_version() {
if command -v opkg >/dev/null 2>&1; then
opkg list-installed "$1" 2>/dev/null | awk '{ print $3 }' | sed -n '1p'
elif [ -f /lib/apk/db/installed ]; then
awk -v p="$1" '$0 == "P:" p { getline; sub(/^V:/, ""); print; exit }' \
/lib/apk/db/installed
fi
}
version_lt() {
[ -n "$1" ] || return 1
awk -v a="$1" -v b="$2" 'BEGIN {
n = split(a, x, "."); m = split(b, y, ".");
for (i = 1; i <= 3; i++) {
xs = (i <= n) ? x[i] : 0;
ys = (i <= m) ? y[i] : 0;
sub(/-.*/, "", xs); sub(/-.*/, "", ys);
if (xs + 0 < ys + 0) exit 0;
if (xs + 0 > ys + 0) exit 1;
}
exit 1;
}'
}
old_v2raya_pkg=0
pkg_has v2raya-nextgen && old_v2raya_pkg=1
pkg_has v2raya-core-nextgen && old_v2raya_pkg=1
pkg_has luci-app-v2raya-nextgen && old_v2raya_pkg=1
if pkg_has v2raya; then
version_lt "$(pkg_version v2raya)" "2.5" && old_v2raya_pkg=1
fi
# The upstream packages install to /usr/share/v2ray, while this feed uses
# /usr/share/v2raya. Check the configured directory first, then both
# well-known paths, so the report is correct with either package set.
assets_dirs=""
configured_assets=$(uci -q get v2raya.config.v2ray_assetsdir 2>/dev/null) || configured_assets=""
[ -n "$configured_assets" ] && assets_dirs="$configured_assets "
assets_dirs="$assets_dirs/usr/share/v2ray /usr/local/share/v2ray /usr/share/v2raya /usr/local/share/v2raya"
geoip_present=0
geosite_present=0
for dir in $assets_dirs; do
[ -f "$dir/geoip.dat" ] && geoip_present=1
[ -f "$dir/geosite.dat" ] && geosite_present=1
done
present=""
enabled=""
for service in xray sing-box v2ray passwall passwall2 ssrplus openclash shellcrash mihomo clash byedpi; do
[ -x "/etc/init.d/$service" ] || continue
present="${present}${present:+,}$service"
if "/etc/init.d/$service" enabled >/dev/null 2>&1; then
enabled="${enabled}${enabled:+,}$service"
fi
done
cat <<EOF
core_path=$core_bin
core_version=$(version_line "$core_bin" version)
xray_path=$xray_bin
xray_version=$(version_line "$xray_bin" version)
xray_package=$xray_pkg
singbox_path=$singbox_bin
singbox_version=$(version_line "$singbox_bin" version)
singbox_package=$singbox_pkg
v2ray_path=$v2ray_bin
v2ray_version=$(version_line "$v2ray_bin" version)
v2ray_package=$v2ray_pkg
old_v2raya_package=$old_v2raya_pkg
geoip_present=$geoip_present
geosite_present=$geosite_present
services_present=$present
services_enabled=$enabled
EOF
+76
View File
@@ -0,0 +1,76 @@
# v2rayA configuration
#
# This file is read by /etc/init.d/v2raya and translated to V2RAYA_*
# environment variables. The names intentionally match the old v2rayA feed
# so an existing /etc/config/v2raya keeps working after the upgrade.
config v2raya 'config'
# Start the service at boot. The procd instance is also enabled/disabled
# by this flag, not only by /etc/rc.d/S99v2raya.
option enabled '0'
# Web UI listening address. Use 127.0.0.1:2017 if you only access it
# through an SSH tunnel or a reverse proxy.
option address '0.0.0.0:2017'
# URL prefix when v2rayA sits behind a reverse proxy. Must start with /.
option baseurl '/'
# auto, on or off. Make sure IPv6 works before forcing it on.
option ipv6_support 'auto'
# auto, on or off. nftables is the default on OpenWrt 22.03+.
option nftables_support 'auto'
# Seconds to wait for v2raya_core to start. Raise this on slow MIPS
# devices if the core is reported as failing to start.
option core_startup_timeout '15'
# trace, debug, info, warn or error. Warn keeps the flash writes down
# on a router; use info while debugging.
option log_level 'warn'
# Number of days to keep rotated log files.
option log_max_days '1'
# The log file already contains timestamps and no terminal colours.
option log_disable_color '1'
option log_disable_timestamp '0'
# Soft Go memory limit for both v2raya and v2raya_core (GOMEMLIMIT).
# 0 disables the limit. 64MiB is a safe start on a 256MiB router.
option gomemlimit '64MiB'
# Go scheduler threads (GOMAXPROCS). 0 uses every CPU core; 2 is
# enough for a home router and uses fewer scheduler resources.
option gomaxprocs '2'
# Go GC target percentage (GOGC). 0 keeps the Go default; lower values
# use less memory at the cost of more CPU.
option gogc '0'
# Maximum open file descriptors. 16384 is plenty for a home router and
# stops a connection flood from exhausting memory.
option nofile '16384'
# Directory containing geoip.dat and geosite.dat. Leave empty to let
# v2rayA search the standard locations.
option v2ray_assetsdir '/usr/share/v2raya'
# Path to v2raya_core. Leave empty to auto-detect the binary next to
# /usr/bin/v2raya or in PATH.
option v2ray_bin ''
# Extra v2ray configuration directory merged into the generated config.
option v2ray_confdir ''
# Hooks run around transparent-proxy and core life-cycle events.
# v2rayA passes --stage (pre-start, post-start, pre-stop, post-stop) and,
# for the transparent hook, --transparent-type (tproxy, redirect).
option transparent_hook ''
option core_hook ''
option plugin_manager ''
# [Linux] In redirect mode, let sockets bound to a device bypass the
# proxy. Requires kernel 5.14+ and cgroup v2.
option redirect_respect_bound_device '0'
+115
View File
@@ -0,0 +1,115 @@
#!/bin/sh /etc/rc.common
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2026 Amr Fateem <amr.fateem@yahoo.com>
#
# procd init script for v2rayA.
#
# All settings are kept in UCI (/etc/config/v2raya) and passed to v2rayA as
# V2RAYA_* environment variables, which is the interface gonfig documents
# upstream. Keeping the command line short also means paths with spaces or
# shell metacharacters cannot break the service.
#
# shellcheck disable=SC2034
# shellcheck disable=SC3043
USE_PROCD=1
START=99
STOP=10
CONF="v2raya"
PROG="/usr/bin/v2raya"
CONF_DIR="/etc/v2raya"
LOG_DIR="/var/log/v2raya"
DEFAULT_ASSETS="/usr/share/v2raya"
is_enabled() {
local enabled
config_get_bool enabled "$1" "$2" "${3:-0}"
[ "$enabled" -eq 1 ]
}
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 0
local assets_dir gomemlimit gomaxprocs gogc nofile
config_get assets_dir "config" "v2ray_assetsdir" "$DEFAULT_ASSETS"
config_get gomemlimit "config" "gomemlimit" "64MiB"
config_get gomaxprocs "config" "gomaxprocs" "2"
config_get gogc "config" "gogc" "0"
config_get nofile "config" "nofile" "16384"
mkdir -p "$CONF_DIR" "$LOG_DIR"
[ -n "$assets_dir" ] && mkdir -p "$assets_dir"
chmod 750 "$CONF_DIR"
chmod 755 "$LOG_DIR"
procd_open_instance "$CONF"
procd_set_param command "$PROG"
procd_set_param env "V2RAYA_CONFIG=$CONF_DIR" "V2RAYA_LOG_FILE=$LOG_DIR/v2raya.log"
# The core inherits this environment, so one limit covers both processes.
[ -n "$gomemlimit" ] && [ "$gomemlimit" != "0" ] && \
procd_append_param env "GOMEMLIMIT=$gomemlimit"
[ -n "$gomaxprocs" ] && [ "$gomaxprocs" -gt 0 ] 2>/dev/null && \
procd_append_param env "GOMAXPROCS=$gomaxprocs"
[ -n "$gogc" ] && [ "$gogc" -gt 0 ] 2>/dev/null && \
procd_append_param env "GOGC=$gogc"
append_env_arg "config" "v2ray_assetsdir" "$DEFAULT_ASSETS"
append_env_arg "config" "address" "0.0.0.0:2017"
append_env_arg "config" "baseurl" "/"
append_env_arg "config" "ipv6_support" "auto"
append_env_arg "config" "nftables_support" "auto"
append_env_arg "config" "core_startup_timeout" "15"
append_env_arg "config" "log_level" "warn"
append_env_arg "config" "log_max_days" "1"
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_bool "config" "log_disable_color"
append_env_bool "config" "log_disable_timestamp"
append_env_bool "config" "redirect_respect_bound_device"
# No core dumps on a router: they fill the overlay and can trip a
# marginal NAND. A 16384 descriptor ceiling is plenty for the LAN and
# keeps a connection flood from allocating unbounded socket buffers.
[ -n "$nofile" ] || nofile=16384
procd_set_param limits core="0 0"
procd_set_param limits nofile="$nofile $nofile"
procd_set_param respawn
procd_set_param term_timeout 30
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
reload_service() {
# v2rayA does not reload its configuration on SIGHUP; a restart is the
# only safe way to apply new UCI values.
restart
}
service_triggers() {
procd_add_reload_trigger "$CONF"
}
+1
View File
@@ -0,0 +1 @@
/etc/v2raya
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2026 Amr Fateem <amr.fateem@yahoo.com>
case "$1" in
v2raya)
/usr/bin/v2raya --version | grep -F "$2"
;;
*)
exit 1
;;
esac