From 529b5787b0d1aeac93845499747f23a2ae8b4c19 Mon Sep 17 00:00:00 2001 From: Fyodor Sotnikov Date: Sun, 22 Feb 2026 22:36:20 +0300 Subject: [PATCH 1/4] Fix sub info page --- src/bin/api/core/http/handlers/sub.rs | 83 +++++++++++++++++++-------- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/src/bin/api/core/http/handlers/sub.rs b/src/bin/api/core/http/handlers/sub.rs index 1eed8fe8..c9406d80 100644 --- a/src/bin/api/core/http/handlers/sub.rs +++ b/src/bin/api/core/http/handlers/sub.rs @@ -293,7 +293,11 @@ where format!("0") }; let base_link = format!("{}/sub?id={}&env={}", host, id, env); - let main_link = format!("{}/sub?id={}&format=txt&env={}", host, id, env); + let main_link_vless = format!("{}/sub?id={}&format=txt&env={}&proto=Xray", host, id, env); + let main_link_h2 = format!( + "{}/sub?id={}&format=txt&env={}&proto=Hysteria2", + host, id, env + ); let html = format!( r#" @@ -355,6 +359,7 @@ button-id:hover {{ margin-top: 16px; text-align: center; }} + .small {{ font-size: 13px; color: #94a3b8; @@ -371,6 +376,13 @@ button-id:hover {{ text-align: right; margin-top: 0px; }} +.badge {{ + font-size: 12px; + color: var(--accent-2); + border: 1px solid rgba(34, 211, 238, 0.3); + padding: 4px 10px; + border-radius: 999px; + }} .footer-line {{ display: flex; justify-content: flex-end; @@ -387,11 +399,12 @@ ul {{

Подписка на Рилзопровод

-
Статус: {status_text}
Дата окончания: {expires}
Осталось дней: {days}
-
Id: {subscription_id}
+
+ +Id: {subscription_id}

@@ -401,54 +414,70 @@ ul {{

Ссылки для подключения

-Xray Универсальная ссылка (рекомендуется) +

Xray

+ +Универсальная ссылка

-
-Hysteria2(Beta) Универсальная ссылка (рекомендуется) -
- - -

Дополнительные форматы Xray:

+
-

Дополнительные форматы Hysteria2:

- +
+ -
+
Отсканируйте в приложении
+

Поддерживаемые приложения

+ +Приложения с поддержкой Xray Vless +
+

Hysteria2(Beta)

+ +Универсальная ссылка +
+ + +

Дополнительные форматы Hysteria2:

+ +
-

QR-код

- + -
Отсканируйте в VPN-приложении
+
Отсканируйте в приложении

+

Поддерживаемые приложения

+ +Приложения с поддержкой Hysteria2 + + + +
+

Реферальная программа

Ваш реферальный код: {ref}
-
Вы пригласили: {invited}
+
Вы пригласили: {invited}
Вы получили {bonus_days} бесплатных дней
@@ -475,7 +504,13 @@ function copyText(text) {{ window.onload = () => {{ QRCode.toCanvas( document.getElementById("qr"), - "{main_link}", + "{main_link_vless}", + {{ width: 220 }} + ); + + QRCode.toCanvas( + document.getElementById("qr2"), + "{main_link_h2}", {{ width: 220 }} ); }}; From a81eaf6efab639c299c2589a63dce1535e32f103 Mon Sep 17 00:00:00 2001 From: Fyodor Sotnikov Date: Sun, 22 Feb 2026 22:36:40 +0300 Subject: [PATCH 2/4] v0.2.5 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a33434a..6b634e22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2112,7 +2112,7 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "pony" -version = "0.2.4" +version = "0.2.5" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 38d7ee57..57f125d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pony" -version = "0.2.4" +version = "0.2.5" edition = "2021" build = "build.rs" From fddbd47c057f7181035734ba0bf8e508bda89c70 Mon Sep 17 00:00:00 2001 From: Fyodor Sotnikov Date: Fri, 27 Feb 2026 13:45:29 +0300 Subject: [PATCH 3/4] Add Mtproto (tg-proxy) --- Cargo.lock | 1 + Cargo.toml | 1 + dev/dev.sql | 5 + src/bin/agent/core/service.rs | 15 +- src/bin/agent/core/tasks.rs | 6 + src/bin/api/core/http/handlers/connection.rs | 1 + src/bin/api/core/http/handlers/html.rs | 167 ++++++++++++ src/bin/api/core/http/handlers/mod.rs | 1 + src/bin/api/core/http/handlers/sub.rs | 252 ++++++++++--------- src/bin/api/core/http/routes.rs | 9 + src/bin/api/core/postgres/node.rs | 13 +- src/config/settings.rs | 16 ++ src/config/xray.rs | 2 + src/http/requests.rs | 12 + src/lib.rs | 1 + src/memory/connection/proto.rs | 2 + src/memory/node.rs | 26 +- src/memory/tag.rs | 7 + src/mtproto_op/mod.rs | 23 ++ 19 files changed, 434 insertions(+), 126 deletions(-) create mode 100644 src/bin/api/core/http/handlers/html.rs create mode 100644 src/mtproto_op/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 6b634e22..e33b6360 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2131,6 +2131,7 @@ dependencies = [ "log", "netstat2", "openssl", + "percent-encoding", "postgres-types", "prost", "prost-derive", diff --git a/Cargo.toml b/Cargo.toml index 57f125d8..0cfbba0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ ipnet = { version = "2", features=["serde"] } log = "0.4" netstat2 = { version = "0.11.1" } openssl = { version = "0.10", features = ["vendored"] } +percent-encoding = "2" prost = { version = "0.13" } prost-derive = { version = "0.13" } rand = "0.8" diff --git a/dev/dev.sql b/dev/dev.sql index cfa4cf40..6845f1d0 100644 --- a/dev/dev.sql +++ b/dev/dev.sql @@ -198,4 +198,9 @@ ALTER TABLE connections ADD COLUMN token UUID DEFAULT NULL; ALTER TABLE inbounds ADD COLUMN h2 JSONB DEFAULT NULL; +ALTER TABLE inbounds ADD COLUMN mtproto_secret TEXT DEFAULT NULL; + +ALTER TYPE proto ADD VALUE 'mtproto'; + + diff --git a/src/bin/agent/core/service.rs b/src/bin/agent/core/service.rs index 5eba29f2..b21f55f2 100644 --- a/src/bin/agent/core/service.rs +++ b/src/bin/agent/core/service.rs @@ -120,6 +120,13 @@ pub async fn run(settings: AgentSettings) -> Result<()> { None }; + // Init Mtproto + let mtproto_config = if settings.mtproto.enabled { + Some(settings.mtproto.clone()) + } else { + None + }; + let subscriber = ZmqSubscriber::new( &settings.zmq.endpoint, &settings.node.uuid, @@ -127,7 +134,13 @@ pub async fn run(settings: AgentSettings) -> Result<()> { ); let node_config = NodeConfig::from_raw(settings.node.clone()); - let node = Node::new(node_config?, xray_config, wg_config.clone(), h2_config); + let node = Node::new( + node_config?, + xray_config, + wg_config.clone(), + h2_config, + mtproto_config, + ); let memory: Arc> = Arc::new(RwLock::new(MemoryCache::with_node(node.clone()))); diff --git a/src/bin/agent/core/tasks.rs b/src/bin/agent/core/tasks.rs index 6351ee05..c45e1a9b 100644 --- a/src/bin/agent/core/tasks.rs +++ b/src/bin/agent/core/tasks.rs @@ -247,6 +247,9 @@ where Tag::Hysteria2 => { return Err(PonyError::Custom("Hysteria2 is not supported".into())) } + Tag::Mtproto => { + return Err(PonyError::Custom("Mtproto is not supported".into())) + } } } @@ -299,6 +302,9 @@ where Tag::Hysteria2 => { return Err(PonyError::Custom("Hysteria2 is not supported".into())) } + Tag::Mtproto => { + return Err(PonyError::Custom("Mtproto is not supported".into())) + } } } diff --git a/src/bin/api/core/http/handlers/connection.rs b/src/bin/api/core/http/handlers/connection.rs index b018b8d2..76f200a4 100644 --- a/src/bin/api/core/http/handlers/connection.rs +++ b/src/bin/api/core/http/handlers/connection.rs @@ -307,6 +307,7 @@ where ProtoTag::Hysteria2 => Proto::Hysteria2 { token: conn_req.token.unwrap(), }, + ProtoTag::Mtproto => unreachable!("Mtproto handled earlier"), }; drop(mem); diff --git a/src/bin/api/core/http/handlers/html.rs b/src/bin/api/core/http/handlers/html.rs new file mode 100644 index 00000000..21195f48 --- /dev/null +++ b/src/bin/api/core/http/handlers/html.rs @@ -0,0 +1,167 @@ +pub static HEAD: &str = r#" + + + +Информация о подписке + +"#; + +pub static FOOTER: &str = r#" +"#; diff --git a/src/bin/api/core/http/handlers/mod.rs b/src/bin/api/core/http/handlers/mod.rs index 7f58ded9..080c3bf6 100644 --- a/src/bin/api/core/http/handlers/mod.rs +++ b/src/bin/api/core/http/handlers/mod.rs @@ -1,4 +1,5 @@ pub mod connection; +pub mod html; pub mod node; pub mod sub; diff --git a/src/bin/api/core/http/handlers/sub.rs b/src/bin/api/core/http/handlers/sub.rs index c9406d80..47a231e9 100644 --- a/src/bin/api/core/http/handlers/sub.rs +++ b/src/bin/api/core/http/handlers/sub.rs @@ -1,7 +1,10 @@ use base64::Engine; use chrono::DateTime; use chrono::Utc; +use pony::mtproto_op::mtproto_conn; +use url::Url; +use pony::http::requests::MtprotoQueryParam; use pony::http::requests::TagReq; use warp::http::Response; use warp::http::StatusCode; @@ -28,6 +31,7 @@ use pony::SubscriptionOp; use pony::SubscriptionStorageOp; use pony::Tag; +use super::html::{FOOTER, HEAD}; use crate::core::sync::tasks::SyncOp; use crate::core::sync::MemSync; @@ -292,7 +296,9 @@ where } else { format!("0") }; + let base_link = format!("{}/sub?id={}&env={}", host, id, env); + let base_link_mtproto = format!("{}/sub/mtproto?id={}&env={}", host, id, env); let main_link_vless = format!("{}/sub?id={}&format=txt&env={}&proto=Xray", host, id, env); let main_link_h2 = format!( "{}/sub?id={}&format=txt&env={}&proto=Hysteria2", @@ -300,100 +306,7 @@ where ); let html = format!( -r#" - - - -Информация о подписке - - +r#"{head}
@@ -402,9 +315,7 @@ ul {{
Статус: {status_text}
Дата окончания: {expires}
Осталось дней: {days}
-
- -Id: {subscription_id}
+
Id: {subscription_id}

@@ -414,16 +325,16 @@ Id: {subscription_id}

Ссылки для подключения

-

Xray

+

Xray Vless

Универсальная ссылка

-

Дополнительные форматы Xray:

-
    -
  • TXT для v2ray
  • -
  • Clash — для Clash / Clash Meta
  • +

    Дополнительные форматы:

    +
    @@ -435,23 +346,23 @@ Id: {subscription_id}

Поддерживаемые приложения

-Приложения с поддержкой Xray Vless - -
+


+
+

Hysteria2(Beta)

Универсальная ссылка
-

Дополнительные форматы Hysteria2:

-