Replaces LICENSE (GPLv3 -> AGPLv3) and prepends `SPDX-License-Identifier: AGPL-3.0-or-later` to every source file across decnet/, decnet_web/, tests/, scripts/, and tools/. Rationale: closes the GPLv3 ASP loophole so any party operating a modified DECNET as a network service must offer their modified source. Personal copyright (Samuel Paschuan) + inbound=outbound contributions make a future unilateral relicense infeasible. - LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt) - COPYRIGHT: project copyright notice - tools/add_spdx_headers.py: idempotent header injector (shebang- and PEP 263-aware) Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh). No behavior change; comments only.
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Tarpit rule table + HTTP request/response shapes."""
|
|
from datetime import datetime, timezone
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field as PydanticField
|
|
from sqlmodel import Field, SQLModel
|
|
|
|
|
|
class TarpitRule(SQLModel, table=True):
|
|
"""One active tarpit rule — one per decky at a time.
|
|
|
|
``ports`` is JSON-encoded (e.g. ``"[22, 80]"``). One row per decky;
|
|
``set_tarpit_rule`` upserts on ``decky_name`` so re-enabling with
|
|
different parameters replaces the old rule.
|
|
"""
|
|
__tablename__ = "tarpit_rules"
|
|
|
|
id: str = Field(primary_key=True)
|
|
decky_name: str = Field(index=True, unique=True)
|
|
ports: str # JSON list[int]
|
|
delay_ms: int
|
|
created_at: datetime = Field(
|
|
default_factory=lambda: datetime.now(timezone.utc)
|
|
)
|
|
created_by: str # operator UUID from JWT
|
|
|
|
|
|
class TarpitEnableRequest(BaseModel):
|
|
ports: list[int] = PydanticField(..., min_length=1)
|
|
delay_ms: int = PydanticField(..., ge=100, le=300_000)
|
|
|
|
|
|
class TarpitRuleResponse(BaseModel):
|
|
id: str
|
|
decky_name: str
|
|
ports: list[int]
|
|
delay_ms: int
|
|
created_at: datetime
|
|
created_by: str
|
|
|
|
|
|
class TarpitStatusResponse(BaseModel):
|
|
rule: TarpitRuleResponse
|
|
active_connections: list[dict[str, Any]]
|