Files
shater/xrayctl/Makefile
T
omarandClaude Opus 4.8 146ae252cc
build / aarch64_cortex-a53 (push) Successful in 2m59s
build / x86_64 (push) Successful in 3m0s
feat(geodata): make geoip.dat/geosite.dat optional + on-demand download
The ~25 MB geo data files are no longer a hard dependency (critical on
small-flash routers). The plugin works without them; the generator strips
geosite:/geoip: matchers from routing rules and the dns object when the data
is absent so the config stays valid and deterministic. Users download them on
demand — only when there is disk to spare — and remove them to reclaim flash.

- xrayctl/geodata.go: `geodata status|download|remove`; free-space check via
  `df -k`; opkg/apk install of v2ray-geoip/v2ray-geosite + asset-dir symlinks;
  errors reported in-band (JSON `error`) for the UI.
- generate.go/dns.go: builder.geoOK = geoAssetPresent(); geoOK threaded into
  dnsRender; geoStrip() drops geo matchers when absent.
- LuCI: geodata panel on the Lists page (presence, sizes, free/need, Download/
  Remove buttons gated on free space); ubus geodata_status/download/remove + acl.
- tests: TestGeoStrip, TestDNSRenderGeoOptional, TestBuildConfigStripsGeoWhenAbsent.

Verified live on the 512M VM: status reports present+sizes+free; xray 25.1.30
starts without geodata (lazy-load); ubus wiring returns correct JSON. r8.

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

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:=8
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))