[PR #5099] [MERGED] feat: add manual and automatic WARP IP rotation #5781

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

📋 Pull Request Information

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

Base: main ← Head: feat/warp-ip-rotation


📝 Commits (3)

  • 1ca1823 feat: add manual and automatic WARP IP rotation
  • 809689b fix: update generated api and frontend schemas
  • ee5f5b1 fix(warp): validate rotation interval, fix auto-update timing, sync editor

📊 Changes

27 files changed (+436 additions, -28 deletions)

View changed files

📝 frontend/public/openapi.json (+12 -0)
📝 frontend/src/generated/examples.ts (+2 -0)
📝 frontend/src/generated/schemas.ts (+12 -0)
📝 frontend/src/generated/types.ts (+2 -0)
📝 frontend/src/generated/zod.ts (+2 -0)
📝 frontend/src/pages/xray/overrides/WarpModal.tsx (+89 -21)
➕ util/wireguard.go (+24 -0)
📝 web/controller/xray_setting.go (+26 -7)
📝 web/entity/entity.go (+3 -0)
➕ web/job/warp_ip_job.go (+52 -0)
📝 web/service/setting.go (+17 -0)
📝 web/service/warp.go (+40 -0)
📝 web/service/xray_setting.go (+89 -0)
📝 web/translation/ar-EG.json (+5 -0)
📝 web/translation/en-US.json (+5 -0)
📝 web/translation/es-ES.json (+5 -0)
📝 web/translation/fa-IR.json (+5 -0)
📝 web/translation/id-ID.json (+5 -0)
📝 web/translation/ja-JP.json (+5 -0)
📝 web/translation/pt-BR.json (+5 -0)

...and 7 more files

📄 Description

Problem Description

Sites like Google, Spotify, and Apple often block or restrict traffic originating from DataCenter IPs, which is why users rely on Cloudflare WARP as an outbound to bypass these restrictions. However, because the WARP IP address does not change automatically, the assigned IP can become "dirty" over time, leading to Google Captcha challenges and other connectivity issues.

Currently, there is no easy way for users to manually request a new WARP IP or automate this process in the 3x-ui panel without rebuilding the entire outbound configuration.

Solution Implemented

This PR introduces a complete workflow to manually and automatically rotate the WARP outbound IP address:

  1. Manual IP Rotation:

    • Added a "Change IP" button in the WARP settings modal (WarpModal.tsx).
    • Created a new backend API endpoint /panel/api/xray/warp/changeIp that generates a new WireGuard keypair and re-registers the WARP account with Cloudflare to acquire a fresh IP address.
    • Dynamically updates the Xray config template with the newly acquired private key, reserved bytes, local address, and peer public key, followed by an automatic Xray restart.
  2. Automated IP Rotation:

    • Added an "Auto Update IP Address" setting in the WARP settings modal to let users configure an update interval (in days). Setting it to 0 disables the feature.
    • Introduced WarpUpdateInterval and WarpLastUpdate to the application's SettingService to store the interval and track the last update timestamp.
    • Implemented a background cron job (WarpIpJob) that runs hourly. It checks if the configured number of days has elapsed since the last update and triggers the IP rotation automatically if needed.

Files Modified

  • web/entity/entity.go: Added WarpUpdateInterval.
  • web/service/setting.go: Added default value, getters, and setters for warpUpdateInterval and warpLastUpdate.
  • web/service/warp.go: Implemented ChangeWarpIP() logic and integrated it with Xray settings updates.
  • web/service/xray_setting.go: Implemented UpdateWarpXraySetting to apply new WARP credentials deeply into the existing Xray config template.
  • web/controller/xray_setting.go: Registered the /changeIp and /interval API routes.
  • util/wireguard.go: Created helper function GenerateWireguardKeypair to generate new Curve25519 keys for the WireGuard interface.
  • web/job/warp_ip_job.go: Implemented the scheduled cron job for automated rotation.
  • web/web.go: Registered WarpIpJob to run hourly.
  • frontend/src/pages/xray/overrides/WarpModal.tsx: Built the UI components for manual and automatic rotation, communicating with the newly created APIs.

Testing Performed

  • Validated that clicking "Change IP" successfully retrieves a new configuration, updates the settings, and restarts Xray.
  • Verified TypeScript compilation (npm run typecheck), linting (eslint), and bundling (npm run build) in the frontend.
  • Confirmed the Go backend successfully compiles and boots.

🔄 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/5099 **Author:** [@rqzbeh](https://github.com/rqzbeh) **Created:** 6/8/2026 **Status:** ✅ Merged **Merged:** 6/8/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/warp-ip-rotation` --- ### 📝 Commits (3) - [`1ca1823`](https://github.com/MHSanaei/3x-ui/commit/1ca18238292f7bb7d3a6a8a5e19a865eace9a4b3) feat: add manual and automatic WARP IP rotation - [`809689b`](https://github.com/MHSanaei/3x-ui/commit/809689b136f6e87a63814fb9fae37f40029703d5) fix: update generated api and frontend schemas - [`ee5f5b1`](https://github.com/MHSanaei/3x-ui/commit/ee5f5b183fe56f44d1f05cbfba9cc6a9d611a955) fix(warp): validate rotation interval, fix auto-update timing, sync editor ### 📊 Changes **27 files changed** (+436 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `frontend/public/openapi.json` (+12 -0) 📝 `frontend/src/generated/examples.ts` (+2 -0) 📝 `frontend/src/generated/schemas.ts` (+12 -0) 📝 `frontend/src/generated/types.ts` (+2 -0) 📝 `frontend/src/generated/zod.ts` (+2 -0) 📝 `frontend/src/pages/xray/overrides/WarpModal.tsx` (+89 -21) ➕ `util/wireguard.go` (+24 -0) 📝 `web/controller/xray_setting.go` (+26 -7) 📝 `web/entity/entity.go` (+3 -0) ➕ `web/job/warp_ip_job.go` (+52 -0) 📝 `web/service/setting.go` (+17 -0) 📝 `web/service/warp.go` (+40 -0) 📝 `web/service/xray_setting.go` (+89 -0) 📝 `web/translation/ar-EG.json` (+5 -0) 📝 `web/translation/en-US.json` (+5 -0) 📝 `web/translation/es-ES.json` (+5 -0) 📝 `web/translation/fa-IR.json` (+5 -0) 📝 `web/translation/id-ID.json` (+5 -0) 📝 `web/translation/ja-JP.json` (+5 -0) 📝 `web/translation/pt-BR.json` (+5 -0) _...and 7 more files_ </details> ### 📄 Description ## Problem Description Sites like Google, Spotify, and Apple often block or restrict traffic originating from DataCenter IPs, which is why users rely on Cloudflare WARP as an outbound to bypass these restrictions. However, because the WARP IP address does not change automatically, the assigned IP can become "dirty" over time, leading to Google Captcha challenges and other connectivity issues. Currently, there is no easy way for users to manually request a new WARP IP or automate this process in the 3x-ui panel without rebuilding the entire outbound configuration. ## Solution Implemented This PR introduces a complete workflow to manually and automatically rotate the WARP outbound IP address: 1. **Manual IP Rotation**: - Added a "Change IP" button in the WARP settings modal (`WarpModal.tsx`). - Created a new backend API endpoint `/panel/api/xray/warp/changeIp` that generates a new WireGuard keypair and re-registers the WARP account with Cloudflare to acquire a fresh IP address. - Dynamically updates the Xray config template with the newly acquired private key, reserved bytes, local address, and peer public key, followed by an automatic Xray restart. 2. **Automated IP Rotation**: - Added an "Auto Update IP Address" setting in the WARP settings modal to let users configure an update interval (in days). Setting it to `0` disables the feature. - Introduced `WarpUpdateInterval` and `WarpLastUpdate` to the application's `SettingService` to store the interval and track the last update timestamp. - Implemented a background cron job (`WarpIpJob`) that runs hourly. It checks if the configured number of days has elapsed since the last update and triggers the IP rotation automatically if needed. ## Files Modified - `web/entity/entity.go`: Added `WarpUpdateInterval`. - `web/service/setting.go`: Added default value, getters, and setters for `warpUpdateInterval` and `warpLastUpdate`. - `web/service/warp.go`: Implemented `ChangeWarpIP()` logic and integrated it with Xray settings updates. - `web/service/xray_setting.go`: Implemented `UpdateWarpXraySetting` to apply new WARP credentials deeply into the existing Xray config template. - `web/controller/xray_setting.go`: Registered the `/changeIp` and `/interval` API routes. - `util/wireguard.go`: Created helper function `GenerateWireguardKeypair` to generate new Curve25519 keys for the WireGuard interface. - `web/job/warp_ip_job.go`: Implemented the scheduled cron job for automated rotation. - `web/web.go`: Registered `WarpIpJob` to run hourly. - `frontend/src/pages/xray/overrides/WarpModal.tsx`: Built the UI components for manual and automatic rotation, communicating with the newly created APIs. ## Testing Performed - Validated that clicking "Change IP" successfully retrieves a new configuration, updates the settings, and restarts Xray. - Verified TypeScript compilation (`npm run typecheck`), linting (`eslint`), and bundling (`npm run build`) in the frontend. - Confirmed the Go backend successfully compiles and boots. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:02 +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#5781
No description provided.