parent
46d1607aa1
commit
e6fbe24a70
@ -0,0 +1,11 @@ |
|||||||
|
A gateway |
||||||
|
A gateway |
||||||
|
A gateway |
||||||
|
A proxy |
||||||
|
A proxy |
||||||
|
D gateway2 |
||||||
|
D gateway5 |
||||||
|
A proxy |
||||||
|
A gateway |
||||||
|
A gateway |
||||||
|
A gateway |
@ -1,3 +1,24 @@ |
|||||||
|
use std::io::{self, BufRead}; |
||||||
|
|
||||||
|
use lazy_static::lazy_static; |
||||||
|
use regex::Regex; |
||||||
|
|
||||||
|
use hostnames_allocator::hostnames_allocator::HostnamesAllocator; |
||||||
|
|
||||||
|
lazy_static! { |
||||||
|
static ref COMMAND_REGEX: Regex = Regex::new(r"^([AD])\s+(\w+)$").unwrap(); |
||||||
|
} |
||||||
|
|
||||||
fn main() { |
fn main() { |
||||||
println!("Hello, world!"); |
let mut hostnames_allocator = HostnamesAllocator::new(); |
||||||
|
let stdin = io::stdin(); |
||||||
|
for line_result in stdin.lock().lines() { |
||||||
|
let line = line_result.unwrap(); |
||||||
|
let (_, [command, argument]) = COMMAND_REGEX.captures(&line).unwrap().extract(); |
||||||
|
match command { |
||||||
|
"A" => println!("{}", hostnames_allocator.allocate(argument)), |
||||||
|
"D" => hostnames_allocator.free(argument), |
||||||
|
_ => panic!(), |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue