Implement the initial handshake
This commit is contained in:
parent
a39c3d47d9
commit
04a47e18e4
2 changed files with 27 additions and 1 deletions
23
src/handshake.rs
Normal file
23
src/handshake.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
pub const CONFIG_END: &str = "config|ready";
|
||||
pub const CONFIG_TAG: &str = "config|";
|
||||
|
||||
pub fn read_config() {
|
||||
let mut buffer = String::new();
|
||||
let stdin = std::io::stdin();
|
||||
loop {
|
||||
buffer.clear();
|
||||
stdin.read_line(&mut buffer).unwrap();
|
||||
let entry = buffer.trim_end();
|
||||
if entry == CONFIG_END {
|
||||
return;
|
||||
}
|
||||
if !entry.starts_with(CONFIG_TAG) {
|
||||
eprintln!("invalid config line: {entry}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_filter() {
|
||||
println!("register|filter|smtp-in|data-line");
|
||||
println!("register|ready");
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
mod handshake;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
handshake::read_config();
|
||||
handshake::register_filter();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue