Persist settings in CA, expose /admin/vpn and /internal/vpn, and route Telegram (and optional web/nlp) traffic through mihomo SOCKS when enabled. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
823 B
Python
32 lines
823 B
Python
import os
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from .models import Consumer, ConsumerFilter
|
|
from .services.filtering import hash_api_key
|
|
from .services.vpn import ensure_vpn_settings
|
|
|
|
|
|
def seed_objects(db: Session) -> None:
|
|
"""No demo map objects — map shows ingested events only."""
|
|
|
|
|
|
def seed_test_consumer(db: Session) -> None:
|
|
if db.query(Consumer).filter(Consumer.name == "test-pi").first():
|
|
return
|
|
|
|
api_key = os.getenv("TEST_PI_API_KEY", "test-pi-api-key-change-me")
|
|
consumer = Consumer(
|
|
name="test-pi",
|
|
api_key_hash=hash_api_key(api_key),
|
|
is_active=True,
|
|
)
|
|
db.add(consumer)
|
|
db.flush()
|
|
db.add(ConsumerFilter(consumer_id=consumer.id, regions=None, topics=None))
|
|
db.commit()
|
|
|
|
|
|
def seed_vpn_settings(db: Session) -> None:
|
|
ensure_vpn_settings(db)
|