diff --git a/security/xray-core/Makefile b/security/xray-core/Makefile index 54cbe312b49d..35d445e2d871 100644 --- a/security/xray-core/Makefile +++ b/security/xray-core/Makefile @@ -1,45 +1,53 @@ PORTNAME= xray-core DISTVERSIONPREFIX= v DISTVERSION= 26.7.28 +PORTREVISION= 1 CATEGORIES= security MASTER_SITES= https://github.com/v2fly/geoip/releases/download/202608050239/:geoip \ https://github.com/v2fly/domain-list-community/releases/download/20260831141734/:geosite DISTFILES= geoip.dat:geoip \ dlc.dat:geosite EXTRACT_ONLY= XTLS-Xray-core-v${DISTVERSION}_GH0.tar.gz MAINTAINER= kirill@drlebedev.com COMMENT= Set of network penetration tools WWW= https://github.com/XTLS/Xray-core LICENSE= MPL20 LICENSE_FILE= ${WRKSRC}/LICENSE -USES= go:1.26+,modules +USES= go:modules USE_GITHUB= yes GH_ACCOUNT= XTLS GH_PROJECT= Xray-core USE_RC_SUBR= xray GO_MOD_DIST= github GO_MODULE= github.com/${GH_ACCOUNT}/${PORTNAME} GO_PKGNAME= github.com/${GH_ACCOUNT}/${PORTNAME} GO_TARGET= ./main:xray CONFLICTS_INSTALL= xray -SUB_FILES= pkg-message -SUB_LIST= GROUP="${GROUPS}" \ - USER="${USERS}" +XRAY_USER?= v2ray +XRAY_GROUP?= v2ray -USERS= v2ray -GROUPS= v2ray +SUB_FILES= pkg-message +SUB_LIST= GROUP="${XRAY_GROUP}" \ + USER="${XRAY_USER}" + +.if ${XRAY_USER} == v2ray +USERS= ${XRAY_USER} +.endif +.if ${XRAY_GROUP} == v2ray +GROUPS= ${XRAY_GROUP} +.endif post-install: ${MKDIR} ${STAGEDIR}${ETCDIR} \ ${STAGEDIR}${DATADIR} ${INSTALL_DATA} ${DISTDIR}/${DIST_SUBDIR}/geoip.dat ${STAGEDIR}${DATADIR}/geoip.dat ${INSTALL_DATA} ${DISTDIR}/${DIST_SUBDIR}/dlc.dat ${STAGEDIR}${DATADIR}/geosite.dat ${INSTALL_DATA} ${FILESDIR}/*.json.sample ${STAGEDIR}${ETCDIR}/ .include diff --git a/security/xray-core/files/09_reverse.json.sample b/security/xray-core/files/09_reverse.json.sample deleted file mode 100644 index 5a6b7dcc3e2b..000000000000 --- a/security/xray-core/files/09_reverse.json.sample +++ /dev/null @@ -1,8 +0,0 @@ -{ - "reverse": { - "bridges": [ - ], - "portals": [ - ] - } -} diff --git a/security/xray-core/files/xray.in b/security/xray-core/files/xray.in index 18c9beeb4f5c..ee1e895df70c 100644 --- a/security/xray-core/files/xray.in +++ b/security/xray-core/files/xray.in @@ -1,48 +1,70 @@ #!/bin/sh # PROVIDE: xray-core # REQUIRE: LOGIN # KEYWORD: shutdown # Add these lines to /etc/rc.conf.local or /etc/rc.conf to enable `xray': # -# xray_enable (bool): Set to "NO" by default. -# Set it to "YES" to enable xray -# xray_config (path): Set to "%%PREFIX%%/etc/xray-core" by default -# Set it to the xray server config -# xray_logdir (path): Set to "/var/log/xray-core" by default. -# Set it to the directory of xray log files -# xray_env (str): Set to "" by default. -# Set it to the desired environment variables +# xray_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable xray +# xray_config (path): Set to "%%PREFIX%%/etc/xray-core" by default +# Set it to the xray server config +# xray_logdir (path): Set to "/var/log/xray-core" by default. +# Set it to the directory of xray log files +# xray_env (str): Set to "" by default. +# Set it to the desired environment variables +# xray_syslog_output_enable (str): Set to YES to enable syslog output +# Default is "NO". See daemon(8). +# xray_syslog_output_tag (str): Set syslog tag if syslog enabled. +# Default is "xray". See daemon(8). +# xray_syslog_output_priority (str): Set syslog priority if syslog enabled. +# Default is "notice". See daemon(8). +# xray_syslog_output_facility (str): Set syslog facility if syslog enabled. +# Default is "daemon". See daemon(8). . /etc/rc.subr name="xray" rcvar="xray_enable" load_rc_config "$name" : ${xray_enable="NO"} : ${xray_config="%%PREFIX%%/etc/${name}-core"} : ${xray_logdir="/var/log/${name}-core"} -: ${xray_env=""} +: ${xray_syslog_output_enable:="NO"} : ${xray_user="%%USER%%"} : ${xray_group="%%GROUP%%"} +if checkyesno xray_syslog_output_enable; then + if [ -n "${xray_syslog_output_tag}" ]; then + xray_syslog_output_flags="-T ${xray_syslog_output_tag}" + else + xray_syslog_output_flags="-T ${name}" + fi + if [ -n "${xray_syslog_output_priority}" ]; then + xray_syslog_output_flags="${xray_syslog_output_flags} -s ${xray_syslog_output_priority}" + fi + if [ -n "${xray_syslog_output_facility}" ]; then + xray_syslog_output_flags="${xray_syslog_output_flags} -l ${xray_syslog_output_facility}" + fi +fi + asset_env="XRAY_LOCATION_ASSET=%%PREFIX%%/share/${name}-core" pidfile="/var/run/$name.pid" procname="%%PREFIX%%/bin/xray" command="/usr/sbin/daemon" -command_args="-c -p ${pidfile} /usr/bin/env ${asset_env} ${xray_env} ${procname} -confdir ${xray_config}" +command_args="-f -t ${name} ${xray_syslog_output_flags} -p ${pidfile} /usr/bin/env ${asset_env} ${xray_env} ${procname} -confdir ${xray_config}" required_files="${xray_config}" start_precmd="xray_startprecmd" xray_startprecmd() { touch "${pidfile}" chown ${xray_user}:${xray_group} "${pidfile}" mkdir -p "${xray_logdir}" chown -R ${xray_user}:${xray_group} "${xray_logdir}" } run_rc_command "$1" diff --git a/security/xray-core/pkg-plist b/security/xray-core/pkg-plist index 78101a2857a4..39087ce0afd8 100644 --- a/security/xray-core/pkg-plist +++ b/security/xray-core/pkg-plist @@ -1,13 +1,12 @@ bin/xray @sample %%ETCDIR%%/00_log.json.sample @sample %%ETCDIR%%/01_api.json.sample @sample %%ETCDIR%%/02_dns.json.sample @sample %%ETCDIR%%/03_routing.json.sample @sample %%ETCDIR%%/04_policy.json.sample @sample %%ETCDIR%%/05_inbounds.json.sample @sample %%ETCDIR%%/06_outbounds.json.sample @sample %%ETCDIR%%/07_transport.json.sample @sample %%ETCDIR%%/08_stats.json.sample -@sample %%ETCDIR%%/09_reverse.json.sample %%DATADIR%%/geoip.dat %%DATADIR%%/geosite.dat