|
21 | 21 | import sys
|
22 | 22 | import inspect
|
23 | 23 |
|
24 |
| -from typing import Optional, Union, Dict, List, TypeVar, Type, cast, Any, Tuple |
| 24 | +from typing import Optional, Dict, List, TypeVar, Type, cast, Any, Tuple |
25 | 25 |
|
| 26 | +from .types import IpAddress |
26 | 27 | from .utils import text_, bytes_
|
27 | 28 | from .constants import DEFAULT_LOG_LEVEL, DEFAULT_LOG_FILE, DEFAULT_LOG_FORMAT, DEFAULT_BACKLOG, DEFAULT_BASIC_AUTH
|
28 | 29 | from .constants import DEFAULT_TIMEOUT, DEFAULT_DEVTOOLS_WS_PATH, DEFAULT_DISABLE_HTTP_PROXY, DEFAULT_DISABLE_HEADERS
|
@@ -67,8 +68,7 @@ def __init__(
|
67 | 68 | ca_signing_key_file: Optional[str] = None,
|
68 | 69 | ca_file: Optional[str] = None,
|
69 | 70 | num_workers: int = 0,
|
70 |
| - hostname: Union[ipaddress.IPv4Address, |
71 |
| - ipaddress.IPv6Address] = DEFAULT_IPV6_HOSTNAME, |
| 71 | + hostname: IpAddress = DEFAULT_IPV6_HOSTNAME, |
72 | 72 | port: int = DEFAULT_PORT,
|
73 | 73 | backlog: int = DEFAULT_BACKLOG,
|
74 | 74 | static_server_dir: str = DEFAULT_STATIC_SERVER_DIR,
|
@@ -99,8 +99,7 @@ def __init__(
|
99 | 99 | self.ca_signing_key_file: Optional[str] = ca_signing_key_file
|
100 | 100 | self.ca_file = ca_file
|
101 | 101 | self.num_workers: int = num_workers if num_workers > 0 else multiprocessing.cpu_count()
|
102 |
| - self.hostname: Union[ipaddress.IPv4Address, |
103 |
| - ipaddress.IPv6Address] = hostname |
| 102 | + self.hostname: IpAddress = hostname |
104 | 103 | self.family: socket.AddressFamily = socket.AF_INET6 if hostname.version == 6 else socket.AF_INET
|
105 | 104 | self.port: int = port
|
106 | 105 | self.backlog: int = backlog
|
@@ -161,7 +160,8 @@ def initialize(
|
161 | 160 | # Setup limits
|
162 | 161 | Flags.set_open_file_limit(args.open_file_limit)
|
163 | 162 |
|
164 |
| - # Prepare list of plugins to load based upon --enable-* and --disable-* flags |
| 163 | + # Prepare list of plugins to load based upon --enable-* and --disable-* |
| 164 | + # flags |
165 | 165 | default_plugins: List[Tuple[str, bool]] = []
|
166 | 166 | if args.enable_dashboard:
|
167 | 167 | default_plugins.append((PLUGIN_WEB_SERVER, True))
|
@@ -249,8 +249,7 @@ def initialize(
|
249 | 249 | opts.get(
|
250 | 250 | 'ca_file',
|
251 | 251 | args.ca_file)),
|
252 |
| - hostname=cast(Union[ipaddress.IPv4Address, |
253 |
| - ipaddress.IPv6Address], |
| 252 | + hostname=cast(IpAddress, |
254 | 253 | opts.get('hostname', ipaddress.ip_address(args.hostname))),
|
255 | 254 | port=cast(int, opts.get('port', args.port)),
|
256 | 255 | backlog=cast(int, opts.get('backlog', args.backlog)),
|
|
0 commit comments