Skip to main content

futu_backend/auth/commconfig/
mod.rs

1//! auth/commconfig — 拆 commconfig.rs 1123 → commconfig/{mod, 5 子}.rs
2//! (v1.4.110 CC Batch M)
3//!
4//! C++ `PullCommonConfigV2()` 对齐:动态拉取后台 IP 池 + 配置, 比 DNS / 硬编码
5//! 更权威 (`guaranteed_ip_for_conn` 按 ConnIdentity 分组).
6//!
7//! 子模块:
8//! - `types`      : 6 type alias + 9 const (CONN_WEB_*) + 2 struct (ForcedIpEntry, CommonConfigSnapshot)
9//! - `totp`       : base32_decode + gen_totp_sha1 (Google Authenticator 风格 6 digit)
10//! - `parsers`    : api_root + fetch_page + 4 parse_* + value_kind + is_*_identity
11//! - `fetch`      : fetch_all (主入口) + SharedCommConfig + empty_snapshot + spawn_refresher
12//! - `accessors`  : forced_ip_for_attribution + 3 ips_for_* + webtcp_hardcoded_addrs + 3 identity 派生
13//! - `tests`      : 单元测试 (内容不变, 已 split sibling)
14//!
15//! Parent auth/mod.rs `pub mod commconfig;` 路径不变 (mod.rs re-export 全 pub 项).
16
17mod accessors;
18mod fetch;
19mod parsers;
20mod totp;
21mod types;
22
23#[cfg(test)]
24mod tests;
25
26// hoist for tests.rs (super::* 接 trade_query 类似套路)
27#[cfg(test)]
28pub(super) use super::*;
29
30// ===== 外部 callers 直接用的 (auth/webtcp.rs, auth/broker.rs, auth/mod.rs) =====
31pub use accessors::{
32    broker_auth_webtcp_identity, default_webtcp_identity_for_client_type,
33    forced_ip_for_attribution, ips_for_attribution, ips_for_broker, ips_for_web_identity,
34    spawn_refresher, webtcp_addrs_for_identity, webtcp_hardcoded_addrs,
35};
36pub use fetch::{SharedCommConfig, empty_snapshot, fetch_all};
37pub use parsers::is_web_identity;
38pub use totp::gen_totp_sha1;
39pub use types::{
40    AuthGuaranteedDomainMap, CONN_WEB_AU, CONN_WEB_CA, CONN_WEB_CN, CONN_WEB_HK, CONN_WEB_JP,
41    CONN_WEB_MY, CONN_WEB_SG, CONN_WEB_US, CommonConfigSnapshot, ForcedIpEntry, ForcedIpMap,
42    GuaranteedBrokerIpMap, GuaranteedIpMap, GuaranteedWebIpMap,
43};
44
45// ===== 内部 re-export 给 sibling tests.rs (super::* 接) =====
46#[cfg(test)]
47pub(super) use accessors::delay_until_next_refresh;
48#[cfg(test)]
49pub(super) use parsers::client_version_dotted;
50#[cfg(test)]
51pub(super) use parsers::{
52    api_root_for_client, is_broker_identity, parse_auth_guaranteed_domain_list, parse_forced_ip,
53    parse_guaranteed_ip, parse_web_tcp_config_identity, value_kind,
54};
55#[cfg(test)]
56pub(super) use std::collections::HashMap;
57#[cfg(test)]
58pub(super) use totp::base32_decode;