Struct vsmtp_rule_engine::RuleEngine
pub struct RuleEngine { /* private fields */ }Expand description
a sharable rhai engine. contains an ast representation of the user’s parsed .vsl script files, and modules / packages to create a cheap rhai runtime.
Implementations§
§impl RuleEngine
impl RuleEngine
pub fn new(
config: Arc<Config>,
resolvers: Arc<DnsResolvers>,
queue_manager: Arc<dyn GenericQueueManager>
) -> Result<Self>
pub fn new( config: Arc<Config>, resolvers: Arc<DnsResolvers>, queue_manager: Arc<dyn GenericQueueManager> ) -> Result<Self>
creates a new instance of the rule engine, reading all files in the
script_path parameter.
if script_path is None, a warning is emitted and a deny-all script
is loaded.
Errors
- failed to register
script_pathas a valid module folder. - failed to compile or load any script located at
script_path.
pub fn spawn_at_connect(
&self,
client_addr: SocketAddr,
server_addr: SocketAddr,
server_name: Domain,
timestamp: OffsetDateTime,
uuid: Uuid
) -> Arc<RuleState>
pub fn spawn_at_connect( &self, client_addr: SocketAddr, server_addr: SocketAddr, server_name: Domain, timestamp: OffsetDateTime, uuid: Uuid ) -> Arc<RuleState>
pub fn spawn_finished(
&self,
mail_context: Context,
message: MessageBody
) -> Arc<RuleState>
pub fn spawn_finished( &self, mail_context: Context, message: MessageBody ) -> Arc<RuleState>
build a cheap rhai engine with vsl’s api.
pub fn run_when(
&self,
rule_state: &RuleState,
skipped: &mut Option<Status>,
smtp_state: ExecutionStage
) -> Status
pub fn run_when( &self, rule_state: &RuleState, skipped: &mut Option<Status>, smtp_state: ExecutionStage ) -> Status
Runs all rules from a stage using the current transaction state.
the server_address parameter is used to distinguish logs from each other,
printing the address & port associated with this run session, not the current
context. (because the context could have been pulled from the filesystem when
receiving delegation results)
Panics
pub fn just_run_when(
&self,
skipped: &mut Option<Status>,
state: ExecutionStage,
mail_context: Context,
mail_message: MessageBody
) -> (Context, MessageBody, Status)
pub fn just_run_when( &self, skipped: &mut Option<Status>, state: ExecutionStage, mail_context: Context, mail_message: MessageBody ) -> (Context, MessageBody, Status)
pub fn new_rhai_engine() -> Engine
pub fn new_rhai_engine() -> Engine
create a rhai engine to compile all scripts with vsl’s configuration.
pub fn build_static_modules(
engine: &mut Engine,
config: &Config
) -> Result<Vec<(String, Shared<Module>)>>
pub fn build_static_modules( engine: &mut Engine, config: &Config ) -> Result<Vec<(String, Shared<Module>)>>
pub fn is_handled_domain(&self, domain: &Domain) -> bool
pub fn is_handled_domain(&self, domain: &Domain) -> bool
Return true if the given domain or any parent domain is handled by the configuration.
pub fn get_delegation_directive_bound_to_address(
&self,
socket: SocketAddr
) -> Option<&Directive>
pub fn get_delegation_directive_bound_to_address( &self, socket: SocketAddr ) -> Option<&Directive>
Find the delegate directive that matches the given socket.