forked from akanyan/STARTLINER
feat: segatools.ini loading
This commit is contained in:
@ -5,6 +5,32 @@ use ini::Ini;
|
||||
use crate::model::profile::{Network, NetworkType};
|
||||
|
||||
impl Network {
|
||||
pub fn load_from_ini(&mut self, ini: &Ini) -> Result<()> {
|
||||
log::debug!("loading network");
|
||||
if let Some(s) = ini.section(Some("dns")) {
|
||||
if let Some(default) = s.get("default") {
|
||||
if default.starts_with("192.") || default.starts_with("127.") {
|
||||
self.network_type = NetworkType::Artemis;
|
||||
} else {
|
||||
self.network_type = NetworkType::Remote;
|
||||
self.remote_address = default.to_owned();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(s) = ini.section(Some("netenv")) {
|
||||
s.get("addrSuffix").map(|v|
|
||||
self.suffix = v.parse::<i32>().ok()
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(s) = ini.section(Some("keychip")) {
|
||||
s.get("subnet").map(|v| self.subnet = v.to_owned());
|
||||
s.get("id").map(|v| self.keychip = v.to_owned());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
pub fn line_up(&self, ini: &mut Ini) -> Result<()> {
|
||||
log::debug!("begin line-up: network");
|
||||
|
||||
|
Reference in New Issue
Block a user