Merge pull request #19571 from 1715173329/v2

[openwrt-22.03] v2ray-core: add new package
This commit is contained in:
Josef Schlehofer 2022-10-12 08:43:04 +02:00 committed by GitHub
commit 97a25e6778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 269 additions and 33 deletions

111
net/v2ray-core/Makefile Normal file
View file

@ -0,0 +1,111 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021-2022 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=v2ray-core
PKG_VERSION:=5.1.0
PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/v2fly/v2ray-core/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=b3dbd2bbee9486999b81d1968545c5a6caa7b0f4726a7259939f1bda54fcf5ea
PKG_LICENSE:=MIT
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/v2fly/v2ray-core/v5
GO_PKG_BUILD_PKG:=$(GO_PKG)/main
GO_PKG_LDFLAGS_X:= \
$(GO_PKG).build=OpenWrt \
$(GO_PKG).version=$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include ../../lang/golang/golang-package.mk
define Package/v2ray/template
TITLE:=A platform for building proxies to bypass network restrictions
SECTION:=net
CATEGORY:=Network
URL:=https://www.v2fly.org
endef
define Package/v2ray-core
$(call Package/v2ray/template)
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
endef
define Package/v2ray-example
$(call Package/v2ray/template)
TITLE+= (example configs)
DEPENDS:=v2ray-core
PKGARCH:=all
endef
define Package/v2ray-extra
$(call Package/v2ray/template)
TITLE+= (extra resources)
DEPENDS:=v2ray-core
PKGARCH:=all
endef
define Package/v2ray/description
Project V is a set of network tools that help you to build your own computer network.
It secures your network connections and thus protects your privacy.
endef
define Package/v2ray-core/description
$(call Package/v2ray/description)
endef
define Package/v2ray-example/description
$(call Package/v2ray/description)
This includes example configuration files for v2ray-core.
endef
define Package/v2ray-extra/description
$(call Package/v2ray/description)
This includes extra resources for v2ray-core.
endef
define Package/v2ray-core/conffiles
/etc/config/v2ray
/etc/v2ray/
endef
define Package/v2ray-core/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/main $(1)/usr/bin/v2ray
$(INSTALL_DIR) $(1)/etc/v2ray/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/release/config/config.json $(1)/etc/v2ray/
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) $(CURDIR)/files/v2ray.conf $(1)/etc/config/v2ray
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) $(CURDIR)/files/v2ray.init $(1)/etc/init.d/v2ray
endef
define Package/v2ray-example/install
$(INSTALL_DIR) $(1)/etc/v2ray/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/release/config/vpoint_socks_vmess.json $(1)/etc/v2ray/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/release/config/vpoint_vmess_freedom.json $(1)/etc/v2ray/
endef
define Package/v2ray-extra/install
$(INSTALL_DIR) $(1)/usr/share/v2ray/
$(CP) $(PKG_BUILD_DIR)/release/extra/* $(1)/usr/share/v2ray/
endef
$(eval $(call BuildPackage,v2ray-core))
$(eval $(call BuildPackage,v2ray-example))
$(eval $(call BuildPackage,v2ray-extra))

View file

@ -0,0 +1,11 @@
config v2ray 'enabled'
option enabled '0'
config v2ray 'config'
option confdir '/etc/v2ray'
list conffiles '/etc/v2ray/config.json'
option datadir '/usr/share/v2ray'
option format 'json'
option memconservative '1'

57
net/v2ray-core/files/v2ray.init Executable file
View file

@ -0,0 +1,57 @@
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=99
CONF="v2ray"
PROG="/usr/bin/v2ray"
start_service() {
config_load "$CONF"
local enabled
config_get_bool enabled "enabled" "enabled" "0"
[ "$enabled" -eq "0" ] && exit 1
local confdir
local conffiles
local datadir
local format
config_get confdir "config" "confdir"
config_get conffiles "config" "conffiles"
config_get datadir "config" "datadir" "/usr/share/v2ray"
config_get format "config" "format" "json"
config_get_bool memconservative "config" "memconservative" "1"
procd_open_instance "$CONF"
procd_set_param command "$PROG" run
[ -n "$confdir" ] && procd_append_param command -confdir "$confdir"
[ -n "$conffiles" ] && {
for i in $conffiles
do
procd_append_param command -config "$i"
done
}
[ -n "$format" ] && procd_append_param command -format "$format"
procd_set_param env v2ray.local.asset="$datadir"
[ "$memconservative" -eq "1" ] && procd_append_param env V2RAY_CONF_GEOLOADER="memconservative"
procd_set_param file $conffiles
procd_set_param limits core="unlimited"
procd_set_param limits nofile="1000000 1000000"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
reload_service() {
stop
start
}
service_triggers() {
procd_add_reload_trigger "$CONF"
}

7
net/v2ray-core/test.sh Normal file
View file

@ -0,0 +1,7 @@
#!/bin/sh
case "$1" in
"v2ray-core")
v2ray version 2>&1 | grep "$PKG_VERSION"
;;
esac

View file

@ -0,0 +1,83 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021-2022 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=v2ray-geodata
PKG_RELEASE:=$(AUTORELEASE)
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
include $(INCLUDE_DIR)/package.mk
GEOIP_VER:=202209170841
GEOIP_FILE:=geoip.dat.$(GEOIP_VER)
define Download/geoip
URL:=https://github.com/v2fly/geoip/releases/download/$(GEOIP_VER)/
URL_FILE:=geoip.dat
FILE:=$(GEOIP_FILE)
HASH:=ceb0cfdf0fab39141e807fe7bb8a0972c6b3f616abcd1097ac30c26368f368a5
endef
GEOSITE_VER:=20220918140014
GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
define Download/geosite
URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
URL_FILE:=dlc.dat
FILE:=$(GEOSITE_FILE)
HASH:=8a69b68f02d422ab05f351772c871f367bf387fa78dc37c4f8c1e421a13540a6
endef
define Package/v2ray-geodata/template
SECTION:=net
CATEGORY:=Network
SUBMENU:=IP Addresses and Names
URL:=https://www.v2fly.org
PKGARCH:=all
endef
define Package/v2ray-geoip
$(call Package/v2ray-geodata/template)
TITLE:=GeoIP List for V2Ray
PROVIDES:=v2ray-geodata xray-geodata xray-geoip
VERSION:=$(GEOIP_VER)-$(PKG_RELEASE)
LICENSE:=CC-BY-SA-4.0
endef
define Package/v2ray-geosite
$(call Package/v2ray-geodata/template)
TITLE:=Geosite List for V2Ray
PROVIDES:=v2ray-geodata xray-geodata xray-geosite
VERSION:=$(GEOSITE_VER)-$(PKG_RELEASE)
LICENSE:=MIT
endef
define Build/Prepare
$(call Build/Prepare/Default)
ifneq ($(CONFIG_PACKAGE_v2ray-geoip),)
$(call Download,geoip)
endif
ifneq ($(CONFIG_PACKAGE_v2ray-geosite),)
$(call Download,geosite)
endif
endef
define Build/Compile
endef
define Package/v2ray-geoip/install
$(INSTALL_DIR) $(1)/usr/share/v2ray $(1)/usr/share/xray
$(INSTALL_DATA) $(DL_DIR)/$(GEOIP_FILE) $(1)/usr/share/v2ray/geoip.dat
$(LN) ../v2ray/geoip.dat $(1)/usr/share/xray/geoip.dat
endef
define Package/v2ray-geosite/install
$(INSTALL_DIR) $(1)/usr/share/v2ray $(1)/usr/share/xray
$(INSTALL_DATA) $(DL_DIR)/$(GEOSITE_FILE) $(1)/usr/share/v2ray/geosite.dat
$(LN) ../v2ray/geosite.dat $(1)/usr/share/xray/geosite.dat
endef
$(eval $(call BuildPackage,v2ray-geoip))
$(eval $(call BuildPackage,v2ray-geosite))

View file

@ -78,32 +78,6 @@ define Package/xray-core/conffiles
/etc/config/xray /etc/config/xray
endef endef
GEOIP_VER:=202209170841
GEOIP_FILE:=geoip.dat.$(GEOIP_VER)
define Download/geoip
URL:=https://github.com/v2fly/geoip/releases/download/$(GEOIP_VER)/
URL_FILE:=geoip.dat
FILE:=$(GEOIP_FILE)
HASH:=ceb0cfdf0fab39141e807fe7bb8a0972c6b3f616abcd1097ac30c26368f368a5
endef
GEOSITE_VER:=20220918140014
GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
define Download/geosite
URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
URL_FILE:=dlc.dat
FILE:=$(GEOSITE_FILE)
HASH:=8a69b68f02d422ab05f351772c871f367bf387fa78dc37c4f8c1e421a13540a6
endef
define Build/Prepare
$(call Build/Prepare/Default)
ifneq ($(CONFIG_PACKAGE_xray-geodata),)
$(call Download,geoip)
$(call Download,geosite)
endif
endef
define Package/xray-core/install define Package/xray-core/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR)) $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin/ $(INSTALL_DIR) $(1)/usr/bin/
@ -124,12 +98,5 @@ define Package/xray-example/install
$(INSTALL_DATA) $(CURDIR)/files/vpoint_vmess_freedom.json $(1)/etc/xray/ $(INSTALL_DATA) $(CURDIR)/files/vpoint_vmess_freedom.json $(1)/etc/xray/
endef endef
define Package/xray-geodata/install
$(INSTALL_DIR) $(1)/usr/share/xray/
$(INSTALL_DATA) $(DL_DIR)/$(GEOIP_FILE) $(1)/usr/share/xray/geoip.dat
$(INSTALL_DATA) $(DL_DIR)/$(GEOSITE_FILE) $(1)/usr/share/xray/geosite.dat
endef
$(eval $(call BuildPackage,xray-core)) $(eval $(call BuildPackage,xray-core))
$(eval $(call BuildPackage,xray-example)) $(eval $(call BuildPackage,xray-example))
$(eval $(call BuildPackage,xray-geodata))