1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 03:36:48 +00:00

fix(interfaces): a host interface can be created with DHCP or no IPv4, and every value is validated

The IPv4 address and gateway were required even for DHCP or no IPv4, so
such an interface could not be created; malformed addresses passed and a
missing prefix crashed the XML builder. They are validated like the IPv6
fields now (netmask notation accepted, IPv6 scope ids rejected), and a
static address without a gateway gets no empty route. Interface names
follow the Linux rule (up to 15 letters, digits, . _ -). A bridge member,
or the device an ethernet interface configures, must be a device of the
host (the page no longer falls back to made-up names), a bridge cannot
contain itself, and needs STP and a non-negative delay.
This commit is contained in:
catborise 2026-10-07 20:23:39 +03:00
parent 3c0d5efb18
commit 443b31d86b
5 changed files with 229 additions and 58 deletions

View file

@ -34,9 +34,10 @@ class wvmInterfaces(wvmConnect):
if ipv4_type == "static":
address, prefix = ipv4_addr.split("/")
xml += f"""<protocol family='ipv4'>
<ip address='{address}' prefix='{prefix}'/>
<route gateway='{ipv4_gw}'/>
</protocol>"""
<ip address='{address}' prefix='{prefix}'/>"""
if ipv4_gw:
xml += f"""<route gateway='{ipv4_gw}'/>"""
xml += """</protocol>"""
if ipv6_type == "dhcp":
xml += """<protocol family='ipv6'>
<dhcp/>