mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
Merge branch '3.1' into 3.1
This commit is contained in:
51 files changed
+3155
-183
No files matched your search
@@ -14,15 +14,18 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from enum import StrEnum
|
||||
import re
|
||||
from enum import Enum
|
||||
from typing import List, Optional, Union
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
|
||||
from ..common import NodeStatus
|
||||
from ..update import PartialUpdateModel
|
||||
|
||||
LINUX_TAP_NAME_PATTERN = r"^[a-zA-Z0-9_.:-]{1,15}$"
|
||||
|
||||
|
||||
class HostInterfaceType(StrEnum):
|
||||
ethernet = "ethernet"
|
||||
@@ -57,6 +60,7 @@ class HostInterface(BaseModel):
|
||||
name: str = Field(..., description="Interface name")
|
||||
type: HostInterfaceType = Field(..., description="Interface type")
|
||||
special: bool = Field(..., description="Whether the interface is non standard")
|
||||
is_bridge: bool = Field(False, description="Whether this is a Linux bridge")
|
||||
ip_addresses: List[HostInterfaceIPAddress] = Field(
|
||||
default_factory=list, description="All IPv4 and IPv6 addresses on this interface"
|
||||
)
|
||||
@@ -94,6 +98,19 @@ class TAPPort(BaseModel):
|
||||
port_number: int
|
||||
type: TAPType
|
||||
interface: str
|
||||
bridge: Optional[str] = Field(
|
||||
None,
|
||||
min_length=1,
|
||||
max_length=15,
|
||||
pattern=LINUX_TAP_NAME_PATTERN,
|
||||
description="Existing Linux bridge to attach the TAP to",
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_bridged_interface(self):
|
||||
if self.bridge and not re.fullmatch(LINUX_TAP_NAME_PATTERN, self.interface):
|
||||
raise ValueError("A bridged TAP name must be 1-15 letters, digits, underscores, dots, colons or hyphens")
|
||||
return self
|
||||
|
||||
|
||||
class UDPType(StrEnum):
|
||||
|
||||
Reference in new issue
Block a user