Files
3x-rule-sync/README.md
T

48 lines
2.4 KiB
Markdown

# 3x-rule-sync
[Русский](#русский) · [English](#english)
## Русский
CLI синхронизирует управляемые Xray routing rules между панелями 3x-ui, сохраняя правила и балансировщики, созданные вручную.
```sh
cp config.example.yaml config.yaml
go run . -config config.yaml -once
go run . -config config.yaml -once -dry-run -debug
go run . -config config.yaml
```
`tokenEnv` задаёт имя переменной окружения и имеет приоритет над непустым `token`.
- `disabled: true` записывает в правило `enabled: false`; правило остаётся в конфигурации.
- Один совпавший `outbound.tag` используется напрямую; несколько создают балансировщик.
- `leastPing` и `leastLoad` требуют Xray `observatory`.
- Порядок правил в YAML сохраняется; `sync.position` выбирает размещение блока: `first` или `last`.
- В YAML используйте одинарные кавычки для regex с `\`: `tagRegex: '^[a-z\-]+$'`.
- `-debug` выводит доступные outbound tags. Теги outbound-подписок участвуют в regex, но не записываются в редактируемый Xray template.
Не добавляйте `config.yaml` с токенами в репозиторий.
## English
CLI for synchronizing managed Xray routing rules across 3x-ui panels while preserving manually maintained rules and balancers.
```sh
cp config.example.yaml config.yaml
go run . -config config.yaml -once
go run . -config config.yaml -once -dry-run -debug
go run . -config config.yaml
```
`tokenEnv` names an environment variable and overrides a non-empty `token`.
- `disabled: true` writes `enabled: false` to the rule while retaining it in configuration.
- One matching `outbound.tag` is used directly; several matches create a balancer.
- `leastPing` and `leastLoad` require an Xray `observatory`.
- YAML rule order is retained; `sync.position` places the managed block at `first` or `last`.
- Use single YAML quotes for regexes containing `\`: `tagRegex: '^[a-z\-]+$'`.
- `-debug` logs available outbound tags. Subscription outbound tags participate in regex matching but are not saved into the editable Xray template.
Do not commit `config.yaml` containing tokens.