diff --git a/net/sing-box/Makefile b/net/sing-box/Makefile index c8d624cbc926..94e8e500b23d 100644 --- a/net/sing-box/Makefile +++ b/net/sing-box/Makefile @@ -1,21 +1,58 @@ PORTNAME= sing-box DISTVERSIONPREFIX= v DISTVERSION= 1.13.8 +PORTREVISION= 1 CATEGORIES= net MAINTAINER= yuri@FreeBSD.org COMMENT= Universal proxy platform WWW= https://sing-box.sagernet.org \ https://github.com/SagerNet/sing-box LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE USES= go:1.24+,modules GO_MODULE= github.com/sagernet/sing-box GO_TARGET= ./cmd/sing-box PLIST_FILES= bin/${PORTNAME} -.include +USE_RC_SUBR= ${PORTNAME} + +OPTIONS_DEFINE= QUIC GRPC DHCP WIREGUARD UTLS ACME CLASH_API V2RAY_API GVISOR EMBEDDED_TOR CCM OCM +OPTIONS_DEFAULT= QUIC UTLS + +QUIC_DESC= Build with QUIC support +GRPC_DESC= Build with standard gRPC support +DHCP_DESC= Build with DHCP support +WIREGUARD_DESC= Build with WireGuard support +UTLS_DESC= Build with uTLS support for TLS outbound +ACME_DESC= Build with ACME TLS issuer support +CLASH_API_DESC= Build with Clash API support +V2RAY_API_DESC= Build with V2Ray API support +GVISOR_DESC= Build with gVisor support +EMBEDDED_TOR_DESC= Build with embedded Tor support +CCM_DESC= Build with Claude Code Multiplexer service support +OCM_DESC= Build with OpenAI Codex Multiplexer service support + +QUIC_VARS= GO_TAGS+=with_quic +GRPC_VARS= GO_TAGS+=with_grpc +DHCP_VARS= GO_TAGS+=with_dhcp +WIREGUARD_VARS= GO_TAGS+=with_wireguard +UTLS_VARS= GO_TAGS+=with_utls +ACME_VARS= GO_TAGS+=with_acme +CLASH_API_VARS= GO_TAGS+=with_clash_api +V2RAY_API_VARS= GO_TAGS+=with_v2ray_api +GVISOR_VARS= GO_TAGS+=with_gvisor +EMBEDDED_TOR_VARS= GO_TAGS+=with_embedded_tor CGO_ENABLED=1 +CCM_VARS= GO_TAGS+=with_ccm +OCM_VARS= GO_TAGS+=with_ocm + +.include +.if !empty (GO_TAGS) +GO_BUILDFLAGS+= -tags "${GO_TAGS}" +.endif + +.include diff --git a/net/sing-box/files/sing-box.in b/net/sing-box/files/sing-box.in new file mode 100644 index 000000000000..a23f57a3d0dc --- /dev/null +++ b/net/sing-box/files/sing-box.in @@ -0,0 +1,40 @@ +#!/bin/sh + +# PROVIDE: singbox +# REQUIRE: NETWORKING SERVERS +# BEFORE: DAEMON +# KEYWORD: shutdown +# +# Add the following lines to /etc/rc.conf to enable sing-box: +# +# singbox_enable (bool): Set it to "YES" to enable sing-box +# singbox_configfile (str): Path to config file +# singbox_dbdir (str): Path to runtime data directory +# singbox_pidfile (str): Path to PID file +# + +. /etc/rc.subr + +name=singbox +rcvar=singbox_enable + +set_rcvar singbox_configfile "%%PREFIX%%/etc/sing-box.json" +set_rcvar singbox_dbdir "/var/db/sing-box/" "Path to runtime data directory" +set_rcvar singbox_pidfile "/var/run/sing-box.pid" "Path to PID file" + +load_rc_config $name + +command=/usr/sbin/daemon +actual_command="%%PREFIX%%/bin/sing-box" +pidfile=${singbox_pidfile} +command_args="-c -P ${pidfile} ${actual_command} run -D ${singbox_dbdir} -c ${singbox_configfile}" + +start_precmd=singbox_startprecmd +singbox_startprecmd() +{ + if [ ! -d ${singbox_dbdir} ]; then + install -d ${singbox_dbdir} + fi +} + +run_rc_command "$1"