mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-06-29 03:12:12 +08:00
feat: 添加浏览器指纹黑名单功能 (#757)
* feat: 添加浏览器指纹黑名单功能 - 前端集成 @fingerprintjs/fingerprintjs 库自动采集浏览器指纹 - 在所有 API 请求中通过 x-fingerprint header 传递指纹信息 - 将指纹黑名单集成到现有的 IP 黑名单功能中 - 支持精确匹配和正则表达式模式匹配指纹 - 在 App.vue mount 时预初始化指纹,避免首次请求延迟 - 使用 Vue 全局状态缓存指纹,避免重复生成 - 管理后台新增指纹黑名单配置,与 IP/ASN 黑名单统一管理 - 后端在限流 API 请求前检查指纹黑名单,返回 403 阻止访问 技术细节: - 指纹生成时间:50-300ms(一次性) - 缓存命中:<1ms - 请求开销:~20 字节/请求 - 支持最多 1000 条指纹黑名单规则 - 完善的错误处理,失败时不阻塞正常请求 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: 优化浏览器指纹初始化逻辑 - 移除 App.vue 中的预初始化,改为在首次 API 调用时自动初始化 - 移除不必要的 clearFingerprintCache 函数 - 初始化失败时返回特殊值 'ERROR' 而非空字符串 - 失败值会被缓存,避免重复尝试失败 优势: - 减少页面加载时的初始化开销 - 简化代码,去除不必要的函数 - 更清晰的错误标识 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { h } from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
import i18n from '../i18n'
|
||||
import { getFingerprint } from '../utils/fingerprint'
|
||||
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || "";
|
||||
const {
|
||||
@@ -20,6 +21,9 @@ const instance = axios.create({
|
||||
const apiFetch = async (path, options = {}) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
// Get browser fingerprint for request tracking
|
||||
const fingerprint = await getFingerprint();
|
||||
|
||||
const response = await instance.request(path, {
|
||||
method: options.method || 'GET',
|
||||
data: options.body || null,
|
||||
@@ -29,6 +33,7 @@ const apiFetch = async (path, options = {}) => {
|
||||
'x-user-access-token': userSettings.value.access_token,
|
||||
'x-custom-auth': auth.value,
|
||||
'x-admin-auth': adminAuth.value,
|
||||
'x-fingerprint': fingerprint,
|
||||
'Authorization': `Bearer ${jwt.value}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user