Files
shater/shater-core/Makefile
T
omarandClaude Opus 4.8 f1e4f16a9f
build / aarch64_cortex-a53 (push) Successful in 3m29s
build / x86_64 (push) Successful in 3m17s
fix(profiles): pick the active uplink via ip route get (metric/policy-aware)
defaultIface() now asks the kernel authoritatively which interface it would egress
a public destination through (`ip route get 8.8.8.8`/`1.1.1.1`) instead of parsing
`ip route show default` by metric. This is correct for multi-WAN / mwan3 / policy-
routing setups where the active uplink is chosen by metric AND ip rules — the query
carries no fwmark so it reflects the real WAN egress, not the tproxy loopback table.
Falls back to the lowest-metric default route if `ip route get` is unavailable.

Clarifies the two orderings: which INTERFACE is active = kernel route metric; which
PROFILE applies = profile priority among those whose conditions all hold.

Verified live: `ip route get 8.8.8.8` -> eth1; a profile matching dum0 with HIGHER
priority stays inactive (its iface condition fails) while the eth1 profile (lower
priority, condition holds) is active — priority never overrides an unmet condition.

- profile_wanmode.go: defaultIface -> ip route get + devFromRouteGet +
  lowestMetricDefaultIface fallback.
- test: TestDevFromRouteGet. r17.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 17:16:16 +03:00

83 lines
2.9 KiB
Makefile

#
# shater-core — data-plane glue for the Shater transparent-proxy stack.
#
# Ships the "железно" (rock-solid) static layer that the Go control-plane
# (xrayctl) and the LuCI app sit on: the procd init that supervises the stock
# xray binary against xrayctl's generated /etc/xray/run.json, the hotplug hook
# that re-persists policy routing, the sysctl knobs TPROXY needs, a minimal
# inert UCI default, and one-time rt_tables seeding.
#
# Pure scripts + config => PKGARCH:=all. Nothing is compiled here.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=shater-core
PKG_VERSION:=0.1.0
PKG_RELEASE:=17
PKG_MAINTAINER:=Shater <maqrota@icloud.com>
PKG_LICENSE:=GPL-2.0-or-later
include $(INCLUDE_DIR)/package.mk
define Package/shater-core
SECTION:=net
CATEGORY:=Network
TITLE:=Shater transparent-proxy data-plane glue
URL:=https://github.com/shater
# xrayctl : control-plane (gen/test/apply/reconcile) invoked by our init/hotplug
# xray-core: the /usr/bin/xray engine our init supervises
# dnsmasq-full: nftset= support for domain-based routing sets
# kmod-nft-tproxy + kmod-nft-socket: kernel TPROXY (xrayctl emits the rules)
# ip-full : `ip rule`/`ip route`/rt_tables for policy routing
DEPENDS:=+xrayctl +xray-core +dnsmasq-full +kmod-nft-tproxy +kmod-nft-socket +ip-full
PKGARCH:=all
endef
define Package/shater-core/description
Static data-plane glue for the Shater xray-based transparent proxy: procd
init (supervises xray on xrayctl-generated /etc/xray/run.json and reconciles
policy routing / our nft table `inet shater`), an ifup/ifdown hotplug hook
that re-persists ip rules & routes, TPROXY sysctl settings, a minimal inert
UCI default (globals disabled until configured), and idempotent first-boot
setup. Designed to never break connectivity: fully inert until explicitly
enabled and a generated runtime config exists.
endef
# /etc/config/shater is user-editable desired state -> preserve on upgrade.
define Package/shater-core/conffiles
/etc/config/shater
endef
# Nothing to fetch or build.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile
endef
define Package/shater-core/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/etc/init.d/shater $(1)/etc/init.d/shater
$(INSTALL_BIN) ./files/etc/init.d/shater-cron $(1)/etc/init.d/shater-cron
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/99-shater $(1)/etc/hotplug.d/iface/99-shater
$(INSTALL_DIR) $(1)/etc/sysctl.d
$(INSTALL_DATA) ./files/etc/sysctl.d/99-shater.conf $(1)/etc/sysctl.d/99-shater.conf
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/etc/config/shater $(1)/etc/config/shater
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/etc/uci-defaults/30_shater-core $(1)/etc/uci-defaults/30_shater-core
$(INSTALL_DIR) $(1)/usr/share/shater
$(INSTALL_DATA) ./files/usr/share/shater/README $(1)/usr/share/shater/README
endef
$(eval $(call BuildPackage,shater-core))