feat(email-generator): 更新 Cloudflare 邮箱生成逻辑,使用 10 位随机前缀格式

This commit is contained in:
QLHazyCoder
2026-04-13 01:47:51 +08:00
parent 843b1fee8a
commit fbaf7629b8
2 changed files with 22 additions and 14 deletions
+4 -3
View File
@@ -182,9 +182,10 @@ Cloudflare 模式下,插件不会再调用 Cloudflare API 创建路由。
它现在只做一件事: 它现在只做一件事:
1. 根据你当前选中的 `CF 域名` 1. 根据你当前选中的 `CF 域名`
2. 本地生成一个随机前缀 2. 本地生成一个 10 位随机前缀
3. 直接得到一个类似 `user20260412153000123@example.xyz` 的注册邮箱 3. 前缀由 `6 个小写字母 + 4 个数字` 组成,顺序随机打乱
4. 把这个邮箱写入当前流程继续往下跑 4. 直接得到一个类似 `a3b9cd1e2f@example.xyz` 的注册邮箱
5. 把这个邮箱写入当前流程继续往下跑
也就是说,插件默认认为: 也就是说,插件默认认为:
+18 -11
View File
@@ -3027,17 +3027,24 @@ function getEmailGeneratorLabel(generator) {
} }
function generateCloudflareAliasLocalPart() { function generateCloudflareAliasLocalPart() {
const now = new Date(); const letters = 'abcdefghijklmnopqrstuvwxyz';
const stamp = [ const digits = '0123456789';
now.getFullYear(), const chars = [];
String(now.getMonth() + 1).padStart(2, '0'),
String(now.getDate()).padStart(2, '0'), for (let i = 0; i < 6; i++) {
String(now.getHours()).padStart(2, '0'), chars.push(letters[Math.floor(Math.random() * letters.length)]);
String(now.getMinutes()).padStart(2, '0'), }
String(now.getSeconds()).padStart(2, '0'),
].join(''); for (let i = 0; i < 4; i++) {
const randomPart = String(Math.floor(Math.random() * 900) + 100); chars.push(digits[Math.floor(Math.random() * digits.length)]);
return `user${stamp}${randomPart}`.toLowerCase(); }
for (let i = chars.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[chars[i], chars[j]] = [chars[j], chars[i]];
}
return chars.join('');
} }
async function fetchCloudflareEmail(state, options = {}) { async function fetchCloudflareEmail(state, options = {}) {