mirror of
https://github.com/vvbbnn00/WARP-Clash-API.git
synced 2026-06-29 21:00:52 +08:00
20 lines
571 B
Python
20 lines
571 B
Python
import logging
|
|
|
|
from models import Account
|
|
from services.cloudflare import register
|
|
from utils.wireguard import generate_wireguard_keys
|
|
|
|
|
|
def getCurrentAccount(logger=logging.Logger(__name__)):
|
|
logger.info(f"Get current account")
|
|
try:
|
|
account = Account.load()
|
|
except FileNotFoundError:
|
|
account = None
|
|
if account is None:
|
|
logger.info(f"No account found, register a new one")
|
|
privkey, pubkey = generate_wireguard_keys()
|
|
account = register(pubkey, privkey)
|
|
account.save()
|
|
return account
|