Skip to main content

ActrixConfig

Struct ActrixConfig 

Source
pub struct ActrixConfig {
Show 15 fields pub enable: u8, pub name: String, pub env: String, pub user: Option<String>, pub group: Option<String>, pub pid: Option<String>, pub bind: BindConfig, pub turn: TurnConfig, pub location_tag: String, pub control: ControlConfig, pub services: ServicesConfig, pub sqlite_path: PathBuf, pub actrix_shared_key: String, pub recording: RecordingConfig, pub monitoring: MonitoringConfig,
}
Expand description

Actrix 辅助服务的主配置结构体

这是系统的核心配置,包含了所有服务的配置信息。 配置文件使用 TOML 格式,支持完整的类型安全加载。

Fields§

§enable: u8

Service enable flags (bitmask) - Primary switch for业务服务

This is the primary control mechanism for enabling业务服务。 control 是常驻控制面能力,不受该位掩码控制。

Bit positions(仅业务服务):

  • Bit 0 (1): Signaling service
  • Bit 1 (2): STUN service
  • Bit 2 (4): TURN service
  • Bit 3 (8): AIS (Actor Identity Service)
  • Bit 4 (16): Signer

Examples:

  • enable = 31 enables all services (1+2+4+8+16=31)
  • enable = 6 enables STUN + TURN (2+4=6)
  • enable = 7 enables Signaling + STUN + TURN (1+2+4=7)
§name: String

服务器实例名称

用于标识不同的服务器实例,在集群部署中用于区分节点。 建议使用有意义的命名规则,如:actrix-01, actrix-prod-east-1 等。

§env: String

运行环境标识

指定当前运行环境,影响安全策略和默认行为:

  • “dev”: 开发环境,允许 HTTP,证书检查较松
  • “prod”: 生产环境,强制 HTTPS,严格的安全检查
  • “test”: 测试环境,用于自动化测试
§user: Option<String>

运行用户(可选)

指定服务运行的系统用户。服务会在绑定端口后切换到此用户运行, 以提高安全性。留空则保持当前用户。

§group: Option<String>

运行用户组(可选)

指定服务运行的系统用户组。与 user 配置配合使用。

§pid: Option<String>

PID 文件路径(可选)

用于存储进程 ID 的文件路径。系统管理工具可以使用此文件 来监控和管理服务进程。

§bind: BindConfig

网络绑定配置

定义各种网络服务的绑定地址和端口配置。

§turn: TurnConfig

TURN 服务特定配置

TURN 中继服务的专用配置,包括公网地址、端口范围、认证域等。

§location_tag: String

位置标签

用于标识服务器的地理位置或逻辑分组,便于运维管理和监控。 例如:us-west-1, office-beijing, edge-node-01

§control: ControlConfig

控制面配置(常驻)

控制面始终可用,不受 enable 位掩码控制。

§services: ServicesConfig

服务配置集合

包含所有业务服务的配置,每个服务可以独立配置自己的参数和依赖。 采用服务级别的配置结构,实现高内聚低耦合。

§sqlite_path: PathBuf

SQLite 数据库文件存储目录路径

指定用于存储所有 SQLite 数据库文件的目录路径。 主数据库文件将存储为 {sqlite_path}/actrix.db。 包括 Realm 信息、访问控制列表、nonce 缓存等。

§actrix_shared_key: String

Actrix 内部服务通信共享密钥

用于 Actrix 各服务之间的内部通信认证,如 AIS 与 Signer 之间的通信。 这是系统级的内部认证密钥,仅用于服务间通信,不应用于对外业务。

注意:

  • 此密钥仅限 Actrix 内部服务使用
  • 不应用于 Realm 业务或外部 API 访问
  • 在生产环境中应使用强随机密钥
  • 字段名保留 actrix_shared_key 以保持向后兼容
§recording: RecordingConfig

记录管线配置(日志 + 追踪)

将日志和 OpenTelemetry 追踪配置合并到统一的 recording 段,便于统一管理。

§monitoring: MonitoringConfig

Monitoring endpoints configuration

Controls authentication for /health and /metrics endpoints. Supports IP whitelist (CIDR) and/or HTTP Basic Auth (htpasswd file). When both are configured, a request matching either is allowed (OR logic). Per-service overrides replace the global config for that service.

Implementations§

Source§

impl ActrixConfig

Source

pub fn is_signaling_enabled(&self) -> bool

检查是否启用了信令服务

Service is enabled if the ENABLE_SIGNALING bit is set in the enable bitmask.

Source

pub fn is_stun_enabled(&self) -> bool

检查是否启用了 STUN 服务

Source

pub fn is_turn_enabled(&self) -> bool

检查是否启用了 TURN 服务

Source

pub fn is_ais_enabled(&self) -> bool

检查是否启用了 AIS (AId Issue Service) 身份认证服务

Service is enabled if the ENABLE_AIS bit is set in the enable bitmask.

Source

pub fn is_signer_enabled(&self) -> bool

检查是否启用了 Signer 密钥服务

Service is enabled if the ENABLE_SIGNER bit is set in the enable bitmask.

Source

pub fn is_ice_enabled(&self) -> bool

检查是否启用了 ICE 服务(STUN 或 TURN)

Source

pub fn control_head(&self) -> ControlHead

当前控制面头类型

Source

pub fn admin_ui_enabled(&self) -> bool

Admin UI 是否启用。

Source

pub fn grpc_api_enabled(&self) -> bool

NodeAdminService gRPC API 是否启用。

Source

pub fn superv_managed(&self) -> bool

是否处于 superv 接管模式。

Source

pub fn get_pid_path(&self) -> Option<String>

获取 PID 文件路径,如果没有配置则使用默认值

Source

pub fn get_actrix_shared_key(&self) -> &str

获取 Actrix 内部服务通信共享密钥

此密钥用于 Actrix 系统内部服务间的认证通信, 如 AIS 与 Signer 之间的服务调用。

注意:此密钥仅用于内部服务通信,不应用于对外业务

Source

pub fn recording_config(&self) -> &RecordingConfig

返回记录管线配置引用

Source

pub fn recording_service_name(&self) -> &str

返回 OTLP service.name

Source

pub fn get_filter_level(&self) -> String

获取复合日志/追踪过滤级别,优先使用 RUST_LOG。

With semantic filters, channel targets are set to TRACE so that all events reach the recording layer (which applies its own gate). The base level stays info to suppress third-party noise.

Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>

从文件加载配置

Source

pub fn from_toml(content: &str) -> Result<Self, Error>

从 TOML 字符串加载配置

Source

pub fn to_toml(&self) -> Result<String, Error>

将配置序列化为 TOML 字符串

Source

pub fn validate(&self) -> Result<(), Vec<String>>

验证配置有效性

检查所有配置项的合法性,包括:

  • 必需字段是否存在
  • 数值范围是否合理
  • 文件路径是否有效
  • 服务配置是否一致

Trait Implementations§

Source§

impl Clone for ActrixConfig

Source§

fn clone(&self) -> ActrixConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActrixConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ActrixConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ActrixConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ActrixConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more