Files
vpn-control-panel/app/models/server.py
smolkik-code 7c7c88621d Initial commit: VPN Control Panel
- FastAPI REST API with JWT auth
- aiogram 3 Telegram bot with admin middleware
- APScheduler daily tasks (expiry, reminders, revoke, sync)
- SQLAlchemy 2 async ORM with Alembic migrations
- Jinja2 admin panel (Dashboard, Users, Payments, Servers, Tariffs)
- VPN provider abstraction with MockProvider
- Stats service with revenue/subscription analytics
- Docker Compose (PostgreSQL + Redis + app)
- Healthcheck endpoint
2026-07-05 17:50:11 +07:00

37 lines
1.3 KiB
Python

import enum
from datetime import datetime
from sqlalchemy import Boolean, DateTime, Enum, Integer, String, func
from sqlalchemy.orm import Mapped, mapped_column
from app.database import Base
class ServerProtocol(str, enum.Enum):
OUTLINE = "outline"
WIREGUARD = "wireguard"
XRAY = "xray"
class Server(Base):
__tablename__ = "servers"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
name: Mapped[str] = mapped_column(String(64), unique=True, nullable=False)
host: Mapped[str] = mapped_column(String(255), nullable=False)
port: Mapped[int] = mapped_column(Integer, nullable=False)
protocol: Mapped[ServerProtocol] = mapped_column(
Enum(ServerProtocol, name="server_protocol"), nullable=False
)
location: Mapped[str] = mapped_column(String(128), nullable=False)
country_code: Mapped[str] = mapped_column(String(4), nullable=False)
load_percent: Mapped[int] = mapped_column(Integer, default=0)
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
max_users: Mapped[int] = mapped_column(Integer, default=100)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now()
)
def __repr__(self) -> str:
return f"<Server id={self.id} {self.name} ({self.protocol.value})>"