Skip to content

[Feature Request] 在调用日志中记录请求 IP 与客户端标识(系统开关控制,默认关闭) #7620

Description

@taotecode

Agent

  • Tool: DeepSeek Harness (DSH)
  • Tool version: 0.2.0-rc.1
  • Model (full id): glm-5.3
  • Host (CLI / IDE / GitHub coding agent / other): CLI
  • Date (UTC): 2026-09-30

User request

  • Verbatim:

    增加功能:用户的调用模型记录中,支持记录用户的IP和客户端标识。 这个功能需要在系统设置中找一个合适的位置进行开关此功能,默认关闭。

  • Later constraints or corrections from the user (quote, or none):

    还需要开关功能,是否让普通用户也能看到自己的IP和客户端

Out of scope — refuse

  • Matched: no
  • If yes, what was told to the user (stop here; do not file): 不适用(核心日志功能,不在拒绝清单内)

File gate — do not file unless all are satisfied

  • Out of scope (including pass-through): no
  • Usage / configuration / integration (answered instead of filing): no
  • Required facts present without invention (actual behavior, impact, frequency, evidence in new-api, applicable type fields): yes
  • Body is short and factual; no unfiltered AI-generated text: yes
  • File: yes
  • If no, what was told to the user (stop here): 不适用

Kind

  • Bug
  • Feature
  • Investigation
  • Other:

Usage / configuration / integration check

  • https://docs.newapi.ai/ — 检索 sitemap(919 页)中日志/设置相关页面,并打开《使用日志》《运营设置》两页:仅描述日志查看与既有日志记录设置,无记录调用方 IP / 客户端标识的选项。
  • https://deepwiki.com/QuantumNous/new-api — 打开时被 Vercel 安全检查拦截(429),未能读取;以下结论以代码检索为准。
  • README / repo docs: README 无调用日志记录 IP / 客户端标识的功能描述。
  • Relevant code paths and conclusion: model/log.go 的 RecordConsumeLog / RecordErrorLog(main @ 789c970)仅在用户个人设置 RecordIpLog(record_ip_log,个人设置页)开启时把 c.ClientIP() 写入 Log.Ip;不记录任何客户端标识;无系统级开关。
  • Can the current version already do this? (required for feature requests): 部分——仅用户本人自愿开启的「记录本人 IP」;无客户端标识记录、无管理员级系统开关、无普通用户可见性控制。
  • Verdict: product bug or new feature / usage question (stop here): new feature(功能缺失,非故障、非使用问题)

Environment

  • new-api version / commit / image tag (not latest / unknown): main @ 789c970
  • Deploy source (repo release / official image / main source / other): main source
  • Database (sqlite / mysql / postgres): sqlite(本地测试)

Problem facts

  • Actual behavior: 调用日志(消费/错误日志)默认不含调用方 IP 与客户端标识;仅当用户在个人设置开启 record_ip_log 时记录其本人 IP 到 ip 字段。
  • Impact: 管理员无法审计异常调用的来源 IP 与客户端标识;也无法按隐私要求统一控制记录行为与普通用户可见性。
  • Frequency: 每次模型调用均如此。
  • Evidence that the problem is in new-api rather than the client or upstream: 代码与文档检索确认功能不存在(功能缺失,非外部故障)。

Type-specific details

功能请求,无故障复现,以下均 not applicable。

Relay / API

  • not applicable

Billing

  • not applicable

Frontend

  • not applicable(新开关 UI 属本功能实现范围,非既有页面故障)

Deployment / upgrade

  • not applicable

Reproduction and expected result

  • Steps to reproduce: 管理员在控制台查看任意用户的调用日志详情。
  • Expected result: 在管理员开启对应系统开关的前提下,可见该次调用的来源 IP 与客户端标识。
  • Related screenshots (optional): 无

Feature (feature requests only)

  • Feature description:
    1. 调用模型记录(消费与错误日志)支持记录用户 IP 与客户端标识(如 User-Agent)。
    2. 在系统设置中提供开关,默认关闭。
    3. 另一个开关控制普通用户能否在自己的日志中看到自己的 IP 与客户端标识。
  • Use case: 管理员审计异常/滥用调用来源;默认不记录、可见性可控,兼顾隐私。

Duplicate check

Research

Docs

  • https://docs.newapi.ai/ : sitemap 检索 + 打开《使用日志》《运营设置》页——无相关选项。
  • https://deepwiki.com/QuantumNous/new-api : 被 Vercel 安全检查拦截(429),未能打开。
  • README / other repo docs: README 无相关描述。
  • Conclusions: 现有文档与配置均不含本功能。

Code

  • model/log.go — RecordConsumeLog / RecordErrorLog:日志写入路径挂接点;现仅按用户级 RecordIpLog 写 Ip 字段。
  • relaykit/dto/user_settings.go + controller/user.go — 现有 record_ip_log 个人开关的存取路径(本功能不改其语义)。

Experiments

  • not applicable(功能在当前版本不存在,无对照实验;未部署实例)

Working theory

  • What is broken or missing: 日志写入路径不持久化调用方 IP / 客户端标识,也无系统级记录开关与用户可见性控制。
  • Why: RecordConsumeLog / RecordErrorLog 未从请求上下文提取这两项信息。
  • What would falsify this: 存在已支持该记录的系统选项或文档说明(已检索:不存在)。

Scope

  • In scope for a later PR: 两个系统开关(记录开关默认关闭;普通用户可见性开关)、消费/错误日志元数据写入、用户自查接口按可见性开关过滤。
  • Out of scope / not this repo: 客户端工具名解析、按客户端统计面板(见 [Feature Request] 支持识别底层 AI 客户端/工具访问,并在日志和统计面板中展示 #5277)。
  • Large or directional feature? If yes, this issue is for maintainer alignment; do not open a PR yet: 否——小范围可选增强,无表结构变更(复用日志 other 元数据 TEXT 列)。

Proposed direction

  • 验收标准(非实现方案):
    1. 系统设置新增「记录调用方 IP 和客户端标识」开关,默认关闭;开启后消费与错误日志记录请求 IP 与客户端标识。
    2. 系统设置新增「允许用户查看自己的 IP 和客户端标识」开关,默认关闭;关闭时普通用户日志查询不返回这两项,管理员/Root 不受限;翻转开关对历史日志即时生效。
    3. 不改变数据库表结构;现有 record_ip_log 用户级开关行为不变。

Not verified

  • MySQL / PostgreSQL / ClickHouse 实例(无 schema 变更;测试基于 SQLite)
  • deepwiki(被反爬拦截)

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions