pub struct Args {Show 40 fields
pub cfg_file: Option<String>,
pub config: Option<String>,
pub ip: Option<String>,
pub port: Option<u16>,
pub login_account: Option<String>,
pub login_pwd: Option<String>,
pub login_pwd_md5: Option<String>,
pub login_pwd_file: Option<String>,
pub login_region: Option<LoginRegion>,
pub platform: Option<Platform>,
pub auth_server: Option<String>,
pub device_id: Option<String>,
pub reset_device: bool,
pub setup_only: bool,
pub verify_code: Option<String>,
pub log_level: Option<LogLevel>,
pub websocket_port: Option<u16>,
pub telnet_port: Option<u16>,
pub telnet_ip: Option<String>,
pub rest_port: Option<u16>,
pub rest_tls_cert: Option<PathBuf>,
pub rest_tls_key: Option<PathBuf>,
pub grpc_port: Option<u16>,
pub rsa_private_key: Option<String>,
pub json_log: bool,
pub lang: Option<String>,
pub language_pack_auto_update: Option<bool>,
pub language_pack_endpoint: Option<String>,
pub language_pack_cache_dir: Option<PathBuf>,
pub language_pack_update_timeout_ms: Option<u64>,
pub rest_keys_file: Option<PathBuf>,
pub grpc_keys_file: Option<PathBuf>,
pub ws_keys_file: Option<PathBuf>,
pub allow_tcp_unauthenticated: bool,
pub no_allow_tcp_unauthenticated: bool,
pub audit_log: Option<PathBuf>,
pub tz: Option<String>,
pub client_sig_proactive_refresh: bool,
pub client_sig_reactive_refresh: bool,
pub history_kline_cloud_sync: Option<bool>,
}Expand description
FutuOpenD Rust Gateway — 完全替代 C++ OpenD
Fields§
§cfg_file: Option<String>XML 配置文件路径 (兼容 C++ FutuOpenD.xml)
config: Option<String>TOML 配置文件路径 (v1.4.2+;字段与 CLI 参数对齐, CLI 参数覆盖).
字段白名单 (与 XmlConfig schema 一致):
- 登录:
login_account/login_pwd/login_pwd_md5/login_pwd_file/login_region/platform - 监听:
ip/port(aliasapi_port) /rest_port/grpc_port/websocket_port/telnet_port/telnet_ip - 安全:
rsa_private_key/rest_keys_file/rest_tls_cert/rest_tls_key/grpc_keys_file/ws_keys_file/audit_log/allow_tcp_unauthenticated - 系统:
lang/log_level/tz/client_sig_proactive_refresh/client_sig_reactive_refresh/history_kline_cloud_sync/language_pack_auto_update/language_pack_endpoint/language_pack_cache_dir/language_pack_update_timeout_ms
不能写 TOML 的 CLI-only 字段 (运维 / 调试 / 一次性流程):
device_id / reset_device / setup_only / verify_code /
json_log / inject_auth_failure_every (dev-flags feature only)
任何 unknown field / typo 都会触发 fatal parse error 并中止启动, 不会静默忽略。
示例:
login_account = "123456"
ip = "0.0.0.0"
port = 11111
rest_port = 22222
grpc_port = 33333
rest_keys_file = "/etc/futu/keys.json"
audit_log = "/var/log/futu-audit.jsonl"
tz = "Asia/Hong_Kong"ip: Option<String>API 服务监听地址
port: Option<u16>API 服务监听端口
login_account: Option<String>登录账号
login_pwd: Option<String>登录密码明文(legacy argv fallback;不建议生产使用:会暴露在 ps 输出
和 shell history。优先用 --login-pwd-file)
login_pwd_md5: Option<String>登录密码 MD5 (32 位小写 hex;legacy argv fallback;不建议生产使用:
MD5 可直接登录,且同样会暴露在 ps 输出和 shell history)
login_pwd_file: Option<String>登录密码从文件读(v1.4.18+)——适用于 systemd LoadCredential= /
Docker secrets 场景。argv 里只有文件路径,不会泄露明文。
文件内容:明文密码(末尾 \n 会被 trim 掉)。
login_region: Option<LoginRegion>后端连接区域 (gz / sh / hk) —— 仅对 --platform futunn 生效
这三个值是 futunn 平台的广州 / 上海 / 香港数据中心标识。
对 --platform moomoo 账户此 flag 会被忽略:daemon 内 commconfig 根据
user_attribution 查 guaranteed_ip 列表覆盖。想切 moomoo 各区用
--platform moomoo + 账号本身决定归属。
v1.4.40 起 clap 封闭 enum 拒绝非法值(v1.4.39 及以前静默接受任意字符串)。
platform: Option<Platform>账号平台(v1.4.14+)—— futunn=牛牛/CN/HK,moomoo=US/SG/AU/JP/CA
同手机号 / 邮箱可以在两边各注册独立账号(不同密码)。默认 futunn。
--auth-server 显式指定 URL 时覆盖 --platform。
auth_server: Option<String>认证服务器 URL(覆盖 --platform 推导的默认值,主要给测试环境用)
device_id: Option<String>设备 ID(16 位 hex)—— 覆盖自动生成/持久化的值。
v1.4.17+ 默认从 ~/.futu-opend-rs/device-{hash}.dat 读(首次随机生成
并写入)。本参数用于显式指定,并更新持久化文件。
如果 device_id 被服务端锁定(error_code=15/21),可用
--reset-device 一键清空文件让下次启动随机生成新值。
reset_device: bool重置 device_id + credentials 文件后再启动(v1.4.17+)
当用户的 device_id 因空验证码 / 多次 SMS 输错被服务端锁定,
所有后续请求都返回 error_code=15 长时间没有登录 无法恢复。
本参数删除 ~/.futu-opend-rs/device-{hash}.dat 和
credentials-{hash}.json,下次 login 重新生成随机 device_id 走
完整首登流程。
setup_only: bool只完成首次设备验证 + 凭据缓存后退出(v1.4.17+)
用于 systemd / Docker / cron 场景:先在前台终端手动跑一次
futu-opend --setup-only 完成 SMS 验证,写入 credentials 文件,然后
生产环境启动时直接走 remember-login 跳过 SMS。
verify_code: Option<String>直接传入 SMS 验证码,跳过终端交互。用于 systemd / Docker / CI / 远程中继等非 TTY 场景。
若同一 HOME 下已有仍有效、尚未完成的 SMS challenge:
- 前台 TTY 重启会在发出替换 challenge 的请求前安全提示输入验证码;
- 非 TTY 重启必须提供本参数,否则会保留原 challenge 并在发请求前退出。
典型用法:
# 1. 先不带 --verify-code 启动触发 SMS(非 TTY 会退出,但 SMS 已发)
futu-opend --setup-only --login-account X --login-pwd-file /path/to/login-pwd
# 2. 收到 SMS 后使用同一 HOME,立即带验证码重新启动
futu-opend --setup-only --login-account X --login-pwd-file /path/to/login-pwd --verify-code 123456log_level: Option<LogLevel>日志级别(trace/debug/info/warn/error/off);非法值在参数解析阶段拒绝。
websocket_port: Option<u16>WebSocket 服务监听端口(可选,不指定则不启动 WebSocket)
telnet_port: Option<u16>Telnet 管理端口(可选,不指定则不启动 Telnet)
telnet_ip: Option<String>Telnet 管理口监听地址(默认 127.0.0.1;仅在 –telnet-port 启用时生效)
与主 --ip 独立:即使 FTAPI/REST/gRPC 绑定 0.0.0.0,Telnet 默认也
只监听 loopback,避免误暴露无鉴权管理口。
rest_port: Option<u16>REST API 监听端口(可选,不指定则不启动 REST API)
rest_tls_cert: Option<PathBuf>REST listener TLS certificate chain(PEM)。
rest_tls_key: Option<PathBuf>REST listener TLS private key(PEM;必须与 certificate 成对配置)。
grpc_port: Option<u16>gRPC 服务监听端口(可选,不指定则不启动 gRPC)
rsa_private_key: Option<String>RSA 私钥文件路径(PEM 格式,启用后 InitConnect 使用 RSA 加解密)
json_log: boolJSON 格式日志
lang: Option<String>界面语言 (chs=简体中文, cht=繁体中文, en=英文)
language_pack_auto_update: Option<bool>后台自动更新语言包。默认 true;无 endpoint 或下载失败不会阻塞启动。
endpoint 来源优先级: CLI --language-pack-endpoint > TOML/XML
language_pack_endpoint > FUTU_LANGUAGE_PACK_ENDPOINT。未配置 endpoint
时状态为 enabled_no_endpoint,不联网。
language_pack_endpoint: Option<String>完整 manifest URL,或必须以 / 结尾的 HTTPS 目录 URL(自动追加 manifest.json)。
默认不写死任何内部 endpoint;HTTP 仅允许 localhost 测试。
language_pack_cache_dir: Option<PathBuf>语言包 cache 根目录;默认按 OS cache dir 或 FUTU_LANGUAGE_PACK_CACHE_DIR。
language_pack_update_timeout_ms: Option<u64>语言包后台更新 HTTP 超时,单位毫秒;默认 3000。
rest_keys_file: Option<PathBuf>REST API Bearer Token 鉴权:加载 keys.json(futucli gen-key 生成)
不指定时 REST API 只读接口保持 legacy 无鉴权;写交易/admin 仍要求 API key。
grpc_keys_file: Option<PathBuf>gRPC Bearer Token 鉴权:加载 keys.json(futucli gen-key 生成)
不指定时 gRPC 无鉴权。通常与 –rest-keys-file 指向同一文件。
ws_keys_file: Option<PathBuf>核心 WebSocket Bearer Token 鉴权:加载 keys.json
v1.0 起核心 WS(--websocket-port,Futu SDK 使用的 binary WS)支持
握手 + per-message scope 鉴权。客户端用 ?token=<plaintext> query 或
Authorization: Bearer <plaintext> header 传 key。不指定这个 flag 时
WS 无鉴权(legacy 保持兼容,启动 warn)。通常与 --rest-keys-file 指向
同一文件。
allow_tcp_unauthenticated: bool显式允许 native TCP(FTAPI --port)接受无鉴权连接。
背景: native TCP FTAPI 协议 (Python SDK / C++ OpenD 用) 没有 Authorization header 概念, InitConnect proto 无 Bearer 字段. 加 keystore 后无法做 caller-specific scope 检查.
默认行为 (v1.4.104+): 配置任一 keys file (--rest-keys-file /
--grpc-keys-file / --ws-keys-file) → daemon 关闭 TCP 端口
(fail-closed,避免跨 surface 绕过鉴权)。
显式 opt-in 此 flag → 保留 TCP 端口, daemon 启动 loud warn 用户该 端口完全无 auth.
no_allow_tcp_unauthenticated: bool显式禁止 native TCP(FTAPI --port)接受无鉴权连接。
此负向 CLI 开关用于覆盖 TOML/XML 中持久化的
allow_tcp_unauthenticated = true;CLI 显式值优先于配置文件。
audit_log: Option<PathBuf>审计日志输出:JSONL 文件路径或目录
- 带扩展名的路径(如
/var/log/futu-audit.jsonl)→ 单文件 append - 不带扩展名 / 以
/结尾(如/var/log/futu-audit/)→ 每日滚动, 文件名futu-audit.log+ 日期后缀
只记录 auth / 交易 事件(target = “futu_audit”),常规日志不受影响。
tz: Option<String>时区覆盖(IANA name,如 “Asia/Hong_Kong” / “America/New_York”)
用于 hours_window 限额检查等 “local time” 语义. 不指定时用系统 TZ
环境变量, 仍未设则用 UTC. 典型场景:
- Daemon 跑在 UTC server 但想 HK 交易时段限额 →
--tz Asia/Hong_Kong - Daemon 跑在 local workstation 且
TZ已正确 → 不用--tz
优先级: --tz flag > TZ env var > UTC.
client_sig_proactive_refresh: bool长跑 daemon: 在 client_sig 到期前 1 小时主动刷新。
默认关闭。也可通过环境变量 FUTU_CLIENT_SIG_PROACTIVE_REFRESH=1 打开。
建议先在非关键账户长跑验证后再用于生产。
client_sig_reactive_refresh: bool长跑 daemon: reconnect 连续 TCP 登录失败时尝试刷新 client_sig 后再登录。
默认关闭。也可通过环境变量 FUTU_CLIENT_SIG_REACTIVE_REFRESH=1 打开。
该路径只在连续失败达到阈值后触发,避免把瞬时网络抖动当成凭据过期。
history_kline_cloud_sync: Option<bool>与官方 OpenD/App 共用历史 K 线已使用额度的云端状态。
默认开启。可显式传 false 进入 local-compat 模式;该模式只关闭
CMD20175/20179/20180 网络副作用,不关闭本地 quota owner。
Trait Implementations§
Source§impl Args for Args
impl Args for Args
Source§fn group_id() -> Option<Id>
fn group_id() -> Option<Id>
ArgGroup::id][crate::ArgGroup::id] for this set of argumentsSource§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Command] so it can instantiate self via
[FromArgMatches::update_from_arg_matches_mut] Read moreSource§impl FromArgMatches for Args
impl FromArgMatches for Args
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§impl Parser for Args
impl Parser for Args
§fn parse_from<I, T>(itr: I) -> Self
fn parse_from<I, T>(itr: I) -> Self
§fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
§fn update_from<I, T>(&mut self, itr: I)
fn update_from<I, T>(&mut self, itr: I)
§fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
Auto Trait Implementations§
impl Freeze for Args
impl RefUnwindSafe for Args
impl Send for Args
impl Sync for Args
impl Unpin for Args
impl UnsafeUnpin for Args
impl UnwindSafe for Args
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].