-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
34 lines (24 loc) · 735 Bytes
/
data.py
File metadata and controls
34 lines (24 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from pydantic import BaseModel, IPvAnyAddress, validator
class HostData(BaseModel):
host_name: str | None = None
host_ips: list[IPvAnyAddress]
ports: list[int]
@validator("ports", each_item=True)
def validate_port(cls, v: int) -> int:
assert 0 <= v <= 65535, "Port must be between 0 and 65535"
return v
class RawData(BaseModel):
host: str
ports: list[str]
@validator("ports", each_item=True)
def validate_port(cls, v: str) -> str:
assert len(v) > 0
return v
class PortInfo(BaseModel):
port: int
is_open: bool
class ScanResult(BaseModel):
host_name: str | None
host_ip: IPvAnyAddress
round_trip_time: float
port_info: PortInfo | None