Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions PasarGuardNodeBridge/common/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ message BaseInfoResponse {
enum BackendType {
XRAY = 0;
WIREGUARD = 1;
MTPROTO = 2;
}

message Backend {
Expand Down Expand Up @@ -137,13 +138,24 @@ message Hysteria {
string auth = 1;
}

message Mtproto {
string secret = 1;
string user_ad_tag = 2;
uint32 max_tcp_conns = 3;
uint32 max_unique_ips = 4;
// Note: data quota and expiry are intentionally omitted. The panel owns
// quota/expiry enforcement (via usage reporting and user sync), the same as
// for the xray and wireguard backends; telemt must not enforce them.
}

message Proxy {
Vmess vmess = 1;
Vless vless = 2;
Trojan trojan = 3;
Shadowsocks shadowsocks = 4;
Wireguard wireguard = 5;
Hysteria hysteria = 6;
Mtproto mtproto = 7;
}

message User {
Expand Down
32 changes: 17 additions & 15 deletions PasarGuardNodeBridge/common/service_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions PasarGuardNodeBridge/common/service_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BackendType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = ()
XRAY: _ClassVar[BackendType]
WIREGUARD: _ClassVar[BackendType]
MTPROTO: _ClassVar[BackendType]

class StatType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = ()
Expand All @@ -22,6 +23,7 @@ class StatType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
UserStat: _ClassVar[StatType]
XRAY: BackendType
WIREGUARD: BackendType
MTPROTO: BackendType
Outbounds: StatType
Outbound: StatType
Inbounds: StatType
Expand Down Expand Up @@ -228,21 +230,35 @@ class Hysteria(_message.Message):
auth: str
def __init__(self, auth: _Optional[str] = ...) -> None: ...

class Mtproto(_message.Message):
__slots__ = ("secret", "user_ad_tag", "max_tcp_conns", "max_unique_ips")
SECRET_FIELD_NUMBER: _ClassVar[int]
USER_AD_TAG_FIELD_NUMBER: _ClassVar[int]
MAX_TCP_CONNS_FIELD_NUMBER: _ClassVar[int]
MAX_UNIQUE_IPS_FIELD_NUMBER: _ClassVar[int]
secret: str
user_ad_tag: str
max_tcp_conns: int
max_unique_ips: int
def __init__(self, secret: _Optional[str] = ..., user_ad_tag: _Optional[str] = ..., max_tcp_conns: _Optional[int] = ..., max_unique_ips: _Optional[int] = ...) -> None: ...

class Proxy(_message.Message):
__slots__ = ("vmess", "vless", "trojan", "shadowsocks", "wireguard", "hysteria")
__slots__ = ("vmess", "vless", "trojan", "shadowsocks", "wireguard", "hysteria", "mtproto")
VMESS_FIELD_NUMBER: _ClassVar[int]
VLESS_FIELD_NUMBER: _ClassVar[int]
TROJAN_FIELD_NUMBER: _ClassVar[int]
SHADOWSOCKS_FIELD_NUMBER: _ClassVar[int]
WIREGUARD_FIELD_NUMBER: _ClassVar[int]
HYSTERIA_FIELD_NUMBER: _ClassVar[int]
MTPROTO_FIELD_NUMBER: _ClassVar[int]
vmess: Vmess
vless: Vless
trojan: Trojan
shadowsocks: Shadowsocks
wireguard: Wireguard
hysteria: Hysteria
def __init__(self, vmess: _Optional[_Union[Vmess, _Mapping]] = ..., vless: _Optional[_Union[Vless, _Mapping]] = ..., trojan: _Optional[_Union[Trojan, _Mapping]] = ..., shadowsocks: _Optional[_Union[Shadowsocks, _Mapping]] = ..., wireguard: _Optional[_Union[Wireguard, _Mapping]] = ..., hysteria: _Optional[_Union[Hysteria, _Mapping]] = ...) -> None: ...
mtproto: Mtproto
def __init__(self, vmess: _Optional[_Union[Vmess, _Mapping]] = ..., vless: _Optional[_Union[Vless, _Mapping]] = ..., trojan: _Optional[_Union[Trojan, _Mapping]] = ..., shadowsocks: _Optional[_Union[Shadowsocks, _Mapping]] = ..., wireguard: _Optional[_Union[Wireguard, _Mapping]] = ..., hysteria: _Optional[_Union[Hysteria, _Mapping]] = ..., mtproto: _Optional[_Union[Mtproto, _Mapping]] = ...) -> None: ...

class User(_message.Message):
__slots__ = ("email", "proxies", "inbounds")
Expand Down
11 changes: 11 additions & 0 deletions PasarGuardNodeBridge/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from PasarGuardNodeBridge.common.service_pb2 import (
Hysteria,
Mtproto,
Proxy,
Shadowsocks,
Trojan,
Expand All @@ -29,6 +30,10 @@ def create_proxy(
wireguard_public_key: str | None = None,
wireguard_peer_ips: list[str] | None = None,
hysteria_auth: str | None = None,
mtproto_secret: str | None = None,
mtproto_user_ad_tag: str | None = None,
mtproto_max_tcp_conns: int = 0,
mtproto_max_unique_ips: int = 0,
) -> Proxy:
if wireguard_peer_ips is None:
wireguard_peer_ips = []
Expand All @@ -40,6 +45,12 @@ def create_proxy(
shadowsocks=Shadowsocks(password=shadowsocks_password, method=shadowsocks_method),
wireguard=Wireguard(public_key=wireguard_public_key, peer_ips=wireguard_peer_ips),
hysteria=Hysteria(auth=hysteria_auth),
mtproto=Mtproto(
secret=mtproto_secret,
user_ad_tag=mtproto_user_ad_tag,
max_tcp_conns=mtproto_max_tcp_conns,
max_unique_ips=mtproto_max_unique_ips,
),
)


Expand Down