mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-05-02 14:46:12 -04:00
switch out capabilities
This commit is contained in:
parent
cf9d8cf7c2
commit
dfb4eefd92
22 changed files with 172 additions and 205 deletions
|
@ -2,7 +2,7 @@ from dataclasses import dataclass, fields
|
|||
from enum import StrEnum
|
||||
from typing import Optional, Self
|
||||
|
||||
from .types import TypedKey, TypedSecret
|
||||
from .types import TypedKey, TypedSecret, Capability
|
||||
|
||||
|
||||
class VeilidConfigLogLevel(StrEnum):
|
||||
|
@ -41,13 +41,7 @@ class ConfigBase:
|
|||
|
||||
@dataclass
|
||||
class VeilidConfigCapabilities(ConfigBase):
|
||||
protocol_udp: bool
|
||||
protocol_connect_tcp: bool
|
||||
protocol_accept_tcp: bool
|
||||
protocol_connect_ws: bool
|
||||
protocol_accept_ws: bool
|
||||
protocol_connect_wss: bool
|
||||
protocol_accept_wss: bool
|
||||
disable: list[Capability]
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -52,6 +52,14 @@ class CryptoKind(StrEnum):
|
|||
CRYPTO_KIND_VLD0 = "VLD0"
|
||||
|
||||
|
||||
class Capability(StrEnum):
|
||||
CAP_WILL_ROUTE = "ROUT"
|
||||
CAP_WILL_TUNNEL = "TUNL"
|
||||
CAP_WILL_SIGNAL = "SGNL"
|
||||
CAP_WILL_RELAY = "RLAY"
|
||||
CAP_WILL_VALIDATE_DIAL_INFO = "DIAL"
|
||||
|
||||
|
||||
class Stability(StrEnum):
|
||||
LOW_LATENCY = "LowLatency"
|
||||
RELIABLE = "Reliable"
|
||||
|
@ -67,6 +75,7 @@ class DHTSchemaKind(StrEnum):
|
|||
DFLT = "DFLT"
|
||||
SMPL = "SMPL"
|
||||
|
||||
|
||||
class SafetySelectionKind(StrEnum):
|
||||
UNSAFE = "Unsafe"
|
||||
SAFE = "Safe"
|
||||
|
@ -235,11 +244,10 @@ class VeilidVersion:
|
|||
if self._patch < other._patch:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, VeilidVersion) and self.data == other.data and self.seq == other.seq and self.writer == other.writer
|
||||
|
||||
|
||||
@property
|
||||
def major(self):
|
||||
return self._major
|
||||
|
@ -308,7 +316,8 @@ class DHTSchema:
|
|||
if DHTSchemaKind(j["kind"]) == DHTSchemaKind.SMPL:
|
||||
return cls.smpl(
|
||||
j["o_cnt"],
|
||||
[DHTSchemaSMPLMember.from_json(member) for member in j["members"]],
|
||||
[DHTSchemaSMPLMember.from_json(member)
|
||||
for member in j["members"]],
|
||||
)
|
||||
raise Exception("Unknown DHTSchema kind", j["kind"])
|
||||
|
||||
|
@ -339,7 +348,8 @@ class DHTRecordDescriptor:
|
|||
return cls(
|
||||
TypedKey(j["key"]),
|
||||
PublicKey(j["owner"]),
|
||||
None if j["owner_secret"] is None else SecretKey(j["owner_secret"]),
|
||||
None if j["owner_secret"] is None else SecretKey(
|
||||
j["owner_secret"]),
|
||||
DHTSchema.from_json(j["schema"]),
|
||||
)
|
||||
|
||||
|
@ -404,14 +414,15 @@ class SafetySpec:
|
|||
|
||||
@classmethod
|
||||
def from_json(cls, j: dict) -> Self:
|
||||
return cls(RouteId(j["preferred_route"]) if "preferred_route" in j else None,
|
||||
j["hop_count"],
|
||||
Stability(j["stability"]),
|
||||
Sequencing(j["sequencing"]))
|
||||
return cls(RouteId(j["preferred_route"]) if "preferred_route" in j else None,
|
||||
j["hop_count"],
|
||||
Stability(j["stability"]),
|
||||
Sequencing(j["sequencing"]))
|
||||
|
||||
def to_json(self) -> dict:
|
||||
return self.__dict__
|
||||
|
||||
|
||||
class SafetySelection:
|
||||
kind: SafetySelectionKind
|
||||
|
||||
|
@ -438,9 +449,8 @@ class SafetySelection:
|
|||
|
||||
def to_json(self) -> dict:
|
||||
if self.kind == SafetySelectionKind.UNSAFE:
|
||||
return {"Unsafe": self.sequencing }
|
||||
return {"Unsafe": self.sequencing}
|
||||
elif self.kind == SafetySelectionKind.SAFE:
|
||||
return {"Safe": self.safety_spec.to_json() }
|
||||
return {"Safe": self.safety_spec.to_json()}
|
||||
else:
|
||||
raise Exception("Invalid SafetySelection")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue