Compare commits
18 Commits
04c440ac2b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d66b08728 | |||
| 5d36fa750a | |||
| be64961777 | |||
| 55738548ad | |||
| 0fd78e2a04 | |||
| c8562cc676 | |||
| e8ab47db2c | |||
| 48ebb5554f | |||
| 3e0f942371 | |||
| 26fb8a222c | |||
| 4406131676 | |||
| 6f81d9f9cf | |||
| d604c1e8ab | |||
| ad9ece7763 | |||
| fd7681930b | |||
| 1dd676c628 | |||
| 4935d4abff | |||
| f8d6d82f4f |
BIN
aarch64/dnstt-server
Normal file
BIN
aarch64/dnstt-server
Normal file
Binary file not shown.
@@ -17,7 +17,7 @@ function alterardata($user, $data)
|
|||||||
function alterardatanew($id, $data)
|
function alterardatanew($id, $data)
|
||||||
{
|
{
|
||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT usr FROM users where id = $1";
|
$query = "SELECT usr FROM users where id = $1";
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ function printvalidnew($id)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT usr FROM users WHERE id=$1";
|
$query = "SELECT usr FROM users WHERE id=$1";
|
||||||
$params = array($id);
|
$params = array($id);
|
||||||
@@ -60,7 +60,7 @@ function printvalinew()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function printlim()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT * FROM users";
|
$query = "SELECT * FROM users";
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ function uplimit($username, $newLimit)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "UPDATE users SET limi = $1 WHERE usr = $2";
|
$query = "UPDATE users SET limi = $1 WHERE usr = $2";
|
||||||
$params = array($newLimit, $username);
|
$params = array($newLimit, $username);
|
||||||
@@ -52,7 +52,7 @@ function printlim2($user)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT limi FROM users WHERE usr=$1";
|
$query = "SELECT limi FROM users WHERE usr=$1";
|
||||||
$params = array($user);
|
$params = array($user);
|
||||||
@@ -74,7 +74,7 @@ function uplimitnew($id, $limit)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT usr FROM users where id = $1";
|
$query = "SELECT usr FROM users where id = $1";
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ function printlim2new($id)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT * FROM users WHERE id=$1";
|
$query = "SELECT * FROM users WHERE id=$1";
|
||||||
$params = array($id);
|
$params = array($id);
|
||||||
@@ -117,7 +117,7 @@ function printlimnew()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT * FROM users";
|
$query = "SELECT * FROM users";
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ function printpass()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT id,usr, pass FROM users";
|
$query = "SELECT id,usr, pass FROM users";
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ function printpass2($user)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT pass FROM users WHERE usr=$1";
|
$query = "SELECT pass FROM users WHERE usr=$1";
|
||||||
$params = array($user);
|
$params = array($user);
|
||||||
@@ -59,7 +59,7 @@ function uppass2($username, $pass)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "UPDATE users SET pass = $1 WHERE usr = $2";
|
$query = "UPDATE users SET pass = $1 WHERE usr = $2";
|
||||||
$params = array($pass, $username);
|
$params = array($pass, $username);
|
||||||
@@ -75,7 +75,7 @@ function uppassnew($id, $pass)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT usr FROM users where id = $1";
|
$query = "SELECT usr FROM users where id = $1";
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ function printpassnew($id)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT usr,pass FROM users WHERE id=$1";
|
$query = "SELECT usr,pass FROM users WHERE id=$1";
|
||||||
$params = array($id);
|
$params = array($id);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function createautostart()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
echo "Failed to connect to PostgreSQL";
|
echo "Failed to connect to PostgreSQL";
|
||||||
@@ -38,7 +38,7 @@ function incone($cone, $porta, $banner, $token, $tipo)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ function autostart()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -99,6 +99,33 @@ function startsv($cone, $port, $banner, $token, $tipo)
|
|||||||
shell_exec("/usr/bin/screen -dmS limitador bash -c 'while true; do php /opt/DragonCore/limiter.php; done'");
|
shell_exec("/usr/bin/screen -dmS limitador bash -c 'while true; do php /opt/DragonCore/limiter.php; done'");
|
||||||
} elseif ($cone == "botulek") {
|
} elseif ($cone == "botulek") {
|
||||||
shell_exec("screen -dmS botulek bash -c 'while true; do ulimit -n 999999 && /opt/DragonCore/ulekbot --token $banner --id $token; done'");
|
shell_exec("screen -dmS botulek bash -c 'while true; do ulimit -n 999999 && /opt/DragonCore/ulekbot --token $banner --id $token; done'");
|
||||||
|
} elseif ($cone == "dnstt") {
|
||||||
|
$bin = '/opt/DragonCore/dnstt-server';
|
||||||
|
$confDir = '/opt/DragonCore/dnstt';
|
||||||
|
$privFile = $confDir . '/server.key';
|
||||||
|
if (!is_dir($confDir)) {
|
||||||
|
mkdir($confDir, 0700, true);
|
||||||
|
}
|
||||||
|
if (!file_exists($privFile)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$cmd = "iptables -C INPUT -p udp --dport {$port} -j ACCEPT 2>/dev/null || iptables -I INPUT -p udp --dport {$port} -j ACCEPT";
|
||||||
|
shell_exec($cmd);
|
||||||
|
$cmd = "iptables -t nat -C PREROUTING -p udp --dport 53 -j REDIRECT --to-ports {$port} 2>/dev/null || iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports {$port}";
|
||||||
|
shell_exec($cmd);
|
||||||
|
|
||||||
|
$cmd = "/usr/bin/screen -dmS dnstt bash -c '"
|
||||||
|
. "while true; do "
|
||||||
|
. "ulimit -n 999999 && "
|
||||||
|
. escapeshellcmd($bin)
|
||||||
|
. " -udp 0.0.0.0:" . $port
|
||||||
|
. " -privkey-file " . escapeshellarg($privFile)
|
||||||
|
. " " . escapeshellarg($banner)
|
||||||
|
. " " . escapeshellarg($token)
|
||||||
|
. "; "
|
||||||
|
. "sleep 2; "
|
||||||
|
. "done'";
|
||||||
|
shell_exec($cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +134,7 @@ function deletecone($cone)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
|
|||||||
14
database.php
14
database.php
@@ -6,7 +6,7 @@ function createTable()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
echo "Failed to connect to PostgreSQL";
|
echo "Failed to connect to PostgreSQL";
|
||||||
@@ -34,7 +34,7 @@ function retrieveDataAndCount()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ function insertData($user, $pass, $limi)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ function deleteData($user)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ function printusers()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ function printvalid()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ function printvalid2($user)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
|
|||||||
113
dnstt.php
Normal file
113
dnstt.php
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function dnstt($port, $nsDomain, $target)
|
||||||
|
{
|
||||||
|
$port = preg_replace('/\D/', '', (string)$port);
|
||||||
|
if ($port === '') {
|
||||||
|
$port = '5300';
|
||||||
|
}
|
||||||
|
|
||||||
|
$nsDomain = trim($nsDomain);
|
||||||
|
$target = trim($target);
|
||||||
|
|
||||||
|
if ($nsDomain === '' || $target === '') {
|
||||||
|
echo "NS domain e destino nao podem estar vazios.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bin = '/opt/DragonCore/dnstt-server';
|
||||||
|
$confDir = '/opt/DragonCore/dnstt';
|
||||||
|
$privFile = $confDir . '/server.key';
|
||||||
|
$pubFile = $confDir . '/server.pub';
|
||||||
|
|
||||||
|
if (!file_exists($bin)) {
|
||||||
|
echo "Binario DNSTT nao encontrado em {$bin}\n";
|
||||||
|
echo "Coloque o dnstt-server nesse caminho.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_dir($confDir)) {
|
||||||
|
mkdir($confDir, 0700, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($privFile) || !file_exists($pubFile)) {
|
||||||
|
$cmdGen = escapeshellcmd($bin) .
|
||||||
|
' -gen-key -privkey-file ' . escapeshellarg($privFile) .
|
||||||
|
' -pubkey-file ' . escapeshellarg($pubFile) .
|
||||||
|
' 2>/dev/null';
|
||||||
|
shell_exec($cmdGen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($privFile) || !file_exists($pubFile)) {
|
||||||
|
echo "Falha ao gerar as chaves do DNSTT.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cmd = "iptables -C INPUT -p udp --dport {$port} -j ACCEPT 2>/dev/null || iptables -I INPUT -p udp --dport {$port} -j ACCEPT";
|
||||||
|
shell_exec($cmd);
|
||||||
|
|
||||||
|
$cmd = "iptables -t nat -C PREROUTING -p udp --dport 53 -j REDIRECT --to-ports {$port} 2>/dev/null || iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports {$port}";
|
||||||
|
shell_exec($cmd);
|
||||||
|
|
||||||
|
if (function_exists('deletecone') && function_exists('incone')) {
|
||||||
|
deletecone('dnstt');
|
||||||
|
incone('dnstt', $port, $nsDomain, $target, 'udp');
|
||||||
|
}
|
||||||
|
|
||||||
|
$onoff = trim(shell_exec('screen -list | grep -q dnstt && echo 1 || echo 0'));
|
||||||
|
if ($onoff === '1') {
|
||||||
|
shell_exec('screen -X -S dnstt quit');
|
||||||
|
}
|
||||||
|
|
||||||
|
$cmd = "/usr/bin/screen -dmS dnstt bash -c '"
|
||||||
|
. "while true; do "
|
||||||
|
. "ulimit -n 999999 && "
|
||||||
|
. escapeshellcmd($bin)
|
||||||
|
. " -udp 0.0.0.0:" . $port
|
||||||
|
. " -privkey-file " . escapeshellarg($privFile)
|
||||||
|
. " " . escapeshellarg($nsDomain)
|
||||||
|
. " " . escapeshellarg($target)
|
||||||
|
. "; "
|
||||||
|
. "sleep 2; "
|
||||||
|
. "done'";
|
||||||
|
|
||||||
|
shell_exec($cmd);
|
||||||
|
|
||||||
|
echo "DNSTT ON | UDP :{$port} | NS: {$nsDomain} | Destino: {$target}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function dnstton()
|
||||||
|
{
|
||||||
|
$onoff = trim(shell_exec('screen -list | grep -q dnstt && echo 1 || echo 0'));
|
||||||
|
if ($onoff === '1') {
|
||||||
|
echo 'ON';
|
||||||
|
} else {
|
||||||
|
echo 'OFF';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dnsttstop()
|
||||||
|
{
|
||||||
|
if (function_exists('deletecone')) {
|
||||||
|
deletecone('dnstt');
|
||||||
|
}
|
||||||
|
shell_exec('screen -X -S dnstt quit');
|
||||||
|
echo "DNSTT OFF\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function dnsttpub()
|
||||||
|
{
|
||||||
|
$pubFile = '/opt/DragonCore/dnstt/server.pub';
|
||||||
|
|
||||||
|
if (!file_exists($pubFile)) {
|
||||||
|
echo "Pubkey nao encontrada em {$pubFile}. Inicie o DNSTT uma vez para gerar.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = trim(file_get_contents($pubFile));
|
||||||
|
if ($content === '') {
|
||||||
|
echo "Pubkey vazia em {$pubFile}\n";
|
||||||
|
} else {
|
||||||
|
echo "DNSTT PubKey:\n{$content}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ function removeexpired()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once '/opt/DragonCore/config.php';
|
||||||
function createbackup()
|
function createbackup()
|
||||||
{
|
{
|
||||||
$db = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
$db = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
$tableData = array();
|
$tableData = array();
|
||||||
$tables = array("users", "conestart");
|
$tables = array("users", "conestart");
|
||||||
|
|
||||||
|
|||||||
20
install.sh
20
install.sh
@@ -10,6 +10,9 @@ if [ "$system" = "debian" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
sudo apt update
|
sudo apt update
|
||||||
|
sudo apt upgrade -y
|
||||||
|
sudo apt install -y uuid-runtime
|
||||||
|
sudo apt install -y curl
|
||||||
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg curl wget
|
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg curl wget
|
||||||
if [ "$system" = "debian" ]; then
|
if [ "$system" = "debian" ]; then
|
||||||
repos=$(find /etc/apt/ -name '*.list' -exec cat {} + | grep ^[[:space:]]*deb | grep -q "packages.sury.org/php" && echo 1 || echo 0)
|
repos=$(find /etc/apt/ -name '*.list' -exec cat {} + | grep ^[[:space:]]*deb | grep -q "packages.sury.org/php" && echo 1 || echo 0)
|
||||||
@@ -32,6 +35,14 @@ if [ ! -e "/bin/php" ]; then
|
|||||||
sudo ln -s "$(command -v php)" /bin/php
|
sudo ln -s "$(command -v php)" /bin/php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# === BACKUP EXISTING CONFIG.PHP BEFORE REMOVING FOLDER ===
|
||||||
|
CONFIG_BACKUP="/opt/DragonCore_config.php.bak"
|
||||||
|
if [ -f "/opt/DragonCore/config.php" ]; then
|
||||||
|
cp /opt/DragonCore/config.php "$CONFIG_BACKUP"
|
||||||
|
echo "Backup de config.php criado em $CONFIG_BACKUP"
|
||||||
|
fi
|
||||||
|
# =========================================================
|
||||||
|
|
||||||
cd /opt/
|
cd /opt/
|
||||||
rm -rf DragonCore
|
rm -rf DragonCore
|
||||||
cd "$HOME"
|
cd "$HOME"
|
||||||
@@ -43,6 +54,7 @@ rm -rf /opt/DragonCore/install.sh
|
|||||||
|
|
||||||
curl -s -L -o /opt/DragonCore/menu https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/menu
|
curl -s -L -o /opt/DragonCore/menu https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/menu
|
||||||
curl -s -L -o /opt/DragonCore/dragon_go https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/dragon_go
|
curl -s -L -o /opt/DragonCore/dragon_go https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/dragon_go
|
||||||
|
curl -s -L -o /opt/DragonCore/dnstt-server https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/dnstt-server
|
||||||
curl -s -L -o /opt/DragonCore/badvpn-udpgw https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/badvpn-udpgw
|
curl -s -L -o /opt/DragonCore/badvpn-udpgw https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/badvpn-udpgw
|
||||||
curl -s -L -o /opt/DragonCore/libcrypto.so.3 https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/libcrypto.so.3
|
curl -s -L -o /opt/DragonCore/libcrypto.so.3 https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/libcrypto.so.3
|
||||||
curl -s -L -o /opt/DragonCore/libssl.so.3 https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/libssl.so.3
|
curl -s -L -o /opt/DragonCore/libssl.so.3 https://git.dr2.site/penguinehis/DragonCoreSSH-Beta/raw/branch/main/$(uname -m)/libssl.so.3
|
||||||
@@ -53,6 +65,13 @@ cd /opt/DragonCore
|
|||||||
chmod +x *
|
chmod +x *
|
||||||
cd "$HOME"
|
cd "$HOME"
|
||||||
|
|
||||||
|
|
||||||
|
if [ -f "$CONFIG_BACKUP" ]; then
|
||||||
|
cp "$CONFIG_BACKUP" /opt/DragonCore/config.php
|
||||||
|
echo "config.php restaurado de $CONFIG_BACKUP"
|
||||||
|
fi
|
||||||
|
# ==============================================
|
||||||
|
|
||||||
echo -n "/opt/DragonCore/menu" > /bin/menu
|
echo -n "/opt/DragonCore/menu" > /bin/menu
|
||||||
chmod +x /bin/menu
|
chmod +x /bin/menu
|
||||||
|
|
||||||
@@ -88,6 +107,7 @@ php /opt/DragonCore/menu.php createv2table
|
|||||||
php /opt/DragonCore/dbconvert.php convertdba
|
php /opt/DragonCore/dbconvert.php convertdba
|
||||||
php /opt/DragonCore/dbconvert.php finishdba
|
php /opt/DragonCore/dbconvert.php finishdba
|
||||||
php /opt/DragonCore/menu.php deletecone ws
|
php /opt/DragonCore/menu.php deletecone ws
|
||||||
|
php /opt/DragonCore/menu.php createXrayTable
|
||||||
|
|
||||||
sed -i '/# HostKeyAlgorithms/ a\HostKeyAlgorithms +ssh-rsa' /etc/ssh/sshd_config
|
sed -i '/# HostKeyAlgorithms/ a\HostKeyAlgorithms +ssh-rsa' /etc/ssh/sshd_config
|
||||||
sed -i '/# PubkeyAcceptedKeyTypes/ a\PubkeyAcceptedKeyTypes +ssh-rsa' /etc/ssh/sshd_config
|
sed -i '/# PubkeyAcceptedKeyTypes/ a\PubkeyAcceptedKeyTypes +ssh-rsa' /etc/ssh/sshd_config
|
||||||
|
|||||||
129
menu
129
menu
@@ -189,6 +189,51 @@ fi
|
|||||||
#menuv2
|
#menuv2
|
||||||
#--------------------
|
#--------------------
|
||||||
elif [ "$cake" == "4" ]; then
|
elif [ "$cake" == "4" ]; then
|
||||||
|
# Xray Core management
|
||||||
|
clear
|
||||||
|
menuxray
|
||||||
|
|
||||||
|
elif [ "$cake" == "5" ]; then
|
||||||
|
clear
|
||||||
|
dnon="$(php /opt/DragonCore/menu.php dnstton)"
|
||||||
|
if [ "$dnon" == "ON" ]; then
|
||||||
|
echo "DNSTT esta ON."
|
||||||
|
echo "1) Parar DNSTT"
|
||||||
|
echo "2) Mostrar PubKey"
|
||||||
|
echo "0) Voltar"
|
||||||
|
echo -ne "> "; read op
|
||||||
|
if [ "$op" == "1" ]; then
|
||||||
|
php /opt/DragonCore/menu.php dnsttstop
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menucon
|
||||||
|
elif [ "$op" == "2" ]; then
|
||||||
|
php /opt/DragonCore/menu.php dnsttpub
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menucon
|
||||||
|
else
|
||||||
|
menucon
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Configurar DNSTT (SlowDNS)"
|
||||||
|
echo ""
|
||||||
|
echo -ne "Porta UDP (53/5300) [5300] > "; read port
|
||||||
|
[ -z "$port" ] && port=5300
|
||||||
|
echo -ne "NS Domain (ex: t.example.com) > "; read ns
|
||||||
|
if [ -z "$ns" ]; then
|
||||||
|
echo "NS Domain nao pode ficar vazio!"
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menucon
|
||||||
|
fi
|
||||||
|
echo -ne "Destino (host:porta, ex: 127.0.0.1:8000) [127.0.0.1:8000] > "; read dest
|
||||||
|
[ -z "$dest" ] && dest="127.0.0.1:8000"
|
||||||
|
|
||||||
|
clear
|
||||||
|
php /opt/DragonCore/menu.php dnstt "$port" "$ns" "$dest"
|
||||||
|
echo ""
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menucon
|
||||||
|
fi
|
||||||
|
elif [ "$cake" == "6" ]; then
|
||||||
clear
|
clear
|
||||||
echo "Portas Ativas"
|
echo "Portas Ativas"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -201,6 +246,90 @@ menucon
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menuxray(){
|
||||||
|
clear
|
||||||
|
php /opt/DragonCore/menu.php menuxray
|
||||||
|
echo -ne "> "; read option
|
||||||
|
if [ -z "$option" ]; then
|
||||||
|
menuxray
|
||||||
|
elif [ "$option" == "0" ]; then
|
||||||
|
menucon
|
||||||
|
elif [ "$option" == "1" ]; then
|
||||||
|
clear
|
||||||
|
echo -ne "Nome do usuario > "; read usr
|
||||||
|
if [ -z "$usr" ]; then
|
||||||
|
menuxray
|
||||||
|
else
|
||||||
|
echo -ne "Protocolo (ws/xhttp/grpc/tcp) [ws] > "; read proto
|
||||||
|
[ -z "$proto" ] && proto="ws"
|
||||||
|
php /opt/DragonCore/menu.php xrayAddUser "$usr" "$proto"
|
||||||
|
echo ""
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menuxray
|
||||||
|
fi
|
||||||
|
elif [ "$option" == "2" ]; then
|
||||||
|
clear
|
||||||
|
php /opt/DragonCore/menu.php xrayListUsers
|
||||||
|
echo ""
|
||||||
|
echo -ne "ID ou UUID para remover > "; read ident
|
||||||
|
if [ -n "$ident" ]; then
|
||||||
|
php /opt/DragonCore/menu.php xrayRemoveUser "$ident"
|
||||||
|
echo ""
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menuxray
|
||||||
|
fi
|
||||||
|
menuxray
|
||||||
|
elif [ "$option" == "3" ]; then
|
||||||
|
clear
|
||||||
|
php /opt/DragonCore/menu.php xrayListUsers
|
||||||
|
echo ""
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menuxray
|
||||||
|
elif [ "$option" == "4" ]; then
|
||||||
|
clear
|
||||||
|
php /opt/DragonCore/menu.php xrayInfo
|
||||||
|
echo ""
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menuxray
|
||||||
|
elif [ "$option" == "5" ]; then
|
||||||
|
clear
|
||||||
|
echo -ne "Dominio (ex: vpn.seudominio.com) > "; read dominio
|
||||||
|
if [ -n "$dominio" ]; then
|
||||||
|
php /opt/DragonCore/menu.php xrayCert "$dominio"
|
||||||
|
echo ""
|
||||||
|
chmod 777 -R /opt/DragonCoreSSL
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menuxray
|
||||||
|
fi
|
||||||
|
menuxray
|
||||||
|
elif [ "$option" == "6" ]; then
|
||||||
|
clear
|
||||||
|
echo -ne "Porta do inbound [443] > "; read p
|
||||||
|
[ -z "$p" ] && p=443
|
||||||
|
echo -ne "Protocolo (ws/xhttp/grpc/tcp) [ws] > "; read pr
|
||||||
|
[ -z "$pr" ] && pr="ws"
|
||||||
|
bash <(php /opt/DragonCore/menu.php xrayInstall)
|
||||||
|
php /opt/DragonCore/menu.php xrayGenerateConfig "$p" "$pr"
|
||||||
|
echo ""
|
||||||
|
chmod 777 /usr/local/etc/xray/config.json
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menuxray
|
||||||
|
elif [ "$option" == "7" ]; then
|
||||||
|
clear
|
||||||
|
echo -ne "Deseja remover o Xray Core? S/n > "; read sn
|
||||||
|
lower=$(echo "$sn" | tr '[:upper:]' '[:lower:]')
|
||||||
|
if [[ "$lower" == "s" || "$lower" == "y" ]]; then
|
||||||
|
bash <(php /opt/DragonCore/menu.php xrayRemove)
|
||||||
|
echo ""
|
||||||
|
echo -ne "Pressione enter para continuar"; read enter
|
||||||
|
menuxray
|
||||||
|
fi
|
||||||
|
menuxray
|
||||||
|
else
|
||||||
|
menuxray
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
menuferrament(){
|
menuferrament(){
|
||||||
clear
|
clear
|
||||||
php /opt/DragonCore/menu.php menuferramenta
|
php /opt/DragonCore/menu.php menuferramenta
|
||||||
|
|||||||
34
menu.php
34
menu.php
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once '/opt/DragonCore/config.php';
|
||||||
require "/opt/DragonCore/criarusuario.php";
|
require "/opt/DragonCore/criarusuario.php";
|
||||||
require "/opt/DragonCore/removeruser.php";
|
require "/opt/DragonCore/removeruser.php";
|
||||||
require "/opt/DragonCore/database.php";
|
require "/opt/DragonCore/database.php";
|
||||||
@@ -14,7 +14,6 @@ require "/opt/DragonCore/infovps.php";
|
|||||||
require "/opt/DragonCore/backup.php";
|
require "/opt/DragonCore/backup.php";
|
||||||
require "/opt/DragonCore/networkms.php";
|
require "/opt/DragonCore/networkms.php";
|
||||||
require "/opt/DragonCore/openvpn.php";
|
require "/opt/DragonCore/openvpn.php";
|
||||||
require "/opt/DragonCore/v2ray.php";
|
|
||||||
require "/opt/DragonCore/network.php";
|
require "/opt/DragonCore/network.php";
|
||||||
require "/opt/DragonCore/checkatt.php";
|
require "/opt/DragonCore/checkatt.php";
|
||||||
require "/opt/DragonCore/autostart.php";
|
require "/opt/DragonCore/autostart.php";
|
||||||
@@ -31,6 +30,8 @@ require "/opt/DragonCore/speedtest.php";
|
|||||||
require "/opt/DragonCore/limiterstart.php";
|
require "/opt/DragonCore/limiterstart.php";
|
||||||
require "/opt/DragonCore/statusvps.php";
|
require "/opt/DragonCore/statusvps.php";
|
||||||
require "/opt/DragonCore/bottg.php";
|
require "/opt/DragonCore/bottg.php";
|
||||||
|
require "/opt/DragonCore/xray.php";
|
||||||
|
require "/opt/DragonCore/dnstt.php";
|
||||||
|
|
||||||
|
|
||||||
function clearScreen()
|
function clearScreen()
|
||||||
@@ -91,6 +92,8 @@ function menuconnect()
|
|||||||
"Dragon X Go" => "",
|
"Dragon X Go" => "",
|
||||||
"Stunnel4" => "",
|
"Stunnel4" => "",
|
||||||
"OpenVPN" => "",
|
"OpenVPN" => "",
|
||||||
|
"Xray Core" => "",
|
||||||
|
"DNSTT (SlowDNS)" => "",
|
||||||
"Portas Ativas" => "",
|
"Portas Ativas" => "",
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -188,25 +191,23 @@ function menuusuario()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function menuv2()
|
function menuxray()
|
||||||
{
|
{
|
||||||
$installv = v2cho();
|
// Build a static set of management options for Xray. Users can install, configure or
|
||||||
|
// remove Xray regardless of its current state. This avoids confusing toggles and allows
|
||||||
|
// explicit selection of actions.
|
||||||
$menuItems = [
|
$menuItems = [
|
||||||
"Criar Usuario" => "",
|
'Criar Usuario Xray' => '',
|
||||||
"Remover Usuario" => "",
|
'Remover Usuario Xray' => '',
|
||||||
"Listar Usuarios" => "",
|
'Listar Usuarios Xray' => '',
|
||||||
"Info V2ray" => "",
|
'Informacao Xray' => '',
|
||||||
"Alterar Protocolo" => "",
|
'Gerar Certificado TLS' => '',
|
||||||
"Ativar TLS" => "",
|
'Instalar/Configurar Xray Core' => '',
|
||||||
"Alterar Porta" => "",
|
'Remover Xray Core' => '',
|
||||||
$installv => "V2ray",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$maxDigits = strlen(count($menuItems));
|
$maxDigits = strlen(count($menuItems));
|
||||||
|
echo "Gerenciamento Xray\n";
|
||||||
echo "Gerenciamento V2ray\n";
|
|
||||||
echo "------------\n";
|
echo "------------\n";
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach ($menuItems as $item => $description) {
|
foreach ($menuItems as $item => $description) {
|
||||||
$number = str_pad($i, $maxDigits, " ", STR_PAD_LEFT);
|
$number = str_pad($i, $maxDigits, " ", STR_PAD_LEFT);
|
||||||
@@ -217,7 +218,6 @@ function menuv2()
|
|||||||
echo "\n";
|
echo "\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "0. Voltar para o menu\n";
|
echo "0. Voltar para o menu\n";
|
||||||
echo "------------\n";
|
echo "------------\n";
|
||||||
}
|
}
|
||||||
|
|||||||
34
network.php
34
network.php
@@ -1,49 +1,63 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function bitmask()
|
function bitmask()
|
||||||
{
|
{
|
||||||
$cores = intval(shell_exec("/usr/bin/grep -c ^processor /proc/cpuinfo"));
|
$cores = intval(shell_exec("/usr/bin/grep -c ^processor /proc/cpuinfo"));
|
||||||
$half_cores = ceil($cores / 2);
|
$half_cores = ceil($cores / 2);
|
||||||
$bitmask = 0;
|
$bitmask = 0;
|
||||||
|
|
||||||
for ($i = 0; $i < $half_cores; $i++) {
|
for ($i = 0; $i < $half_cores; $i++) {
|
||||||
$bitmask |= (1 << $i);
|
$bitmask |= (1 << $i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bitmask;
|
return $bitmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function netinter()
|
function netinter()
|
||||||
{
|
{
|
||||||
$interface = trim(shell_exec("/usr/bin/ip route get 1 | grep -Po '(?<=dev )(\S+)'"));
|
$interface = trim(shell_exec("/usr/bin/ip route get 1 | grep -Po '(?<=dev )(\S+)'"));
|
||||||
return $interface;
|
return $interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function insertnet()
|
function insertnet()
|
||||||
{
|
{
|
||||||
$netface = netinter();
|
$netface = netinter();
|
||||||
$checknet = trim(shell_exec("/usr/bin/cat /sys/class/net/$netface/queues/rx-0/rps_cpus"));
|
if ($netface === '') {
|
||||||
|
echo "Não foi possível detectar interface de rede.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = "/sys/class/net/$netface/queues/rx-0/rps_cpus";
|
||||||
|
|
||||||
|
$checknet = trim(@shell_exec("/usr/bin/cat $path"));
|
||||||
$bit = bitmask();
|
$bit = bitmask();
|
||||||
if (str_contains($checknet, $bit)) {
|
|
||||||
|
if ((int)$checknet === (int)$bit) {
|
||||||
deletecone("netsta");
|
deletecone("netsta");
|
||||||
shell_exec("/usr/bin/echo \"0\" > /sys/class/net/$netface/queues/rx-0/rps_cpus");
|
shell_exec("/usr/bin/echo \"0\" > $path");
|
||||||
echo "Balanceamento Desativado! \n";
|
echo "Balanceamento Desativado! \n";
|
||||||
} else {
|
} else {
|
||||||
deletecone("netsta");
|
deletecone("netsta");
|
||||||
incone("netsta", "null", "null", "null", "null");
|
incone("netsta", "null", "null", "null", "null");
|
||||||
shell_exec("/usr/bin/echo \"$bit\" > /sys/class/net/$netface/queues/rx-0/rps_cpus");
|
shell_exec("/usr/bin/echo \"$bit\" > $path");
|
||||||
echo "Balanceamento ativado! \n";
|
echo "Balanceamento ativado! \n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function checknet()
|
function checknet()
|
||||||
{
|
{
|
||||||
$netface = netinter();
|
$netface = netinter();
|
||||||
$checknet = trim(shell_exec("/usr/bin/cat /sys/class/net/$netface/queues/rx-0/rps_cpus"));
|
if ($netface === '') {
|
||||||
|
echo "OFF";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = "/sys/class/net/$netface/queues/rx-0/rps_cpus";
|
||||||
|
|
||||||
|
$checknet = trim(@shell_exec("/usr/bin/cat $path"));
|
||||||
$bit = bitmask();
|
$bit = bitmask();
|
||||||
if (str_contains($checknet, $bit)) {
|
|
||||||
|
if ((int)$checknet === (int)$bit) {
|
||||||
echo "ON";
|
echo "ON";
|
||||||
} else {
|
} else {
|
||||||
echo "OFF";
|
echo "OFF";
|
||||||
|
|||||||
@@ -2,28 +2,61 @@
|
|||||||
|
|
||||||
function installpostgre()
|
function installpostgre()
|
||||||
{
|
{
|
||||||
// Generate a secure random password (20 chars, URL-safe)
|
$dir = '/opt/DragonCore';
|
||||||
|
$configPath = $dir . '/config.php';
|
||||||
|
|
||||||
|
$password = null;
|
||||||
|
$db_user = 'dragoncore34'; // default user
|
||||||
|
$db_name = 'dragoncore'; // default db name
|
||||||
|
|
||||||
|
// If config already exists, load existing password (and user/db if needed)
|
||||||
|
if (file_exists($configPath)) {
|
||||||
|
include $configPath; // defines $db_pass, $db_user, $db_name, etc.
|
||||||
|
|
||||||
|
if (isset($db_pass)) {
|
||||||
|
$password = $db_pass;
|
||||||
|
}
|
||||||
|
// if you ever want to override db_user/db_name from config, you can:
|
||||||
|
// if (isset($db_user)) $db_user = $db_user;
|
||||||
|
// if (isset($db_name)) $db_name = $db_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no password loaded from config, generate a new one
|
||||||
|
if ($password === null) {
|
||||||
if (function_exists('random_bytes')) {
|
if (function_exists('random_bytes')) {
|
||||||
$bytes = random_bytes(16);
|
$bytes = random_bytes(16);
|
||||||
} else {
|
} else {
|
||||||
$bytes = openssl_random_pseudo_bytes(16);
|
$bytes = openssl_random_pseudo_bytes(16);
|
||||||
}
|
}
|
||||||
$password = substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, 20);
|
$password = substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, 20);
|
||||||
|
}
|
||||||
|
|
||||||
echo 'sudo apt update' . "\n";
|
echo 'sudo apt update' . "\n";
|
||||||
echo 'sudo apt install postgresql postgresql-contrib -y' . "\n";
|
echo 'sudo apt install postgresql postgresql-contrib -y' . "\n";
|
||||||
#$pgVersion = exec('pg_config --version | awk \'{print $NF}\' | cut -d\'.\' -f1-2');
|
|
||||||
#echo 'sudo cp /etc/postgresql/' . $pgVersion . '/main/pg_hba.conf /etc/postgresql/' . $pgVersion . '/main/pg_hba.conf.bak' . "\n";
|
|
||||||
#echo 'sudo sh -c "echo \'host all all 127.0.0.1/32 md5\' > /etc/postgresql/' . $pgVersion . '/main/pg_hba.conf"' . "\n";
|
|
||||||
echo 'sudo systemctl restart postgresql' . "\n";
|
|
||||||
echo 'sudo -u postgres psql -c "CREATE DATABASE dragoncore;"' . "\n";
|
|
||||||
echo 'sudo -u postgres psql -c "CREATE USER dragoncore2 WITH PASSWORD \'' . $password . '\';"' . "\n";
|
|
||||||
echo 'sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE dragoncore TO dragoncore;"' . "\n";
|
|
||||||
echo 'sudo -u postgres psql -c "GRANT USAGE, CREATE ON SCHEMA public TO dragoncore;"' . "\n";
|
|
||||||
echo 'sudo systemctl restart postgresql' . "\n";
|
echo 'sudo systemctl restart postgresql' . "\n";
|
||||||
|
|
||||||
|
// DB + user + basic grants
|
||||||
|
echo 'sudo -u postgres psql -c "CREATE DATABASE ' . $db_name . ';"' . "\n";
|
||||||
|
echo 'sudo -u postgres psql -c "CREATE USER ' . $db_user . ' WITH PASSWORD \'' . $password . '\';"' . "\n";
|
||||||
|
echo 'sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ' . $db_name . ' TO ' . $db_user . ';"' . "\n";
|
||||||
|
echo 'sudo -u postgres psql -d ' . $db_name . ' -c "GRANT USAGE, CREATE ON SCHEMA public TO ' . $db_user . ';"' . "\n";
|
||||||
|
|
||||||
|
// OPTIONAL: make dragoncore2 the owner of everything that was owned by dragoncore in this DB
|
||||||
|
echo 'sudo -u postgres psql -d ' . $db_name . ' -c "REASSIGN OWNED BY dragoncore TO ' . $db_user . ';"' . "\n";
|
||||||
|
|
||||||
|
// Also give full privileges on all existing tables/sequences (nice to have)
|
||||||
|
echo 'sudo -u postgres psql -d ' . $db_name . ' -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO ' . $db_user . ';"' . "\n";
|
||||||
|
echo 'sudo -u postgres psql -d ' . $db_name . ' -c "GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO ' . $db_user . ';"' . "\n";
|
||||||
|
|
||||||
|
echo 'sudo systemctl restart postgresql' . "\n";
|
||||||
|
|
||||||
|
// If config already existed, don't overwrite it
|
||||||
|
if (file_exists($configPath)) {
|
||||||
|
echo "Config file already exists at {$configPath}, not overwriting.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure /opt/DragonCore exists
|
// Ensure /opt/DragonCore exists
|
||||||
$dir = '/opt/DragonCore';
|
|
||||||
if (!is_dir($dir)) {
|
if (!is_dir($dir)) {
|
||||||
if (!mkdir($dir, 0755, true) && !is_dir($dir)) {
|
if (!mkdir($dir, 0755, true) && !is_dir($dir)) {
|
||||||
fwrite(STDERR, "Failed to create directory: $dir\n");
|
fwrite(STDERR, "Failed to create directory: $dir\n");
|
||||||
@@ -36,12 +69,11 @@ function installpostgre()
|
|||||||
<?php
|
<?php
|
||||||
\$db_host = '127.0.0.1';
|
\$db_host = '127.0.0.1';
|
||||||
\$db_port = '5432';
|
\$db_port = '5432';
|
||||||
\$db_name = 'dragoncore';
|
\$db_name = '{$db_name}';
|
||||||
\$db_user = 'dragoncore2';
|
\$db_user = '{$db_user}';
|
||||||
\$db_pass = '{$password}';
|
\$db_pass = '{$password}';
|
||||||
PHP;
|
PHP;
|
||||||
|
|
||||||
$configPath = $dir . '/config.php';
|
|
||||||
if (file_put_contents($configPath, $config) === false) {
|
if (file_put_contents($configPath, $config) === false) {
|
||||||
fwrite(STDERR, "Failed to write config file at {$configPath}\n");
|
fwrite(STDERR, "Failed to write config file at {$configPath}\n");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ function createdbdragon()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
echo "Failed to connect to PostgreSQL";
|
echo "Failed to connect to PostgreSQL";
|
||||||
@@ -101,7 +101,7 @@ function dragonprhash($hash)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ function del232409875892309ete()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ function dragonprhash2()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function relatoriouser()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function deleteall()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
die("Connection failed: " . pg_last_error());
|
die("Connection failed: " . pg_last_error());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function delusernew($id)
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT usr FROM users where id = $1";
|
$query = "SELECT usr FROM users where id = $1";
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function sshmonitor()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT * FROM users";
|
$query = "SELECT * FROM users";
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ function sshmonitordragon()
|
|||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
|
||||||
|
|
||||||
$query = "SELECT * FROM users";
|
$query = "SELECT * FROM users";
|
||||||
|
|
||||||
|
|||||||
269
v2ray
269
v2ray
@@ -1,269 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# EDIT: @kiritossh
|
|
||||||
# github: https://github.com/Jrohy/multi-v2ray
|
|
||||||
|
|
||||||
#定时任务北京执行时间(0~23)
|
|
||||||
BEIJING_UPDATE_TIME=3
|
|
||||||
|
|
||||||
#记录最开始运行脚本的路径
|
|
||||||
BEGIN_PATH=$(pwd)
|
|
||||||
|
|
||||||
#安装方式, 0为全新安装, 1为保留v2ray配置更新
|
|
||||||
INSTALL_WAY=0
|
|
||||||
|
|
||||||
#定义操作变量, 0为否, 1为是
|
|
||||||
HELP=0
|
|
||||||
|
|
||||||
REMOVE=0
|
|
||||||
|
|
||||||
CHINESE=0
|
|
||||||
|
|
||||||
BASE_SOURCE_PATH="https://multi.netlify.app"
|
|
||||||
|
|
||||||
UTIL_PATH="/etc/v2ray_util/util.cfg"
|
|
||||||
|
|
||||||
UTIL_CFG="$BASE_SOURCE_PATH/v2ray_util/util_core/util.cfg"
|
|
||||||
|
|
||||||
BASH_COMPLETION_SHELL="$BASE_SOURCE_PATH/v2ray"
|
|
||||||
|
|
||||||
CLEAN_IPTABLES_SHELL="$BASE_SOURCE_PATH/v2ray_util/global_setting/clean_iptables.sh"
|
|
||||||
|
|
||||||
#Centos 临时取消别名
|
|
||||||
[[ -f /etc/redhat-release && -z $(echo $SHELL|grep zsh) ]] && unalias -a
|
|
||||||
|
|
||||||
[[ -z $(echo $SHELL|grep zsh) ]] && ENV_FILE=".bashrc" || ENV_FILE=".zshrc"
|
|
||||||
|
|
||||||
#######color code########
|
|
||||||
RED="31m"
|
|
||||||
GREEN="32m"
|
|
||||||
YELLOW="33m"
|
|
||||||
BLUE="36m"
|
|
||||||
FUCHSIA="35m"
|
|
||||||
|
|
||||||
colorEcho(){
|
|
||||||
COLOR=$1
|
|
||||||
echo -e "\033[${COLOR}${@:2}\033[0m"
|
|
||||||
}
|
|
||||||
|
|
||||||
#######get params#########
|
|
||||||
while [[ $# > 0 ]];do
|
|
||||||
key="$1"
|
|
||||||
case $key in
|
|
||||||
--remove)
|
|
||||||
REMOVE=1
|
|
||||||
;;
|
|
||||||
-h|--help)
|
|
||||||
HELP=1
|
|
||||||
;;
|
|
||||||
-k|--keep)
|
|
||||||
INSTALL_WAY=1
|
|
||||||
colorEcho ${BLUE} "keep config to update\n"
|
|
||||||
;;
|
|
||||||
--zh)
|
|
||||||
CHINESE=1
|
|
||||||
colorEcho ${BLUE} "安装中文版..\n"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# unknown option
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift # past argument or value
|
|
||||||
done
|
|
||||||
#############################
|
|
||||||
|
|
||||||
help(){
|
|
||||||
echo "bash v2ray.sh [-h|--help] [-k|--keep] [--remove]"
|
|
||||||
echo " -h, --help Show help"
|
|
||||||
echo " -k, --keep keep the config.json to update"
|
|
||||||
echo " --remove remove v2ray,xray && multi-v2ray"
|
|
||||||
echo " no params to new install"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
removeV2Ray() {
|
|
||||||
#卸载V2ray脚本
|
|
||||||
bash <(curl -L -s https://multi.netlify.app/go.sh) --remove >/dev/null 2>&1
|
|
||||||
rm -rf /etc/v2ray >/dev/null 2>&1
|
|
||||||
rm -rf /var/log/v2ray >/dev/null 2>&1
|
|
||||||
|
|
||||||
#卸载Xray脚本
|
|
||||||
bash <(curl -L -s https://multi.netlify.app/go.sh) --remove -x >/dev/null 2>&1
|
|
||||||
rm -rf /etc/xray >/dev/null 2>&1
|
|
||||||
rm -rf /var/log/xray >/dev/null 2>&1
|
|
||||||
|
|
||||||
#清理v2ray相关iptable规则
|
|
||||||
bash <(curl -L -s $CLEAN_IPTABLES_SHELL)
|
|
||||||
|
|
||||||
#卸载multi-v2ray
|
|
||||||
pip uninstall v2ray_util -y
|
|
||||||
rm -rf /usr/share/bash-completion/completions/v2ray.bash >/dev/null 2>&1
|
|
||||||
rm -rf /usr/share/bash-completion/completions/v2ray >/dev/null 2>&1
|
|
||||||
rm -rf /usr/share/bash-completion/completions/xray >/dev/null 2>&1
|
|
||||||
rm -rf /etc/bash_completion.d/v2ray.bash >/dev/null 2>&1
|
|
||||||
rm -rf /usr/local/bin/v2ray >/dev/null 2>&1
|
|
||||||
rm -rf /etc/v2ray_util >/dev/null 2>&1
|
|
||||||
|
|
||||||
#删除v2ray定时更新任务
|
|
||||||
crontab -l|sed '/SHELL=/d;/v2ray/d'|sed '/SHELL=/d;/xray/d' > crontab.txt
|
|
||||||
crontab crontab.txt >/dev/null 2>&1
|
|
||||||
rm -f crontab.txt >/dev/null 2>&1
|
|
||||||
|
|
||||||
if [[ ${PACKAGE_MANAGER} == 'dnf' || ${PACKAGE_MANAGER} == 'yum' ]];then
|
|
||||||
systemctl restart crond >/dev/null 2>&1
|
|
||||||
else
|
|
||||||
systemctl restart cron >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#删除multi-v2ray环境变量
|
|
||||||
sed -i '/v2ray/d' ~/$ENV_FILE
|
|
||||||
sed -i '/xray/d' ~/$ENV_FILE
|
|
||||||
source ~/$ENV_FILE
|
|
||||||
|
|
||||||
colorEcho ${GREEN} "uninstall success!"
|
|
||||||
}
|
|
||||||
|
|
||||||
closeSELinux() {
|
|
||||||
#禁用SELinux
|
|
||||||
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
|
|
||||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
|
||||||
setenforce 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
checkSys() {
|
|
||||||
#检查是否为Root
|
|
||||||
[ $(id -u) != "0" ] && { colorEcho ${RED} "Error: You must be root to run this script"; exit 1; }
|
|
||||||
|
|
||||||
if [[ `command -v apt-get` ]];then
|
|
||||||
PACKAGE_MANAGER='apt-get'
|
|
||||||
elif [[ `command -v dnf` ]];then
|
|
||||||
PACKAGE_MANAGER='dnf'
|
|
||||||
elif [[ `command -v yum` ]];then
|
|
||||||
PACKAGE_MANAGER='yum'
|
|
||||||
else
|
|
||||||
colorEcho $RED "Not support OS!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#安装依赖
|
|
||||||
installDependent(){
|
|
||||||
if [[ ${PACKAGE_MANAGER} == 'dnf' || ${PACKAGE_MANAGER} == 'yum' ]];then
|
|
||||||
${PACKAGE_MANAGER} install socat crontabs bash-completion which -y
|
|
||||||
else
|
|
||||||
${PACKAGE_MANAGER} update
|
|
||||||
${PACKAGE_MANAGER} install socat cron bash-completion ntpdate -y
|
|
||||||
fi
|
|
||||||
|
|
||||||
#install python3 & pip
|
|
||||||
source <(curl -sL https://python3.netlify.app/install.sh)
|
|
||||||
}
|
|
||||||
|
|
||||||
updateProject() {
|
|
||||||
[[ ! $(type pip 2>/dev/null) ]] && colorEcho $RED "pip no install!" && exit 1
|
|
||||||
|
|
||||||
pip install -U v2ray_util
|
|
||||||
|
|
||||||
if [[ -e $UTIL_PATH ]];then
|
|
||||||
[[ -z $(cat $UTIL_PATH|grep lang) ]] && echo "lang=en" >> $UTIL_PATH
|
|
||||||
else
|
|
||||||
mkdir -p /etc/v2ray_util
|
|
||||||
curl $UTIL_CFG > $UTIL_PATH
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ $CHINESE == 1 ]] && sed -i "s/lang=en/lang=zh/g" $UTIL_PATH
|
|
||||||
|
|
||||||
rm -f /usr/local/bin/v2ray >/dev/null 2>&1
|
|
||||||
ln -s $(which v2ray-util) /usr/local/bin/v2ray
|
|
||||||
rm -f /usr/local/bin/xray >/dev/null 2>&1
|
|
||||||
ln -s $(which v2ray-util) /usr/local/bin/xray
|
|
||||||
|
|
||||||
#移除旧的v2ray bash_completion脚本
|
|
||||||
[[ -e /etc/bash_completion.d/v2ray.bash ]] && rm -f /etc/bash_completion.d/v2ray.bash
|
|
||||||
[[ -e /usr/share/bash-completion/completions/v2ray.bash ]] && rm -f /usr/share/bash-completion/completions/v2ray.bash
|
|
||||||
|
|
||||||
#更新v2ray bash_completion脚本
|
|
||||||
curl $BASH_COMPLETION_SHELL > /usr/share/bash-completion/completions/v2ray
|
|
||||||
curl $BASH_COMPLETION_SHELL > /usr/share/bash-completion/completions/xray
|
|
||||||
if [[ -z $(echo $SHELL|grep zsh) ]];then
|
|
||||||
source /usr/share/bash-completion/completions/v2ray
|
|
||||||
source /usr/share/bash-completion/completions/xray
|
|
||||||
fi
|
|
||||||
|
|
||||||
#安装V2ray主程序
|
|
||||||
[[ ${INSTALL_WAY} == 0 ]] && bash <(curl -L -s https://multi.netlify.app/go.sh)
|
|
||||||
}
|
|
||||||
|
|
||||||
#时间同步
|
|
||||||
timeSync() {
|
|
||||||
if [[ ${INSTALL_WAY} == 0 ]];then
|
|
||||||
echo -e "${Info} Time Synchronizing.. ${Font}"
|
|
||||||
if [[ `command -v ntpdate` ]];then
|
|
||||||
ntpdate pool.ntp.org
|
|
||||||
elif [[ `command -v chronyc` ]];then
|
|
||||||
chronyc -a makestep
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $? -eq 0 ]];then
|
|
||||||
echo -e "${OK} Time Sync Success ${Font}"
|
|
||||||
echo -e "${OK} now: `date -R`${Font}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
profileInit() {
|
|
||||||
|
|
||||||
#清理v2ray模块环境变量
|
|
||||||
[[ $(grep v2ray ~/$ENV_FILE) ]] && sed -i '/v2ray/d' ~/$ENV_FILE && source ~/$ENV_FILE
|
|
||||||
|
|
||||||
#解决Python3中文显示问题
|
|
||||||
[[ -z $(grep PYTHONIOENCODING=utf-8 ~/$ENV_FILE) ]] && echo "export PYTHONIOENCODING=utf-8" >> ~/$ENV_FILE && source ~/$ENV_FILE
|
|
||||||
|
|
||||||
#全新安装的新配置
|
|
||||||
[[ ${INSTALL_WAY} == 0 ]] && v2ray new
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
installFinish() {
|
|
||||||
#回到原点
|
|
||||||
cd ${BEGIN_PATH}
|
|
||||||
|
|
||||||
[[ ${INSTALL_WAY} == 0 ]] && WAY="install" || WAY="update"
|
|
||||||
colorEcho ${GREEN} "multi-v2ray ${WAY} success!\n"
|
|
||||||
|
|
||||||
if [[ ${INSTALL_WAY} == 0 ]]; then
|
|
||||||
clear
|
|
||||||
|
|
||||||
echo -e "\n\033[1;32mV2RAY INSTALADO COM SUCESSO !\033[0m"
|
|
||||||
v2ray info
|
|
||||||
|
|
||||||
echo -e "Por favor insira o comando 'v2ray' para gerenciar v2ray\n"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
main() {
|
|
||||||
|
|
||||||
[[ ${HELP} == 1 ]] && help && return
|
|
||||||
|
|
||||||
[[ ${REMOVE} == 1 ]] && removeV2Ray && return
|
|
||||||
|
|
||||||
[[ ${INSTALL_WAY} == 0 ]] && colorEcho ${BLUE} "new install\n"
|
|
||||||
|
|
||||||
checkSys
|
|
||||||
|
|
||||||
installDependent
|
|
||||||
|
|
||||||
closeSELinux
|
|
||||||
|
|
||||||
timeSync
|
|
||||||
|
|
||||||
updateProject
|
|
||||||
|
|
||||||
profileInit
|
|
||||||
|
|
||||||
installFinish
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
||||||
244
v2ray.php
244
v2ray.php
@@ -1,244 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once '/opt/DragonCore/config.php';
|
|
||||||
|
|
||||||
|
|
||||||
function createv2table()
|
|
||||||
{
|
|
||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
|
||||||
|
|
||||||
if (!$conn) {
|
|
||||||
echo "Failed to connect to PostgreSQL";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = "CREATE TABLE IF NOT EXISTS v2ray (
|
|
||||||
ID SERIAL PRIMARY KEY,
|
|
||||||
UUID TEXT,
|
|
||||||
nck TEXT,
|
|
||||||
vlc TEXT
|
|
||||||
)";
|
|
||||||
|
|
||||||
$result = pg_query($conn, $query);
|
|
||||||
|
|
||||||
if (!$result) {
|
|
||||||
echo "Error creating table: " . pg_last_error($conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
pg_close($conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function v2users()
|
|
||||||
{
|
|
||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
|
||||||
if (!$conn) {
|
|
||||||
die("Connection failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
$query = "SELECT * FROM v2ray";
|
|
||||||
$result = pg_query($conn, $query);
|
|
||||||
if (!$result) {
|
|
||||||
die("Query execution failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
while ($row = pg_fetch_assoc($result)) {
|
|
||||||
$ID = $row['id'];
|
|
||||||
$UUID = $row['uuid'];
|
|
||||||
$nick = $row['nck'];
|
|
||||||
echo "ID: " . $ID . " | " . "NOME: " . $nick . " | " . "UUID: " . $UUID . "\n";
|
|
||||||
}
|
|
||||||
pg_close($conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function v2uid($id)
|
|
||||||
{
|
|
||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
|
||||||
if (!$conn) {
|
|
||||||
die("Connection failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
$query = "SELECT uuid FROM v2ray WHERE id=$id";
|
|
||||||
$result = pg_query($conn, $query);
|
|
||||||
if (!$result) {
|
|
||||||
die("Query execution failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
while ($row = pg_fetch_assoc($result)) {
|
|
||||||
$UUID = $row['uuid'];
|
|
||||||
echo $UUID;
|
|
||||||
}
|
|
||||||
pg_close($conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function inv2($uuid, $nick, $valid)
|
|
||||||
{
|
|
||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
|
||||||
if (!$conn) {
|
|
||||||
die("Connection failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
$query = "INSERT INTO v2ray (UUID, nck, vlc) VALUES ($1, $2, $3)";
|
|
||||||
$result = pg_prepare($conn, "", $query);
|
|
||||||
if (!$result) {
|
|
||||||
die("Statement preparation failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
$result = pg_execute($conn, "", array($uuid, $nick, $valid));
|
|
||||||
if (!$result) {
|
|
||||||
die("Execution failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
pg_close($conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function intallv2()
|
|
||||||
{
|
|
||||||
$filePath = '/bin/v2ray';
|
|
||||||
if (file_exists($filePath)) {
|
|
||||||
echo "/opt/DragonCore/v2ray --remove";
|
|
||||||
} else {
|
|
||||||
echo "apt install python3-pip -y" . "\n" . "/opt/DragonCore/v2ray";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function v2protocol()
|
|
||||||
{
|
|
||||||
echo "v2ray stream";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function v2tls()
|
|
||||||
{
|
|
||||||
echo "v2ray tls";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function v2port()
|
|
||||||
{
|
|
||||||
echo "v2ray port";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function v2stats()
|
|
||||||
{
|
|
||||||
echo "v2ray stats";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function removev2()
|
|
||||||
{
|
|
||||||
echo "/opt/DragonCore/v2ray --remove";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function v2info()
|
|
||||||
{
|
|
||||||
echo "v2ray info";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function uuidgen()
|
|
||||||
{
|
|
||||||
return shell_exec('uuidgen');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function addv2user($nick)
|
|
||||||
{
|
|
||||||
$valid = date("Y-m-d", strtotime("+31 days"));
|
|
||||||
$MAILITO = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);
|
|
||||||
$UUID = uuidgen();
|
|
||||||
$UUID2 = str_replace(array("\r", "\n"), '', $UUID);
|
|
||||||
$configPath = "/etc/v2ray/config.json";
|
|
||||||
$newClient = [
|
|
||||||
'{
|
|
||||||
"alterId": 0,',
|
|
||||||
' "id": "' . $UUID2 . '",',
|
|
||||||
' "email": "' . $MAILITO . '@gmail.com"}'
|
|
||||||
];
|
|
||||||
$config = file_get_contents($configPath);
|
|
||||||
$pos = strpos($config, '"clients": [');
|
|
||||||
if ($pos !== false) {
|
|
||||||
$config = substr_replace($config, implode("\n", $newClient) . ',', $pos + strlen('"clients": ['), 0);
|
|
||||||
file_put_contents($configPath, $config);
|
|
||||||
inv2($UUID, $nick, $valid);
|
|
||||||
system("v2ray restart > /dev/null 2>&1");
|
|
||||||
echo "UUID Criado: " . $UUID2 . "\n\n" . extractVmessUrlByUUID($UUID2);
|
|
||||||
} else {
|
|
||||||
echo "Error: Unable to find 'clients' array in the config file.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function delv2($uuidel)
|
|
||||||
{
|
|
||||||
$lineP = shell_exec("sed -n '/'" . $uuidel . "'/=' /etc/v2ray/config.json");
|
|
||||||
$numl1 = 2;
|
|
||||||
$resta = $lineP - $numl1;
|
|
||||||
shell_exec("sed -i \"" . $resta . "d\" /etc/v2ray/config.json");
|
|
||||||
shell_exec("sed -i \"" . $resta . "d\" /etc/v2ray/config.json");
|
|
||||||
shell_exec("sed -i \"" . $resta . "d\" /etc/v2ray/config.json");
|
|
||||||
shell_exec("sed -i \"" . $resta . "d\" /etc/v2ray/config.json");
|
|
||||||
shell_exec("sed -i \"" . $resta . "d\" /etc/v2ray/config.json");
|
|
||||||
shell_exec("v2ray restart > /dev/null 2>&1");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function dlv2($id)
|
|
||||||
{
|
|
||||||
global $db_host, $db_port, $db_name, $db_user, $db_pass;
|
|
||||||
|
|
||||||
|
|
||||||
$conn = pg_connect("host=localhost dbname=dragoncore user=dragoncore 2password=$db_pass");
|
|
||||||
if (!$conn) {
|
|
||||||
die("Connection failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
$query = "DELETE FROM v2ray WHERE id = $1";
|
|
||||||
$result = pg_prepare($conn, "", $query);
|
|
||||||
if (!$result) {
|
|
||||||
die("Statement preparation failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
$result = pg_execute($conn, "", array($id));
|
|
||||||
if (!$result) {
|
|
||||||
die("Execution failed: " . pg_last_error());
|
|
||||||
}
|
|
||||||
pg_close($conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function v2cho()
|
|
||||||
{
|
|
||||||
$filePath = '/bin/v2ray';
|
|
||||||
if (file_exists($filePath)) {
|
|
||||||
return "Remover";
|
|
||||||
} else {
|
|
||||||
return "Instalar";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function extractVmessUrlByUUID($uuid)
|
|
||||||
{
|
|
||||||
$v2link = shell_exec("v2ray info | grep -A4 \"UUID: $uuid\" | tail -n1 | grep -o 'vmess://.*'");
|
|
||||||
if (str_contains($v2link, "vmess")) {
|
|
||||||
return "$v2link";
|
|
||||||
} else {
|
|
||||||
$v2link2 = shell_exec("v2ray info | grep -A4 \"ID: $uuid\" | tail -n1 | grep -o 'vless://.*'");
|
|
||||||
if (str_contains($v2link2, "vless")) {
|
|
||||||
return "$v2link2";
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +1 @@
|
|||||||
30 Year Of the Tubular Dragon
|
40 Year Of the Noodle Dragon
|
||||||
BIN
x86_64/dnstt-server
Normal file
BIN
x86_64/dnstt-server
Normal file
Binary file not shown.
514
xray.php
Normal file
514
xray.php
Normal file
@@ -0,0 +1,514 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once '/opt/DragonCore/config.php';
|
||||||
|
|
||||||
|
function createXrayTable()
|
||||||
|
{
|
||||||
|
global $db_user, $db_pass;
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
if (!$conn) {
|
||||||
|
echo "Failed to connect to PostgreSQL\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$query = "CREATE TABLE IF NOT EXISTS xray (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
uuid TEXT,
|
||||||
|
nick TEXT,
|
||||||
|
expiry DATE,
|
||||||
|
protocol TEXT
|
||||||
|
);";
|
||||||
|
$result = pg_query($conn, $query);
|
||||||
|
if (!$result) {
|
||||||
|
echo "Error creating Xray table: " . pg_last_error($conn) . "\n";
|
||||||
|
}
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayConfigPath(): string
|
||||||
|
{
|
||||||
|
return '/usr/local/etc/xray/config.json';
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayEnsureConfigDir(): void
|
||||||
|
{
|
||||||
|
$dir = dirname(xrayConfigPath());
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
mkdir($dir, 0755, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isXrayInstalled(): bool
|
||||||
|
{
|
||||||
|
$paths = [
|
||||||
|
'/usr/local/bin/xray',
|
||||||
|
'/usr/bin/xray'
|
||||||
|
];
|
||||||
|
foreach ($paths as $p) {
|
||||||
|
if (file_exists($p)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayInstall()
|
||||||
|
{
|
||||||
|
if (isXrayInstalled()) {
|
||||||
|
echo "echo 'Xray ja esta instalado';\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo 'bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayRemove()
|
||||||
|
{
|
||||||
|
if (!isXrayInstalled()) {
|
||||||
|
echo "echo 'Xray nao esta instalado';\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo 'bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayGetProtocols()
|
||||||
|
{
|
||||||
|
global $db_user, $db_pass;
|
||||||
|
$protocols = [];
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
if ($conn) {
|
||||||
|
$res = pg_query($conn, 'SELECT DISTINCT protocol FROM xray ORDER BY protocol');
|
||||||
|
while ($row = pg_fetch_assoc($res)) {
|
||||||
|
$protocols[] = $row['protocol'];
|
||||||
|
}
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
echo implode(', ', $protocols);
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayListSimple()
|
||||||
|
{
|
||||||
|
global $db_user, $db_pass;
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
if ($conn) {
|
||||||
|
$res = pg_query($conn, 'SELECT uuid, expiry FROM xray ORDER BY id');
|
||||||
|
while ($row = pg_fetch_assoc($res)) {
|
||||||
|
echo $row['uuid'] . ' ' . $row['expiry'] . "\n";
|
||||||
|
}
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayChoice(): string
|
||||||
|
{
|
||||||
|
return isXrayInstalled() ? 'Remover' : 'Instalar';
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayUuid(): string
|
||||||
|
{
|
||||||
|
$uuid = trim((string)@shell_exec('uuidgen'));
|
||||||
|
if ($uuid !== '') {
|
||||||
|
return $uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function_exists('random_bytes')) {
|
||||||
|
$data = random_bytes(16);
|
||||||
|
$data[6] = chr((ord($data[6]) & 0x0f) | 0x40);
|
||||||
|
$data[8] = chr((ord($data[8]) & 0x3f) | 0x80);
|
||||||
|
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
return md5(uniqid((string)mt_rand(), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayGenerateConfig($port, string $network = 'xhttp')
|
||||||
|
{
|
||||||
|
$configPath = xrayConfigPath();
|
||||||
|
xrayEnsureConfigDir();
|
||||||
|
|
||||||
|
$port = (int)$port;
|
||||||
|
if ($port <= 0 || $port > 65535) {
|
||||||
|
$port = 443;
|
||||||
|
}
|
||||||
|
|
||||||
|
$network = strtolower($network);
|
||||||
|
if (!in_array($network, ['xhttp', 'ws', 'grpc', 'tcp'], true)) {
|
||||||
|
$network = 'xhttp';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$apiInbound = [
|
||||||
|
'tag' => 'api',
|
||||||
|
'port' => 1080,
|
||||||
|
'protocol' => 'dokodemo-door',
|
||||||
|
'settings' => [
|
||||||
|
'address' => '127.0.0.1',
|
||||||
|
],
|
||||||
|
'listen' => '127.0.0.1',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$streamSettings = [
|
||||||
|
'network' => $network,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($network === 'xhttp') {
|
||||||
|
$streamSettings['security'] = 'tls';
|
||||||
|
$streamSettings['tlsSettings'] = [
|
||||||
|
'certificates' => [[
|
||||||
|
'certificateFile' => '/opt/DragonCoreSSL/fullchain.pem',
|
||||||
|
'keyFile' => '/opt/DragonCoreSSL/privkey.pem',
|
||||||
|
]],
|
||||||
|
'alpn' => ['http/1.1'],
|
||||||
|
];
|
||||||
|
$streamSettings['xhttpSettings'] = [
|
||||||
|
'headers' => null,
|
||||||
|
'host' => '',
|
||||||
|
'mode' => '',
|
||||||
|
'noSSEHeader' => false,
|
||||||
|
'path' => '/',
|
||||||
|
'scMaxBufferedPosts' => 30,
|
||||||
|
'scMaxEachPostBytes' => '1000000',
|
||||||
|
'scStreamUpServerSecs' => '20-80',
|
||||||
|
'xPaddingBytes' => '100-1000',
|
||||||
|
];
|
||||||
|
} elseif ($network === 'ws') {
|
||||||
|
$streamSettings['security'] = 'none';
|
||||||
|
$streamSettings['wsSettings'] = [
|
||||||
|
'acceptProxyProtocol' => false,
|
||||||
|
'headers' => (object)[],
|
||||||
|
'heartbeatPeriod' => 0,
|
||||||
|
'host' => '',
|
||||||
|
'path' => '/',
|
||||||
|
];
|
||||||
|
} elseif ($network === 'grpc') {
|
||||||
|
$streamSettings['security'] = 'none';
|
||||||
|
$streamSettings['grpcSettings'] = [
|
||||||
|
'serviceName' => 'vlessgrpc',
|
||||||
|
'multiMode' => false,
|
||||||
|
'idle_timeout' => 60,
|
||||||
|
'permit_without_stream' => false,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$streamSettings['security'] = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$dragonInbound = [
|
||||||
|
'tag' => 'inbound-dragoncore',
|
||||||
|
'port' => $port,
|
||||||
|
'protocol' => 'vless',
|
||||||
|
'settings' => [
|
||||||
|
'clients' => [],
|
||||||
|
'decryption' => 'none',
|
||||||
|
'fallbacks' => [],
|
||||||
|
],
|
||||||
|
'streamSettings' => $streamSettings,
|
||||||
|
];
|
||||||
|
|
||||||
|
$config = [
|
||||||
|
'api' => [
|
||||||
|
'services' => [
|
||||||
|
'HandlerService',
|
||||||
|
'LoggerService',
|
||||||
|
'StatsService',
|
||||||
|
],
|
||||||
|
'tag' => 'api',
|
||||||
|
],
|
||||||
|
'burstObservatory' => null,
|
||||||
|
'dns' => null,
|
||||||
|
'fakedns' => null,
|
||||||
|
'inbounds' => [
|
||||||
|
$apiInbound,
|
||||||
|
$dragonInbound,
|
||||||
|
],
|
||||||
|
'observatory' => null,
|
||||||
|
'outbounds' => [
|
||||||
|
[
|
||||||
|
'protocol' => 'freedom',
|
||||||
|
'settings' => (object)[],
|
||||||
|
'tag' => 'direct',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'protocol' => 'blackhole',
|
||||||
|
'settings' => (object)[],
|
||||||
|
'tag' => 'blocked',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'reverse' => null,
|
||||||
|
'routing' => [
|
||||||
|
'domainStrategy' => 'AsIs',
|
||||||
|
'rules' => [
|
||||||
|
[
|
||||||
|
'inboundTag' => ['api'],
|
||||||
|
'outboundTag' => 'api',
|
||||||
|
'type' => 'field',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'ip' => ['geoip:private'],
|
||||||
|
'outboundTag' => 'blocked',
|
||||||
|
'type' => 'field',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'outboundTag' => 'blocked',
|
||||||
|
'protocol' => ['bittorrent'],
|
||||||
|
'type' => 'field',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'stats' => (object)[],
|
||||||
|
'transport' => null,
|
||||||
|
];
|
||||||
|
|
||||||
|
file_put_contents(
|
||||||
|
$configPath,
|
||||||
|
json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
|
||||||
|
);
|
||||||
|
|
||||||
|
@shell_exec('systemctl restart xray');
|
||||||
|
echo "Config Xray gerado em {$configPath} (porta {$port}, protocolo {$network})\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayFixEmptyObjects(array &$config): void
|
||||||
|
{
|
||||||
|
|
||||||
|
if (isset($config['stats']) && is_array($config['stats']) && empty($config['stats'])) {
|
||||||
|
$config['stats'] = (object)[];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (isset($config['outbounds']) && is_array($config['outbounds'])) {
|
||||||
|
foreach ($config['outbounds'] as &$out) {
|
||||||
|
if (isset($out['settings']) && is_array($out['settings']) && empty($out['settings'])) {
|
||||||
|
$out['settings'] = (object)[];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayAddUser(string $nick, string $protocol = 'xhttp')
|
||||||
|
{
|
||||||
|
global $db_user, $db_pass;
|
||||||
|
|
||||||
|
$uuid = xrayUuid();
|
||||||
|
$expiry = date('Y-m-d', strtotime('+30 days'));
|
||||||
|
|
||||||
|
$configPath = xrayConfigPath();
|
||||||
|
if (!file_exists($configPath)) {
|
||||||
|
echo "Arquivo de configuracao {$configPath} nao encontrado. Gere o config Xray primeiro.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = json_decode(file_get_contents($configPath), true);
|
||||||
|
if (!is_array($config)) {
|
||||||
|
echo "Falha ao ler/decodificar {$configPath}.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$inboundIndex = null;
|
||||||
|
if (isset($config['inbounds']) && is_array($config['inbounds'])) {
|
||||||
|
foreach ($config['inbounds'] as $idx => $in) {
|
||||||
|
if (isset($in['tag']) && $in['tag'] === 'inbound-dragoncore') {
|
||||||
|
$inboundIndex = $idx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($inboundIndex === null) {
|
||||||
|
echo "Inbound 'inbound-dragoncore' nao encontrado no config Xray.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!isset($config['inbounds'][$inboundIndex]['settings']['clients']) ||
|
||||||
|
!is_array($config['inbounds'][$inboundIndex]['settings']['clients'])
|
||||||
|
) {
|
||||||
|
$config['inbounds'][$inboundIndex]['settings']['clients'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$client = [
|
||||||
|
'id' => $uuid,
|
||||||
|
'email' => $nick,
|
||||||
|
'level' => 0,
|
||||||
|
];
|
||||||
|
$config['inbounds'][$inboundIndex]['settings']['clients'][] = $client;
|
||||||
|
|
||||||
|
xrayFixEmptyObjects($config);
|
||||||
|
file_put_contents(
|
||||||
|
$configPath,
|
||||||
|
json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
if ($conn) {
|
||||||
|
$query = "INSERT INTO xray (uuid, nick, expiry, protocol) VALUES ($1,$2,$3,$4)";
|
||||||
|
$stmt = pg_prepare($conn, '', $query);
|
||||||
|
pg_execute($conn, '', [$uuid, $nick, $expiry, $protocol]);
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@shell_exec('systemctl restart xray');
|
||||||
|
|
||||||
|
$domain = trim((string)shell_exec('hostname -I | awk "{print $1}"'));
|
||||||
|
if ($domain === '') {
|
||||||
|
$domain = '127.0.0.1';
|
||||||
|
}
|
||||||
|
$port = $config['inbounds'][$inboundIndex]['port'];
|
||||||
|
$uri = "vless://{$uuid}@{$domain}:{$port}#{$nick}";
|
||||||
|
|
||||||
|
echo "UUID Criado: {$uuid}\n{$uri}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayRemoveUser($identifier)
|
||||||
|
{
|
||||||
|
global $db_user, $db_pass;
|
||||||
|
$uuid = null;
|
||||||
|
|
||||||
|
if (is_numeric($identifier)) {
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
if ($conn) {
|
||||||
|
$res = pg_query_params($conn, 'SELECT uuid FROM xray WHERE id = $1', [$identifier]);
|
||||||
|
if ($res && ($row = pg_fetch_assoc($res))) {
|
||||||
|
$uuid = $row['uuid'];
|
||||||
|
}
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$uuid = $identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$uuid) {
|
||||||
|
echo "UUID nao encontrado\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$configPath = xrayConfigPath();
|
||||||
|
if (file_exists($configPath)) {
|
||||||
|
$config = json_decode(file_get_contents($configPath), true);
|
||||||
|
if (isset($config['inbounds']) && is_array($config['inbounds'])) {
|
||||||
|
$inboundIndex = null;
|
||||||
|
foreach ($config['inbounds'] as $idx => $in) {
|
||||||
|
if (isset($in['tag']) && $in['tag'] === 'inbound-dragoncore') {
|
||||||
|
$inboundIndex = $idx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
$inboundIndex !== null &&
|
||||||
|
isset($config['inbounds'][$inboundIndex]['settings']['clients']) &&
|
||||||
|
is_array($config['inbounds'][$inboundIndex]['settings']['clients'])
|
||||||
|
) {
|
||||||
|
|
||||||
|
$clients = &$config['inbounds'][$inboundIndex]['settings']['clients'];
|
||||||
|
foreach ($clients as $index => $cli) {
|
||||||
|
if (isset($cli['id']) && $cli['id'] === $uuid) {
|
||||||
|
array_splice($clients, $index, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xrayFixEmptyObjects($config);
|
||||||
|
file_put_contents(
|
||||||
|
$configPath,
|
||||||
|
json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
if ($conn) {
|
||||||
|
pg_query_params($conn, 'DELETE FROM xray WHERE uuid = $1', [$uuid]);
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@shell_exec('systemctl restart xray');
|
||||||
|
echo "Usuario removido: {$uuid}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayListUsers()
|
||||||
|
{
|
||||||
|
global $db_user, $db_pass;
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
if (!$conn) {
|
||||||
|
echo "Falha ao conectar ao banco de dados\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$res = pg_query($conn, 'SELECT id, uuid, nick, expiry, protocol FROM xray ORDER BY id');
|
||||||
|
while ($row = pg_fetch_assoc($res)) {
|
||||||
|
echo "ID: {$row['id']} | NICK: {$row['nick']} | UUID: {$row['uuid']} | EXPIRA: {$row['expiry']} | PROTO: {$row['protocol']}\n";
|
||||||
|
}
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayCert(string $domain)
|
||||||
|
{
|
||||||
|
$sslDir = '/opt/DragonCoreSSL';
|
||||||
|
$keyFile = $sslDir . '/privkey.pem';
|
||||||
|
$crtFile = $sslDir . '/fullchain.pem';
|
||||||
|
|
||||||
|
if (!is_dir($sslDir)) {
|
||||||
|
mkdir($sslDir, 0700, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$subject = '/C=BR/ST=SP/L=SaoPaulo/O=DragonCore/OU=VPN/CN=' . $domain;
|
||||||
|
|
||||||
|
$cmd = 'openssl req -x509 -nodes -newkey rsa:2048 '
|
||||||
|
. '-days 9999 '
|
||||||
|
. '-subj ' . escapeshellarg($subject) . ' '
|
||||||
|
. '-keyout ' . escapeshellarg($keyFile) . ' '
|
||||||
|
. '-out ' . escapeshellarg($crtFile) . ' 2>/dev/null';
|
||||||
|
|
||||||
|
@shell_exec($cmd);
|
||||||
|
|
||||||
|
if (file_exists($keyFile) && file_exists($crtFile)) {
|
||||||
|
echo "Certificado TLS autoassinado (9999 dias) gerado para {$domain}\n";
|
||||||
|
} else {
|
||||||
|
echo "Falha ao gerar certificado autoassinado para {$domain}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayPurgeExpired()
|
||||||
|
{
|
||||||
|
global $db_user, $db_pass;
|
||||||
|
$today = date('Y-m-d');
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
if ($conn) {
|
||||||
|
$res = pg_query_params($conn, 'SELECT uuid FROM xray WHERE expiry < $1', [$today]);
|
||||||
|
while ($row = pg_fetch_assoc($res)) {
|
||||||
|
xrayRemoveUser($row['uuid']);
|
||||||
|
}
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function xrayInfo()
|
||||||
|
{
|
||||||
|
$binary = isXrayInstalled() ? '/usr/local/bin/xray' : 'xray';
|
||||||
|
$version = trim((string)shell_exec($binary . ' -version 2>&1'));
|
||||||
|
|
||||||
|
global $db_user, $db_pass;
|
||||||
|
$conn = pg_connect("host=localhost dbname=dragoncore user={$db_user} password={$db_pass}");
|
||||||
|
$count = 0;
|
||||||
|
$protocols = [];
|
||||||
|
if ($conn) {
|
||||||
|
$res = pg_query($conn, 'SELECT COUNT(*) AS c FROM xray');
|
||||||
|
if ($row = pg_fetch_assoc($res)) {
|
||||||
|
$count = $row['c'];
|
||||||
|
}
|
||||||
|
$res2 = pg_query($conn, 'SELECT DISTINCT protocol FROM xray');
|
||||||
|
while ($r = pg_fetch_assoc($res2)) {
|
||||||
|
$protocols[] = $r['protocol'];
|
||||||
|
}
|
||||||
|
pg_close($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Xray Versao: {$version}\n";
|
||||||
|
echo "Usuarios cadastrados: {$count}\n";
|
||||||
|
echo "Protocolos em uso: " . implode(', ', $protocols) . "\n";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user