This commit is contained in:
Lev 2025-12-08 22:00:40 +03:00
parent da045a7c02
commit f20f9528aa
9 changed files with 37 additions and 8 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
.venv
.venv
configs/config/params_spectralvpn.conf

View file

@ -1,9 +1,13 @@
from fastapi import FastAPI, HTTPException, Query, status
from pydantic import BaseModel, EmailStr
import configparser
import utils
app = FastAPI()
args = ["", "", "", "", 0, "", ""]
config = configparser.ConfigParser()
config.read('../configs/config/params.conf', encoding='utf-8')
args = [config["api"]["path"], config["api"]["host"], config["api"]["username"], config["api"]["password"], config.getint("api", "inbaund_id"), config["api"]["inbaund_url"]]
class RegisterBody(BaseModel) :
email : EmailStr

View file

@ -8,7 +8,7 @@ import requests
import random
class API :
def __init__(self, path: str, host: str, username: str, passwd: str, inbaund_id: int, inbaund_url: str, inbaund_port: str) :
def __init__(self, path: str, host: str, username: str, passwd: str, inbaund_id: int, inbaund_url: str) :
self.con = sqlite3.connect(path)
self.cur = self.con.cursor()
self.cur.execute("""
@ -38,7 +38,6 @@ class API :
self.inbaund_id = inbaund_id
self.inbaund_url = inbaund_url
self.inbaund_port = inbaund_port
def read_table(self, sql_command: str, params=None) -> dict :
if params == None :
@ -148,7 +147,7 @@ class API :
if inbaund == None :
raise TypeError
url = f"vless://{uid}@{self.inbaund_url}:{self.inbaund_port}?security=reality&pbk={pbk}&fp=random&sni={sni}&sid={suid}&spx=%2F&flow=xtls-rprx-vision#SpectralVPN-{url_name}"
url = f"vless://{uid}@{self.inbaund_url}?security=reality&pbk={pbk}&fp=random&sni={sni}&sid={suid}&spx=%2F&flow=xtls-rprx-vision#SpectralVPN-{url_name}"
urls.append(url_name)
@ -201,7 +200,7 @@ class API :
if client == None :
raise TypeError
uid = client["id"]
url = f"vless://{uid}@{self.inbaund_url}:{self.inbaund_port}?security=reality&pbk={pbk}&fp=random&sni={sni}&sid={suid}&spx=%2F&flow=xtls-rprx-vision#SpectralVPN-{url_name}"
url = f"vless://{uid}@{self.inbaund_url}?security=reality&pbk={pbk}&fp=random&sni={sni}&sid={suid}&spx=%2F&flow=xtls-rprx-vision#SpectralVPN-{url_name}"
return {"code": 0, "data": {"id": int(data["id"]["0"]), "email": email, "urls": urls, "url": url}}

View file

@ -1,5 +1,5 @@
const port = 8000;
const API_URL = "https://spectralvpn.ru:${port}";
const API_URL = "http://localhost:${port}";
async function sha256(text) {
const encoder = new TextEncoder();

View file

@ -0,0 +1,7 @@
[api]
path = spectralvpn.db
host =
username =
password =
inbaund_id = 0
inbaund_url =

View file

@ -0,0 +1,7 @@
https {
listen 443;
listen [::]:443;
server_name spectralvpn.ru;
root /var/www/html/spectralvpn.ru;
}

View file

@ -0,0 +1,7 @@
http {
listen 80 spectralvpn.ru;
listen [::]:80 spectralvpn.ru;
root /var/www/html/spectralvpn.ru;
Pages/index.html;
}

View file

@ -0,0 +1,3 @@
server {
}

View file

@ -1,2 +1,3 @@
fastapi[all]
pandas
pandas
configparser