diff --git a/app/bot.php b/app/bot.php
index b1f7e73..b1752c8 100644
--- a/app/bot.php
+++ b/app/bot.php
@@ -651,6 +651,9 @@ class Bot
case preg_match('~^/changeTGDomain$~', $this->input['callback'], $m):
$this->changeTGDomain();
break;
+ case preg_match('~^/setTGAdtag$~', $this->input['callback'], $m):
+ $this->changeTGAdtag();
+ break;
case preg_match('~^/include (\w+)$~', $this->input['callback'], $m):
$this->include($m[1]);
break;
@@ -731,14 +734,32 @@ class Bot
$this->mtproto();
}
+ public function setTelegramAdtag($adtag)
+ {
+ $adtag = trim($adtag);
+ if ($adtag === '0') {
+ $adtag = '';
+ } elseif (!preg_match('~^[a-f0-9]{32}$~i', $adtag)) {
+ $this->update($this->input['chat'], $this->input['message_id'], 'wrong adtag');
+ sleep(2);
+ $this->mtproto();
+ return;
+ }
+ file_put_contents('/config/mtprotoadtag', strtolower($adtag));
+ $this->restartTG();
+ $this->mtproto();
+ }
+
public function restartTG()
{
$secret = file_get_contents('/config/mtprotosecret');
$fakedomain = file_get_contents('/config/mtprotodomain') ?: 'yandex.ru';
+ $adtag = trim(file_exists('/config/mtprotoadtag') ? file_get_contents('/config/mtprotoadtag') : '');
$this->ssh('pkill mtproto-proxy', 'tg');
if (preg_match('~^\w{32}$~', $secret)) {
$p = getenv('TGPORT');
- $this->ssh("mtproto-proxy --domain $fakedomain -u nobody -H $p --nat-info 10.10.0.8:{$this->ip} -S $secret --aes-pwd /proxy-secret /proxy-multi.conf -M 1", 'tg', false, '/logs/mtproto');
+ $proxyTag = $adtag ? " -P " . escapeshellarg($adtag) : '';
+ $this->ssh("mtproto-proxy --domain $fakedomain -u nobody -H $p --nat-info 10.10.0.8:{$this->ip} -S $secret --aes-pwd /proxy-secret /proxy-multi.conf -M 1$proxyTag", 'tg', false, '/logs/mtproto');
}
}
@@ -835,10 +856,12 @@ class Bot
public function mtproto()
{
$d = file_get_contents('/config/mtprotodomain') ?: 'yandex.ru';
+ $adtag = trim(file_exists('/config/mtprotoadtag') ? file_get_contents('/config/mtprotoadtag') : '');
$st = $this->ssh('pgrep mtproto-proxy', 'tg') ? 'on' : 'off';
$text[] = "Menu -> MTProto\n";
$text[] = "status: $st\n";
$text[] = "fake domain: $d\n";
+ $text[] = "adtag: " . ($adtag ?: 'off') . "\n";
if ($st == 'on') {
$text[] = $this->linkMtproto();
}
@@ -860,6 +883,12 @@ class Bot
'callback_data' => "/changeTGDomain",
],
];
+ $data[] = [
+ [
+ 'text' => $this->i18n('setAdTag'),
+ 'callback_data' => "/setTGAdtag",
+ ],
+ ];
$data[] = [
[
'text' => $this->i18n('show QR'),
@@ -1850,6 +1879,7 @@ class Bot
] : false,
'mtproto' => file_get_contents('/config/mtprotosecret'),
'mtprotodomain' => file_get_contents('/config/mtprotodomain'),
+ 'mtprotoadtag' => file_exists('/config/mtprotoadtag') ? file_get_contents('/config/mtprotoadtag') : '',
'xray' => $this->getXray(),
'hy' => yaml_parse_file('/config/hysteria.yaml'),
'oc' => file_get_contents('/config/ocserv.conf'),
@@ -1959,6 +1989,7 @@ class Bot
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
file_put_contents('/config/mtprotosecret', $json['mtproto']);
file_put_contents('/config/mtprotodomain', $json['mtprotodomain'] ?: '');
+ file_put_contents('/config/mtprotoadtag', trim($json['mtprotoadtag'] ?? ''));
$this->restartTG();
}
// hwid
@@ -9124,6 +9155,22 @@ DNS-over-HTTPS with IP:
];
}
+ public function changeTGAdtag()
+ {
+ $r = $this->send(
+ $this->input['chat'],
+ "@{$this->input['username']} enter adtag or 0 for disable",
+ $this->input['message_id'],
+ reply: 'enter adtag or 0 for disable',
+ );
+ $_SESSION['reply'][$r['result']['message_id']] = [
+ 'start_message' => $this->input['message_id'],
+ 'start_callback' => $this->input['callback_id'],
+ 'callback' => 'setTelegramAdtag',
+ 'args' => [],
+ ];
+ }
+
public function setFakeDomain($domain, $self = false)
{
$c = $this->getXray();
diff --git a/app/i18n.php b/app/i18n.php
index 756f98c..6c60261 100644
--- a/app/i18n.php
+++ b/app/i18n.php
@@ -261,6 +261,10 @@ $i = [
'en' => 'setSecret',
'ru' => 'установить свой ключ',
],
+ 'setAdTag' => [
+ 'en' => 'set adtag',
+ 'ru' => 'установить adtag',
+ ],
'defaultDNS' => [
'en' => 'defaultDNS',
'ru' => 'дефолтный днс',