Skip to content

pg-node geofiles CLI command parsing and inconsistent behavior #49

@Cid0r0v1ch

Description

@Cid0r0v1ch

Environment

  • pg-node version: v0.4.3
  • Xray-core version: 26.3.27
  • OS: Linux 24.04.3 LTS (Noble Numbat) (systemd + Docker)
  • Service: pg-node-service
  • Docker Compose v2 installed

Summary

The pg-node geofiles command has inconsistent and broken argument parsing behavior.

The command:

  • ignores region arguments (ru, russia, iran, etc.)
  • sometimes falls back to Iran silently
  • sometimes returns Unknown option
  • sometimes triggers shell autocompletion output instead of executing
  • has no discoverable help or usage syntax
  • behaves inconsistently between identical invocations

This makes regional geofile installation effectively unusable outside the default flow.


Expected Behavior

The command should support explicit region selection, for example:

pg-node geofiles ru
pg-node geofiles russia
pg-node geofiles iran

Expected:

  • geofiles for the specified region are downloaded
  • command usage/help is documented
  • invalid regions return a proper validation message
  • behavior is deterministic

Example expected output:

Downloading Russia geofiles...
Russia geofiles downloaded to /var/lib/pg-node/assets

Actual Behavior

Case 1 — region argument rejected

pg-node geofiles ru

Result:

Unknown option: ru

Same for:

pg-node geofiles russia
pg-node geofiles Russia
pg-node geofiles iran
pg-node geofiles RU

Case 2 — no help available

pg-node geofiles help
pg-node geofiles ?

Result:

Unknown option

No syntax/help output exists for the subcommand.


Case 3 — autocompletion-like output instead of execution

Running:

pg-node geofiles

sometimes outputs:

completion
edit
install
renew-cert
...

instead of executing the command.

This looks like shell completion leaking into runtime execution.


Case 4 — inconsistent execution

The same command:

pg-node geofiles

eventually succeeds later without any configuration changes:

No region specified, defaulting to Iran geofiles...
Downloading Iran geofiles...
Iran geofiles downloaded to /var/lib/pg-node/assets
XRAY_ASSETS_PATH updated in /opt/pg-node/.env
Restarting node services...
...
Geofiles updated and node restarted.

This inconsistency suggests unstable argument parsing or command dispatch logic.


Additional Observations

.env lookup inconsistency inside container

Container logs always show:

Failed to load env file ... open .env: no such file or directory

even though:

Environment="ENV_FILE=/opt/pg-node/.env"

is configured in systemd and the node works correctly afterward.

This may indicate:

  • container process ignores ENV_FILE
  • relative .env lookup is hardcoded
  • startup warning is misleading/noisy

Relevant Logs

Successful service startup

pg-node-service listening on https://localhost:62051
API key protection enabled
TLS enabled on port 62051

Geofiles failure logs

geofiles update failed (exit code: -1): signal: killed

Container startup

Starting Node: v0.4.3
gRPC Server listening on 0.0.0.0:62050
xray started, Version: 26.3.27

Reproduction Steps

  1. Install/start pg-node
  2. Run:
pg-node geofiles ru
  1. Observe:
Unknown option: ru
  1. Run:
pg-node geofiles
  1. Observe inconsistent behavior:
  • sometimes shell-like completion output
  • sometimes actual geofile installation

Impact

  • Regional geofiles cannot be selected explicitly
  • CLI UX is confusing and undocumented
  • Automation/scripts cannot reliably use geofiles
  • Behavior appears nondeterministic

Suggested Fixes

  1. Implement proper positional argument parsing for regions

  2. Add:

    pg-node geofiles --help
  3. Validate supported region names

  4. Remove shell completion leakage into runtime execution

  5. Ensure deterministic command dispatch

  6. Clarify .env loading logic inside container startup

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions