feat: add address source tracking (source_meta field) (#794)

- Add source_meta field to address table for tracking creation source
- Web: records client IP address (with fallback to 'web:unknown')
- Telegram: records 'tg:{userId}'
- Admin: records 'admin'
- Add database migration with field existence check
- Add frontend display in admin Account page
- Backward compatible: fallback if field doesn't exist

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Dream Hunter
2025-12-28 13:44:52 +08:00
committed by GitHub
parent 499f65078b
commit 3b3968f3b4
11 changed files with 99 additions and 16 deletions

View File

@@ -144,11 +144,17 @@ api.post('/api/new_address', async (c) => {
}
try {
const addressPrefix = await getAddressPrefix(c);
// Get client IP for source tracking
const sourceMeta = c.req.header('CF-Connecting-IP')
|| c.req.header('X-Forwarded-For')?.split(',')[0]?.trim()
|| c.req.header('X-Real-IP')
|| 'web:unknown';
const res = await newAddress(c, {
name, domain,
enablePrefix: true,
checkLengthByConfig: true,
addressPrefix
addressPrefix,
sourceMeta
});
return c.json(res);
} catch (e) {