Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a7af1c30f | |||
| 2a17b4f1f3 | |||
| d005ccc919 | |||
| 5df89e7f89 | |||
| f6d72800cb | |||
| 4ff1929a22 | |||
| 46d54ffeee |
+2
-1
@@ -16,4 +16,5 @@
|
||||
.vscode/
|
||||
.idea/
|
||||
mirror/.env
|
||||
update/
|
||||
update/*
|
||||
!update/update.sh
|
||||
|
||||
+17
-8
@@ -1061,6 +1061,9 @@ class Bot
|
||||
if ($this->getPacConf()['amnezia'] != $json['pac']['amnezia']) {
|
||||
$switch_amnezia = 1;
|
||||
}
|
||||
if ($this->getPacConf()['wg1_amnezia'] != $json['pac']['wg1_amnezia']) {
|
||||
$switch_wg1amnezia = 1;
|
||||
}
|
||||
$this->setPacConf($json['pac']);
|
||||
$out[] = 'update naiveproxy';
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
@@ -1082,7 +1085,7 @@ class Bot
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$this->wg = 1;
|
||||
$this->saveClients($json['wg1']['clients']);
|
||||
$this->restartWG($this->createConfig($json['wg1']['server']), $switch_amnezia);
|
||||
$this->restartWG($this->createConfig($json['wg1']['server']), $switch_wg1amnezia);
|
||||
$this->iptablesWG();
|
||||
}
|
||||
// ad
|
||||
@@ -3829,7 +3832,6 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function readStatus()
|
||||
{
|
||||
// $this->sd([$this->getWGType(), $this->getInstanceWG()]);
|
||||
$r = $this->ssh($this->getWGType(), $this->getInstanceWG());
|
||||
$r = explode(PHP_EOL, $r);
|
||||
$r = array_filter($r);
|
||||
@@ -4002,14 +4004,21 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function syncPortClients()
|
||||
{
|
||||
$endpoint = $this->ip . ':' . getenv('WGPORT');
|
||||
$clients = $this->readClients();
|
||||
foreach ($clients as $k => $v) {
|
||||
foreach ($v['peers'] as $i => $j) {
|
||||
$clients[$k]['peers'][$i]['Endpoint'] = $endpoint;
|
||||
$endpoint = [
|
||||
$this->ip . ':' . getenv('WGPORT'),
|
||||
$this->ip . ':' . getenv('WG1PORT'),
|
||||
];
|
||||
for ($i=0; $i < 2; $i++) {
|
||||
$this->wg = $i;
|
||||
$clients = $this->readClients();
|
||||
foreach ($clients as $k => $v) {
|
||||
foreach ($v['peers'] as $i => $j) {
|
||||
$clients[$k]['peers'][$i]['Endpoint'] = $endpoint[$i];
|
||||
}
|
||||
}
|
||||
$this->saveClients($clients);
|
||||
}
|
||||
$this->saveClients($clients);
|
||||
unset($this->wg);
|
||||
}
|
||||
|
||||
public function saveClients(array $clients)
|
||||
|
||||
@@ -2,7 +2,7 @@ b:
|
||||
docker compose build
|
||||
u: # запуск контейнеров
|
||||
bash ./update/update.sh &
|
||||
IP=$(shell ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$$|\1|p' | awk '{print $1}' | head -1) VER=$(shell git describe --tags) docker compose up -d --force-recreate
|
||||
IP=$(shell curl https://ipinfo.io/ip) VER=$(shell git describe --tags) docker compose up -d --force-recreate
|
||||
d: # остановка контейнеров
|
||||
-kill -9 $(shell cat ./update/update_pid) > /dev/null
|
||||
docker compose down --remove-orphans
|
||||
@@ -54,4 +54,5 @@ s:
|
||||
git status -su
|
||||
c:
|
||||
git add config/
|
||||
git checkout .
|
||||
git checkout .
|
||||
git reset
|
||||
+33
-14
@@ -1,3 +1,7 @@
|
||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||
ssh-keygen -A
|
||||
exec /usr/sbin/sshd -D -e "$@" &
|
||||
|
||||
INTERFACE=$(route | grep '^default' | grep -o '[^ ]*$')
|
||||
if [ $(cat /etc/wireguard/wg0.conf | wc -c) -eq 0 ]
|
||||
then
|
||||
@@ -13,21 +17,36 @@ fi
|
||||
iptables -t nat -A POSTROUTING --destination 10.10.0.5 -j ACCEPT
|
||||
iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE
|
||||
ln -s /etc/wireguard/wg0.conf /etc/amnezia/amneziawg/wg0.conf
|
||||
if [ $(cat /pac.json | jq .amnezia) -eq 1 ]
|
||||
if [ "$HOSTNAME" = "wireguard1" ]
|
||||
then
|
||||
awg-quick up wg0
|
||||
if [ $(cat /pac.json | jq .wg1_amnezia) -eq 1 ]
|
||||
then
|
||||
awg-quick up wg0
|
||||
else
|
||||
wg-quick up wg0
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .wg1_blocktorrent) -eq 1 ]
|
||||
then
|
||||
sh /block_torrent.sh
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .wg1_exchange) -eq 1 ]
|
||||
then
|
||||
sh /block_exchange.sh
|
||||
fi
|
||||
else
|
||||
wg-quick up wg0
|
||||
fi
|
||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||
ssh-keygen -A
|
||||
exec /usr/sbin/sshd -D -e "$@" &
|
||||
if [ $(cat /pac.json | jq .blocktorrent) -eq 1 ]
|
||||
then
|
||||
sh /block_torrent.sh
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .exchange) -eq 1 ]
|
||||
then
|
||||
sh /block_exchange.sh
|
||||
if [ $(cat /pac.json | jq .amnezia) -eq 1 ]
|
||||
then
|
||||
awg-quick up wg0
|
||||
else
|
||||
wg-quick up wg0
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .blocktorrent) -eq 1 ]
|
||||
then
|
||||
sh /block_torrent.sh
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .exchange) -eq 1 ]
|
||||
then
|
||||
sh /block_exchange.sh
|
||||
fi
|
||||
fi
|
||||
tail -f /dev/null
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
pwd=`pwd`
|
||||
> $pwd/update/pipe
|
||||
echo "$$" > $pwd/update/update_pid
|
||||
|
||||
while true
|
||||
do
|
||||
cmd=$(cat $pwd/update/pipe)
|
||||
if [[ -n "$cmd" ]]
|
||||
then
|
||||
docker compose down --remove-orphans
|
||||
git reset --hard
|
||||
git pull > ./update/message
|
||||
IP=$(curl https://ipinfo.io/ip) VER=$(git describe --tags) docker compose up -d --force-recreate
|
||||
bash $pwd/update/update.sh &
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
@@ -1,3 +1,6 @@
|
||||
04.03.2024
|
||||
- решение "серого айпи" при запуске
|
||||
- фикс стартового скрипта второго контейнера wireguard
|
||||
03.03.2024 возможность обновления бота по кнопке из самого бота
|
||||
- <code>git pull && make r</code>
|
||||
02.03.2024 2 сервера wireguard, для возможности один запускать как wireguard а второй как amnezia
|
||||
|
||||
Reference in New Issue
Block a user