Compare commits

..

9 Commits

Author SHA1 Message Date
ff615e2b67 Обновить .woodpecker/pipeline.yml
Some checks are pending
ci/woodpecker/push/pipeline Pipeline is pending
ci/woodpecker/manual/pipeline Pipeline is pending
2025-04-05 23:59:19 +03:00
1a93336d30 Deploy: change deployment
Some checks are pending
ci/woodpecker/push/pipeline Pipeline was successful
ci/woodpecker/manual/pipeline Pipeline is pending
2025-01-22 13:26:00 +03:00
17a1e4bb36 Feat: change deployment
All checks were successful
ci/woodpecker/push/pipeline Pipeline was successful
2025-01-22 13:25:45 +03:00
d5b045984f Deploy: update woodpecker
All checks were successful
ci/woodpecker/push/pipeline Pipeline was successful
ci/woodpecker/manual/pipeline Pipeline was successful
2025-01-22 12:59:58 +03:00
0faff426a7 Feat: update woodpecker
All checks were successful
ci/woodpecker/push/pipeline Pipeline was successful
2025-01-22 12:59:35 +03:00
e3a15dad50 Hotfix: pg_isready
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
2025-01-20 15:27:47 +03:00
970a0e6fd4 Hotfix: pg_isready healthcheck
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-01-20 15:27:31 +03:00
8420ff3f52 Deploy: Added url correcter
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-01-20 13:47:27 +03:00
c13eb62770 Feat: url correcter util
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-01-20 13:44:54 +03:00
7 changed files with 31 additions and 10 deletions

View File

@@ -5,5 +5,6 @@ POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
DOMAIN_NAME=localhost
COMPOSE_PROJECT_NAME=nwxraybot

View File

@@ -1,6 +1,3 @@
when:
- branch: [master, deploy]
event: [push, manual]
steps:
- name: build
image: docker:latest
@@ -13,7 +10,8 @@ steps:
ENV_FILE:
from_secret: ENV_FILE
when:
- event: [push, manual]
- branch: [deploy, master]
event: [push, manual]
- name: deploy
image: docker:latest
commands:
@@ -24,6 +22,7 @@ steps:
environment:
ENV_FILE:
from_secret: ENV_FILE
depends_on: [build]
depends_on: build
when:
- event: manual
- branch: deploy
event: manual

View File

@@ -24,7 +24,7 @@ services:
ports:
- "127.0.0.1:${POSTGRES_PORT}:5432"
healthcheck:
test: ["CMD", "pg_isready"]
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
interval: 10s
timeout: 5s
retries: 10

View File

@@ -1,3 +1,4 @@
from nwxraybot.bot import NwXrayBot
from nwxraybot.config import Settings
from nwxraybot.utils import get_code, get_subscription_info
from nwxraybot.utils import (get_code, get_correct_user_url,
get_subscription_info)

View File

@@ -10,6 +10,7 @@ class Settings(BaseSettings):
postgres_db: str = Field('db', env="POSTGRES_DB")
postgres_host: str = Field('localhost', env="POSTGRES_HOST")
postgres_port: int = Field(5432, env="POSTGRES_PORT")
domain_name: str = Field('localhost', env="DOMAIN_NAME")
@property
def postgres_url(self) -> str:

View File

@@ -16,7 +16,7 @@ from nwxraybot.fsm import BroadcastStates
from nwxraybot.meta import Handler
from nwxraybot.middlewares import AdminMiddleware
from nwxraybot.models import User
from nwxraybot.utils import get_subscription_info
from nwxraybot.utils import get_correct_user_url
class AdminHandler(Handler):
@@ -45,13 +45,15 @@ class AdminHandler(Handler):
await message.reply('Вы ввели команду в неверном формате. Вводите в формате:\n``` /adduser name vless://.... 01.01.1970 00:00```', parse_mode=ParseMode.MARKDOWN)
return
user_dict = match.groupdict()
url = user_dict['url']
url = get_correct_user_url(url)
date = None
if user_dict['date']:
date = datetime.strptime(f"{user_dict['date']} {
user_dict['time']}", "%d.%m.%Y %H:%M")
code = get_code()
new_user = User(
name=user_dict['name'], url=user_dict['url'], time=date, code=code)
name=user_dict['name'], url=url, time=date, code=code)
new_user.save()
await message.answer(f'Пользователь создан. Вот его ссылка для доступа:\n`https://t.me/nwproxybot?start={code}`', parse_mode=ParseMode.MARKDOWN)

View File

@@ -2,9 +2,13 @@ import logging
from datetime import datetime
from secrets import token_urlsafe
from typing import Optional
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
from nwxraybot import Settings
from nwxraybot.models import User
config = Settings()
def get_subscription_info(telegram_id: str) -> str:
user: User = User.select().where(User.telegram_id == telegram_id).first()
@@ -20,3 +24,16 @@ def get_subscription_info(telegram_id: str) -> str:
def get_code(length: int = 10) -> str:
return token_urlsafe(length)[:length]
def get_correct_user_url(url: str) -> str:
parsed_url = urlparse(url)
query = parse_qs(parsed_url.query)
query['fp'] = 'chrome'
query['alpn'] = 'h2,h3'
query['packetEncoding'] = 'xudp'
query['security'] = 'tls'
new_query = urlencode(query, doseq=True)
new_url = urlunparse((parsed_url.scheme, parsed_url.netloc.replace("127.0.0.1:1234", f"{
config.domain_name}:443"), parsed_url.path, parsed_url.params, new_query, parsed_url.fragment))
return new_url