pub struct CoreState {
pub script_interceptor: Arc<ScriptInterceptor>,
pub policy_tx: Sender<ProxyPolicy>,
pub flows_dropped: Arc<AtomicUsize>,
/* private fields */
}Fields§
§script_interceptor: Arc<ScriptInterceptor>§policy_tx: Sender<ProxyPolicy>§flows_dropped: Arc<AtomicUsize>Implementations§
Source§impl CoreState
impl CoreState
pub async fn new(db_url: Option<String>) -> Self
pub async fn get_metrics(&self) -> CoreMetrics
pub async fn get_metrics_prometheus_text(&self) -> String
pub fn status_snapshot(&self) -> CoreStatusSnapshot
pub async fn status_report(&self) -> CoreStatusReport
pub async fn intercept_snapshot(&self) -> CoreInterceptSnapshot
pub fn audit_snapshot(&self, limit: usize) -> CoreAuditSnapshot
pub async fn query_audit_snapshot( &self, query: CoreAuditQuery, ) -> CoreAuditSnapshot
pub async fn get_flow(&self, id: String) -> Option<Flow>
pub async fn get_rules(&self) -> Vec<Rule>
pub async fn set_rules(&self, rules: Vec<Rule>)
pub async fn upsert_rule_from( &self, actor: AuditActor, operation: &str, target: String, details: Value, rule: Rule, ) -> Result<(), String>
pub async fn delete_rule_from( &self, actor: AuditActor, operation: &str, target: String, details: Value, rule_id: &str, ) -> Result<bool, String>
pub async fn create_mock_response_rule_from( &self, actor: AuditActor, target: String, details: Value, config: MockResponseRuleConfig, ) -> Result<String, String>
pub async fn create_intercept_rule_from( &self, actor: AuditActor, target: String, details: Value, config: InterceptRuleConfig, ) -> Result<String, String>
pub async fn upsert_legacy_intercept_rule_from( &self, actor: AuditActor, target: String, details: Value, rule: InterceptRule, ) -> Result<(), String>
pub async fn set_rules_from( &self, actor: AuditActor, operation: &str, target: String, details: Value, rules: Vec<Rule>, ) -> Result<(), String>
pub async fn set_legacy_rules(&self, rules: Vec<InterceptRule>)
pub async fn get_rule_engine(&self) -> Arc<RuleEngine>
pub fn update_policy(&self, policy: ProxyPolicy)
pub fn patch_policy_from( &self, actor: AuditActor, target: String, patch: ProxyPolicyPatch, )
pub fn policy_snapshot(&self) -> ProxyPolicy
pub fn update_policy_from( &self, actor: AuditActor, target: String, policy: ProxyPolicy, )
pub async fn register_intercept( &self, key: String, tx: Sender<InterceptionResult>, )
pub async fn resolve_intercept( &self, key: String, result: InterceptionResult, ) -> Result<(), String>
pub async fn get_pending_ws_message( &self, key: String, ) -> Option<WebSocketMessage>
pub async fn set_pending_ws_message( &self, key: String, message: WebSocketMessage, )
pub async fn is_intercept_pending(&self, key: String) -> bool
pub async fn is_flow_intercepted(&self, flow_id: String) -> bool
pub fn upsert_flow(&self, flow: Box<Flow>)
pub fn append_ws_message(&self, flow_id: String, message: WebSocketMessage)
pub fn update_http_body( &self, flow_id: String, body: BodyData, direction: Direction, )
Sourcepub fn subscribe_flow_updates(&self) -> Receiver<FlowUpdate>
pub fn subscribe_flow_updates(&self) -> Receiver<FlowUpdate>
订阅 FlowUpdate 广播。调用者获得独立 Receiver,lag 时自动跳过过期消息。
pub fn subscribe_audit_events(&self) -> Receiver<AuditEvent>
pub fn record_flow_events_lagged(&self, skipped: u64)
pub fn record_audit_events_lagged(&self, skipped: u64)
pub fn lifecycle(&self) -> RuntimeLifecycle
pub fn subscribe_lifecycle(&self) -> Receiver<RuntimeLifecycle>
pub fn stop_proxy(&self) -> Result<ProxyStopResult, String>
pub fn recent_audit_events(&self) -> Vec<AuditEvent>
Sourcepub async fn search_flows(&self, query: FlowQuery) -> Vec<FlowSummary>
pub async fn search_flows(&self, query: FlowQuery) -> Vec<FlowSummary>
搜索内存中的 Flow 列表,返回轻量摘要。
pub fn redact_flow_update_for_output(&self, update: FlowUpdate) -> FlowUpdate
Sourcepub async fn resolve_intercept_with_modifications(
&self,
key: String,
action: &str,
mods: Option<FlowModification>,
) -> Result<(), String>
pub async fn resolve_intercept_with_modifications( &self, key: String, action: &str, mods: Option<FlowModification>, ) -> Result<(), String>
解除截获并可选地应用修改。
action 为 "drop" 时直接丢弃;其他值(含 "continue")则:
- 若
mods为 None,直接 Continue; - 若
mods存在,根据key格式决定修改请求/响应还是 WebSocket 消息。
key 格式约定:
"<flow_id>:<phase>"— 修改请求或响应(phase 以 “request”/“response” 开头)"<flow_id>:ws_msg:<msg_id>"— 修改 WebSocket 消息
pub async fn resolve_intercept_with_modifications_from( &self, actor: AuditActor, key: String, action: &str, mods: Option<FlowModification>, ) -> Result<(), String>
pub async fn load_script_from( &self, actor: AuditActor, target: String, script: &str, ) -> Result<(), String>
pub fn spawn_proxy( self: &Arc<Self>, config: ProxyConfig, sink: Sender<FlowUpdate>, extra_interceptor: Option<Arc<dyn Interceptor>>, ) -> Result<ProxySpawnResult, String>
pub async fn start_proxy( self: &Arc<Self>, config: ProxyConfig, sink: Sender<FlowUpdate>, extra_interceptor: Option<Arc<dyn Interceptor>>, ) -> Result<(), String>
Trait Implementations§
Source§impl AuditService for CoreState
impl AuditService for CoreState
fn audit_snapshot(&self, limit: usize) -> CoreAuditSnapshot
fn query_audit_snapshot<'life0, 'async_trait>(
&'life0 self,
query: CoreAuditQuery,
) -> Pin<Box<dyn Future<Output = CoreAuditSnapshot> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_audit_events(&self) -> Receiver<AuditEvent>
fn record_audit_events_lagged(&self, skipped: u64)
Source§impl FlowEventHub for CoreState
impl FlowEventHub for CoreState
fn subscribe_flow_updates(&self) -> Receiver<FlowUpdate>
fn redact_flow_update_for_output(&self, update: FlowUpdate) -> FlowUpdate
fn record_flow_events_lagged(&self, skipped: u64)
Source§impl FlowReadService for CoreState
impl FlowReadService for CoreState
fn get_flow<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Flow>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search_flows<'life0, 'async_trait>(
&'life0 self,
query: FlowQuery,
) -> Pin<Box<dyn Future<Output = Vec<FlowSummary>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl InterceptService for CoreState
impl InterceptService for CoreState
fn register_intercept<'life0, 'async_trait>(
&'life0 self,
key: String,
tx: Sender<InterceptionResult>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn resolve_intercept_with_modifications_from<'life0, 'life1, 'async_trait>(
&'life0 self,
actor: AuditActor,
key: String,
action: &'life1 str,
mods: Option<FlowModification>,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn is_flow_intercepted<'life0, 'async_trait>(
&'life0 self,
flow_id: String,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn intercept_snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CoreInterceptSnapshot> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl PolicyService for CoreState
impl PolicyService for CoreState
fn policy_snapshot(&self) -> ProxyPolicy
fn update_policy_from( &self, actor: AuditActor, target: String, policy: ProxyPolicy, )
fn patch_policy_from( &self, actor: AuditActor, target: String, patch: ProxyPolicyPatch, )
Source§impl RuleService for CoreState
impl RuleService for CoreState
fn get_rules<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<Rule>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_rule_engine<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Arc<RuleEngine>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn upsert_rule_from<'life0, 'life1, 'async_trait>(
&'life0 self,
actor: AuditActor,
operation: &'life1 str,
target: String,
details: Value,
rule: Rule,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_rule_from<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
actor: AuditActor,
operation: &'life1 str,
target: String,
details: Value,
rule_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create_mock_response_rule_from<'life0, 'async_trait>(
&'life0 self,
actor: AuditActor,
target: String,
details: Value,
config: MockResponseRuleConfig,
) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_intercept_rule_from<'life0, 'async_trait>(
&'life0 self,
actor: AuditActor,
target: String,
details: Value,
config: InterceptRuleConfig,
) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl RuntimeStatusService for CoreState
impl RuntimeStatusService for CoreState
fn status_snapshot(&self) -> CoreStatusSnapshot
fn status_report<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CoreStatusReport> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CoreMetrics> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_metrics_prometheus_text<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_lifecycle(&self) -> Receiver<RuntimeLifecycle>
Source§impl ScriptService for CoreState
impl ScriptService for CoreState
Auto Trait Implementations§
impl !Freeze for CoreState
impl !RefUnwindSafe for CoreState
impl Send for CoreState
impl Sync for CoreState
impl Unpin for CoreState
impl UnsafeUnpin for CoreState
impl !UnwindSafe for CoreState
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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