optimize ip info

This commit is contained in:
mercury
2023-04-08 00:53:23 +04:00
parent 7c6021c396
commit 06ca54756c
3 changed files with 13 additions and 11 deletions
+9 -8
View File
@@ -11,6 +11,7 @@ class Bot
$this->file = "https://api.telegram.org/file/bot$key/";
$this->clients = '/config/clients.json';
$this->pac = '/config/pac.json';
$this->ip = getenv('IP');
}
public function input()
@@ -305,7 +306,7 @@ class Bot
$ssl = $this->nginxGetTypeCert();
$c = $this->getSSConfig();
$l = $this->getSSLocalConfig();
$domain = $this->getPacConf()['domain'] ?: file_get_contents('https://ipinfo.io/ip');
$domain = $this->getPacConf()['domain'] ?: $this->ip;
if ($c['plugin']) {
unset($c['plugin']);
unset($c['plugin_opts']);
@@ -510,7 +511,7 @@ class Bot
public function qrSS()
{
$conf = $this->getPacConf();
$ip = file_get_contents('https://ipinfo.io/ip');
$ip = $this->ip;
$domain = $conf['domain'] ?: $ip;
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
$ss = $this->getSSConfig();
@@ -1326,7 +1327,7 @@ DNS-over-HTTPS with IP:
$pac = stat(__DIR__ . '/zapretlists/pac');
$conf = $this->getPacConf();
$zapret = $conf['zapret'] ? 'ON' : 'OFF';
$ip = $conf['domain'] ?: file_get_contents('https://ipinfo.io/ip');
$ip = $conf['domain'] ?: $this->ip;
$hash = substr(md5($this->key), 0, 8);
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
$text = <<<text
@@ -1564,7 +1565,7 @@ DNS-over-HTTPS with IP:
public function menuSS()
{
$conf = $this->getPacConf();
$ip = file_get_contents('https://ipinfo.io/ip');
$ip = $this->ip;
$domain = $conf['domain'] ?: $ip;
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
$ss = $this->getSSConfig();
@@ -1716,7 +1717,7 @@ DNS-over-HTTPS with IP:
public function adguardMenu()
{
$conf = $this->getPacConf();
$ip = file_get_contents('https://ipinfo.io/ip');
$ip = $this->ip;
$domain = $conf['domain'] ?: $ip;
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
@@ -2017,7 +2018,7 @@ DNS-over-HTTPS with IP:
'peers' => [
[
'PublicKey' => $public_server_key,
'Endpoint' => file_get_contents('https://ipinfo.io/ip') . ":" . getenv('WGPORT'),
'Endpoint' => $this->ip . ":" . getenv('WGPORT'),
'AllowedIPs' => $ips_user ?: "0.0.0.0/0",
'PersistentKeepalive' => 20,
]
@@ -2044,7 +2045,7 @@ DNS-over-HTTPS with IP:
public function syncPortClients()
{
$endpoint = file_get_contents('https://ipinfo.io/ip') . ':' . getenv('WGPORT');
$endpoint = $this->ip . ':' . getenv('WGPORT');
$clients = $this->readClients();
foreach ($clients as $k => $v) {
foreach ($v['peers'] as $i => $j) {
@@ -2119,7 +2120,7 @@ DNS-over-HTTPS with IP:
public function setwebhook()
{
$ip = file_get_contents('https://ipinfo.io/ip');
$ip = $this->ip;
if (empty($ip)) {
die('нет айпи');
}
+2 -2
View File
@@ -1,12 +1,12 @@
version: "3.7"
x-logging:
x-logging:
&default-logging
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
networks:
default:
ipam:
+2 -1
View File
@@ -1,6 +1,7 @@
export IP=$(curl https://ipinfo.io/ip)
rm /ssh/key*
ssh-keygen -m PEM -t rsa -f /ssh/key -N ''
openssl req -newkey rsa:2048 -sha256 -nodes -x509 -days 365 -keyout /certs/self_private -out /certs/self_public -subj "/C=NN/ST=N/L=N/O=N/CN=$(curl https://ipinfo.io/ip)"
openssl req -newkey rsa:2048 -sha256 -nodes -x509 -days 365 -keyout /certs/self_private -out /certs/self_public -subj "/C=NN/ST=N/L=N/O=N/CN=$IP"
php init.php
unitd --log /logs/unit_error
curl -X PUT --data-binary @/config/unit.json --unix-socket /var/run/control.unit.sock http://localhost/config