Peer enhancements: notes, traffic quotas with auto-disable, batch create, usage tracking; relay subnets for bridging into other tunnels
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent
d97ae64c85
commit
c4dc22074e
@@ -22,6 +22,20 @@ class Peer(Base):
|
||||
enabled: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
expires_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
note: Mapped[str] = mapped_column(String(256), default="")
|
||||
quota_bytes: Mapped[int] = mapped_column(Integer, default=0)
|
||||
cum_rx: Mapped[int] = mapped_column(Integer, default=0)
|
||||
cum_tx: Mapped[int] = mapped_column(Integer, default=0)
|
||||
last_rx: Mapped[int] = mapped_column(Integer, default=0)
|
||||
last_tx: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
@property
|
||||
def cum_total(self) -> int:
|
||||
return self.cum_rx + self.cum_tx
|
||||
|
||||
@property
|
||||
def over_quota(self) -> bool:
|
||||
return self.quota_bytes > 0 and self.cum_total >= self.quota_bytes
|
||||
|
||||
|
||||
class TrafficSample(Base):
|
||||
|
||||
Reference in New Issue
Block a user