[GH-ISSUE #6947] [Feature]: RFC: Secure, versioned plugin API for optional 3x-ui extensions #4598

Open
opened 2026-10-31 20:40:47 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @HamedSanaei on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6947

3x-ui should remain lightweight, stable, and focused on core proxy management. However, there are useful features that only a small subset of operators need. Merging all of them into the core increases maintenance, database, CPU, and memory costs for everyone.

For example, traffic history by arbitrary date range (#6353) is useful to some operators but does not justify mandatory historical storage for all installations. A community member has already built an external companion for that use case: 3x-ui-traffic-monitor.

I propose a documented, versioned plugin/extension standard so operators can add optional features without forking 3x-ui or making the core panel carry every specialized requirement.

Prior art / not a duplicate: The general plugin request #4306 was closed, and PR #5789 (manifest, ZIP installation, catalog/UI, but no executable runtime) was closed without merging. This issue requests agreement on a minimal, secure extension contract and integration points, rather than immediately adding an unrestricted plugin installer.

Describe the solution you'd like

An opt-in, capability-based plugin API, with the following design principles:

  1. Stable contract: Versioned manifest (plugin ID/version, compatible 3x-ui versions, required capabilities/permissions, configuration schema, events/hooks and optional UI contributions). Publish an SDK/reference implementation and compatibility policy.
  2. Isolation and security: Prefer out-of-process companions/sidecars communicating over a constrained API or event channel. No arbitrary untrusted Go/JS execution inside the panel process, unrestricted SQL access, or direct Xray mutations. Use scoped credentials, explicit permissions, authenticated requests, timeouts, rate limits, resource bounds, and audit logs.
  3. Lifecycle: Admin-controlled install/register, enable/disable, update and uninstall; validate manifests and packages, handle version incompatibilities, and ensure a crashed/unavailable plugin cannot break core services.
  4. Useful extension points: Read-only client/node/inbound metadata, safe lifecycle events (client created/updated/depleted/reset), traffic accounting events, narrowly scoped subscription/UI contributions, and optional billing/reseller integrations. Event IDs, retry semantics and idempotency must be specified.
  5. Minimal default overhead: No background tasks, additional tables, or per-traffic-poll plugin work unless the relevant plugin is explicitly enabled. Keep traffic collection and quota enforcement reliable even if a plugin fails.

Important accounting limitation: Xray's current per-user stats aggregate traffic by email across inbounds. A plugin cannot reliably apply different coefficients to Hosts, IPv6, CDN, or individual inbounds without a trustworthy source of per-route/per-inbound byte attribution. The standard should expose only accurate, available signals (e.g. per-node deltas when attributable), clearly distinguish raw usage from billable usage, and never silently approximate or overwrite core quota counters. Any quota-affecting plugin would require a separately reviewed, atomic accounting policy hook.

Concrete use cases

  • Historical analytics: A plugin/companion like 3x-ui-traffic-monitor provides per-client history, date filters and charts without forcing all users to store history in the panel (#6353).
  • Custom traffic coefficients / incentives: Operators might want a 0.25× charged-traffic coefficient for an attributable IPv6 route, a discounted CDN-backed route, and 1.00× for a more expensive Iran-to-foreign-server tunnel. This is a desired policy, not currently guaranteed technically feasible at Host granularity; it needs accurate attribution and safe quota integration. Related discussions: #5791 and #6509.
  • Resellers / delegated administration: A plugin could provide sub-admins with strictly limited visibility and management of assigned clients and quotas, with permissions enforced on the server, not just hidden UI controls.
  • Pay-as-you-go services: Optional usage-based charging, wallet integrations, and external payment workflows, without embedding a billing system in the core 3x-ui distribution.

Suggested minimal implementation / acceptance criteria

Phase 1 — RFC and protocol first: Agree on the security boundaries, permission model, versioned manifest, supported read APIs/events, delivery/retry semantics, and compatibility rules. Reuse existing authenticated panel APIs where sufficient. Demonstrate one read-only companion plugin end to end.

Phase 2 — opt-in extension host: Add explicit plugin registration/lifecycle and a small set of safe, versioned event/API hooks. Verify disabled-plugin overhead is negligible, failures are isolated, upgrades remain backward compatible, and behavior is tested on SQLite/PostgreSQL and multi-node setups.

Phase 3 — privileged extensions only after separate review: Billing modifiers, delegated-admin authorization, and other operations that affect quotas or access control need dedicated design and security reviews, not generic unrestricted hooks.

Acceptance: Existing installations operate unchanged when no plugins are enabled; no silent traffic double-counting; no privilege escalation; documented sample, tests, migration/rollback and failure-handling strategy.

Alternatives you've considered

  • Add each niche feature directly to core: Increases complexity and resource usage for operators who do not need it.
  • Standalone scripts and existing REST API: Already viable for some read-only use cases (such as the traffic monitor), but they lack a consistent permission/capability contract and safe, documented integration events; they are not sufficient for every feature.
  • Maintain custom forks: Expensive to keep compatible with frequent upstream releases.

Maintainer discussion requested

@MHSanaei, would a small, secure, out-of-process plugin API standard be acceptable in principle, or do you prefer third-party integrations to remain entirely external through the existing REST API? If acceptable, I suggest agreeing on the contract and MVP scope before opening another large implementation PR.

Related: #4306 (closed), #5789 (closed, unmerged), #6353, #5791, #6509.

Which parts of the panel would this affect?

Backend/API, frontend/plugin management, security/permissions, optional statistics and subscription integration, database only if strictly necessary.

Before submitting

  • I checked related issues and the prior unmerged plugin PR; this RFC specifies a more limited security model and phased contract, rather than repeating the original generic request.
  • Written in English.
Originally created by @HamedSanaei on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6947 ### Is your feature request related to a problem? 3x-ui should remain lightweight, stable, and focused on core proxy management. However, there are useful features that only a small subset of operators need. Merging all of them into the core increases maintenance, database, CPU, and memory costs for everyone. For example, traffic history by arbitrary date range (#6353) is useful to some operators but does not justify mandatory historical storage for all installations. A community member has already built an external companion for that use case: [3x-ui-traffic-monitor](https://github.com/abolfazlakbarzadeh/3x-ui-traffic-monitor). I propose a **documented, versioned plugin/extension standard** so operators can add optional features without forking 3x-ui or making the core panel carry every specialized requirement. **Prior art / not a duplicate:** The general plugin request #4306 was closed, and PR #5789 (manifest, ZIP installation, catalog/UI, but no executable runtime) was closed without merging. This issue requests **agreement on a minimal, secure extension contract and integration points**, rather than immediately adding an unrestricted plugin installer. ### Describe the solution you'd like An **opt-in, capability-based plugin API**, with the following design principles: 1. **Stable contract:** Versioned manifest (plugin ID/version, compatible 3x-ui versions, required capabilities/permissions, configuration schema, events/hooks and optional UI contributions). Publish an SDK/reference implementation and compatibility policy. 2. **Isolation and security:** Prefer out-of-process companions/sidecars communicating over a constrained API or event channel. No arbitrary untrusted Go/JS execution inside the panel process, unrestricted SQL access, or direct Xray mutations. Use scoped credentials, explicit permissions, authenticated requests, timeouts, rate limits, resource bounds, and audit logs. 3. **Lifecycle:** Admin-controlled install/register, enable/disable, update and uninstall; validate manifests and packages, handle version incompatibilities, and ensure a crashed/unavailable plugin cannot break core services. 4. **Useful extension points:** Read-only client/node/inbound metadata, safe lifecycle events (client created/updated/depleted/reset), traffic accounting events, narrowly scoped subscription/UI contributions, and optional billing/reseller integrations. Event IDs, retry semantics and idempotency must be specified. 5. **Minimal default overhead:** No background tasks, additional tables, or per-traffic-poll plugin work unless the relevant plugin is explicitly enabled. Keep traffic collection and quota enforcement reliable even if a plugin fails. **Important accounting limitation:** Xray's current per-user stats aggregate traffic by email across inbounds. A plugin cannot reliably apply different coefficients to *Hosts*, IPv6, CDN, or individual inbounds without a trustworthy source of per-route/per-inbound byte attribution. The standard should expose only accurate, available signals (e.g. per-node deltas when attributable), clearly distinguish raw usage from billable usage, and never silently approximate or overwrite core quota counters. Any quota-affecting plugin would require a separately reviewed, atomic accounting policy hook. ### Concrete use cases - **Historical analytics:** A plugin/companion like [3x-ui-traffic-monitor](https://github.com/abolfazlakbarzadeh/3x-ui-traffic-monitor) provides per-client history, date filters and charts without forcing all users to store history in the panel (#6353). - **Custom traffic coefficients / incentives:** Operators might want a **0.25×** charged-traffic coefficient for an attributable IPv6 route, a discounted CDN-backed route, and **1.00×** for a more expensive Iran-to-foreign-server tunnel. This is a desired policy, **not currently guaranteed technically feasible at Host granularity**; it needs accurate attribution and safe quota integration. Related discussions: #5791 and #6509. - **Resellers / delegated administration:** A plugin could provide sub-admins with strictly limited visibility and management of assigned clients and quotas, with permissions enforced on the server, not just hidden UI controls. - **Pay-as-you-go services:** Optional usage-based charging, wallet integrations, and external payment workflows, without embedding a billing system in the core 3x-ui distribution. ### Suggested minimal implementation / acceptance criteria **Phase 1 — RFC and protocol first:** Agree on the security boundaries, permission model, versioned manifest, supported read APIs/events, delivery/retry semantics, and compatibility rules. Reuse existing authenticated panel APIs where sufficient. Demonstrate one **read-only** companion plugin end to end. **Phase 2 — opt-in extension host:** Add explicit plugin registration/lifecycle and a small set of safe, versioned event/API hooks. Verify disabled-plugin overhead is negligible, failures are isolated, upgrades remain backward compatible, and behavior is tested on SQLite/PostgreSQL and multi-node setups. **Phase 3 — privileged extensions only after separate review:** Billing modifiers, delegated-admin authorization, and other operations that affect quotas or access control need dedicated design and security reviews, not generic unrestricted hooks. **Acceptance:** Existing installations operate unchanged when no plugins are enabled; no silent traffic double-counting; no privilege escalation; documented sample, tests, migration/rollback and failure-handling strategy. ### Alternatives you've considered - **Add each niche feature directly to core:** Increases complexity and resource usage for operators who do not need it. - **Standalone scripts and existing REST API:** Already viable for some read-only use cases (such as the traffic monitor), but they lack a consistent permission/capability contract and safe, documented integration events; they are not sufficient for every feature. - **Maintain custom forks:** Expensive to keep compatible with frequent upstream releases. ### Maintainer discussion requested @MHSanaei, would a **small, secure, out-of-process plugin API standard** be acceptable in principle, or do you prefer third-party integrations to remain entirely external through the existing REST API? If acceptable, I suggest agreeing on the contract and MVP scope **before** opening another large implementation PR. Related: #4306 (closed), #5789 (closed, unmerged), #6353, #5791, #6509. ### Which parts of the panel would this affect? Backend/API, frontend/plugin management, security/permissions, optional statistics and subscription integration, database only if strictly necessary. ### Before submitting - [x] I checked related issues and the prior unmerged plugin PR; this RFC specifies a more limited security model and phased contract, rather than repeating the original generic request. - [x] Written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 26, 2026):

This is a feature request and a design question for the maintainer. The current code has no plugin or extension host. Whether to add one is a project-direction decision that the source can't answer, so this reply only maps what exists today against what the RFC asks for.

What already exists that an out-of-process companion can use

  • Scoped API tokens. Requests to /panel/api/* accept Authorization: Bearer <token> (internal/web/controller/api.go:46). The token's scope is enforced by enforceTokenScope (api.go:142). The known scopes are fixed in internal/database/model/model.go:167-170: admin, monitor, node-sync, node-admin.
  • The monitor scope is too narrow for your use cases. It is a GET-only allowlist of server/Xray/node health endpoints (monitorScopeAllow, api.go:84-95). It does not cover inbound or client traffic reads. So a read-only companion like the traffic-monitor project you link has to hold an admin token today. That gap matches your "lack a consistent permission/capability contract" point. A narrower read-only scope (e.g. clients/traffic GET-only) would be the smallest concrete step toward your Phase 1, and it fits the existing allowlist mechanism.
  • There are no outbound events. internal/eventbus/events.go:8-26 defines only outbound.down/up, xray.crash, node.down/up, cpu.high, memory.high and login.attempt. Its only subscribers are the in-process email, Discord and Telegram notifiers (internal/web/web.go:670,678,754). There are no client lifecycle or traffic events, and no webhook delivery (no webhook match anywhere under internal/). Your Phase 2 would need new event types, plus a delivery, retry and idempotency layer that doesn't exist yet.

Your accounting caveat is correct. Client traffic is parsed from Xray stats by clientTrafficRegex = regexp.MustCompile(\user>>>([^>]+)>>>traffic>>>(downlink|uplink)`) (internal/xray/api.go:51`). That counter is keyed only by email, so per-inbound or per-route coefficients can't be attributed from it.

Prior attempts: #4306 (generic plugin request) is closed, and PR #5789 ("add plugin contract and installer UI") was closed without being merged. #6353 (traffic history by date range) is still open. This RFC is a narrower re-proposal, not a duplicate.

You asked the maintainer about this directly, so the decision is theirs. A practical way to split it: (1) a read-only API-token scope for client/inbound/traffic data, and (2) outbound client lifecycle events. Each can be decided on its own, before any generic plugin host is designed.

Verdict: Feature request

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:6412977439 --> @github-actions[bot] commented on GitHub (Oct 26, 2026): This is a feature request and a design question for the maintainer. The current code has no plugin or extension host. Whether to add one is a project-direction decision that the source can't answer, so this reply only maps what exists today against what the RFC asks for. **What already exists that an out-of-process companion can use** - **Scoped API tokens.** Requests to `/panel/api/*` accept `Authorization: Bearer <token>` (`internal/web/controller/api.go:46`). The token's scope is enforced by `enforceTokenScope` (`api.go:142`). The known scopes are fixed in `internal/database/model/model.go:167-170`: `admin`, `monitor`, `node-sync`, `node-admin`. - **The `monitor` scope is too narrow for your use cases.** It is a GET-only allowlist of server/Xray/node health endpoints (`monitorScopeAllow`, `api.go:84-95`). It does not cover inbound or client traffic reads. So a read-only companion like the traffic-monitor project you link has to hold an `admin` token today. That gap matches your "lack a consistent permission/capability contract" point. A narrower read-only scope (e.g. clients/traffic GET-only) would be the smallest concrete step toward your Phase 1, and it fits the existing allowlist mechanism. - **There are no outbound events.** `internal/eventbus/events.go:8-26` defines only `outbound.down/up`, `xray.crash`, `node.down/up`, `cpu.high`, `memory.high` and `login.attempt`. Its only subscribers are the in-process email, Discord and Telegram notifiers (`internal/web/web.go:670,678,754`). There are no client lifecycle or traffic events, and no webhook delivery (no `webhook` match anywhere under `internal/`). Your Phase 2 would need new event types, plus a delivery, retry and idempotency layer that doesn't exist yet. **Your accounting caveat is correct.** Client traffic is parsed from Xray stats by `clientTrafficRegex = regexp.MustCompile(\`user>>>([^>]+)>>>traffic>>>(downlink|uplink)\`)` (`internal/xray/api.go:51`). That counter is keyed only by email, so per-inbound or per-route coefficients can't be attributed from it. **Prior attempts:** #4306 (generic plugin request) is closed, and PR #5789 ("add plugin contract and installer UI") was closed without being merged. #6353 (traffic history by date range) is still open. This RFC is a narrower re-proposal, not a duplicate. You asked the maintainer about this directly, so the decision is theirs. A practical way to split it: (1) a read-only API-token scope for client/inbound/traffic data, and (2) outbound client lifecycle events. Each can be decided on its own, before any generic plugin host is designed. Verdict: Feature request _This reply was generated automatically; a maintainer may follow up._ <!-- claude-issue:analyst -->
Author
Owner

@HamedSanaei commented on GitHub (Oct 28, 2026):

Proposal: a secure, versioned Extension Platform (discussion draft)

I reviewed the current Go/Gin backend, REST authorization, in-process event bus, React/Vite frontend, and the closed plugin PR #5789. My recommendation is to build a VS Code-like extension developer experience, but not to execute arbitrary third-party Go/JS code inside the 3x-ui process. The first milestone should be an agreed, versioned integration contract—not a ZIP installer or marketplace.

1. Architecture and trust boundary

3x-ui Core (Go/Gin + SQLite/PostgreSQL + Xray)
   |-- versioned, authenticated REST API
   |-- optional durable event delivery
   v
Extension API / registration layer (opt-in)
   |-- traffic analytics companion (read-only)
   |-- billing companion (later security review)
   |-- reseller companion (later authorization review)
   `-- optional isolated UI page
  • Run extensions out of process as operator-managed sidecars/services/containers communicating via authenticated HTTP or a protected local socket.
  • Explicitly register and authorize capabilities; a manifest is not permission to execute code. Avoid general-purpose ZIP execution, arbitrary SQL, shell access, and unrestricted Xray mutations.
  • Enforce bounded request timeouts, rate limits, credential rotation/revocation, strict API response schemas, and appropriate resource limits.
  • A broken, offline, or incompatible extension must never block panel startup, Xray operation, quota enforcement, or traffic sampling.

2. Versioned manifest and compatibility contract

For discussion only (not currently supported):

{
  "schemaVersion": "3x-ui.extension/v1",
  "id": "community.traffic-history",
  "version": "1.0.0",
  "requires": { "apiVersion": "v1" },
  "permissions": ["clients:read", "traffic:read"],
  "events": ["client.updated.v1"],
  "ui": { "page": "traffic-history", "label": "Traffic History" }
}

Document unique IDs, JSON Schema, stable capability naming, API/manifest versions, compatibility negotiation, optional vs required permissions, upgrade/downgrade and rollback rules, configuration/secrets handling, disable/uninstall behavior, and a sample SDK/companion. Requested capabilities should be individually approved and server-enforced, not trusted merely because they appear in a manifest.

3. Reuse existing infrastructure without assuming it is sufficient

Auth and APIs: internal/web/controller/api.go already supports Bearer tokens and exact route/method allowlists, but monitor is limited to health and metrics. A read-only analytics companion currently needs a broad admin token to read clients/inbounds/traffic. A narrow read-only scope (or capability-based authorization) with pagination, filtering, redaction and negative authorization tests would be a useful standalone first PR. Do not leak secrets, private keys, or unrelated tenants' information.

Events: internal/eventbus/bus.go is best-effort, in-memory, and explicitly drops events on full queues; process restart also loses buffered events. It should not be treated as reliable billing/event delivery. For integration events requiring delivery guarantees, use an opt-in transactional outbox (SQLite + PostgreSQL), stable event IDs and schemas, at-least-once delivery, bounded retries/backoff, replay/retention, subscriber checkpoints and idempotent consumers. Avoid synchronous callbacks/network I/O in the traffic hot path. If this is too much for v1, use a pull-only read API first.

Frontend: React/Vite is compiled and embedded, and routes/sidebar are built from frontend/src/routes/panelRoutes.tsx. A single compiled /extensions/:id/* host route with registered sidebar metadata is preferable to dynamic arbitrary module injection. Render any third-party UI via a sandboxed iframe on an isolated origin, with CSP and a tightly validated postMessage bridge; no third-party JS in the authenticated panel origin. Backend-only extensions should work without any UI contribution.

Master/node: Define plugin scope (master, node, or per-installation), node identity and permissions, deduplication, and the provenance of traffic/events. Extensions must not bypass node-sync authorization or double-count master/node data.

4. Important accounting/security limitations

  • Current Xray per-user stats are keyed by email (internal/xray/api.go). They cannot prove per-Host/CDN/IPv6 route byte attribution, so a generic extension cannot safely implement such multipliers using existing counters.
  • Treat raw measured usage and billable usage as distinct concepts. Changes to quotas, payments, delegated admin access, or traffic coefficients require separate, explicitly authorized, atomic/idempotent policy APIs—not generic plugin hooks that rewrite database counters.
  • Do not allow extensions direct DB access, unrestricted admin tokens, arbitrary config changes, or access to panel session cookies.

5. Suggested PR sequence

Milestone Scope Acceptance
RFC / contract Manifest, capabilities, API versioning, threat model, compatibility and sample design Maintainer agreement before implementing installer/runtime
PR 1 Read-only client/inbound/traffic endpoints + scoped tokens + example external companion No admin token; denied writes/secret reads are tested
PR 2 Optional versioned client lifecycle events and reliable delivery if justified Stable IDs, retries, dedup/replay, crash recovery; no hot-path blocking
PR 3 Opt-in registry/lifecycle: register, enable/disable, update, health, revoke Failure isolation, graceful incompatibility handling; minimal idle overhead
PR 4 Optional isolated UI integration, permission prompts and developer guide No same-origin JS injection; CSP/origin/accessibility tests
Separate RFCs Billing/quota writes, reseller roles, package installer/catalog Dedicated security review and transactional accounting design

For each applicable PR, cover SQLite and PostgreSQL, disabled-plugin behavior, failed/unavailable extensions, restart/recovery, and master/node integration. A runnable, genuinely read-only sample is essential for verifying the API contract.

6. Questions for maintainers and contributors

  1. Would you accept an out-of-process-only extension model for v1?
  2. Is a narrowly scoped read-only API + companion example a suitable first PR?
  3. Should we defer package installation/marketplace until security, lifecycle and compatibility contracts are stable?
  4. Which concrete events are worth adding first, if any, and should durable delivery be opt-in?

PR #5789 is useful prior art but was closed without merge; I would not resurrect it as a single large PR. I'd rather establish a minimal contract and land independently reviewable foundations.

Success criterion: with extensions disabled, existing installations behave exactly as before with negligible idle overhead; enabled extensions cannot escalate privileges or disrupt core services; the API stays versioned and testable.

<!-- gh-comment-id:6472271809 --> @HamedSanaei commented on GitHub (Oct 28, 2026): ## Proposal: a secure, versioned Extension Platform (discussion draft) I reviewed the current Go/Gin backend, REST authorization, in-process event bus, React/Vite frontend, and the closed plugin PR #5789. My recommendation is to build a **VS Code-like extension developer experience**, but **not** to execute arbitrary third-party Go/JS code inside the 3x-ui process. The first milestone should be an agreed, versioned integration contract—not a ZIP installer or marketplace. ### 1. Architecture and trust boundary ```text 3x-ui Core (Go/Gin + SQLite/PostgreSQL + Xray) |-- versioned, authenticated REST API |-- optional durable event delivery v Extension API / registration layer (opt-in) |-- traffic analytics companion (read-only) |-- billing companion (later security review) |-- reseller companion (later authorization review) `-- optional isolated UI page ``` - Run extensions **out of process** as operator-managed sidecars/services/containers communicating via authenticated HTTP or a protected local socket. - Explicitly register and authorize capabilities; a manifest is not permission to execute code. Avoid general-purpose ZIP execution, arbitrary SQL, shell access, and unrestricted Xray mutations. - Enforce bounded request timeouts, rate limits, credential rotation/revocation, strict API response schemas, and appropriate resource limits. - A broken, offline, or incompatible extension must **never** block panel startup, Xray operation, quota enforcement, or traffic sampling. ### 2. Versioned manifest and compatibility contract For discussion only (not currently supported): ```json { "schemaVersion": "3x-ui.extension/v1", "id": "community.traffic-history", "version": "1.0.0", "requires": { "apiVersion": "v1" }, "permissions": ["clients:read", "traffic:read"], "events": ["client.updated.v1"], "ui": { "page": "traffic-history", "label": "Traffic History" } } ``` Document unique IDs, JSON Schema, stable capability naming, API/manifest versions, compatibility negotiation, optional vs required permissions, upgrade/downgrade and rollback rules, configuration/secrets handling, disable/uninstall behavior, and a sample SDK/companion. Requested capabilities should be **individually approved and server-enforced**, not trusted merely because they appear in a manifest. ### 3. Reuse existing infrastructure without assuming it is sufficient **Auth and APIs:** `internal/web/controller/api.go` already supports Bearer tokens and exact route/method allowlists, but `monitor` is limited to health and metrics. A read-only analytics companion currently needs a broad `admin` token to read clients/inbounds/traffic. A narrow read-only scope (or capability-based authorization) with pagination, filtering, redaction and negative authorization tests would be a useful **standalone first PR**. Do not leak secrets, private keys, or unrelated tenants' information. **Events:** `internal/eventbus/bus.go` is best-effort, in-memory, and explicitly drops events on full queues; process restart also loses buffered events. It should not be treated as reliable billing/event delivery. For integration events requiring delivery guarantees, use an **opt-in transactional outbox** (SQLite + PostgreSQL), stable event IDs and schemas, at-least-once delivery, bounded retries/backoff, replay/retention, subscriber checkpoints and idempotent consumers. Avoid synchronous callbacks/network I/O in the traffic hot path. If this is too much for v1, use a pull-only read API first. **Frontend:** React/Vite is compiled and embedded, and routes/sidebar are built from `frontend/src/routes/panelRoutes.tsx`. A single compiled `/extensions/:id/*` host route with registered sidebar metadata is preferable to dynamic arbitrary module injection. Render any third-party UI via a **sandboxed iframe on an isolated origin**, with CSP and a tightly validated `postMessage` bridge; no third-party JS in the authenticated panel origin. Backend-only extensions should work without any UI contribution. **Master/node:** Define plugin scope (master, node, or per-installation), node identity and permissions, deduplication, and the provenance of traffic/events. Extensions must not bypass node-sync authorization or double-count master/node data. ### 4. Important accounting/security limitations - Current Xray per-user stats are keyed by email (`internal/xray/api.go`). They cannot prove per-Host/CDN/IPv6 route byte attribution, so a generic extension cannot safely implement such multipliers using existing counters. - Treat **raw measured usage** and **billable usage** as distinct concepts. Changes to quotas, payments, delegated admin access, or traffic coefficients require separate, explicitly authorized, atomic/idempotent policy APIs—not generic plugin hooks that rewrite database counters. - Do not allow extensions direct DB access, unrestricted admin tokens, arbitrary config changes, or access to panel session cookies. ### 5. Suggested PR sequence | Milestone | Scope | Acceptance | | --- | --- | --- | | RFC / contract | Manifest, capabilities, API versioning, threat model, compatibility and sample design | Maintainer agreement before implementing installer/runtime | | PR 1 | Read-only client/inbound/traffic endpoints + scoped tokens + example external companion | No admin token; denied writes/secret reads are tested | | PR 2 | Optional versioned client lifecycle events and reliable delivery if justified | Stable IDs, retries, dedup/replay, crash recovery; no hot-path blocking | | PR 3 | Opt-in registry/lifecycle: register, enable/disable, update, health, revoke | Failure isolation, graceful incompatibility handling; minimal idle overhead | | PR 4 | Optional isolated UI integration, permission prompts and developer guide | No same-origin JS injection; CSP/origin/accessibility tests | | Separate RFCs | Billing/quota writes, reseller roles, package installer/catalog | Dedicated security review and transactional accounting design | For each applicable PR, cover **SQLite and PostgreSQL**, disabled-plugin behavior, failed/unavailable extensions, restart/recovery, and master/node integration. A runnable, genuinely read-only sample is essential for verifying the API contract. ### 6. Questions for maintainers and contributors 1. Would you accept an **out-of-process-only** extension model for v1? 2. Is a narrowly scoped **read-only API + companion example** a suitable first PR? 3. Should we defer package installation/marketplace until security, lifecycle and compatibility contracts are stable? 4. Which concrete events are worth adding first, if any, and should durable delivery be opt-in? PR #5789 is useful prior art but was closed without merge; I would **not** resurrect it as a single large PR. I'd rather establish a minimal contract and land independently reviewable foundations. **Success criterion:** with extensions disabled, existing installations behave exactly as before with negligible idle overhead; enabled extensions cannot escalate privileges or disrupt core services; the API stays versioned and testable.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4598
No description provided.