mirror of
https://github.com/cubixle/radius-rs.git
synced 2026-04-30 13:48:44 +01:00
Refactor
This commit is contained in:
@@ -14,6 +14,8 @@ const VALUE_KIND: &str = "VALUE";
|
|||||||
|
|
||||||
const RADIUS_VALUE_TYPE: &str = "u32";
|
const RADIUS_VALUE_TYPE: &str = "u32";
|
||||||
|
|
||||||
|
const UESR_PASSWORD_TYPE_OPT: &str = "encrypt=1";
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct RadiusAttribute {
|
struct RadiusAttribute {
|
||||||
name: String,
|
name: String,
|
||||||
@@ -412,11 +414,16 @@ fn parse_dict_file(dict_file_path: &Path) -> Result<DictParsed, String> {
|
|||||||
let attribute_type_leaf = trailing_comment_re.replace(items[3], "").to_string();
|
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 type_descriptions: Vec<&str> = spaces_re.split(&attribute_type_leaf).collect();
|
||||||
|
|
||||||
let is_encrypt = if type_descriptions.len() >= 2 {
|
let mut is_encrypt = false;
|
||||||
type_descriptions[1] == "encrypt=1" // FIXME: ad-hoc!!!
|
if type_descriptions.len() >= 2 {
|
||||||
} else {
|
// TODO consider to extract to a method
|
||||||
false
|
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]) {
|
let typ = match RadiusAttributeValueType::from_str(type_descriptions[0]) {
|
||||||
Ok(t) => {
|
Ok(t) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user