Files
operating-room-monitor-server/backend/app/services/video/rtsp_redact.py
Kevin 1af442481e 重组为 backend/clients/docs 三层结构,并清理 git 污染。
将后端迁入 backend/,完善根目录 .gitignore,删除误提交的 .mypy_cache 缓存文件。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-21 16:02:25 +08:00

15 lines
367 B
Python

"""RTSP URL 日志脱敏。"""
from __future__ import annotations
import re
_RTSP_CRED_RE = re.compile(r"(?P<scheme>rtsp://)(?P<userinfo>[^@/\s]+@)")
def redact_rtsp_url(url: str | None) -> str:
"""把 ``rtsp://user:pwd@host/...`` 脱敏为 ``rtsp://***@host/...``。"""
if not url:
return ""
return _RTSP_CRED_RE.sub(r"\g<scheme>***@", url)