Rename WovenMesh to WovenConfig
This commit is contained in:
parent
4c44df62a2
commit
0257a5a721
12
woven.py
12
woven.py
|
@ -59,7 +59,7 @@ class WovenMeshNode:
|
|||
ipv6_ranges: list[IPv6Network] = field(factory = list, converter = list_of_ipv6_networks)
|
||||
|
||||
@define
|
||||
class WovenMesh:
|
||||
class WovenConfig:
|
||||
min_port: int = field(validator = validator_range(0, 0xFFFF))
|
||||
max_port: int = field(validator = validator_range(0, 0xFFFF))
|
||||
ptp_ipv4_range: IPv4Network = field(converter = IPv4Network)
|
||||
|
@ -92,12 +92,12 @@ class WovenMesh:
|
|||
return self.wireguard_dir / f"{tunnel_name}.{self.wireguard_config_ext}"
|
||||
|
||||
@staticmethod
|
||||
def from_json_str(config: str) -> WovenMesh:
|
||||
return woven_config_converter.structure(loads(config), WovenMesh)
|
||||
def from_json_str(config: str) -> WovenConfig:
|
||||
return woven_config_converter.structure(loads(config), WovenConfig)
|
||||
|
||||
@staticmethod
|
||||
def load_json_file(path: str | bytes | PathLike) -> WovenMesh:
|
||||
return WovenMesh.from_json_str(Path(path).read_text(encoding = "UTF-8"))
|
||||
def load_json_file(path: str | bytes | PathLike) -> WovenConfig:
|
||||
return WovenConfig.from_json_str(Path(path).read_text(encoding = "UTF-8"))
|
||||
|
||||
def to_json_str(self) -> str:
|
||||
return dumps(woven_config_converter.unstructure(self), indent = 4)
|
||||
|
@ -310,7 +310,7 @@ def main():
|
|||
|
||||
with redirect_stdout(open(devnull, "w") if args.quiet else stdout):
|
||||
try:
|
||||
config = WovenMesh.load_json_file(args.config)
|
||||
config = WovenConfig.load_json_file(args.config)
|
||||
except FileNotFoundError:
|
||||
print(f"No configuration file found at '{args.config}'", file = stderr)
|
||||
exit(1)
|
||||
|
|
Loading…
Reference in New Issue