Commit graph

1321 commits

Author SHA1 Message Date
root
aadd8fdd89 style: apply gofmt formatting 2026-04-24 14:43:44 +08:00
root
288635adfc fix: Clash YAML injection, path validation, and default template
- Quote all YAML string values with %q to prevent injection
- Remove unused host parameter from GetClash
- Add backend path normalization for SubClashPath
- Log StreamSettings JSON unmarshal errors
- Expand template panel by default and provide default template
2026-04-24 14:35:28 +08:00
root
11cdb07e89 feat: add Clash YAML subscription endpoint with template injection
Add /clash/:subid endpoint that returns complete Clash YAML config.
User provides full template (DNS, routing, proxy-groups, rules) in
settings, panel generates proxies from inbound/client data and injects
via proxies: [] placeholder replacement.

- New SubClashService reads template, generates vmess/vless/trojan/ss
  proxy entries with transport (ws/grpc/h2/tcp/httpupgrade), TLS, and
  Reality support
- Settings: subClashEnable, subClashPath, subClashURI, subClashTemplate
- UI: Clash settings tab, QR code on subpage, Desktop dropdown with
  clash-verge:// deep link preferring Clash URL
- Version bump to v1.5.2-beta
2026-04-24 11:25:10 +08:00
root
1a02ebb024 fix: MariaDB JSON_EACH compatibility for subscription and traffic queries
Replace SQLite-only JSON_EACH with DB-type branching (JSON_TABLE for
MariaDB) in subscription, client traffic, and migration queries.
Bump version to v1.5.1.
2026-04-24 10:16:48 +08:00
root
51f17922fa fix: resolve shared-mode traffic flush blocked by stale inboundId=0 delta
The traffic-pending.json file could contain a stale client traffic delta
with inboundId=0 (created before the InboundId resolution fix). When
flushToDatabase tried to INSERT this into client_traffics, it violated
the foreign key constraint fk_inbounds_client_stats, causing the entire
transaction to roll back and blocking ALL traffic from being written to
MariaDB.

- Skip deltas with InboundID==0 in flushToDatabase with a warning log
- Share a single TrafficPendingStore between XrayTrafficJob and the
  flush loop to eliminate a race condition from dual file instances
- Add test for zero InboundID skip behavior
2026-04-24 02:56:23 +08:00
root
99e2e6c2e2 fix: resolve client traffic InboundId from DB in shared mode, set online clients
In shared mode the Xray API returns InboundId=0 for client traffic.
Collect() now looks up the real InboundId from the client_traffics table
by email, and skips unknown emails with a warning. Also computes and
sets online clients in XrayTrafficJob since addClientTraffic is bypassed.
2026-04-24 02:29:02 +08:00
Sora39831
e50b2f471d feat: improve mariadb flow, db settings init, and traffic flush 2026-04-15 16:58:49 +08:00
Sora39831
87282dde33 feat: add durable traffic deltas and shared flush loop 2026-04-10 15:25:16 +08:00
Sora39831
3cfa554786 feat: add cache-backed worker sync and heartbeat loops 2026-04-10 15:15:42 +08:00
Sora39831
34b9f01d0a feat: guard shared writes and bump version transactionally 2026-04-10 11:22:49 +08:00
Sora39831
135ef32477 Add panel domain persistence 2026-04-09 21:39:39 +08:00
Sora39831
8e9e36e1b8 Fix turnstile tab re-render and bump version 2026-04-08 15:34:50 +08:00
Sora39831
8a43a516ac Fix turnstile reload after auth tab switch 2026-04-08 15:18:00 +08:00
Sora39831
ae08f4a50f fix: separate register turnstile layout 2026-04-07 17:32:57 +08:00
Sora39831
b921ed740c chore: add generated fingerprinted assets 2026-04-07 17:17:41 +08:00
Sora39831
5ad2203f24 build: generate fingerprinted assets before compile 2026-04-07 16:43:18 +08:00
Sora39831
cfb169d2fb refactor: resolve template assets through manifest helper 2026-04-07 16:41:55 +08:00
Sora39831
e6752e04db feat: load fingerprinted asset manifest 2026-04-07 12:24:33 +08:00
Sora39831
faeb8dd244 feat: add asset generation command 2026-04-07 12:08:10 +08:00
Sora39831
05ece0bd8e feat: add fingerprinted asset generator 2026-04-07 11:59:25 +08:00
Sora39831
cc6d3daa3a fix: harden migration and setting writes 2026-04-07 02:12:02 +08:00
Sora39831
e298996d77 Harden admin access for panel APIs 2026-04-06 22:12:38 +08:00
Sora39831
6131c55882 fix dashboard and inbounds load failure states 2026-04-06 21:51:33 +08:00
Sora39831
537c73c1b2 fix settings and xray load failure regressions 2026-04-06 21:22:33 +08:00
Sora39831
266f368b07 fix remaining modal state leaks 2026-04-06 21:03:50 +08:00
Sora39831
6564cf8202 fix settings and xray page state leaks 2026-04-06 21:02:58 +08:00
Sora39831
3e1b6ed76f fix frontend loading and client modal bugs 2026-04-06 21:00:02 +08:00
Sora39831
39ba517d9f Fix inbound email options on add modal 2026-04-06 17:14:12 +08:00
Sora39831
2fad726ee1 Change IP limit to 3-minute temporary disable 2026-04-06 16:58:43 +08:00
Sora39831
e468a08a54 Fix IP limit fallback Xray API port resolution 2026-04-06 16:31:39 +08:00
Sora39831
9864224897 fix(iplimit): enforce limit without fail2ban via xray api fallback 2026-04-06 16:04:27 +08:00
Sora39831
2008ae6dc3 style(go): gofmt check_client_ip_job 2026-04-06 15:52:25 +08:00
Sora39831
c085fc3814 fix(iplimit): keep IP records working without fail2ban 2026-04-06 15:45:55 +08:00
Sora39831
03144a16ca fix(mariadb): quote settings key column in xray template queries 2026-04-06 11:04:43 +08:00
Sora39831
15144e199d test(limit): add regression tests for reentry and disabled-limit unban
- inject lightweight hooks in CheckDeviceLimitJob for deterministic tests

