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