Unbreak network configuration page.

This commit is contained in:
whitequark 2018-03-27 09:32:37 +00:00
parent 2d29078ba1
commit 2bdc483e15
1 changed files with 12 additions and 8 deletions

View File

@ -4,6 +4,7 @@ use core::cell::RefCell;
use core::str; use core::str;
use cortex_m; use cortex_m;
use cortex_m::interrupt::Mutex; use cortex_m::interrupt::Mutex;
use smoltcp::wire::IpCidr;
use smoltcp::socket::TcpSocket; use smoltcp::socket::TcpSocket;
use http; use http;
@ -96,14 +97,17 @@ pub fn serve(output: &mut TcpSocket, request: &http::Request,
if ip_arg.is_ok() { if ip_arg.is_ok() {
let ip_arg = str::from_utf8(ip_arg.unwrap()); let ip_arg = str::from_utf8(ip_arg.unwrap());
if ip_arg.is_ok() { if ip_arg.is_ok() {
let ip = ip_arg.unwrap().parse(); let mut ip_arg = ip_arg.unwrap().split("%2F");
if ip.is_ok() { let ip = ip_arg.next().map(|x| x.parse());
let ip = ip.unwrap(); let cidr = ip_arg.next().map(|x| x.parse());
status = "IP address has been updated and will be active after a reboot."; match (ip, cidr) {
config.ip = ip; (Some(Ok(ip)), Some(Ok(cidr))) => {
config.save(); status = "IP address has been updated and will be active after a reboot.";
} else { config.ip = IpCidr::new(ip, cidr);
status = "failed to parse IP address"; config.save();
}
_ =>
status = "failed to parse IP address"
} }
} else { } else {
status = "IP address contains an invalid UTF-8 character"; status = "IP address contains an invalid UTF-8 character";