mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-04-29 06:14:14 +00:00
tui: make auto-deteced routes optional
If, for some reason, the network is not properly configured (due to e.g. no DHCP server being present on the network), there will be no routes in the runtime environment as well. So do not depend on that, otherwise the installer fails at the start. Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
parent
cc82d42e8d
commit
00268c0cb8
@ -359,24 +359,26 @@ impl From<&NetworkInfo> for NetworkOptions {
|
||||
this.fqdn = Fqdn::from(&format!("pve.{}", domain)).unwrap_or_else(|_| domain.clone());
|
||||
}
|
||||
|
||||
let mut filled = false;
|
||||
if let Some(gw) = &info.routes.gateway4 {
|
||||
if let Some(iface) = info.interfaces.get(&gw.dev) {
|
||||
if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv4()) {
|
||||
this.ifname = iface.name.clone();
|
||||
this.gateway = gw.gateway;
|
||||
this.address = addr.clone();
|
||||
filled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !filled {
|
||||
if let Some(gw) = &info.routes.gateway6 {
|
||||
if let Some(routes) = &info.routes {
|
||||
let mut filled = false;
|
||||
if let Some(gw) = &routes.gateway4 {
|
||||
if let Some(iface) = info.interfaces.get(&gw.dev) {
|
||||
if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv6()) {
|
||||
if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv4()) {
|
||||
this.ifname = iface.name.clone();
|
||||
this.gateway = gw.gateway;
|
||||
this.address = addr.clone();
|
||||
filled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !filled {
|
||||
if let Some(gw) = &routes.gateway6 {
|
||||
if let Some(iface) = info.interfaces.get(&gw.dev) {
|
||||
if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv6()) {
|
||||
this.ifname = iface.name.clone();
|
||||
this.gateway = gw.gateway;
|
||||
this.address = addr.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ pub struct RuntimeInfo {
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct NetworkInfo {
|
||||
pub dns: Dns,
|
||||
pub routes: Routes,
|
||||
pub routes: Option<Routes>,
|
||||
|
||||
/// Maps devices to their configuration, if it has a usable configuration.
|
||||
/// (Contains no entries for devices with only link-local addresses.)
|
||||
|
Loading…
Reference in New Issue
Block a user