Files
zTools2/config.example.yaml
zikai fffba79022 feat: 文件浏览页 + 共享白板 + 白板管理页(含补登记分片上传/隧道历史改动)
本次提交包含两批改动(7月2日遗留未入库 + 本次新功能),分述如下:

【补登记:7月2日已上线但未提交的功能】
- 分片上传:chunk_upload_controller/service/dao + UploadSession model/schema,
  支持 4MiB 分片、乱序、断点续传、去重、幂等 complete;后台 reaper 清理过期会话。
- 反向隧道:tunnel_controller/service/dao + TunnelSession model/schema,
  SSH remote forward 经 /api/userPort/{userName} 反代到 user 本地服务。
- 上传页:views/upload_html.py(拖拽/多文件/分片/断点续传 UI)。
- config.py:StorageConfig.chunk_session_dir/ttl、TunnelConfig;
  requirements.txt 加 httpx;start.sh 清理 .work/ 残留;
  schema.sql 加 upload_session/tunnel_session 表;sftp_server 承载隧道转发。

【本次新功能】
- 文件浏览页:GET /files(Basic Auth 同 docs)+ /api/admin/files(list/get/download/DELETE)。
  硬删除(DB 行 + 磁盘文件),删除后列表不再显示。前端 static/file_browser.*。
- 共享白板:GET /whiteboard/{id}(公开,不存在则新建)+ WS /ws/whiteboard/{id}。
  MySQL 持久化(whiteboard 表),Canvas 实时同步,心跳 3s/5 次失活移除,
  清空/复制按钮,移动端兼容。WhiteboardHub 管理 {board_id: set[Connection]},
  disconnect 幂等 + 空 set 清理防泄漏,broadcast 失败连接自动移除。
- 白板管理页:GET /whiteboard-admin(Basic Auth)+ /api/admin/whiteboards(list/DELETE)。
  删除时 hub.close_board 踢出在线连接。
- 清理:合并 UploadService.get_out_with_disk_path(下载/删除复用,消除重复 DB 读),
  移除无用 resolve_disk_path。
- config.py:WhiteboardConfig(heartbeat/threshold/board_id 长度/list_limit);
  schema.sql 加 whiteboard 表;README 补新接口与心跳/内存说明。
- 验证:tests/manual_whiteboard_hub.py / _ws.py / _kick.py 全部通过。
2026-07-21 14:28:13 +00:00

67 lines
3.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Application runtime configuration. Copy from config.example.yaml and fill in real values.
# All secrets (DB password, SFTP user hashes/keys) live here - keep it out of version control.
server:
host: 127.0.0.1 # bind address; Apache proxies f.zikai.wang -> here
port: 6867 # internal port; MUST match the Apache ProxyPass target
workers: 1 # uvicorn worker count
database:
host: 127.0.0.1
port: 3306
user: zikai_filesvc
password: "CHANGE_ME" # generated/overwritten by setup.sh provisioning
database: zikai_filesvc # independent new database (not shared with other apps)
pool_size: 5
pool_recycle: 1800
storage:
upload_dir: ./uploads # where uploaded files are written (shared with SFTP)
chunk_bytes: 1048576 # 1 MiB streaming chunk for HTTP upload (keeps RAM flat)
sha256_on_upload: true # compute sha256 while streaming to disk
chunk_session_dir: ./.work # 分片上传会话暂存目录(相对 upload_dir拼接在此完成
chunk_session_ttl_seconds: 300 # 被放弃会话的存活秒数;后台 reaper 据此清理临时文件
sftp:
enabled: true
host: 0.0.0.0 # SFTP cannot go through Apache's HTTP proxy, expose directly
port: 2022 # open this port in the firewall for external SFTP clients
host_key_path: ./keys/ssh_host_ed25519_key
authorized_keys_path: ./keys/authorized_keys
# Each user may authenticate by password (bcrypt hash) and/or by a public key listed
# in authorized_keys_path. Generate a bcrypt hash with:
# python -c "import bcrypt;print(bcrypt.hashpw(b'yourpass',bcrypt.gensalt()).decode())"
users:
- username: uploader
password_hash: "CHANGE_ME_BCRYPT_HASH"
# public keys for this user go in keys/authorized_keys (one key per line, OpenSSH format)
docs:
# /docs, /redoc and /openapi.json are protected with HTTP Basic Auth.
# Password is stored as plaintext here -- this file is root-owned and lives
# only on this server; comparison is constant-time. No hashing needed.
enabled: true
username: admin
password: "CHANGE_ME"
realm: "zikai docs"
tunnel:
# 反向隧道user 端通过 SSH 反向转发把本地服务暴露到 serverserver 再经
# HTTP 路由 /api/userPort/{userName} 对公网提供访问。disabled 时 SSH 拒绝转发请求。
enabled: false
users:
- username: tunneluser
password_hash: "CHANGE_ME_BCRYPT_HASH" # bcrypt生成方式同 sftp.users
tunnel_port: 9001 # server 侧 SSH remote forward 绑定的本地端口
local_port: 8080 # user 端要暴露的本地服务端口(仅记录用)
whiteboard:
# 共享白板:/whiteboard/{id} 公开访问并实时协作WebSocket管理页 /whiteboard-admin
# 与 /api/admin/whiteboards 走 docs 同款 Basic Auth。
# 心跳:客户端每 heartbeat_interval_seconds 发一次 ping连续丢失 heartbeat_miss_threshold
# 次判失活,服务端关闭并移除该连接。
heartbeat_interval_seconds: 3
heartbeat_miss_threshold: 5
max_board_id_length: 64 # board_id 合法字符 [a-zA-Z0-9_-],长度上限
list_limit: 100 # 管理页单次列表上限