Initial commit: abyssVpn project
- Tauri desktop app (apps/desktop) - Python Django API service (services/api) - Deployment scripts and docs
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from django.db import models
|
||||
|
||||
from accounts.models import User
|
||||
|
||||
|
||||
class Device(models.Model):
|
||||
STATUS_ACTIVE = "active"
|
||||
STATUS_REVOKED = "revoked"
|
||||
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="devices")
|
||||
device_name = models.CharField(max_length=128)
|
||||
device_fingerprint = models.CharField(max_length=256, blank=True)
|
||||
netmaker_node_id = models.CharField(max_length=128, blank=True)
|
||||
status = models.CharField(max_length=16, default=STATUS_ACTIVE)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.user_id}:{self.device_name}"
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["user", "device_fingerprint"],
|
||||
name="unique_user_device_fingerprint",
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class VpnLog(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
device = models.ForeignKey(Device, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
action = models.CharField(max_length=64)
|
||||
detail = models.JSONField(default=dict, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
Reference in New Issue
Block a user