This commit is contained in:
Jeremy Soller
2018-11-25 10:34:42 -07:00
parent a5279b648f
commit 0ac16556bc
24 changed files with 474 additions and 349 deletions
+3 -6
View File
@@ -1,14 +1,11 @@
use alloc::string::String;
use c_str::CString;
use header::fcntl;
use fs::File;
use header::fcntl;
use io::{BufRead, BufReader};
pub fn get_dns_server() -> String {
let file = match File::open(
&CString::new("/etc/resolv.conf").unwrap(),
fcntl::O_RDONLY
) {
let file = match File::open(&CString::new("/etc/resolv.conf").unwrap(), fcntl::O_RDONLY) {
Ok(file) => file,
Err(_) => return String::new(), // TODO: better error handling
};
@@ -17,7 +14,7 @@ pub fn get_dns_server() -> String {
for line in file.split(b'\n') {
let mut line = match line {
Ok(line) => line,
Err(_) => return String::new() // TODO: pls handle errors
Err(_) => return String::new(), // TODO: pls handle errors
};
if line.starts_with(b"nameserver ") {
line.drain(..11);