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>
58 lines
1.8 KiB
Makefile
58 lines
1.8 KiB
Makefile
#
|
|
# OpenWrt package Makefile for xrayctl — the xray control-plane daemon.
|
|
# Cross-compiled through the OpenWrt SDK against musl (golang-package.mk).
|
|
#
|
|
# Absolute path to THIS package's directory (robust for src-link feeds), captured
|
|
# before any include changes $(MAKEFILE_LIST).
|
|
XRAYCTL_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
PKG_NAME:=xrayctl
|
|
PKG_VERSION:=0.1.0
|
|
PKG_RELEASE:=17
|
|
|
|
PKG_MAINTAINER:=shater
|
|
PKG_LICENSE:=MIT
|
|
|
|
# Build from the source tree shipped alongside this Makefile (no remote tarball).
|
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
|
|
|
# Go import path == module name (see go.mod: `module xrayctl`).
|
|
GO_PKG:=xrayctl
|
|
PKG_BUILD_DEPENDS:=golang/host
|
|
PKG_BUILD_FLAGS:=no-mips16
|
|
|
|
include $(INCLUDE_DIR)/package.mk
|
|
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
|
|
|
define Package/xrayctl
|
|
SECTION:=net
|
|
CATEGORY:=Network
|
|
TITLE:=xray control-plane (UCI -> xray JSON + nft + policy-routing)
|
|
URL:=https://github.com/shater/xrayctl
|
|
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
|
|
endef
|
|
|
|
define Package/xrayctl/description
|
|
xrayctl reads the UCI desired-state (/etc/config/xray), renders an xray JSON
|
|
config, an nftables tproxy table (inet shater) and policy-routing, then applies
|
|
them atomically with commit-confirm/rollback. Subscriptions, multi-hop chains,
|
|
balancer+observatory, per-client/domain/geo routing and DNS split.
|
|
endef
|
|
|
|
# Copy the local Go sources into the build dir before compiling.
|
|
define Build/Prepare
|
|
mkdir -p $(PKG_BUILD_DIR)
|
|
$(CP) $(XRAYCTL_DIR)*.go $(XRAYCTL_DIR)go.mod $(PKG_BUILD_DIR)/
|
|
endef
|
|
|
|
define Package/xrayctl/install
|
|
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
|
$(INSTALL_DIR) $(1)/usr/bin
|
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/xrayctl $(1)/usr/bin/xrayctl
|
|
endef
|
|
|
|
$(eval $(call GoBinPackage,xrayctl))
|
|
$(eval $(call BuildPackage,xrayctl))
|