mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-31 04:45:13 +08:00
update 2026-09-24 16:56:26
This commit is contained in:
1 parent
b31a5c3878
commit
e4cee331e9
6885 files changed
+3240523
No files matched your search
@@ -0,0 +1,170 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#
|
||||
# Copyright (C) 2022-2023 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=sing-box
|
||||
PKG_VERSION:=1.14.1
|
||||
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:=1ea41f7d06b0017fe3d3ba7ee30959048aa0ddde31cb0165dab9257edf673321
|
||||
|
||||
PKG_LICENSE:=GPL-3.0-or-later
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_SING_BOX_TINY_BUILD_ACME \
|
||||
CONFIG_SING_BOX_TINY_BUILD_CLASH_API \
|
||||
CONFIG_SING_BOX_TINY_BUILD_DHCP \
|
||||
CONFIG_SING_BOX_TINY_BUILD_EMBEDDED_TOR \
|
||||
CONFIG_SING_BOX_TINY_BUILD_GRPC \
|
||||
CONFIG_SING_BOX_TINY_BUILD_GVISOR \
|
||||
CONFIG_SING_BOX_TINY_BUILD_QUIC \
|
||||
CONFIG_SING_BOX_TINY_BUILD_TAILSCALE \
|
||||
CONFIG_SING_BOX_TINY_BUILD_UTLS \
|
||||
CONFIG_SING_BOX_TINY_BUILD_V2RAY_API \
|
||||
CONFIG_SING_BOX_TINY_BUILD_WIREGUARD
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_BUILD_FLAGS:=no-mips16
|
||||
|
||||
GO_PKG:=github.com/sagernet/sing-box
|
||||
GO_PKG_BUILD_PKG:=$(GO_PKG)/cmd/sing-box
|
||||
GO_PKG_LDFLAGS_X:=$(GO_PKG)/constant.Version=$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include ../../lang/golang/golang-package.mk
|
||||
|
||||
define Package/sing-box/Default
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=The universal proxy platform
|
||||
URL:=https://sing-box.sagernet.org/
|
||||
DEPENDS:=+ca-bundle +kmod-inet-diag
|
||||
USERID:=sing-box=5566:sing-box=5566
|
||||
endef
|
||||
|
||||
define Package/sing-box
|
||||
$(call Package/sing-box/Default)
|
||||
TITLE+= (full version)
|
||||
DEPENDS+= +kmod-netlink-diag +kmod-tun
|
||||
CONFLICTS:=sing-box-tiny
|
||||
VARIANT:=full
|
||||
DEFAULT_VARIANT:=1
|
||||
endef
|
||||
|
||||
define Package/sing-box/description
|
||||
Sing-box is a universal proxy platform which supports hysteria, SOCKS, Shadowsocks,
|
||||
ShadowTLS, Tor, trojan, VLess, VMess, WireGuard and so on.
|
||||
endef
|
||||
|
||||
define Package/sing-box/config
|
||||
depends on $(subst @,,$(GO_ARCH_DEPENDS))
|
||||
endef
|
||||
|
||||
define Package/sing-box-tiny
|
||||
$(call Package/sing-box/Default)
|
||||
TITLE+= (tiny/custom version)
|
||||
PROVIDES:=sing-box
|
||||
VARIANT:=tiny
|
||||
endef
|
||||
|
||||
Package/sing-box-tiny/description:=$(Package/sing-box/description)
|
||||
|
||||
define Package/sing-box-tiny/config
|
||||
$(call Package/sing-box/config)
|
||||
|
||||
if PACKAGE_sing-box-tiny
|
||||
config SING_BOX_TINY_BUILD_ACME
|
||||
bool "Build with ACME TLS certificate issuer support"
|
||||
|
||||
config SING_BOX_TINY_BUILD_CLASH_API
|
||||
bool "Build with Clash API support"
|
||||
default y
|
||||
|
||||
config SING_BOX_TINY_BUILD_DHCP
|
||||
bool "Build with DHCP support"
|
||||
|
||||
config SING_BOX_TINY_BUILD_EMBEDDED_TOR
|
||||
bool "Build with embedded Tor support"
|
||||
depends on BROKEN
|
||||
|
||||
config SING_BOX_TINY_BUILD_GRPC
|
||||
bool "Build with standard gPRC support"
|
||||
help
|
||||
Standard gRPC has good compatibility but poor performance.
|
||||
|
||||
config SING_BOX_TINY_BUILD_GVISOR
|
||||
bool "Build with gVisor support"
|
||||
default y if aarch64||arm||i386||x86_64
|
||||
|
||||
config SING_BOX_TINY_BUILD_QUIC
|
||||
bool "Build with QUIC support"
|
||||
default y
|
||||
help
|
||||
Required by HTTP3 DNS transports, Naive inbound,
|
||||
Hysteria inbound / outbound, and v2ray QUIC transport.
|
||||
|
||||
config SING_BOX_TINY_BUILD_TAILSCALE
|
||||
bool "Build with Tailscale support"
|
||||
|
||||
config SING_BOX_TINY_BUILD_UTLS
|
||||
bool "Build with uTLS support"
|
||||
default y
|
||||
|
||||
config SING_BOX_TINY_BUILD_V2RAY_API
|
||||
bool "Build with V2Ray API support"
|
||||
|
||||
config SING_BOX_TINY_BUILD_WIREGUARD
|
||||
bool "Build with WireGuard support"
|
||||
default y if aarch64||arm||i386||x86_64
|
||||
endif
|
||||
endef
|
||||
|
||||
ifeq ($(BUILD_VARIANT),full)
|
||||
GO_PKG_TAGS:=with_acme,with_clash_api,with_dhcp,with_gvisor,with_quic,with_tailscale,with_utls,with_wireguard
|
||||
else
|
||||
GO_PKG_TAGS:=$(subst $(space),$(comma),$(strip \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_ACME),with_acme) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_CLASH_API),with_clash_api) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_DHCP),with_dhcp) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_EMBEDDED_TOR),with_embedded_tor) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_GRPC),with_grpc) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_GVISOR),with_gvisor) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_QUIC),with_quic) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_TAILSCALE),with_tailscale) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_UTLS),with_utls) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_V2RAY_API),with_v2ray_api) \
|
||||
$(if $(CONFIG_SING_BOX_TINY_BUILD_WIREGUARD),with_wireguard) \
|
||||
))
|
||||
endif
|
||||
|
||||
define Package/sing-box/conffiles
|
||||
/etc/config/sing-box
|
||||
/etc/sing-box/
|
||||
endef
|
||||
|
||||
Package/sing-box-tiny/conffiles=$(Package/sing-box/conffiles)
|
||||
|
||||
define Package/sing-box/install
|
||||
$(call GoPackage/Package/Install/Bin,$(1))
|
||||
|
||||
$(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
|
||||
|
||||
Package/sing-box-tiny/install=$(Package/sing-box/install)
|
||||
|
||||
$(eval $(call BuildPackage,sing-box))
|
||||
$(eval $(call BuildPackage,sing-box-tiny))
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
config sing-box 'main'
|
||||
option enabled '0'
|
||||
option user 'root'
|
||||
option conffile '/etc/sing-box/config.json'
|
||||
option workdir '/usr/share/sing-box'
|
||||
# list ifaces 'wan'
|
||||
# list ifaces 'wan6'
|
||||
option log_stderr '1'
|
||||
option log_stdout '0'
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
|
||||
script=$(readlink "$initscript")
|
||||
NAME="$(basename ${script:-$initscript})"
|
||||
PROG="/usr/bin/sing-box"
|
||||
|
||||
start_service() {
|
||||
config_load "$NAME"
|
||||
|
||||
local enabled user group conffile workdir ifaces
|
||||
local log_stdout log_stderr
|
||||
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 ifaces "main" "ifaces"
|
||||
config_get workdir "main" "workdir" "/usr/share/sing-box"
|
||||
config_get_bool log_stdout "main" "log_stdout" "0"
|
||||
config_get_bool log_stderr "main" "log_stderr" "1"
|
||||
|
||||
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"
|
||||
[ -z "$ifaces" ] || procd_set_param netdev $ifaces
|
||||
procd_set_param stdout "$log_stdout"
|
||||
procd_set_param stderr "$log_stderr"
|
||||
procd_set_param limits core="unlimited"
|
||||
procd_set_param limits nofile="1000000 1000000"
|
||||
procd_set_param respawn
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
local ifaces
|
||||
config_load "$NAME"
|
||||
config_get ifaces "main" "ifaces"
|
||||
procd_open_trigger
|
||||
for iface in $ifaces; do
|
||||
procd_add_interface_trigger "interface.*.up" $iface /etc/init.d/$NAME restart
|
||||
done
|
||||
procd_close_trigger
|
||||
procd_add_reload_trigger "$NAME"
|
||||
}
|
||||
Reference in new issue
Block a user