From cb83a41b2562eb4bcc8938956bbb9f7be4b945a5 Mon Sep 17 00:00:00 2001 From: moznion Date: Sun, 29 Nov 2020 01:24:17 +0900 Subject: [PATCH] Refactor --- code_generator/src/main.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/code_generator/src/main.rs b/code_generator/src/main.rs index a11a880..a357806 100644 --- a/code_generator/src/main.rs +++ b/code_generator/src/main.rs @@ -14,6 +14,8 @@ const VALUE_KIND: &str = "VALUE"; const RADIUS_VALUE_TYPE: &str = "u32"; +const UESR_PASSWORD_TYPE_OPT: &str = "encrypt=1"; + #[derive(Debug)] struct RadiusAttribute { name: String, @@ -412,11 +414,16 @@ fn parse_dict_file(dict_file_path: &Path) -> Result { let attribute_type_leaf = trailing_comment_re.replace(items[3], "").to_string(); let type_descriptions: Vec<&str> = spaces_re.split(&attribute_type_leaf).collect(); - let is_encrypt = if type_descriptions.len() >= 2 { - type_descriptions[1] == "encrypt=1" // FIXME: ad-hoc!!! - } else { - false - }; + let mut is_encrypt = false; + if type_descriptions.len() >= 2 { + // TODO consider to extract to a method + for type_opt in type_descriptions[1].split(',') { + if type_opt == UESR_PASSWORD_TYPE_OPT { + is_encrypt = true; + continue; + } + } + } let typ = match RadiusAttributeValueType::from_str(type_descriptions[0]) { Ok(t) => {