v2ray-core: add new package
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.
For more details, see https://www.v2fly.org/en_US/guide/faq.html
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(cherry picked from commit 6461d1b055
)
This commit is contained in:
parent
088222c39d
commit
9bdab0d797
4 changed files with 186 additions and 0 deletions
111
net/v2ray-core/Makefile
Normal file
111
net/v2ray-core/Makefile
Normal 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))
|
11
net/v2ray-core/files/v2ray.conf
Normal file
11
net/v2ray-core/files/v2ray.conf
Normal 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
57
net/v2ray-core/files/v2ray.init
Executable 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
7
net/v2ray-core/test.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"v2ray-core")
|
||||||
|
v2ray version 2>&1 | grep "$PKG_VERSION"
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in a new issue