import ipaddress
import urllib.parse
from typing import List, Optional, TypeAlias, TypedDict

URL: TypeAlias = urllib.parse.ParseResult


class InterfaceDict(TypedDict):
    name: str
    private_key: str
    address: ipaddress.IPv4Network
    listen_port: Optional[int]
    dns: Optional[List[ipaddress.IPv4Address]]
    table: Optional[str]
    mtu: Optional[int]
    pre_ups: Optional[List[str]]
    post_ups: Optional[List[str]]
    pre_downs: Optional[List[str]]
    post_downs: Optional[List[str]]


class PeerDict(TypedDict):
    name: str
    public_key: str
    allowed_ips: List[ipaddress.IPv4Network]
    endpoint: Optional[URL]
    persistent_keepalive: Optional[int]
