--- /dev/null
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=sing-box
+PKG_VERSION:=1.1.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/SagerNet/sing-box/tar.gz/v$(PKG_VERSION)?
+PKG_HASH:=a1e642362f41bd0e362cd9c8d2f0d29d2eca6a55a948677f6f03cfb81c4f0657
+
+PKG_LICENSE:=GPL-3.0-or-later
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Van Waholtz <brvphoenix@gmail.com>
+
+PKG_BUILD_DEPENDS:=golang/host
+PKG_BUILD_PARALLEL:=1
+PKG_USE_MIPS16:=0
+
+GO_PKG:=github.com/sagernet/sing-box
+GO_PKG_BUILD_PKG:=$(GO_PKG)/cmd/sing-box
+
+include $(INCLUDE_DIR)/package.mk
+include ../../lang/golang/golang-package.mk
+
+define Package/sing-box
+ TITLE:=The universal proxy platform
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=https://sing-box.sagernet.org
+ DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle +kmod-tun
+ USERID:=sing-box=5566:sing-box=5566
+endef
+
+define Package/sing-box/description
+ Sing-box is a universal proxy platform which supports hysteria, SOCKS, Shadowsocks,
+ ShadowsocksR, ShadowTLS, Tor, trojan, VLess, VMess, WireGuard and so on.
+endef
+
+define Package/sing-box/config
+ menu "Select build options"
+ depends on PACKAGE_sing-box
+
+ config SINGBOX_WITH_ACME
+ bool "Build with ACME TLS certificate issuer support"
+ default n
+
+ config SINGBOX_WITH_CLASH_API
+ bool "Build with Clash API support"
+ default y
+
+ config SINGBOX_WITH_ECH
+ bool "Build with TLS ECH extension support for TLS outbound"
+ default n
+
+ config SINGBOX_WITH_EMBEDDED_TOR
+ bool "Build with embedded Tor support"
+ default n
+
+ config SINGBOX_WITH_GRPC
+ bool "Build with standard gRPC support"
+ default n
+
+ config SINGBOX_WITH_GVISOR
+ bool "Build with gVisor support"
+ default y
+
+ config SINGBOX_WITH_LWIP
+ bool "Build with LWIP Tun stack support"
+ default n
+
+ config SINGBOX_WITH_QUIC
+ bool "Build with QUIC support"
+ default y
+
+ config SINGBOX_WITH_SHADOWSOCKSR
+ bool "Build with ShadowsocksR support"
+ default n
+
+ config SINGBOX_WITH_UTLS
+ bool "Build with uTLS support for TLS outbound"
+ default y
+
+ config SINGBOX_WITH_V2RAY_API
+ bool "Build with V2Ray API support"
+ default n
+
+ config SINGBOX_WITH_WIREGUARD
+ bool "Build with WireGuard support"
+ default y
+ endmenu
+endef
+
+PKG_CONFIG_DEPENDS:= \
+ CONFIG_SINGBOX_WITH_ACME \
+ CONFIG_SINGBOX_WITH_CLASH_API \
+ CONFIG_SINGBOX_WITH_ECH \
+ CONFIG_SINGBOX_WITH_EMBEDDED_TOR \
+ CONFIG_SINGBOX_WITH_GRPC \
+ CONFIG_SINGBOX_WITH_GVISOR \
+ CONFIG_SINGBOX_WITH_LWIP \
+ CONFIG_SINGBOX_WITH_QUIC \
+ CONFIG_SINGBOX_WITH_SHADOWSOCKSR \
+ CONFIG_SINGBOX_WITH_UTLS \
+ CONFIG_SINGBOX_WITH_V2RAY_API \
+ CONFIG_SINGBOX_WITH_WIREGUARD
+
+GO_PKG_TAGS:=$(subst $(space),$(comma),$(strip \
+ $(if $(CONFIG_SINGBOX_WITH_ACME),with_acme) \
+ $(if $(CONFIG_SINGBOX_WITH_CLASH_API),with_clash_api) \
+ $(if $(CONFIG_SINGBOX_WITH_ECH),with_ech) \
+ $(if $(CONFIG_SINGBOX_WITH_EMBEDDED_TOR),with_embedded_tor) \
+ $(if $(CONFIG_SINGBOX_WITH_GRPC),with_grpc) \
+ $(if $(CONFIG_SINGBOX_WITH_GVISOR),with_gvisor) \
+ $(if $(CONFIG_SINGBOX_WITH_LWIP),with_lwip) \
+ $(if $(CONFIG_SINGBOX_WITH_QUIC),with_quic) \
+ $(if $(CONFIG_SINGBOX_WITH_SHADOWSOCKSR),with_shadowsocksr) \
+ $(if $(CONFIG_SINGBOX_WITH_UTLS),with_utls) \
+ $(if $(CONFIG_SINGBOX_WITH_V2RAY_API),with_v2ray_api) \
+ $(if $(CONFIG_SINGBOX_WITH_WIREGUARD),with_wireguard) \
+))
+
+define Package/sing-box/conffiles
+/etc/config/sing-box
+/etc/sing-box/
+endef
+
+define Package/sing-box/install
+ $(INSTALL_DIR) $(1)/usr/bin/
+ $(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/sing-box $(1)/usr/bin/sing-box
+
+ $(INSTALL_DIR) $(1)/etc/sing-box
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/release/config/config.json $(1)/etc/sing-box
+
+ $(INSTALL_DIR) $(1)/etc/config/
+ $(INSTALL_CONF) ./files/sing-box.conf $(1)/etc/config/sing-box
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_BIN) ./files/sing-box.init $(1)/etc/init.d/sing-box
+endef
+
+$(eval $(call BuildPackage,sing-box))
--- /dev/null
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+START=99
+
+NAME="sing-box"
+PROG="/usr/bin/sing-box"
+
+start_service() {
+ config_load "$NAME"
+
+ local enabled user group conffile workdir
+ config_get_bool enabled "main" "enabled" "0"
+ [ "$enabled" -eq "1" ] || return 0
+
+ config_get user "main" "user" "root"
+ config_get conffile "main" "conffile"
+ config_get workdir "main" "workdir" "/usr/share/sing-box"
+
+ mkdir -p "$workdir"
+ local group="$(id -ng $user)"
+ chown $user:$group "$workdir"
+
+ procd_open_instance "$NAME.main"
+ procd_set_param command "$PROG" run -c "$conffile" -D "$workdir"
+
+ # Use root user if you want to use the TUN mode.
+ procd_set_param user "$user"
+ procd_set_param file "$conffile"
+ procd_set_param stdout 1
+ procd_set_param stderr 1
+ procd_set_param respawn
+
+ procd_close_instance
+}
+
+service_triggers() {
+ procd_add_reload_trigger "$NAME"
+}