fn update_portal_info_via_file(config: &mut Config) {
    use std::fs::File;
    use std::io::BufReader;
    use std::io::BufRead;

    let file = config.passphrase_file.as_ref().and_then(|pfile| File::open(pfile).ok());
    if let Some(file) = file {
        let mut file = BufReader::new(file);
        let mut pwd = String::new();
        let mut ssid = String::new();
        let pwd_res = file.read_line(&mut pwd);
        let ssid_res = file.read_line(&mut ssid);
        match (pwd_res, ssid_res) {
            (Ok(_), Ok(_)) => {
                let pwd = pwd.trim_end();
                if verify_password(pwd).is_ok() {
                    info!("Updated portal password via file");
                    config.passphrase = pwd.to_owned();
                }
                if ssid.len() > 3 {
                    let ssid = ssid.trim_end();
                    info!("Updated portal ssid via file: {}", ssid);
                    config.ssid = ssid.to_owned();
                }
            }
            _ => warn!("Portal SSID/Password in file invalid!")
        }
    } else {
        warn!("Portal SSID/Password file given, but file is not readable!");
    }
}
/// Updates SSID/Password via passphrase file, if option is set in config.
///
/// This is not async, because current async file io implementations use the sync API with a background thread.
/// In that case we can do sync io as well (in the main executor thread) and are more efficient!
Updates SSID/Password via passphrase file, if option is set in config.
This is not async, because current async file io implementations use the sync API with a background thread.
In that case we can do sync io as well (in the main executor thread) and are more efficient!
Updates SSID / Password via passphrase file if option is set in config . This is not async because current async file io implementations use the sync API with a background thread . In that case we can do sync io as well ( in the main executor thread ) and are more efficient!
fn update_portal_info_via_file(config: &mut Config) {
    use std::fs::File;
    use std::io::BufReader;
    use std::io::BufRead;
    let file = config.passphrase_file.as_ref().and_then(|pfile| File::open(pfile).ok());
    if let Some(file) = file {
        let mut file = BufReader::new(file);
        let mut pwd = String::new();
        let mut ssid = String::new();
        let pwd_res = file.read_line(&mut pwd);
        let ssid_res = file.read_line(&mut ssid);
        match (pwd_res, ssid_res) {
            (Ok(_), Ok(_)) => {
                let pwd = pwd.trim_end();
                if verify_password(pwd).is_ok() {
                    info!("Updated portal password via file");
                    config.passphrase = pwd.to_owned();
                }
                if ssid.len() > 3 {
                    let ssid = ssid.trim_end();
                    info!("Updated portal ssid via file: {}", ssid);
                    config.ssid = ssid.to_owned();
                }
            }
            _ => warn!("Portal SSID/Password in file invalid!")
        }
    } else {
        warn!("Portal SSID/Password file given, but file is not readable!");
    }
}
fn update_portal_info_via_file ( config : & mut Config ) { use std :: fs :: File ; use std :: io :: BufReader ; use std :: io :: BufRead ; let file = config . passphrase_file . as_ref ( ) . and_then ( | pfile | File :: open ( pfile ) . ok ( ) ) ; if let Some ( file ) = file { let mut file = BufReader :: new ( file ) ; let mut pwd = String :: new ( ) ; let mut ssid = String :: new ( ) ; let pwd_res = file . read_line ( & mut pwd ) ; let ssid_res = file . read_line ( & mut ssid ) ; match ( pwd_res , ssid_res ) { ( Ok ( _ ) , Ok ( _ ) ) => { let pwd = pwd . trim_end ( ) ; if verify_password ( pwd ) . is_ok ( ) { info ! ( " " ) ; config . passphrase = pwd . to_owned ( ) ; } if ssid . len ( ) > 3 { let ssid = ssid . trim_end ( ) ; info ! ( " " ssid ) ; config . ssid = ssid . to_owned ( ) ; } } _ => warn ! ( " " ) } } else { warn ! ( " " ) ; } }
Updates SSID/Password via passphrase file, if option is set in config.
Updates SSID / Password via passphrase file if option is set in config .
config
&mut Config
config
&mut Config