Compare commits

...

20 Commits

Author SHA1 Message Date
mercury baaf0e2d01 clear pac list button 2024-08-06 21:58:08 +04:00
mercury be8bec6a7d fix ocserv pass 2024-08-04 11:51:01 +04:00
mercury acaec83877 update version 2024-08-03 11:19:00 +04:00
mercury 8cf6c512cb extended qr for wireguard 2024-08-03 11:14:53 +04:00
mercury 880a8de7e5 set mtu for wg 2024-08-03 10:39:15 +04:00
mercury 9662fc9d55 fix autobackup hint 2024-07-07 15:35:43 +04:00
mercury 561bcb7023 Merge branch 'dev' 2024-06-05 10:37:39 +04:00
mercury 9d7c735f79 Merge branch 'dev' of github.com:mercurykd/vpnbot into dev 2024-06-05 10:36:42 +04:00
mercury 8091eb4971 fix go version 2024-06-05 10:35:15 +04:00
mercury 967353bcd6 Merge branch 'dev' 2024-05-22 17:21:07 +04:00
mercury 9f218c9f32 chmod +x *.sh 2024-05-22 17:19:32 +04:00
mercury 6a6bd3a4d2 delete debug 2024-05-19 21:26:56 +04:00
mercury bc8b0ff033 Merge branch 'dev' 2024-05-18 17:05:44 +04:00
mercury 6017bc4008 Merge branch 'dev' 2024-05-04 13:00:53 +04:00
mercury 0c3a6cc90e Merge branch 'dev' 2024-05-01 18:42:24 +04:00
mercury c0750c930a Merge branch 'dev' 2024-05-01 17:53:13 +04:00
mercury 45e1455d48 Revert "edge repo for sing-box (#13)"
This reverts commit bb1ac60acc.
2024-04-29 23:13:47 +04:00
mercury 7582dc50c2 Revert "added sing-box from repo (#12)"
This reverts commit 256e43352a.
2024-04-29 23:13:27 +04:00
runalsh bb1ac60acc edge repo for sing-box (#13)
* added sing-box from repo

* add testing repo for sing-box
2024-04-29 20:48:25 +04:00
runalsh 256e43352a added sing-box from repo (#12) 2024-04-29 16:06:52 +04:00
27 changed files with 162 additions and 19 deletions
+150 -18
View File
@@ -9,6 +9,8 @@ class Bot
public $limit;
public $key;
public $file;
public $dns;
public $mtu;
public function __construct($key, $i18n)
{
@@ -22,6 +24,7 @@ class Bot
$this->i18n = $i18n;
$this->language = $this->getPacConf()['language'] ?: 'en';
$this->dns = '1.1.1.1, 8.8.8.8';
$this->mtu = 1350;
$this->limit = $this->getPacConf()['limitpage'] ?: 5;
$this->adguard = '/config/AdGuardHome.yaml';
$this->update = '/update/json';
@@ -139,6 +142,12 @@ class Bot
case preg_match('~^/mtproto$~', $this->input['callback'], $m):
$this->mtproto();
break;
case preg_match('~^/deletePac$~', $this->input['callback'], $m):
$this->deletePac();
break;
case preg_match('~^/deletePacYes$~', $this->input['callback'], $m):
$this->deletePacYes();
break;
case preg_match('~^/addCommunityFilter$~', $this->input['callback'], $m):
$this->addCommunityFilter();
break;
@@ -184,6 +193,9 @@ class Bot
case preg_match('~^/defaultDNS (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
$this->defaultDNS(...explode('_', $m['arg']));
break;
case preg_match('~^/defaultMTU (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
$this->defaultMTU(...explode('_', $m['arg']));
break;
case preg_match('~^/subnet (?P<arg>-?\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
$this->subnet(...explode('_', $m['arg']));
break;
@@ -199,6 +211,9 @@ class Bot
case preg_match('~^/changeAllowedIps (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
$this->changeAllowedIps(...explode('_', $m['arg']));
break;
case preg_match('~^/changeMTU (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
$this->changeMTU(...explode('_', $m['arg']));
break;
case preg_match('~^/calc$~', $this->input['callback'], $m):
$this->calc();
break;
@@ -954,7 +969,6 @@ class Bot
[$start, $period] = explode('/', $c['backup']);
$start = strtotime($start);
$period = strtotime($period, 0);
(var_dump($now, $start, $period, ($now - $start) % $period));
if ($now - $start >= $period && ($now - $start) % $period == 0) {
if (!empty($c['pinbackup'])) {
$this->pinAdmin($c['pinbackup'], 1);
@@ -1474,26 +1488,30 @@ class Bot
$this->menu('config');
}
public function qrPeer($client)
public function sendQr($name, $code, $title = false)
{
$cl = $client;
$client = $this->readClients()[$client];
$name = $this->getName($client['interface']);
if ($this->getWGType() == 'awg') {
$sl = $this->getAmneziaShortLink($client);
$code = preg_replace('/^vpn:\/\//', '', $sl);
} else {
$code = $this->createConfig($client);
}
$qr = preg_replace(['~\s+~', '~\(~', '~\)~'], ['_'], $name);
$qr_file = __DIR__ . "/qr/$qr.png";
exec("qrencode -t png -o $qr_file '$code'");
$r = $this->sendPhoto(
$this->input['chat'],
curl_file_create($qr_file),
($this->getWGType() == 'awg') ? "$name for AmneziaVPN" : $name
$title ?: $name
);
unlink($qr_file);
}
public function qrPeer($client)
{
$cl = $client;
$client = $this->readClients()[$client];
$name = $this->getName($client['interface']);
if ($this->getWGType() == 'awg') {
$this->sendQr($name, preg_replace('/^vpn:\/\//', '', $this->getAmneziaShortLink($client)), "$name for AmneziaVPN");
$this->sendQr($name, $this->createConfig($client), "$name for AmneziaWG");
} else {
$this->sendQr($name, $this->createConfig($client), "$name for Wireguard");
}
if ($this->getPacConf()['blinkmenu']) {
$this->delete($this->input['chat'], $this->input['message_id']);
$this->input['message_id'] = $this->send($this->input['chat'], '.')['result']['message_id'];
@@ -2438,6 +2456,7 @@ DNS-over-HTTPS with IP:
$bt = $c[$this->getInstanceWG(1) . 'blocktorrent'];
$ex = $c[$this->getInstanceWG(1) . 'exchange'];
$dns = $c[$this->getInstanceWG(1) . 'dns'];
$mtu = $c[$this->getInstanceWG(1) . 'mtu'] ?: $this->mtu;
$am = $c[$this->getInstanceWG(1) . 'amnezia'];
$data = [
[
@@ -2465,6 +2484,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('defaultDNS') . ': ' . ($dns ?: $this->dns),
'callback_data' => "/defaultDNS $page",
],
[
'text' => $this->i18n('defaultMTU') . ': ' . $mtu,
'callback_data' => "/defaultMTU $page",
],
],
[
[
@@ -2552,6 +2575,38 @@ DNS-over-HTTPS with IP:
];
}
public function defaultMTU($page = 0)
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter MTU",
$this->input['message_id'],
reply: 'enter MTU',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
'start_callback' => $this->input['callback_id'],
'callback' => 'setMTU',
'args' => [$page],
];
}
public function changeMTU($client, $page = 0)
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter MTU",
$this->input['message_id'],
reply: 'enter MTU',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
'start_callback' => $this->input['callback_id'],
'callback' => 'changeClientMTU',
'args' => [$client, $page],
];
}
public function setDNS($text, $page = 0)
{
$c = $this->getPacConf();
@@ -2564,6 +2619,30 @@ DNS-over-HTTPS with IP:
$this->menu('wg', $page);
}
public function setMTU($text, $page = 0)
{
$c = $this->getPacConf();
if ($text) {
$c[$this->getInstanceWG(1) . 'mtu'] = $text;
} else {
unset($c[$this->getInstanceWG(1) . 'mtu']);
}
$this->setPacConf($c);
$this->menu('wg', $page);
}
public function changeClientMTU($text, $client, $page = 0)
{
$clients = $this->readClients();
if (!empty((int) $text)) {
$clients[$client]['interface']['MTU'] = $text;
} else {
unset($clients[$client]['interface']['MTU']);
}
$this->saveClients($clients);
$this->menu('client', "{$client}_$page");
}
public function subnetAdd($wgpage, $page)
{
$r = $this->send(
@@ -2882,6 +2961,12 @@ DNS-over-HTTPS with IP:
'callback_data' => "/changeAllowedIps {$client}_$page",
],
],
[
[
'text' => $this->i18n('MTU') . " " . ($clients[$client]['interface']['MTU'] ?: $this->getPacConf()[$this->getInstanceWG(1) . 'mtu'] ?: $this->mtu),
'callback_data' => "/changeMTU {$client}_$page",
],
],
[
[
'text' => $this->i18n('delete'),
@@ -3060,6 +3145,40 @@ DNS-over-HTTPS with IP:
);
}
public function deletePacYes()
{
$c = $this->getPacConf();
unset($c['includelist']);
$this->setPacConf($c);
$this->pacUpdate();
$this->menu('pac');
}
public function deletePac($page = 0)
{
$text = <<<text
Menu -> PAC -> delete all
text;
$data[] = [
[
'text' => $this->i18n('yes'),
'callback_data' => "/deletePacYes",
],
];
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/pacMenu 0",
],
];
$this->update(
$this->input['chat'],
$this->input['message_id'],
$text,
$data ?: false,
);
}
public function xtlsblock($page = 0)
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> block list';
@@ -3137,6 +3256,12 @@ DNS-over-HTTPS with IP:
]
];
}
$data[] = [
[
'text' => $this->i18n('delete all'),
'callback_data' => "/deletePac",
],
];
}
return $data;
}
@@ -3516,12 +3641,13 @@ DNS-over-HTTPS with IP:
preg_match('~^camouflage_secret[^\n]+?"([^"]+)*"~sm', $ocserv, $m);
$cs = $m[1];
preg_match('~^dns = ([^\n]+)~sm', $ocserv, $m);
$dns = $m[1];
$dns = $m[1];
$pass = htmlspecialchars($pac['ocserv']);
$text[] = "Menu -> OpenConnect";
if (!empty($m[1])) {
$text[] = "<code>https://oc.{$pac['domain']}/?$cs</code>";
}
$text[] = "password: <span class='tg-spoiler'>{$pac['ocserv']}</span>";
$text[] = "password: <span class='tg-spoiler'>$pass</span>";
$data[] = [
[
'text' => $this->i18n('change secret'),
@@ -4707,9 +4833,13 @@ DNS-over-HTTPS with IP:
'callback_data' => "/import",
],
];
$backup = array_filter(explode('/', $conf['backup']));
if (!empty($backup)) {
$backup = "{$backup[0]} start / {$backup[1]} period";
}
$data[] = [
[
'text' => $this->i18n('backup') . ': ' . (implode(' / ', explode('/', $conf['backup'])) ?: $this->i18n('off')),
'text' => $this->i18n('backup') . ': ' . ($backup ?: $this->i18n('off')),
'callback_data' => "/backup",
],
];
@@ -4848,9 +4978,9 @@ DNS-over-HTTPS with IP:
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter like 1 day/00:00",
"@{$this->input['username']} enter like start / period",
$this->input['message_id'],
reply: 'enter like 1 day/00:00',
reply: 'enter like now / 12:00',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
@@ -5043,6 +5173,9 @@ DNS-over-HTTPS with IP:
if (empty($data['interface']['DNS'])) {
$data['interface']['DNS'] = $this->getPacConf()[$this->getInstanceWG(1) . 'dns'] ?: $this->dns;
}
if (empty($data['interface']['MTU'])) {
$data['interface']['MTU'] = $this->getPacConf()[$this->getInstanceWG(1) . 'mtu'] ?: $this->mtu;
}
}
foreach ($data['interface'] as $k => $v) {
$conf[] = "$k = $v";
@@ -5132,7 +5265,6 @@ DNS-over-HTTPS with IP:
'## name' => $name,
'PrivateKey' => $private_peer_key,
'Address' => "$client_ip/32",
'MTU' => 1350,
],
$this->getPacConf()[$this->getInstanceWG(1) . 'amnezia'] ? $this->amneziaKeys() : []
),
+4
View File
@@ -241,6 +241,10 @@ $i = [
'en' => 'defaultDNS',
'ru' => 'дефолтный днс',
],
'defaultMTU' => [
'en' => 'defaultMTU',
'ru' => 'дефолтный MTU',
],
'debug' => [
'en' => 'debug mode',
'ru' => 'режим отладки',
+3 -1
View File
@@ -1,6 +1,8 @@
ARG image
FROM $image
RUN apk add --no-cache --virtual .build-deps alpine-sdk git go \
COPY --from=golang:1.22.3-alpine /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"
RUN apk add --no-cache --virtual .build-deps alpine-sdk git \
&& apk add iproute2 linux-headers iptables xtables-addons openssh wireguard-tools jq bash htop \
&& git clone https://github.com/amnezia-vpn/amneziawg-go \
&& git clone https://github.com/amnezia-vpn/amneziawg-tools.git \
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
+5
View File
@@ -1,3 +1,8 @@
06.08.2024 v1.41
- возможность очистить РАС лист
03.08.2024 v1.40
- возможность менять MTU для Wireguard/Amnezia
- раздельный qr для AmneziaWG + AmneziaVPN
18.05.2024 v1.39
- изменен автобэкап
04.05.2024 v1.38