Files
proxy-suite-flake/scripts/build-inbound.py
T
FUFSoB fdb2b08790 refactor: overhaul of options and features
Includes, but not limited to:
- zapret2 support
- declarative inbounds
- proxy-ctl revamp
- automatic proxy learning
2026-09-13 22:37:45 +05:00

43 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Read an inbound spec file and emit XRay inbounds plus client share links."""
import argparse
import json
import sys
from proxy_inbound import build_inbounds
def main() -> None:
ap = argparse.ArgumentParser(
description="Render services.proxy-suite.inbounds into XRay inbounds."
)
ap.add_argument("--spec", required=True, help="path to the generated inbound spec JSON")
ap.add_argument(
"--server-address",
default="",
dest="server_address",
help="public address used in generated share links",
)
args = ap.parse_args()
with open(args.spec, encoding="utf-8") as handle:
spec = json.load(handle)
server_address = args.server_address or spec.get("serverAddress") or ""
if spec.get("shareLinks", True) and not server_address:
print("error: no server address available for share links", file=sys.stderr)
sys.exit(1)
try:
result = build_inbounds(spec, server_address)
except (ValueError, OSError) as exc:
print(f"error: {exc}", file=sys.stderr)
sys.exit(1)
print(json.dumps(result))
if __name__ == "__main__":
main()