- add tests for run re-entrancy, disabled enforcement unban, and stale ban cleanup
2026-04-06 10:49:11 +08:00
Sora39831
83b61d9da4 feat(limit): add inbound device-limit enforcement with safe unban flow
- add inbound deviceLimit model/frontend fields and translations

- add CheckDeviceLimitJob with observation window and xray API ban/unban

- prevent job re-entrancy and restore users when limit is disabled

- reduce lock scope via snapshots to avoid blocking log parsing
2026-04-06 10:46:48 +08:00
Sora39831
4a1dac89b6 fix(inbounds): avoid undefined filterEmailOption in client form 2026-04-05 04:40:24 +08:00
Sora39831
67d24ca0e6 fix(user): sync-remove inbound clients when deleting managed user 2026-04-05 03:52:41 +08:00
Sora39831
dfbe02c2b8 feat(user): delete all user inbounds when deleting user 2026-04-05 03:40:32 +08:00
Sora39831
7db5b9e214 fix(login): reliably render turnstile on register tab 2026-04-05 02:55:28 +08:00
Sora39831
78767c082e feat(users): cascade delete user-owned inbounds when deleting user 2026-04-04 22:35:33 +08:00
Sora39831
0775c5f10d fix(panel): correct user.html i18n quoting to avoid template parse failure 2026-04-04 22:16:34 +08:00
Sora39831
b03bb96899 fix(panel): resolve blank /panel/user caused by invalid i18n template quotes 2026-04-04 20:04:38 +08:00
Sora39831
ec70c4ce07 feat: add user email dropdown for inbound clients 2026-04-04 15:05:37 +08:00
Sora39831
2a9d9a0a6b feat: add admin user management 2026-04-04 14:59:40 +08:00
Sora39831
b0ce1a7ace refactor(settings): organize x-ui.json by module and purpose 2026-04-04 14:46:24 +08:00
Sora39831
4a5d8aa702 fix(settings): preserve turnstile and omitted config fields 2026-04-04 14:45:31 +08:00
Sora39831
37c184aa45 Fix shared-email client traffic deletion scope 2026-04-04 14:29:37 +08:00
Sora39831
c94372a22c fix: address all code review issues for MariaDB support
- Prevent DBPassword from leaking to frontend (json:"-")
- Make migration direction explicit via --direction flag, set dbType only after success
- Use driver-appropriate DROP INDEX IF EXISTS for SQLite vs MariaDB
- Build DSN with mysql.Config.FormatDSN() to prevent injection with special chars
- Close DB before re-initialization in InitDB
- Add migration tests (5 tests using SQLite in-memory DBs)
- Parse JSON once in GetDBConfigFromJSON instead of 7 times
- Use Go binary for dbType in shell script instead of fragile grep
- Add rollback on failure in db_switch_to_sqlite
- Validate DB settings in CheckValid
2026-04-03 09:53:20 +08:00
Sora39831
7f015ad27b fix: address code review issues for MariaDB support
- Close migration DB connections with defer to prevent leaks
- Truncate destination tables before migration to avoid duplicates
- Wrap migration in transaction for atomicity
- Pass DB password via env var instead of CLI args to avoid process list exposure
- Improve error messages for MariaDB export/import with alternatives
- Update package doc to reflect dual DB support
- DRY migration logic with shared migrateAllTables function
2026-04-03 09:39:53 +08:00