Documentation
¶
Overview ¶
Package api implements the HTTP API server for xray-subscription management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP API server holding shared dependencies.
func (*Server) ReconcileKillSwitchLoop ¶ added in v0.1.6
ReconcileKillSwitchLoop periodically re-applies the persisted killswitch state to the Xray runtime. This catches the drift caused by an xray restart (Ansible `--tags xray_inbounds`, manual `systemctl restart xray`, package upgrade, …) reloading `/etc/xray/config.d/220-in-fallback.json` from disk while the killswitch is OFF in the DB — without this loop, raven-subscribe would not notice and the fallback inbound would silently start listening again.
The loop is a no-op when XrayAPIAddr is empty or FallbackInboundTags is unset (the same guards as applyKillSwitchInboundsLocked). interval <= 0 disables the loop entirely.
reconcileKillSwitchLocked is idempotent — repeated "remove" calls treat "not found" as benign — so the cadence trades latency-to-detect-drift for gRPC churn.
func (*Server) ReconcileKillSwitchOnStartup ¶ added in v0.1.6
func (s *Server) ReconcileKillSwitchOnStartup()
ReconcileKillSwitchOnStartup applies the current persisted killswitch state to the Xray runtime via gRPC. Intended to be called once after server initialization, before the HTTP listener is up. When disabled, removes fallback inbounds from Xray (they may have been loaded from /etc/xray/config.d/ on Xray's own startup); when enabled, no-op (Xray already has them).
type Syncer ¶
type Syncer interface {
Sync() error
Status() syncer.SyncStatus
}
Syncer is the subset of *syncer.Syncer the api package needs. We import the syncer package only for the SyncStatus type, which lets the health endpoint forward state without redefining a parallel struct.