Format
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user