[PR #6218] [MERGED] fix(warp): preserve WARP Plus license key when changing IP #6180

Closed
opened 2026-11-02 04:06:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6218
Author: @rqzbeh
Created: 8/15/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @MHSanaei

Base: main ← Head: fix/warp-change-ip-preserves-license-key


📝 Commits (2)

  • 943d324 fix(warp): preserve WARP Plus license key when changing IP
  • 280f284 Merge branch 'main' into fix/warp-change-ip-preserves-license-key

📊 Changes

3 files changed (+215 additions, -3 deletions)

View changed files

📝 frontend/src/pages/xray/overrides/WarpModal.tsx (+3 -0)
📝 internal/web/service/integration/warp.go (+39 -3)
➕ internal/web/service/integration/warp_change_ip_test.go (+173 -0)

📄 Description

Summary

Clicking "Change IP" in the WARP modal no longer deletes a saved WARP Plus license key. The key is written back into stored warp data before the Cloudflare re-apply attempt, and the response now returns the final data so the UI keeps showing the key.

Why

ChangeWarpIP rotates the WireGuard keypair by registering a brand-new Cloudflare device (RegWarp), which overwrites the stored warp JSON with the fresh registration's data — including an empty license_key. The old key was then re-applied only best-effort:

  • If SetWarpLicense failed (license rejected/rate-limited/network), the failure was swallowed with a warning log and the key was permanently gone from storage.
  • Even on success, the response returned to the panel was RegWarp's pre-reapply snapshot, so the modal always showed an empty license key after "Change IP".

The same path is used by the auto-update IP job (warp_ip_job.go), so a scheduled rotation could delete the key too.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • New integration tests in internal/web/service/integration/warp_change_ip_test.go against a mock Cloudflare API:
    • TestChangeWarpIPPreservesLicenseKey — stored + returned data keep the key, device still rotates, license re-applied to the new device.
    • TestChangeWarpIPKeepsLicenseWhenReapplyFails — when the license PUT is rejected (HTTP 500), the key stays in storage and the response carries a warning the UI surfaces.
  • go build ./..., go test -shuffle=on -count=1 $(go list ./...), and golangci-lint (latest) all pass locally.
  • Frontend: npm run lint, npm run typecheck, npm test, npm run build pass; the change to WarpModal.tsx shows a warning toast when the license re-apply fails.
  • Manual repro: seed warp data with a license key → POST /panel/api/xray/warp/changeIp → stored warp JSON still contains the key.

Screenshots / recordings

N/A (no visual layout change; a warning toast appears only when the license re-apply fails remotely).

Breaking changes

None. Response shape gains an optional warning field; data now reflects the final stored state (license key present) instead of the transient post-registration state.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6218 **Author:** [@rqzbeh](https://github.com/rqzbeh) **Created:** 8/15/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/warp-change-ip-preserves-license-key` --- ### 📝 Commits (2) - [`943d324`](https://github.com/MHSanaei/3x-ui/commit/943d324e04217cc7769bb9e7d1437ed3fcf48ab1) fix(warp): preserve WARP Plus license key when changing IP - [`280f284`](https://github.com/MHSanaei/3x-ui/commit/280f2844b7c5f045ec916801f25560c94f6143dc) Merge branch 'main' into fix/warp-change-ip-preserves-license-key ### 📊 Changes **3 files changed** (+215 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/xray/overrides/WarpModal.tsx` (+3 -0) 📝 `internal/web/service/integration/warp.go` (+39 -3) ➕ `internal/web/service/integration/warp_change_ip_test.go` (+173 -0) </details> ### 📄 Description ## Summary Clicking "Change IP" in the WARP modal no longer deletes a saved WARP Plus license key. The key is written back into stored warp data before the Cloudflare re-apply attempt, and the response now returns the final data so the UI keeps showing the key. ## Why `ChangeWarpIP` rotates the WireGuard keypair by registering a brand-new Cloudflare device (`RegWarp`), which overwrites the stored warp JSON with the fresh registration's data — including an **empty** `license_key`. The old key was then re-applied only best-effort: - If `SetWarpLicense` failed (license rejected/rate-limited/network), the failure was swallowed with a warning log and the key was permanently gone from storage. - Even on success, the response returned to the panel was RegWarp's pre-reapply snapshot, so the modal always showed an empty license key after "Change IP". The same path is used by the auto-update IP job (`warp_ip_job.go`), so a scheduled rotation could delete the key too. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [x] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - New integration tests in `internal/web/service/integration/warp_change_ip_test.go` against a mock Cloudflare API: - `TestChangeWarpIPPreservesLicenseKey` — stored + returned data keep the key, device still rotates, license re-applied to the new device. - `TestChangeWarpIPKeepsLicenseWhenReapplyFails` — when the license PUT is rejected (HTTP 500), the key stays in storage and the response carries a `warning` the UI surfaces. - `go build ./...`, `go test -shuffle=on -count=1 $(go list ./...)`, and `golangci-lint` (latest) all pass locally. - Frontend: `npm run lint`, `npm run typecheck`, `npm test`, `npm run build` pass; the change to `WarpModal.tsx` shows a warning toast when the license re-apply fails. - Manual repro: seed warp data with a license key → POST `/panel/api/xray/warp/changeIp` → stored warp JSON still contains the key. ## Screenshots / recordings N/A (no visual layout change; a warning toast appears only when the license re-apply fails remotely). ## Breaking changes None. Response shape gains an optional `warning` field; `data` now reflects the final stored state (license key present) instead of the transient post-registration state. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:55 +07:00
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#6180
No description provided.