Skip to main content

Module commconfig

Module commconfig 

Source
Expand description

auth/commconfig — 拆 commconfig.rs 1123 → commconfig/{mod, 5 子}.rs (v1.4.110 CC Batch M)

C++ PullCommonConfigV2() 对齐:动态拉取后台 IP 池 + 配置, 比 DNS / 硬编码 更权威 (guaranteed_ip_for_conn 按 ConnIdentity 分组).

子模块:

  • types : 6 type alias + 9 const (CONN_WEB_*) + 2 struct (ForcedIpEntry, CommonConfigSnapshot)
  • totp : base32_decode + gen_totp_sha1 (Google Authenticator 风格 6 digit)
  • parsers : api_root + fetch_page + 4 parse_* + value_kind + is_*_identity
  • fetch : fetch_all (主入口) + SharedCommConfig + empty_snapshot + spawn_refresher
  • accessors : forced_ip_for_attribution + 3 ips_for_* + webtcp_hardcoded_addrs + 3 identity 派生
  • tests : 单元测试 (内容不变, 已 split sibling)

Parent auth/mod.rs pub mod commconfig; 路径不变 (mod.rs re-export 全 pub 项).

Structs§

CommonConfigSnapshot
CommConfig 协议返回的完整快照(含过期时间)。
ForcedIpEntry

Constants§

CONN_WEB_AU
CONN_WEB_CA
CONN_WEB_CN
CONN_WEB_HK
CONN_WEB_JP
CONN_WEB_MY
CONN_WEB_SG
CONN_WEB_US

Functions§

broker_auth_webtcp_identity
broker_auth 的 WebTCP-short identity 归一入口。
default_webtcp_identity_for_client_type
C++ WebRequestManager::UpdateCommConfig() 的 WebTCP identity 兜底规则: 服务端未下发有效 web_tcp_config.web_conn_identity 时,moomoo app type 默认 CONN_WEB_US,其它(Futu OpenD/Futu HK)默认 CONN_WEB_HK
empty_snapshot
生成一个空 snapshot —— 用于 SharedCommConfig 初始化 / fallback。
fetch_all
forced_ip_for_attribution
gen_totp_sha1
生成 6 位 TOTP auth_token。对齐 C++ GenGoogleOTPCode_SHA1 (OMBase_API_OTP.cpp:12):
ips_for_attribution
从 snapshot 取某 attribution 对应的 IP 池(去拷贝成 Vec<(String, u16)>)。 如果没有则返回空。调用者可以把返回值 merge 到硬编码池最前面。
ips_for_broker
从 snapshot 取 broker_id 对应的 broker 专用 IP 池。
ips_for_web_identity
从 snapshot 取 WebTCP-short identity 对应的 IP 池。
is_web_identity
对齐 C++ FTConnCmn.protoCONN_WEB_* identity。
spawn_refresher
后台循环:按 limit_time 周期刷新 CommConfig,把新 snapshot 存到 SharedCommConfig
webtcp_addrs_for_identity
broker_auth WebTCP-short 的连接候选池:commconfig 优先,空时落到 C++ hardcoded WebTCP 池。调用方不应自己拼 DNS 域名作为主路径。
webtcp_hardcoded_addrs
C++ LoadHardcodeAddress() 里 WebTCP-short identity 的本地保底池。

Type Aliases§

AuthGuaranteedDomainMap
解析后的 auth_guaranteed_domain_list —— 原始鉴权域名 → 兜底域名。
ForcedIpMap
解析后的 forced_ip_for_conn —— identity → (ip, port, expire_ts)。
GuaranteedBrokerIpMap
解析后的 Broker 部分 guaranteed_ip_for_conn —— broker_id → IP 列表。 key 是 FTConnCmn.proto ConnIdentity 里的 CONN_BROKER_FUTU_* 值 (1001=HK / 1007=US / 1008=SG / 1009=AU / 1012=JP / 1017=MY / 1019=CA)。
GuaranteedIpMap
解析后的 Platform 部分 guaranteed_ip_for_conn —— attribution → IP 列表。
GuaranteedWebIpMap
解析后的 WebTCP-short 部分 guaranteed_ip_for_conn —— web conn_identity → IP 列表。 key 是 FTConnCmn.proto CONN_WEB_* 的 10100..10107。
SharedCommConfig
一个 ArcSwap 缓存槽——Bridge 持有,重连/后台刷新器共享。 load() 无锁读,store(Arc::new(new)) 原子替换。